Improved discriptor sub-element handling and debugging.
FossilOrigin-Name: 1be3acc6e8fe2f1b579bf1d84589aca685effc8c551372b536488f66ce0e0d84
This commit is contained in:
@ -65,7 +65,8 @@ UTILOBJS= \
|
||||
send.o \
|
||||
cw_read_wtp_descriptor.o \
|
||||
cw_read_wtp_descriptor_7.o \
|
||||
cw_read_wtp_descriptor_versions.o
|
||||
cw_read_wtp_descriptor_versions.o \
|
||||
cw_read_descriptor_subelems.o
|
||||
|
||||
MAVLOBJS= \
|
||||
mavl_del.o \
|
||||
@ -152,6 +153,7 @@ CAPWAPOBJS= \
|
||||
cw_in_cisco_image_identifier.o\
|
||||
cw_out_radio_operational_state.o\
|
||||
cw_in_ac_descriptor.o\
|
||||
cw_read_ac_descriptor.o\
|
||||
cw_out_capwap_local_ip_address.o\
|
||||
cw_out_wtp_ip_address.o\
|
||||
cw_out_capwap_control_ip_addr_list.o \
|
||||
|
15
src/cw/cw.h
15
src/cw/cw.h
@ -400,13 +400,24 @@ static inline int cw_put_ac_status(uint8_t * dst, struct cw_ac_status *s)
|
||||
}
|
||||
|
||||
|
||||
struct cw_descriptor_subelem_def {
|
||||
int vendor_id;
|
||||
int type;
|
||||
const char *item_id;
|
||||
int maxlen;
|
||||
int mand;
|
||||
};
|
||||
|
||||
|
||||
extern int cw_read_descriptor_subelems(mbag_t store, uint8_t * data, int len, struct cw_descriptor_subelem_def *elems);
|
||||
|
||||
extern int cw_read_wtp_descriptor(mbag_t mbag, struct conn *conn,
|
||||
struct cw_action_in *a, uint8_t * data, int len);
|
||||
struct cw_action_in *a, uint8_t * data, int len,struct cw_descriptor_subelem_def *allowed);
|
||||
|
||||
extern int cw_read_wtp_descriptor_7(mbag_t mbag, struct conn *conn,
|
||||
struct cw_action_in *a, uint8_t * data, int len);
|
||||
struct cw_action_in *a, uint8_t * data, int len,struct cw_descriptor_subelem_def *allowed);
|
||||
|
||||
extern int cw_read_ac_descriptor(mbag_t store, uint8_t *data, int len, struct cw_descriptor_subelem_def *allowed);
|
||||
|
||||
extern int cw_read_wtp_descriptor_versions(mbag_t mbag, uint8_t * data, int len);
|
||||
|
||||
|
@ -1,130 +1,42 @@
|
||||
|
||||
#include "cw.h"
|
||||
#include "capwap_items.h"
|
||||
#include "dbg.h"
|
||||
#include "mbag.h"
|
||||
|
||||
/*
|
||||
static int read_subelem_cisco(struct ac_info* acinfo,int subtype,uint8_t * elem, int len)
|
||||
|
||||
int cw_in_ac_descriptor(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len, struct sockaddr *from)
|
||||
{
|
||||
switch (subtype) {
|
||||
case 0:
|
||||
bstr_replace(&acinfo->hardware_version,bstr_create(elem,len));
|
||||
break;
|
||||
case 1:
|
||||
bstr_replace(&acinfo->software_version,bstr_create(elem,len));
|
||||
break;
|
||||
|
||||
default:
|
||||
//printf("What? %d\n",subtype);
|
||||
break;
|
||||
return cw_read_ac_descriptor(conn->config,data,len,NULL);
|
||||
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
static int read_subelem(struct ac_info* acinfo,int subtype,uint8_t *elem, int len)
|
||||
{
|
||||
switch (subtype){
|
||||
case 0:
|
||||
case 4:
|
||||
bstr_replace(&acinfo->hardware_version,bstr_create(elem,len));
|
||||
break;
|
||||
case 1:
|
||||
case 5:
|
||||
bstr_replace(&acinfo->software_version,bstr_create(elem,len));
|
||||
break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static int read_subeelms(struct conn *conn,struct cw_action_in * a,uint8_t *data,int len,struct sockaddr *from)
|
||||
{
|
||||
int sub=12;
|
||||
//int sublen;
|
||||
|
||||
|
||||
while (sub<len){
|
||||
if (len-sub<8)
|
||||
return 0;
|
||||
|
||||
|
||||
uint32_t vendor_id = cw_get_dword(data+sub);
|
||||
int sublen = cw_get_word(data+sub+6);
|
||||
int subtype = cw_get_word(data+sub+4);
|
||||
//printf("substart : %d\n",sub);
|
||||
|
||||
bstrv_t vstr=NULL;
|
||||
switch (subtype){
|
||||
case 0:
|
||||
case 4:
|
||||
/* hardware version */
|
||||
vstr = mbag_set_bstrv(conn->incomming,CW_ITEM_AC_HARDWARE_VERSION,
|
||||
vendor_id,data+sub+8,sublen);
|
||||
break;
|
||||
case 1:
|
||||
case 5:
|
||||
/* software version */
|
||||
vstr = mbag_set_bstrv(conn->incomming,CW_ITEM_AC_SOFTWARE_VERSION,
|
||||
vendor_id,data+sub+8,sublen);
|
||||
break;
|
||||
}
|
||||
|
||||
cw_dbg_version_subelem(DBG_SUBELEM,"AC Descriptor", subtype, vstr);
|
||||
|
||||
|
||||
if (sub+sublen>len)
|
||||
return -1;
|
||||
|
||||
sub+=sublen+8;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int cw_in_ac_descriptor(struct conn *conn,struct cw_action_in * a,uint8_t *data,int len,struct sockaddr *from)
|
||||
{
|
||||
struct cw_ac_status *status = malloc(sizeof(struct cw_ac_status));
|
||||
if (!status)
|
||||
return 0;
|
||||
|
||||
status->stations = cw_get_word(data);
|
||||
status->limit = cw_get_word(data+2);
|
||||
status->active_wtps=cw_get_word(data+4);
|
||||
status->max_wtps=cw_get_word(data+6);
|
||||
status->security=cw_get_byte(data+8);
|
||||
status->rmac_field=cw_get_byte(data+9);
|
||||
status->dtls_policy=cw_get_byte(data+11);
|
||||
status->limit = cw_get_word(data + 2);
|
||||
status->active_wtps = cw_get_word(data + 4);
|
||||
status->max_wtps = cw_get_word(data + 6);
|
||||
status->security = cw_get_byte(data + 8);
|
||||
status->rmac_field = cw_get_byte(data + 9);
|
||||
status->dtls_policy = cw_get_byte(data + 11);
|
||||
|
||||
cw_dbg(DBG_SUBELEM,"AC Desriptor: WTPs:%d/%d, Stations:%d/%d, Security:%d, Rmac:%d, DTLS-Policy:%d",
|
||||
status->active_wtps,status->max_wtps,
|
||||
status->stations,status->limit,
|
||||
status->security,
|
||||
status->rmac_field,
|
||||
status->dtls_policy);
|
||||
cw_dbg(DBG_SUBELEM,
|
||||
"AC Descriptor: WTPs:%d/%d, Stations:%d/%d, Security:%d, Rmac:%d, DTLS-Policy:%d",
|
||||
status->active_wtps, status->max_wtps, status->stations, status->limit,
|
||||
status->security, status->rmac_field, status->dtls_policy);
|
||||
|
||||
|
||||
mbag_set_ptr(conn->incomming,CW_ITEM_AC_STATUS,status);
|
||||
mbag_set_ptr(conn->incomming, CW_ITEM_AC_STATUS, status);
|
||||
|
||||
static struct cw_descriptor_subelem_def allowed[] = {
|
||||
{0,CW_SUBELEM_AC_HARDWARE_VERSION, CW_ITEM_WTP_HARDWARE_VERSION, 1024,1},
|
||||
{0,CW_SUBELEM_AC_SOFTWARE_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024,1},
|
||||
{0,0, NULL,0, 0}
|
||||
};
|
||||
|
||||
cw_read_descriptor_subelems(conn->config, data + 12, len - 12, allowed);
|
||||
|
||||
read_subeelms(conn,a,data,len,from);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -6,10 +6,9 @@
|
||||
|
||||
|
||||
int cw_read_wtp_descriptor(mbag_t mbag, struct conn *conn,
|
||||
struct cw_action_in *a, uint8_t * data, int len)
|
||||
struct cw_action_in *a, uint8_t * data, int len,struct cw_descriptor_subelem_def *allowed)
|
||||
{
|
||||
|
||||
|
||||
mbag_set_byte(mbag, CW_ITEM_WTP_MAX_RADIOS, cw_get_byte(data));
|
||||
mbag_set_byte(mbag, CW_ITEM_WTP_RADIOS_IN_USE, cw_get_byte(data + 1));
|
||||
|
||||
@ -33,6 +32,17 @@ int cw_read_wtp_descriptor(mbag_t mbag, struct conn *conn,
|
||||
pos += 3;
|
||||
}
|
||||
|
||||
return cw_read_wtp_descriptor_versions(mbag, data + pos, len - pos);
|
||||
static struct cw_descriptor_subelem_def allowed_default[] = {
|
||||
{0,CW_SUBELEM_WTP_HARDWARE_VERSION, CW_ITEM_WTP_HARDWARE_VERSION, 1024,1},
|
||||
{0,CW_SUBELEM_WTP_SOFTWARE_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024,1},
|
||||
{0,CW_SUBELEM_WTP_BOOTLOADER_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024,1},
|
||||
{0,CW_SUBELEM_WTP_OTHERSOFTWARE_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024,0},
|
||||
{0,0, NULL, 0,0}
|
||||
};
|
||||
|
||||
if (!allowed) {
|
||||
allowed=allowed_default;
|
||||
}
|
||||
|
||||
return cw_read_descriptor_subelems(conn->incomming, data + pos, len - pos, allowed);
|
||||
}
|
||||
|
@ -7,7 +7,8 @@
|
||||
* Read WTP Descriptor in Cisco-Style (Draft 7)
|
||||
*/
|
||||
int cw_read_wtp_descriptor_7(mbag_t mbag, struct conn *conn,
|
||||
struct cw_action_in *a, uint8_t * data, int len)
|
||||
struct cw_action_in *a, uint8_t * data, int len,
|
||||
struct cw_descriptor_subelem_def *allowed)
|
||||
{
|
||||
|
||||
mbag_set_byte(mbag, CW_ITEM_WTP_MAX_RADIOS, cw_get_byte(data));
|
||||
@ -20,5 +21,17 @@ int cw_read_wtp_descriptor_7(mbag_t mbag, struct conn *conn,
|
||||
//cw_get_word(data + pos + 2);
|
||||
pos += 2;
|
||||
|
||||
return cw_read_wtp_descriptor_versions(mbag, data + pos, len - pos);
|
||||
|
||||
static struct cw_descriptor_subelem_def allowed_default[] = {
|
||||
{-1,CW_SUBELEM_WTP_HARDWARE_VERSION, CW_ITEM_WTP_HARDWARE_VERSION, 1024,0},
|
||||
{-1,CW_SUBELEM_WTP_SOFTWARE_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024.0},
|
||||
{-1,CW_SUBELEM_WTP_BOOTLOADER_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024,0},
|
||||
{-1,CW_SUBELEM_WTP_OTHERSOFTWARE_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024,0},
|
||||
{0,0, NULL, 0,0}
|
||||
};
|
||||
|
||||
if (!allowed)
|
||||
allowed=allowed_default;
|
||||
|
||||
return cw_read_descriptor_subelems(mbag, data + pos, len - pos, allowed);
|
||||
}
|
||||
|
Reference in New Issue
Block a user