diff --git a/libcw.project b/libcw.project index 5ed821a5..0ce1b7ef 100644 --- a/libcw.project +++ b/libcw.project @@ -18,7 +18,6 @@ - @@ -56,7 +55,6 @@ - @@ -116,7 +114,6 @@ - @@ -195,7 +192,6 @@ - diff --git a/src/ac/ac.conf b/src/ac/ac.conf index 07c4eddd..8c60c020 100644 --- a/src/ac/ac.conf +++ b/src/ac/ac.conf @@ -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 diff --git a/src/ac/config.ktv b/src/ac/config.ktv index 7d37c7e6..eb1713d6 100644 --- a/src/ac/config.ktv +++ b/src/ac/config.ktv @@ -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 diff --git a/src/cw/Makefile b/src/cw/Makefile index bc5217b3..5e5de050 100644 --- a/src/cw/Makefile +++ b/src/cw/Makefile @@ -191,8 +191,6 @@ LOGSRC=\ dbg_strings.c\ MISCSRC=\ - aciplist.c\ - acpriolist.c\ bstr16_create.c\ bstr16_create_from_str.c\ bstr_create.c\ diff --git a/src/cw/aciplist.c b/src/cw/aciplist.c deleted file mode 100644 index 82f6eace..00000000 --- a/src/cw/aciplist.c +++ /dev/null @@ -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 . - -*/ - -/** - * @file - * @brief Implements some aciplist functions - */ - -#include -#include - -#include -#include - -#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); -} - diff --git a/src/cw/aciplist.h b/src/cw/aciplist.h deleted file mode 100644 index 021af739..00000000 --- a/src/cw/aciplist.h +++ /dev/null @@ -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 - diff --git a/src/cw/acpriolist.c b/src/cw/acpriolist.c deleted file mode 100644 index 4b2e96fa..00000000 --- a/src/cw/acpriolist.c +++ /dev/null @@ -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 . - -*/ - - -#include -#include - -#include -#include - -#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; -} - - */ diff --git a/src/cw/acpriolist.h b/src/cw/acpriolist.h deleted file mode 100644 index 0fe4e2c9..00000000 --- a/src/cw/acpriolist.h +++ /dev/null @@ -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 diff --git a/src/cw/capwap.h b/src/cw/capwap.h index 16fbfc1b..927ff100 100644 --- a/src/cw/capwap.h +++ b/src/cw/capwap.h @@ -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 diff --git a/src/cw/cw.h b/src/cw/cw.h index 72664808..a6118b47 100644 --- a/src/cw/cw.h +++ b/src/cw/cw.h @@ -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 { diff --git a/src/cw/cw_in_ac_name_with_priority.c b/src/cw/cw_in_ac_name_with_priority.c index c9cc185c..01a10bf8 100644 --- a/src/cw/cw_in_ac_name_with_priority.c +++ b/src/cw/cw_in_ac_name_with_priority.c @@ -7,7 +7,7 @@ #include "cw.h" -#include "acpriolist.h" +/*#include "acpriolist.h"*/ /* diff --git a/src/wtp/config.ktv b/src/wtp/config.ktv index 73c0d21b..596dc925 100644 --- a/src/wtp/config.ktv +++ b/src/wtp/config.ktv @@ -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 diff --git a/src/wtp/discovery.c b/src/wtp/discovery.c index 1e503829..ef60ed40 100644 --- a/src/wtp/discovery.c +++ b/src/wtp/discovery.c @@ -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); }