diff --git a/src/cw/mbag_get_upd.c b/src/cw/mbag_get_upd.c new file mode 100644 index 00000000..bf7d723e --- /dev/null +++ b/src/cw/mbag_get_upd.c @@ -0,0 +1,31 @@ + + + +#include "mbag.h" +#include "log.h" + + +int mbag_get_upd(mbag_t b, mbag_t b_upd, const char *id, uint8_t *dst, int *found) +{ + struct mbag_item *i = mbag_get(b_upd, id); + if (i) { + if (!i->type->put ){ + cw_log(LOG_ERROR,"No put method for %s",i->type->name); + return -1; + } + (*found)++; + return i->type->put(i, dst); + } + i = mbag_get(b,id); + if (i) { + if (!i->type->put){ + cw_log(LOG_ERROR,"No put method for %s",i->type->name); + return -1; + } + + return i->type->put(i, dst); + } + + return -1; + +} diff --git a/src/cw/mbag_type_bin.c b/src/cw/mbag_type_bin.c new file mode 100644 index 00000000..aeaf7500 --- /dev/null +++ b/src/cw/mbag_type_bin.c @@ -0,0 +1,118 @@ +#include + +#include "capwap80211_types.h" +#include "dot11.h" + + + + + +static int to_str(void *item,char *dst) +{ + mbag_item_t *it= item; + + uint8_t *data = (uint8_t*)it->data; + int n=*data; + data++; + + char *d=dst; + char *space=""; + int i; + for (i=0; idata=data; + + + return item; +} + +static struct mbag_item * get(const uint8_t *src,int len) +{ + + mbag_item_t * item = mbag_item_new(MBAG_BIN); + if (!item) + return NULL; + + uint8_t *data = malloc(len+1); + if (!data){ + free (item); + return NULL; + } + *data=len; + memcpy(data+1,src,len); + item->data=data; + return item; +} + + +const struct mbag_typedef capwap80211_type_rateset = { + .name = "Biary", + .del = free, + .from_str = from_str, + .to_str = to_str, + .get = get + +}; diff --git a/src/cw/mbag_type_bstr.c b/src/cw/mbag_type_bstr.c new file mode 100644 index 00000000..554b8dbe --- /dev/null +++ b/src/cw/mbag_type_bstr.c @@ -0,0 +1,5 @@ +const struct mbag_typedef mbag_type_bstr = { + "bstr",free +}; + + diff --git a/src/mod/cisco/cisco80211_out_wtp_radio_configuration.c b/src/mod/cisco/cisco80211_out_wtp_radio_configuration.c new file mode 100644 index 00000000..150e396f --- /dev/null +++ b/src/mod/cisco/cisco80211_out_wtp_radio_configuration.c @@ -0,0 +1,117 @@ + +#include "cw/mbag.h" +#include "cw/action.h" +#include "cw/dbg.h" +#include "cw/cw.h" + +#include "cisco_items.h" +#include "include/cipwap_items.h" +#include "cw/capwap80211_items.h" + +//int mbag_get_upd(mbag_t b, mbag_t b_upd, const char *id, +// uint8_t * dst, struct mbag_typedef * deftype, uint8_t * def, int deflen); + + +int mbag_get_upd(mbag_t b, mbag_t b_upd, const char *id, uint8_t *dst, int *found); + +int cisco80211_out_wtp_radio_configuration(struct conn *conn, struct cw_action_out *a, uint8_t * dst) +{ + +cw_dbg(DBG_X,"The update beginns ***************************************************************"); + int count=0; + int n; + uint8_t *d = dst+10; + + MAVLITER_DEFINE(it,conn->radios_upd); + mavliter_foreach(&it){ + struct mbag_item *r = mavliter_get(&it); + mbag_t radio_upd = r->data; + mbag_t radio = mbag_i_get_mbag(conn->radios,r->iid,NULL); + + radio = radio_upd; + + d+=cw_put_byte(d,r->iid); + +// mbag_t radio = mbag_i_get(conn->radios,radio_upd->data->iid); + + n = mbag_get_upd(radio,radio_upd,CISCO_RADIOITEM80211_CFG_TYPE,d,&count); + d += n==-1 ? cw_put_byte(dst,0) : n; + n = mbag_get_upd(radio,radio_upd,CIPWAP_RADIOITEM80211_OCCUPANCY_LIMIT,d,&count); + d += n==-1 ? cw_put_word(dst,100) : n; + n = mbag_get_upd(radio,radio_upd,CIPWAP_RADIOITEM80211_CFP_PERIOD,d,&count); + d += n==-1 ? cw_put_byte(dst,4) : n; + n = mbag_get_upd(radio,radio_upd,CIPWAP_RADIOITEM80211_CFP_MAXIMUM_DURATION,d,&count); + d += n==-1 ? cw_put_word(dst,60) : n; + + n = mbag_get_upd(radio,radio_upd,CW_RADIOITEM80211_BSSID,d,&count); + if (n==-1){ + char defbssid[6]={1,2,3,4,5,6}; + memcpy(d,defbssid,6); + d+=6; + } + else + d+=n; + + n = mbag_get_upd(radio,radio_upd,CW_RADIOITEM80211_BEACON_PERIOD,d,&count); + d += n==-1 ? cw_put_word(dst,100) : n; + + + + int dcount = 0; + n = mbag_get_upd(radio,radio_upd,CISCO_RADIOITEM80211_COUNTRY_STR1,d,&dcount); + if (!dcount){ + n = mbag_get_upd(radio,radio_upd,CW_RADIOITEM80211_COUNTRY_STRING,d,&count); + d += n==-1 ? cw_put_data(d,(uint8_t*)"DE ",3) : n; + } + else + d+=n; + + dcount=0; + n = mbag_get_upd(radio,radio_upd,CISCO_RADIOITEM80211_COUNTRY_STR2,d,&dcount); + if (!dcount){ + n = mbag_get_upd(radio,radio_upd,CW_RADIOITEM80211_COUNTRY_STRING,d,&count); + d += n==-1 ? cw_put_data(d,(uint8_t*)"DE ",3) : n; + } + else + d+=n; + + count +=dcount; + + + d+=cw_put_byte(d,10); + d+=cw_put_word(d,1); + d+=cw_put_word(d,0); + d+=cw_put_word(d,177<<8); + + + + + + } + + if (!count){ + cw_dbg(DBG_X,"Return 0, because no item was in radio"); + return 0; + } + + cw_dbg(DBG_X,"Yupp we do!"); + int l = d-dst-10; + return l + cw_put_elem_vendor_hdr(dst, a->vendor_id, a->elem_id, l); + + + /* + + + mbag_set_word(r,CW_RADIOITEM80211_BEACON_PERIOD,cw_get_word(data+13)); + mbag_set_bstr16n(r,CW_RADIOITEM80211_COUNTRY_STRING,data+15,3); + mbag_set_bstr16n(r,CISCO_RADIOITEM80211_COUNTRY_STR1,data+15,3); + mbag_set_bstr16n(r,CISCO_RADIOITEM80211_COUNTRY_STR2,data+18,3); + +*/ + +// mbag_set_byte(r,CISCO_RADIOITEM80211_CFG_TYPE,cw_get_byte(data+1)); + + + + +}