iWork on discovery request ...
FossilOrigin-Name: 43d113474056a9be642476fa1acc8f617a5d20aa7b8bae01e3561ced1747beed
This commit is contained in:
parent
32ac896145
commit
5a71866fbd
@ -18,7 +18,6 @@
|
||||
<File Name="src/cw/bstr.h"/>
|
||||
<File Name="src/cw/mavl_get_node.c"/>
|
||||
<File Name="src/cw/dtls_openssl_connect.c"/>
|
||||
<File Name="src/cw/acpriolist.c"/>
|
||||
<File Name="src/cw/lw_elem_id_to_str.c"/>
|
||||
<File Name="src/cw/cw_put_elem_radio_administrative_state.c"/>
|
||||
<File Name="src/cw/lwapp.h"/>
|
||||
@ -56,7 +55,6 @@
|
||||
<File Name="src/cw/bstr_replace.c"/>
|
||||
<File Name="src/cw/sock_receive.c"/>
|
||||
<File Name="src/cw/capwap_80211_actions.h"/>
|
||||
<File Name="src/cw/acpriolist.h"/>
|
||||
<File Name="src/cw/sock_hwaddrtostr.c"/>
|
||||
<File Name="src/cw/mavliter_next.c"/>
|
||||
<File Name="src/cw/lw_msg_id_to_str.c"/>
|
||||
@ -116,7 +114,6 @@
|
||||
<File Name="src/cw/sock_setport.c"/>
|
||||
<File Name="src/cw/cw_strlist_get_id.c"/>
|
||||
<File Name="src/cw/sock.h"/>
|
||||
<File Name="src/cw/aciplist.c"/>
|
||||
<File Name="src/cw/log_syslog.c"/>
|
||||
<File Name="src/cw/lw_put_ac_descriptor.c"/>
|
||||
<File Name="src/cw/conn_destroy.c"/>
|
||||
@ -195,7 +192,6 @@
|
||||
<File Name="src/cw/cw_readelem_statistics_timer.c"/>
|
||||
<File Name="src/cw/cw_read_ac_descriptor.c"/>
|
||||
<File Name="src/cw/conn_prepare_image_data_request.c"/>
|
||||
<File Name="src/cw/aciplist.h"/>
|
||||
<File Name="src/cw/timer.h"/>
|
||||
<File Name="src/cw/mavl_foreach.c"/>
|
||||
<File Name="src/cw/lwapp_cisco.h"/>
|
||||
|
@ -234,7 +234,7 @@ ssl_cert="../../ssl/certs/ac-cisco.pem"
|
||||
#
|
||||
|
||||
#mods = { cisco, capwap }
|
||||
mods = { capwap, capwap80211 }
|
||||
mods = { cisco, capwap, capwap80211 }
|
||||
#, capwap80211 }
|
||||
|
||||
mods_dir = ../../lib
|
||||
|
@ -13,10 +13,8 @@ ac-descriptor/hardware/vendor:Dword:1234567
|
||||
ac-descriptor/hardware/version:Bstr16:"1.7.3"
|
||||
ac-name:Bstr16:"TubesAC"
|
||||
|
||||
capwap-control-ip-address/address.0:IPAddress:192.168.0.1
|
||||
capwap-control-ip-address/address.1:IPAddress:192.168.0.7
|
||||
capwap-control-ip-address/address.2:IPAddress:2a00:c1a0:48c6:4a00:9965:1b6e:aca3:1398
|
||||
capwap-control-ip-address/wtps.0:Word:13
|
||||
capwap-control-ip-address/address.0:IPAddress:192.168.0.14
|
||||
capwap-control-ip-address/address.1:IPAddress:2a00:c1a0:48c6:4a00:9965:1b6e:aca3:1398
|
||||
capwap-control-ip-address/wtps.0:Word:0
|
||||
capwap-control-ip-address/wtps.1:Word:11
|
||||
capwap-control-ip-address/wtps.2:Word:113
|
||||
|
||||
|
@ -191,8 +191,6 @@ LOGSRC=\
|
||||
dbg_strings.c\
|
||||
|
||||
MISCSRC=\
|
||||
aciplist.c\
|
||||
acpriolist.c\
|
||||
bstr16_create.c\
|
||||
bstr16_create_from_str.c\
|
||||
bstr_create.c\
|
||||
|
@ -1,84 +0,0 @@
|
||||
/*
|
||||
This file is part of libcapwap.
|
||||
|
||||
libcapwap is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
libcapwap is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Implements some aciplist functions
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "aciplist.h"
|
||||
#include "mavl.h"
|
||||
#include "sock.h"
|
||||
|
||||
|
||||
static int acip_cmp(const void *x1, const void *x2)
|
||||
{
|
||||
struct cw_acip *ip1 = *((struct cw_acip **) x1);
|
||||
struct cw_acip *ip2 = *((struct cw_acip **) x2);
|
||||
|
||||
int r = ip1->index - ip2->index;
|
||||
if (r!=0)
|
||||
return r;
|
||||
|
||||
|
||||
if (ip1->ip.ss_family != ip2->ip.ss_family) {
|
||||
if (ip1->ip.ss_family == AF_INET)
|
||||
return -1;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ip1->ip.ss_family == AF_INET) {
|
||||
struct sockaddr_in *s2 = (struct sockaddr_in *) &ip2->ip;
|
||||
struct sockaddr_in *s1 = (struct sockaddr_in *) &ip1->ip;
|
||||
|
||||
return memcmp(&s1->sin_addr, &s2->sin_addr,
|
||||
sock_addrlen((struct sockaddr *) s1));
|
||||
}
|
||||
|
||||
if (ip1->ip.ss_family == AF_INET6) {
|
||||
struct sockaddr_in6 *s2 = (struct sockaddr_in6 *) &ip2->ip;
|
||||
struct sockaddr_in6 *s1 = (struct sockaddr_in6 *) &ip1->ip;
|
||||
|
||||
return memcmp(&s1->sin6_addr.s6_addr, &s2->sin6_addr.s6_addr,
|
||||
sock_addrlen((struct sockaddr *) s1));
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void acip_del(void *d)
|
||||
{
|
||||
free(*(void**)d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a cw_aciplist_t object
|
||||
* @return The created aciplist or NULL if an error has occured.
|
||||
*/
|
||||
cw_aciplist_t cw_aciplist_create()
|
||||
{
|
||||
return mavl_create(acip_cmp, acip_del,1312);
|
||||
}
|
||||
|
@ -1,24 +0,0 @@
|
||||
#ifndef __ACIPLIST_H
|
||||
#define __ACIPLIST_H
|
||||
|
||||
#include "mavl.h"
|
||||
|
||||
struct cw_acip{
|
||||
struct sockaddr_storage ip;
|
||||
uint32_t index;
|
||||
};
|
||||
|
||||
typedef struct cw_acip cw_acip_t;
|
||||
|
||||
typedef struct mavl * cw_aciplist_t;
|
||||
|
||||
extern cw_aciplist_t cw_aciplist_create();
|
||||
|
||||
#define cw_aciplist_destroy(l) mavl_destroy(l)
|
||||
#define cw_aciplist_add(l,elem) mavl_add(l,elem,NULL)
|
||||
#define cw_aciplist_del(l,elem) mavl_del(l,elem)
|
||||
#define cw_aciplist_foreach(l,callback,cbpriv) mavl_foreach_asc(l,callback,cbpriv)
|
||||
#define cw_aciplist_replace(l,r) mavl_replace(l,r,NULL)
|
||||
|
||||
#endif
|
||||
|
@ -1,85 +0,0 @@
|
||||
/*
|
||||
This file is part of libcapwap.
|
||||
|
||||
libcapwap is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
libcapwap is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "acpriolist.h"
|
||||
|
||||
/*
|
||||
static int acprio_cmp(const void *x1, const void *x2)
|
||||
{
|
||||
cw_acprio_t * p1 = (cw_acprio_t*)x1;
|
||||
cw_acprio_t * p2 = (cw_acprio_t*)x2;
|
||||
return strcmp (p1->name,p2->name);
|
||||
|
||||
}
|
||||
|
||||
static void acprio_del(void *d)
|
||||
{
|
||||
cw_acprio_t *p = (cw_acprio_t*)d;
|
||||
if ( p->name )
|
||||
free (p->name);
|
||||
// if ( p->addr )
|
||||
// free(p->addr);
|
||||
free(d);
|
||||
}
|
||||
|
||||
|
||||
const struct mbag_typedef mbag_type_acprio = {
|
||||
"acprio",acprio_del
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
cw_acpriolist_t cw_acpriolist_create()
|
||||
{
|
||||
return mavl_create(acprio_cmp, acprio_del,4);
|
||||
}
|
||||
|
||||
cw_acprio_t * cw_acpriolist_add(cw_acpriolist_t l, const char *name,int name_len, uint8_t prio)
|
||||
{
|
||||
|
||||
cw_acprio_t * s=malloc(sizeof(cw_acprio_t));
|
||||
if (!s)
|
||||
return 0;
|
||||
s->name=strndup(name,name_len);
|
||||
s->prio=prio;
|
||||
|
||||
cw_acpriolist_del(l,s);
|
||||
return mavl_add(l,s,NULL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
int cw_acpriolist_get(cw_acpriolist_t l, char * acname){
|
||||
cw_acprio_t ps,*pf;
|
||||
ps.name=acname;
|
||||
|
||||
pf=mavl_get(l,&ps);
|
||||
if (!pf)
|
||||
return 256;
|
||||
return pf->prio;
|
||||
}
|
||||
|
||||
*/
|
@ -1,44 +0,0 @@
|
||||
#ifndef __ACIPRIORITYLIST_H
|
||||
#define __ACIPRIORITYLIST_H
|
||||
|
||||
#include "mavl.h"
|
||||
|
||||
|
||||
/**
|
||||
* Used to store AC Name With Priority elements.
|
||||
*/
|
||||
struct cw_acprio{
|
||||
/**
|
||||
* AC Name
|
||||
*/
|
||||
char *name;
|
||||
/**
|
||||
* IP of AC
|
||||
*/
|
||||
struct sockaddr_storage * addr;
|
||||
/**
|
||||
* Priority
|
||||
*/
|
||||
uint8_t prio;
|
||||
};
|
||||
|
||||
extern const struct mbag_typedef mbag_type_acprio;
|
||||
|
||||
#define MBAG_ACPRIO (&mbag_type_acprio)
|
||||
|
||||
|
||||
|
||||
typedef struct cw_acprio cw_acprio_t;
|
||||
typedef struct mavl * cw_acpriolist_t;
|
||||
|
||||
extern cw_acpriolist_t cw_acpriolist_create();
|
||||
cw_acprio_t * cw_acpriolist_add(cw_acpriolist_t l, const char *name,int name_len, uint8_t prio);
|
||||
|
||||
int cw_acpriolist_get(cw_acpriolist_t l, char * acname);
|
||||
|
||||
|
||||
|
||||
#define cw_acpriolist_del(l,s) mavl_del(l,s)
|
||||
#define cw_acpriolist_set(l,n,nl,p) cw_acpriolist_add(l,n,nl,p)
|
||||
|
||||
#endif
|
@ -345,6 +345,7 @@
|
||||
*/
|
||||
|
||||
#define CW_SESSION_ID_LEN 16
|
||||
#define CAPWAP_MAX_AC_NAME_LEN 512
|
||||
|
||||
|
||||
/* capwap timer default values */
|
||||
@ -364,7 +365,7 @@
|
||||
#define CAPWAP_STATISTICS_TIMER 120
|
||||
|
||||
|
||||
#define CW_TIMERS ((CW_DISCOVERY_INTERVAL << 8) | CAPWAP_ECHO_INTERVAL)
|
||||
/*#define CW_TIMERS ((CW_DISCOVERY_INTERVAL << 8) | CAPWAP_ECHO_INTERVAL)*/
|
||||
|
||||
/*
|
||||
//#define CAPWAP_CIPHER "PSK-AES128-CBC-SHA:"
|
||||
@ -594,7 +595,7 @@ const char *cw_strelemp_(cw_strheap_t h, int msg_id);
|
||||
|
||||
#define cw_strelemp(p,id) cw_strelemp_((p)->strelem,id)
|
||||
|
||||
|
||||
/*
|
||||
struct cw_ac_status {
|
||||
int stations;
|
||||
int limit;
|
||||
@ -604,6 +605,7 @@ struct cw_ac_status {
|
||||
int rmac_field;
|
||||
int dtls_policy;
|
||||
};
|
||||
*/
|
||||
|
||||
/**
|
||||
*@defgroup CAPWAP CAPWAP
|
||||
|
@ -311,7 +311,7 @@ int cw_put_elem_result_code(uint8_t * dst, uint32_t code);
|
||||
|
||||
|
||||
|
||||
extern int cw_put_ac_status(uint8_t * dst, struct cw_ac_status *s, struct conn *conn);
|
||||
/*extern int cw_put_ac_status(uint8_t * dst, struct cw_ac_status *s, struct conn *conn);*/
|
||||
|
||||
|
||||
struct cw_DescriptorSubelemDef {
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "cw.h"
|
||||
|
||||
|
||||
#include "acpriolist.h"
|
||||
/*#include "acpriolist.h"*/
|
||||
|
||||
|
||||
/*
|
||||
|
@ -35,7 +35,7 @@ wtp-name:Bstr16:WFAT01
|
||||
|
||||
|
||||
wtp-fallback:Byte:1
|
||||
"ac-name-with-priority/TubesAC":Byte:3
|
||||
ac-name-with-priority/TubesACx:Byte:3
|
||||
ac-name-with-priority/"ac2":Byte:01
|
||||
|
||||
|
||||
|
@ -18,8 +18,8 @@
|
||||
|
||||
int cw_select_ac(mavl_t local_cfg,mlist_t aclist){
|
||||
mlistelem_t * e;
|
||||
int en;
|
||||
mavl_t iplist;
|
||||
int en;
|
||||
|
||||
iplist=cw_ktv_create();
|
||||
if (iplist == NULL)
|
||||
@ -29,47 +29,48 @@ int cw_select_ac(mavl_t local_cfg,mlist_t aclist){
|
||||
|
||||
/* for each discovery response */
|
||||
mlist_foreach(e,aclist){
|
||||
char str[1024];
|
||||
char acname[CAPWAP_MAX_AC_NAME_LEN+1];
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
mavl_t remote_cfg;
|
||||
int i;
|
||||
cw_KTV_t * val;
|
||||
int prio;
|
||||
cw_KTV_t * val, *ipval;
|
||||
int prio,i;
|
||||
|
||||
remote_cfg = mlistelem_get_ptr(e);
|
||||
|
||||
/* get ac name */
|
||||
val = cw_ktv_get(remote_cfg,"ac-name", CW_TYPE_BSTR16);
|
||||
if (val==NULL)
|
||||
continue;
|
||||
|
||||
val->type->to_str(val,str,1024);
|
||||
sprintf(key,"ac-name-with-priority/%s",str);
|
||||
|
||||
printf("Get prio: %s\n",key);
|
||||
|
||||
prio = cw_ktv_get_byte(local_cfg,key,255);
|
||||
if (val==NULL){
|
||||
/* this should not happen, because AC Name is a
|
||||
* amndatory message element */
|
||||
prio=255;
|
||||
}
|
||||
else{
|
||||
/* Get priority for AC from
|
||||
* ac-name-with-priority list */
|
||||
val->type->to_str(val,acname,CAPWAP_MAX_AC_NAME_LEN);
|
||||
sprintf(key,"ac-name-with-priority/%s",acname);
|
||||
prio = cw_ktv_get_byte(local_cfg,key,255);
|
||||
}
|
||||
|
||||
/* for each control ip address the AC has sent */
|
||||
i=0;
|
||||
do {
|
||||
cw_KTV_t * ipval;
|
||||
sprintf(key,"%s.%d","capwap-control-ip-address/wtps",i);
|
||||
val = cw_ktv_get(remote_cfg,key,CW_TYPE_WORD);
|
||||
if (val == NULL)
|
||||
break;
|
||||
|
||||
|
||||
sprintf(key,"%s.%d","capwap-control-ip-address/address",i);
|
||||
printf("ipvalkey: %s\n",key);
|
||||
ipval = cw_ktv_get(remote_cfg,key,CW_TYPE_IPADDRESS);
|
||||
|
||||
sprintf(key,"%04d%05d%04d",prio,val->val.word,en);
|
||||
en++;
|
||||
printf("This is the key: %s\n",key);
|
||||
|
||||
|
||||
cw_ktv_add(iplist,key,CW_TYPE_SYSPTR,(uint8_t*)(&ipval),sizeof(ipval));
|
||||
i++;
|
||||
i++;
|
||||
en++;
|
||||
}while(1);
|
||||
printf("Here we have an AC: %s\n",str);
|
||||
printf("Here we have an AC: %s\n",acname);
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user