Do some mgic to send Cisco's AC radio info element

shell
7u83 6 months ago
parent 744e1b55c2
commit c3b921292b
  1. 2
      src/cw/cw.c
  2. 2
      src/cw/cw.h
  3. 2
      src/mod/capwap/capwap_actions.c
  4. 21
      src/mod/capwap80211/capwap80211_messages.c
  5. 117
      src/mod/cisco/cisco80211_out_wtp_radio_configuration.c
  6. 31
      src/mod/cisco/cisco_actions.c
  7. 17
      src/mod/cisco/cisco_out_radio_generic.c
  8. 17
      src/wtp/cisco.ckv
  9. 3
      src/wtp/join.c
  10. 15
      src/wtp/wtp_main.c

@ -125,6 +125,8 @@ int cw_out_radio_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerP
start = params->msgset->header_len(handler)+len;
sprintf(key,"radio.%d/%s",i,handler->key);
//printf("RADIO KEY: %s\n",key);
// cw_dbg(DBG_X,"KEY: %s",key);
l = type->write(params->cfg_list, key,dst+start+1,handler->param);

@ -557,6 +557,8 @@ int cw_put_descriptor_subelem (uint8_t *dst, cw_Cfg_t ** cfg_list,
int subelem_id, const char * parent_key );
int cw_send_request(struct cw_Conn *conn,int msg_id);
/**
*@}
*/

@ -102,7 +102,7 @@ static struct cw_ElemHandler handlers[] = {
0,0, /* Vendor / Proto */
1,1, /* min/max length */
CW_TYPE_BYTE, /* type */
"discovery-type", /* Key */
"capwap/discovery-type", /* Key */
cw_in_generic, /* get */
cw_out_generic, /* put */
NULL,

@ -68,32 +68,33 @@ static struct cw_ElemHandler handlers[] = {
,
{NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL}
};
/*static int discovery_request_states[] = { CAPWAP_STATE_DISCOVERY, 0 };*/
static struct cw_ElemDef discovery_request_elements[] = {
{0, 0, CAPWAP80211_ELEM_WTP_RADIO_INFORMATION, 1, 0},
{0, 0, 0, 0, 0}
};
static struct cw_ElemDef discovery_response_elements[] = {
{0, 0, CAPWAP80211_ELEM_WTP_RADIO_INFORMATION, 1, 0},
{0, 0, 0, 0, 0}
};
/*static int join_request_states[] = { CAPWAP_STATE_JOIN, 0 };*/
static struct cw_ElemDef join_request_elements[] = {
{0, 0, CAPWAP80211_ELEM_WTP_RADIO_INFORMATION, 1, 0},
{0, 0, 0, 0, 0}
};
/*static int join_response_states[] = { CAPWAP_STATE_JOIN, 0 };*/
static struct cw_ElemDef join_response_elements[] = {
{0, 0, CAPWAP80211_ELEM_WTP_RADIO_INFORMATION, 1, 0},
{0, 0, CAPWAP80211_ELEM_WTP_RADIO_INFORMATION, 1, 0},
{0, 0, 0, 0, 0}
};
/*static int configuration_status_response_states[] = { CAPWAP_STATE_JOIN, 0 };*/
static struct cw_ElemDef configuration_status_response_elements[] = {
{0, 0, CAPWAP80211_ELEM_RATE_SET , 1, 0},
{0, 0, 0, 0, 0}
@ -108,6 +109,14 @@ static struct cw_MsgDef messages[] = {
discovery_request_elements
}
,
{
NULL,
CAPWAP_MSG_DISCOVERY_RESPONSE,
CW_ROLE_WTP,
NULL, /* states */
discovery_response_elements
}
,
{
NULL, /* name */
CAPWAP_MSG_JOIN_REQUEST, /* type */

@ -1,117 +0,0 @@
#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->u2.data;
mbag_t radio = mbag_i_get_mbag(conn->radios,r->u1.iid,NULL);
radio = radio_upd;
d+=cw_put_byte(d,r->u1.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));
}

@ -34,6 +34,10 @@ static int postprocess_discovery();
static int preprocess_join_request();
static int postprocess_join_request();
int cisco_out_radio_info(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
, uint8_t * dst);
static cw_ValValRange_t cfg_type[]={
{1,1,"1 - global"},
{2,2,"2 - custom"},
@ -879,17 +883,17 @@ static struct cw_ElemHandler handlers70[] = {
cw_out_generic /* put */
}
,
// {
// "80211 WTP Radio Information - Cisco", /* name * /
// CAPWAP80211_ELEM_WTP_RADIO_INFORMATION, /* Element ID * /
// 0, 0, /* Vendor / Proto * /
// 0, 0, /* min/max length * /
// CW_TYPE_DWORD, /* type * /
// "wtp-radio-information", /* Key * /
// cw_in_radio_generic, /* get * /
// cw_out_radio_generic /* put * /
// }
// ,
{
"80211 WTP Radio Information - Cisco", /* name */
CAPWAP80211_ELEM_WTP_RADIO_INFORMATION, /* Element ID */
0, 0, /* Vendor / Proto */
0, 0, /* min/max length */
CW_TYPE_DWORD, /* type */
"capwap80211/wtp-radio-information", /* Key */
cw_in_radio_generic, /* get */
cisco_out_radio_info /* put */
}
,
{
"Session ID (Cisco min len = 4)", /* name */
CAPWAP_ELEM_SESSION_ID, /* Element ID */
@ -2123,13 +2127,12 @@ static struct cw_ElemHandler handlers70[] = {
};
/*static uint16_t discovery_request_states[] = {CAPWAP_STATE_DISCOVERY,0};*/
static struct cw_ElemDef discovery_request_elements[] ={
/* {0,0, CAPWAP_ELEM_WTP_DESCRIPTOR, 1, 0},*/
{0,0, CAPWAP_ELEM_WTP_BOARD_DATA, 0, 0},
{0,CW_VENDOR_ID_CISCO, CISCO_ELEM_RAD_NAME, 1, 0},
{0,CW_VENDOR_ID_CISCO, CW_CISCO_BOARD_DATA_OPTIONS, 0, 0},
{0,0, CAPWAP80211_ELEM_WTP_RADIO_INFORMATION, 0, 0},
{0,0, CAPWAP80211_ELEM_WTP_RADIO_INFORMATION, 1, 0},
{0,0,0,00}
};
@ -2138,7 +2141,7 @@ static struct cw_ElemDef discovery_request_elements[] ={
static struct cw_ElemDef discovery_response_elements[] ={
{0,CW_VENDOR_ID_CISCO, CISCO_ELEM_AP_TIMESYNC, 1, 0},
{0,CW_VENDOR_ID_CISCO, CISCO_ELEM_MWAR_TYPE, 0, 0},
{0,0, CAPWAP80211_ELEM_WTP_RADIO_INFORMATION, 0, 0},
{0,0, CAPWAP80211_ELEM_WTP_RADIO_INFORMATION, 1, 0},
{0,0,0,00}
};

@ -25,3 +25,20 @@ cw_dbg(DBG_X,"NUM RADIOS: %d",radios);
return len;
}
int cisco_out_radio_info(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
, uint8_t * dst)
{
if (! (params->msgdata->type & 1) ){
int start = params->msgset->header_len(handler);
cw_put_byte(dst+start,0);
cw_put_dword(dst+start+1,7);
return params->msgset->write_header(handler,dst,5);
}
return cw_out_radio_generic(handler,params,dst);
}

@ -9,6 +9,7 @@ capwap-local-ip-address: 192.168.0.13
capwap-timers/echo-interval: 30
capwap-timers/max-discovery-interval: 10
capwap/ac-name:
capwap/discovery-type: 1
cisco-8011-assoc-limit/enable: false
cisco-8011-assoc-limit/interval: 500
cisco-8011-assoc-limit/limit: 25
@ -60,7 +61,7 @@ cisco/ap-username-and-password/login-credentials/password: $1$MX4t$F19wCuY8yN5jB
cisco/ap-username-and-password/login-credentials/username: admin
cisco/cisco-discovery-protocol/data: 513
cisco/cisco-discovery-protocol/enabled: false
cisco/elem132: .x0000000000
cisco/elem132: .x0100000000
cisco/loghost-config/last-joined-ap: None
cisco/loghost-config/loghost: 255.255.255.255
cisco/lw-path-mtu/len: 1095
@ -121,7 +122,7 @@ radio.0/cisco/elem146: .x690f
radio.0/cisco/elem153: .x00
radio.0/cisco/elem156: .x020100
radio.0/cisco/elem16: .x02040b0c
radio.0/cisco/elem19: .xc0a800a10001000cc0a800a103000101003ccd774fc43bd27db633509934957d3acb000000000000000052464d000000000000000000000000000000000000000000000000000000000001060b010101
radio.0/cisco/elem19: .xc0a800a10001000cc0a800a103000101001ecd774fc43bd27db633509934957d3acb000000000000000052464d000000000000000000000000000000000000000000000000000000000001060b010101
radio.0/cisco/elem22: .x0d00b400320102030405060708090a0b0c0d
radio.0/cisco/elem24: .x003c000c
radio.0/cisco/elem39: .x0078
@ -175,7 +176,7 @@ radio.0/wlan.1/add-wlan/scan-defer-time: 100
radio.0/wlan.1/add-wlan/session-timout: 1800
radio.0/wlan.1/add-wlan/ssid: tubeC
radio.0/wlan.1/add-wlan/wep-encryption: false
radio.0/wlan.1/add-wlan/wep-key: .x1994f9d6d5f332f6531f532803
radio.0/wlan.1/add-wlan/wep-key: .x4568d9877819af1f317267e3b7
radio.0/wlan.1/add-wlan/wep-key-index: 1
radio.0/wlan.1/add-wlan/wlan-capability: 1073
radio.0/wlan.1/add-wlan/wlan-id: 1
@ -192,7 +193,7 @@ radio.0/wlan.13/add-wlan/scan-defer-time: 100
radio.0/wlan.13/add-wlan/session-timout: 1800
radio.0/wlan.13/add-wlan/ssid: SuperSSID
radio.0/wlan.13/add-wlan/wep-encryption: false
radio.0/wlan.13/add-wlan/wep-key: .x1994f9d6d5f332f6531f532803
radio.0/wlan.13/add-wlan/wep-key: .x4568d9877819af1f317267e3b7
radio.0/wlan.13/add-wlan/wep-key-index: 1
radio.0/wlan.13/add-wlan/wlan-capability: 1057
radio.0/wlan.13/add-wlan/wlan-id: 13
@ -219,12 +220,12 @@ radio.1/cisco/direct-sequence-control/unknown: 1
radio.1/cisco/elem145: .x01
radio.1/cisco/elem146: .x690f
radio.1/cisco/elem15/cfg-type: 1 - global
radio.1/cisco/elem15/channel: 52
radio.1/cisco/elem15/channel: 132
radio.1/cisco/elem15/rest: .x07ffffffce010001
radio.1/cisco/elem153: .x00
radio.1/cisco/elem156: .x020100
radio.1/cisco/elem16: .x0c121824
radio.1/cisco/elem19: .xc0a800a10001000bc0a800a110000101003ccd774fc43bd27db633509934957d3acb000000000000000052464d000000000000000000000000000000000000000000000000000000000024282c3034383c4064686c707484888c01010101010101010101010101010101
radio.1/cisco/elem19: .xc0a800a10001000bc0a800a110000101001ecd774fc43bd27db633509934957d3acb000000000000000052464d000000000000000000000000000000000000000000000000000000000024282c3034383c4064686c707484888c01010101010101010101010101010101
radio.1/cisco/elem22: .x1000b4003224282c3034383c4064686c707484888c
radio.1/cisco/elem24: .x003c000c
radio.1/cisco/elem39: .x0078
@ -278,7 +279,7 @@ radio.1/wlan.1/add-wlan/scan-defer-time: 100
radio.1/wlan.1/add-wlan/session-timout: 1800
radio.1/wlan.1/add-wlan/ssid: tubeC
radio.1/wlan.1/add-wlan/wep-encryption: false
radio.1/wlan.1/add-wlan/wep-key: .xef86466b27791853131dd3073c
radio.1/wlan.1/add-wlan/wep-key: .xe541d298736af873037ee6e44b
radio.1/wlan.1/add-wlan/wep-key-index: 1
radio.1/wlan.1/add-wlan/wlan-capability: 17
radio.1/wlan.1/add-wlan/wlan-id: 1
@ -295,7 +296,7 @@ radio.1/wlan.13/add-wlan/scan-defer-time: 100
radio.1/wlan.13/add-wlan/session-timout: 1800
radio.1/wlan.13/add-wlan/ssid: SuperSSID
radio.1/wlan.13/add-wlan/wep-encryption: false
radio.1/wlan.13/add-wlan/wep-key: .xef86466b27791853131dd3073c
radio.1/wlan.13/add-wlan/wep-key: .xe541d298736af873037ee6e44b
radio.1/wlan.13/add-wlan/wep-key-index: 1
radio.1/wlan.13/add-wlan/wlan-capability: 1
radio.1/wlan.13/add-wlan/wlan-id: 13

@ -17,6 +17,9 @@
#include "wtp.h"
int run_join(struct cw_Conn *conn);
/*
#define acinfo_log acinfo_log_

@ -84,11 +84,12 @@ int main (int argc, char **argv)
struct cw_Mod * mod;
struct cw_MsgSet * msgset=NULL;
struct cw_Conn * conn=NULL;
FILE * file;
//FILE * file;
cw_Cfg_t * global_cfg =NULL;
const cw_Type_t ** ti;
//const cw_Type_t ** ti;
int i;
int rc;
int rc=EXIT_FAILURE;
struct cw_DiscoveryResults * results;
bootcfg.nmods=0;
@ -175,11 +176,13 @@ int main (int argc, char **argv)
/*cw_run_discovery(conn, "255.255.255.255","192.168.56.1", &dis);*/
/* cw_run_discovery(conn, "255.255.255.255",NULL, &dis);*/
struct cw_DiscoveryResulsts * results;
//cw_run_discovery(conn, "192.168.0.24","192.168.0.14", &dis);
//
results = cw_run_discovery(conn, "255.255.255.255","192.168.0.14");
//results = cw_run_discovery(conn, "255.255.255.255","192.168.0.14");
//results = cw_run_discovery(conn, "255.255.255.255","192.168.0.24");
results = cw_run_discovery(conn, "192.168.0.161","192.168.0.24");
// results = cw_run_discovery(conn, "255.255.255.255","0.0.0.0");
// cw_run_discovery(conn, "192.168.0.255","192.168.0.14", &dis);
//results = cw_run_discovery(conn, "255.255.255.255","192.168.0.14");
// results = cw_run_discovery(conn, "192.168.0.24","192.168.0.14");
@ -187,6 +190,8 @@ int main (int argc, char **argv)
// results = cw_run_discovery(conn, "255.255.255.255","172.16.67.185");
// results = cw_run_discovery(conn, "172.16.67.255","172.16.67.185");
if (!results)
goto errX;
if (!join(conn,results)){

Loading…
Cancel
Save