diff --git a/doc/capwap_cisco.txt b/doc/capwap_cisco.txt index 9b333c93..779c7b2b 100644 --- a/doc/capwap_cisco.txt +++ b/doc/capwap_cisco.txt @@ -1,4 +1,14 @@ +Terms used by Cisco, CAPWAP, LWAPP and others ... + +Slot ID = Radio ID +AC = MWAR = WLC +AP = RAD = WTP + + + + + 2. Cisco MWAR Addr Address of AC @@ -25,7 +35,7 @@ 83. Cisco AP IP Address - The IPv4 configuration of the WTP + The IPv4 configuration of the WTP 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 @@ -36,8 +46,10 @@ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Default Gateway | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Reserved | + | Type | Reserved ... | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Reserved | + +-+-+-+-+-+-+-+-+ Type: 83 Length: 16 @@ -45,6 +57,10 @@ IP Address: The IP address of AP Netmask: Netmask Default Gateway: default gateway + Type: + 1=Static + 0=DHCP + Reserved: (?) 126. Cisco AP Regulatory Domain @@ -54,9 +70,9 @@ 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Band ID | regDomainSet | RegDomainSlot | RegDomainCode | + | Band ID | regDomainSet | RegDomainSlot | RegDomainCode0 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | RegDomainCope1| + | RegDomainCode1| +-+-+-+-+-+-+-+-+ Type: 126 @@ -94,6 +110,9 @@ Type: Time type 0 = Manual (?) +169. Cisco AP IP Domain + +170. Cisco AP IP Name Server 207. Cisco Board Data Options @@ -124,10 +143,34 @@ 01 = Normal MWAR 02 = Configured MWAR +254. Cisco SPAM AP LED Flash Config + LWAPP ===== +20. Ciscp AP Username Password + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Username (32 bytes) ... + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + ... Username | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Password hash ... + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + + +44. Cisco AP Telnet SSH + 0 1 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + Type: 44 + Length: 2 + 73. Cisco Path MTU @@ -136,6 +179,8 @@ LWAPP +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Data length | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Padding data .. + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Type: 73 Length: >=4 diff --git a/src/capwap/Makefile b/src/capwap/Makefile index 804bb7f0..a5436804 100644 --- a/src/capwap/Makefile +++ b/src/capwap/Makefile @@ -64,6 +64,7 @@ LWAPPOBJS = \ lw_put_ac_descriptor.o \ lw_put_cisco_path_mtu.o \ lw_readelem_wtp_name.o \ + lw_put_80211_wtp_wlan_radio_configuration.o \ # LWAPP cisco vendor specific objs diff --git a/src/capwap/capwap.h b/src/capwap/capwap.h index bb919454..bdb85231 100644 --- a/src/capwap/capwap.h +++ b/src/capwap/capwap.h @@ -610,6 +610,7 @@ extern int cw_addelem_vendor_specific_payload(uint8_t * dst, uint32_t vendorid, uint8_t * data, uint16_t len); +extern void cw_prepare_configuration_status_request(struct conn * conn, struct radioinfo * radioinfo, struct wtpinfo *wtpinfo); #define cw_addelem_ac_name(dst,name) \ diff --git a/src/capwap/capwap_cisco.h b/src/capwap/capwap_cisco.h index 12a11d8c..3b9808a3 100644 --- a/src/capwap/capwap_cisco.h +++ b/src/capwap/capwap_cisco.h @@ -35,8 +35,10 @@ #define CW_CISCO_RAD_SLOT 4 #define CW_CISCO_RAD_NAME LW_ELEM_WTP_NAME /* 5 */ #define CW_CISCO_MWAR LW_ELEM_AC_DESCRIPTOR /* 6 */ +#define CW_CISCO_STATION_CFG 8 -#define CWVENDOR_CISCO_BOARD DATA LW_ELEM_WTP_BOARD_DATA /* 50 */ +#define CW_CISCO_CERTIFICATE LW_ELEM_CERTIFICATE /* 44 */ +#define CW_CISCO_BOARD DATA LW_ELEM_WTP_BOARD_DATA /* 50 */ #define CWVENDER_CISCO_AP_MODE_AND_TYPE 54 #define CWVENDOR_CISCO_AP_IP_ADDR 83 @@ -45,7 +47,7 @@ #define CW_CISCO_AP_GROUP_NAME 123 #define CWVENDOR_CISCO_AP_LED_STATE_CONFIG 125 -#define CW_ELEM_CISCO_AP_REGULATORY_DOMAIN 126 +#define CW_CISCO_AP_REGULATORY_DOMAIN 126 #define CWVENDOR_CISCO_AP_PRE_STD_SWITCH_CONFIG 137 #define CWVENDOR_CISCO_AP_POWER_INJECTOR_CONFIG 138 @@ -89,13 +91,25 @@ static inline int cw_addelem_cisco_rad_name(uint8_t * dst, uint8_t * name) * @param name Group name, zero terminated * @return number of bytes put */ -static inline int cw_addelem_cisco_ap_group_name(uint8_t * dst, uint8_t * name) -{ +static inline int cw_addelem_cisco_ap_group_name(uint8_t * dst, uint8_t * name){ return cw_addelem_vendor_specific_payload(dst, CW_VENDOR_ID_CISCO, CW_CISCO_AP_GROUP_NAME, name, strlen((char *) name)); } + +static inline int cw_addelem_cisco_ap_regulatory_domain(uint8_t *dst, struct radioinfo * ri){ + uint8_t *d=dst+10; + + d+=cw_put_byte(d,ri->rid); /* Band ID */ + d+=cw_put_byte(d,1); /* Set True/False */ + d+=cw_put_byte(d,ri->rid); /* Slot ID */ + d+=cw_put_word(d,ri->regDomain); + return 5 + cw_put_elem_vendor_hdr(dst, CW_VENDOR_ID_CISCO, CW_CISCO_AP_REGULATORY_DOMAIN, 5); +} + + + /** * Add a Cisco MWAR message element. * @param dst destinnation buffer @@ -110,6 +124,25 @@ static inline int cw_addelem_cisco_mwar(uint8_t *dst, struct ac_info *acinfo){ return l+cw_put_elem_vendor_hdr(dst,CW_VENDOR_ID_CISCO,CW_CISCO_MWAR,l); } +/** + * Add a Cisco Certificate payload message element + * @param dst destination buffer + * @param src pointer to DER certificate + * @param len length of certificate + * @return number of bytes put + */ +static inline int cw_addelem_cisco_certificate(uint8_t*dst,uint8_t*src,int len){ + int l = lw_put_certificate(dst+10,src,len); + return l+cw_put_elem_vendor_hdr(dst,CW_VENDOR_ID_CISCO,CW_CISCO_CERTIFICATE,l); +} + + + +static inline int cw_addelem_cisco_station_cfg(uint8_t * dst,struct radioinfo *ri){ + int l = lw_put_80211_wtp_wlan_radio_configuration(dst+10,ri); + return l+cw_put_elem_vendor_hdr(dst,CW_VENDOR_ID_CISCO,CW_CISCO_STATION_CFG,l); +} + /* @@ -133,7 +166,14 @@ static inline int cw_addelem_cisco_mwar(uint8_t *dst, struct ac_info *acinfo){ #define cwmsg_addelem_cisco_mwar(cwmsg,acinfo)\ (cwmsg)->pos+=cw_addelem_cisco_mwar(((cwmsg)->msgelems+(cwmsg)->pos),(acinfo)) +#define cwmsg_addelem_cisco_certificate(cwmsg,crt,len)\ + (cwmsg)->pos+=cw_addelem_cisco_certificate(((cwmsg)->msgelems+(cwmsg)->pos),crt,len) +#define cwmsg_addelem_cisco_ap_regulatory_domain(cwmsg,radioinfo)\ + (cwmsg)->pos+=cw_addelem_cisco_ap_regulatory_domain(((cwmsg)->msgelems+(cwmsg)->pos),radioinfo) + +#define cwmsg_addelem_cisco_station_cfg(cwmsg,radioinfo)\ + (cwmsg)->pos+=cw_addelem_cisco_station_cfg(((cwmsg)->msgelems+(cwmsg)->pos),radioinfo) #endif diff --git a/src/capwap/cw_prepare_configuration_status_request.c b/src/capwap/cw_prepare_configuration_status_request.c index a625eec0..da6aa741 100644 --- a/src/capwap/cw_prepare_configuration_status_request.c +++ b/src/capwap/cw_prepare_configuration_status_request.c @@ -1,20 +1,29 @@ #include "capwap.h" #include "lwapp_cisco.h" +#include "capwap_cisco.h" #include "conn.h" #include "wtpinfo.h" -void cw_prepare_configuration_status_request(struct conn * conn, struct wtpinfo *wtpinfo) +void cw_prepare_configuration_status_request(struct conn * conn, struct radioinfo * radioinfo, struct wtpinfo *wtpinfo) { struct cwmsg * cwmsg = &conn->req_msg; uint8_t * buffer = conn->req_buffer; - cwmsg_init(cwmsg,buffer,CW_MSG_CONFIGURATION_STATUS_REQUEST,conn_get_next_seqnum(conn),0); + + cwmsg_init(cwmsg,buffer,CW_MSG_CONFIGURATION_STATUS_REQUEST,conn_get_next_seqnum(conn),radioinfo); cwmsg->capwap_mode=conn->capwap_mode; cwmsg_addelem_ac_name(cwmsg,(uint8_t *)"AC-iMaxi"); + + cwmsg_addelem_cisco_ap_regulatory_domain(cwmsg,&wtpinfo->radioinfo[0]); + cwmsg_addelem_cisco_ap_regulatory_domain(cwmsg,&wtpinfo->radioinfo[1]); + + cwmsg_addelem_cisco_station_cfg(cwmsg,&wtpinfo->radioinfo[0]); + cwmsg_addelem_cisco_station_cfg(cwmsg,&wtpinfo->radioinfo[1]); + /* uint8_t mtu[2048]; int l = lw_put_cisco_path_mtu(mtu,1485,1701); diff --git a/src/capwap/cwmsg_addelem_wtp_board_data.c b/src/capwap/cwmsg_addelem_wtp_board_data.c index 5157e75f..675f55ca 100644 --- a/src/capwap/cwmsg_addelem_wtp_board_data.c +++ b/src/capwap/cwmsg_addelem_wtp_board_data.c @@ -44,6 +44,7 @@ void cwmsg_addelem_wtp_board_data(struct cwmsg *cwmsg, struct wtpinfo *wtpinfo) len += add_board_data_subelem(msg+len,CWBOARDDATA_REVISION,wtpinfo->board_revision); + if (wtpinfo->macaddress) { *((uint32_t *) (msg + len)) = htonl(CWBOARDDATA_MACADDRESS << 16 | wtpinfo->macaddress_len); diff --git a/src/capwap/cwsend_discovery_request.c b/src/capwap/cwsend_discovery_request.c index f5ea410f..e58c4212 100644 --- a/src/capwap/cwsend_discovery_request.c +++ b/src/capwap/cwsend_discovery_request.c @@ -59,7 +59,7 @@ int cwsend_discovery_request(struct conn *conn, struct radioinfo *radioinfo, /* radio infos */ - cwmsg_addelem_wtp_radio_infos(&cwmsg, wtpinfo->radioinfo); +// cwmsg_addelem_wtp_radio_infos(&cwmsg, wtpinfo->radioinfo); /* Non-mandatory elements */ diff --git a/src/capwap/cwsend_join_request.c b/src/capwap/cwsend_join_request.c index 5603df44..cd39b81d 100644 --- a/src/capwap/cwsend_join_request.c +++ b/src/capwap/cwsend_join_request.c @@ -30,6 +30,7 @@ #include "acinfo.h" //Tube +extern int pmu; int cwsend_join_request(struct conn *conn, struct radioinfo *radioinfo, struct wtpinfo *wtpinfo) { @@ -121,7 +122,11 @@ int cwsend_join_request(struct conn *conn, struct radioinfo *radioinfo, struct w case CWMODE_CISCO: { uint8_t mtu[2048]; - int l = lw_put_cisco_path_mtu(mtu,1485,11); + if(pmu) { + int l = lw_put_cisco_path_mtu(mtu,1485,11); + } + + //cwmsg_addelem_cisco_certificate(&cwmsg,mtu,10); // printf("Len = %d\n",l); diff --git a/src/capwap/lw_put_80211_wtp_wlan_radio_configuration.c b/src/capwap/lw_put_80211_wtp_wlan_radio_configuration.c index afce736c..4e871379 100644 --- a/src/capwap/lw_put_80211_wtp_wlan_radio_configuration.c +++ b/src/capwap/lw_put_80211_wtp_wlan_radio_configuration.c @@ -18,6 +18,9 @@ int lw_put_80211_wtp_wlan_radio_configuration(uint8_t*dst,struct radioinfo *ri) lw_put_data(dst+16,ri->country_str,4); lw_put_byte(dst+20,ri->max_bssid); - return 21; + /* XXX not LWAP conform */ + lw_put_data(dst+21,(uint8_t*)"DEAU990",7); + + return 21+7; } diff --git a/src/capwap/lwapp.h b/src/capwap/lwapp.h index e5a3f3ab..99eccda4 100644 --- a/src/capwap/lwapp.h +++ b/src/capwap/lwapp.h @@ -105,19 +105,27 @@ /* LWAPP message elements */ -#define LW_ELEM_AC_ADDRESS 2 -#define LW_ELEM_WTP_DESCRIPTOR 3 -#define LW_ELEM_WTP_NAME 5 -#define LW_ELEM_AC_DESCRIPTOR 6 +#define LW_ELEM_AC_ADDRESS 2 +#define LW_ELEM_WTP_DESCRIPTOR 3 +#define LW_ELEM_WTP_NAME 5 +#define LW_ELEM_AC_DESCRIPTOR 6 -#define LW_ELEM_AC_NAME 31 +#define LW_ELEM_AC_NAME 31 -#define LW_ELEM_SUPPORTED_RATES 16 -#define LW_ELEM_TEST 18 +#define LW_ELEM_SUPPORTED_RATES 16 +#define LW_ELEM_TEST 18 -#define LW_ELEM_WTP_BOARD_DATA 50 +#define LW_ELEM_CERTIFICATE 44 +#define LW_ELEM_WTP_BOARD_DATA 50 +#define LW_ELEM_AP_IP_ADDR 82 -#define LW_ELEM_VENDOR_SPECIFIC 104 +#define LW_ELEM_VENDOR_SPECIFIC 104 + + + +/* LWAPP IEEE 802.11 bindings */ + +#define LW_ELEM_80211_WTP_WLAN_RADIO_CONFIGURATION 8 /* useful macros and inline functions */ @@ -162,6 +170,8 @@ static inline int lw_put_elem_hdr(uint8_t *dst,uint8_t type,uint16_t len) } extern int lw_put_cisco_path_mtu(uint8_t *dst, uint16_t max, uint16_t padding); +#define lw_put_certificate(dst,cert,len) lw_put_data(dst,cert,len) +extern int lw_put_ac_descriptor(uint8_t * dst, struct ac_info * acinfo); /* function proto types */ @@ -170,7 +180,8 @@ extern uint16_t lw_checksum(uint8_t *d,int len); extern int lw_readelem_wtp_board_data(struct wtpinfo *wtpinfo, int type, uint8_t *msgelem, int len); extern int lw_readelem_wtp_name(bstr_t * dst, int type, uint8_t * msgelem, int len); -extern int lw_put_ac_descriptor(uint8_t * dst, struct ac_info * acinfo); + +extern int lw_put_80211_wtp_wlan_radio_configuration(uint8_t*dst,struct radioinfo *ri); diff --git a/src/capwap/radioinfo.h b/src/capwap/radioinfo.h index 9658ec86..b23f662d 100644 --- a/src/capwap/radioinfo.h +++ b/src/capwap/radioinfo.h @@ -31,6 +31,17 @@ struct radioinfo{ int state; int cause; bstr_t rmac; + + uint16_t regDomain; + + uint8_t country_str[4]; + int cfp_period; + int cfp_max_duration; + int beacon_period; + int dtim_period; + int max_bssid; + int occupancy_limit; + }; #endif diff --git a/src/capwap/wtpinfo.h b/src/capwap/wtpinfo.h index 54b8ebae..90614df0 100644 --- a/src/capwap/wtpinfo.h +++ b/src/capwap/wtpinfo.h @@ -67,6 +67,8 @@ struct wtpinfo{ bstr_t session_id; + + struct radioinfo radioinfo[31]; @@ -84,6 +86,9 @@ struct wtpinfo{ uint16_t encryption_cap; + + /** Base MAC address */ + bstr_t base_mac; uint8_t * macaddress; diff --git a/src/wtp/configure.c b/src/wtp/configure.c index 6f7c922f..6d5b6be7 100644 --- a/src/wtp/configure.c +++ b/src/wtp/configure.c @@ -1,13 +1,15 @@ +#include "capwap/capwap.h" #include "capwap/conn.h" #include "wtp_interface.h" int configure() { -sleep(10); struct conn * conn = get_conn(); struct wtpinfo * wtpinfo = get_wtpinfo(); - cw_prepare_configuration_status_request(conn,wtpinfo); + struct radioinfo *rip = &(wtpinfo->radioinfo[0]); + + cw_prepare_configuration_status_request(conn,rip,wtpinfo); conn_send_request(conn); exit(0); diff --git a/src/wtp/wtp_conf.c b/src/wtp/wtp_conf.c index 71db203a..a45da906 100644 --- a/src/wtp/wtp_conf.c +++ b/src/wtp/wtp_conf.c @@ -146,9 +146,10 @@ int wtpconf_name() char * default_ac_list[] = { // "192.168.0.255", - "255.255.255.255", + "255.255.255.255" // "224.0.1.140", //"192.168.0.77" + //"192.168.56.99" }; int wtpconf_ac_list() diff --git a/src/wtp/wtp_interface.c b/src/wtp/wtp_interface.c index 5c264c47..6f1439d5 100644 --- a/src/wtp/wtp_interface.c +++ b/src/wtp/wtp_interface.c @@ -59,6 +59,8 @@ struct wtpinfo * get_wtpinfo() wtpinfo->macaddress=conf_macaddress; wtpinfo->macaddress_len=conf_macaddress_len; + + wtpinfo->max_msg_len=14000; diff --git a/src/wtp/wtp_main.c b/src/wtp/wtp_main.c index cca478c7..1b2706a3 100644 --- a/src/wtp/wtp_main.c +++ b/src/wtp/wtp_main.c @@ -63,7 +63,7 @@ int main() #include - +int pmu; //#include @@ -75,6 +75,10 @@ int do_connect(void *priv,void *data) sock_setport(&ip->ip,atoi(conf_control_port)); // printf("Would connect to %s\n",str); + + +printf("Sleep 5000\n"); +printf("slept\n"); int rc; rc = join(&ip->ip); @@ -83,10 +87,10 @@ int do_connect(void *priv,void *data) printf("Sleep after oin\n"); printf("Go conf\n"); - extern struct conn * get_conn(); - extern join_state(struct conn * conn); - struct conn * conn = get_conn(); -printf("Join conn = %p\n",conn); +// extern struct conn * get_conn(); +// extern join_state(struct conn * conn); +// struct conn * conn = get_conn(); +//printf("Join conn = %p\n",conn); // join_state(conn); diff --git a/src/wtp/wtpdrv.c b/src/wtp/wtpdrv.c index d1d9c9a4..e44a5a4d 100644 --- a/src/wtp/wtpdrv.c +++ b/src/wtp/wtpdrv.c @@ -1215,16 +1215,20 @@ int wtpdrv_get_num_radios() int wtpdrv_get_radioinfo(int rid,struct radioinfo * radioinfo) { - radioinfo->rid=rid; //uint8_t rm[8]="12345600"; // uint8_t rm[8]={0x00,0x19,0xdb,0xe0,0x93,0x27}; -// uint8_t rm[8]={0x00,0x3a,0x99,0x02,0xfa,0xc0}; - uint8_t rm[8]={0x68,0x67,0x65,0x64,0x63,0x62}; + uint8_t rm[8]={0x00,0x3a,0x99,0x02,0xfa,0xc0}; +// uint8_t rm[8]={0x68,0x67,0x65,0x64,0x63,0x62}; radioinfo->rmac = bstr_create(rm,6); + radioinfo->type|=rid+1; //CW_80211_RADIO_TYPE_B; //CWRADIO_TYPE_N; + radioinfo->regDomain=1; + + memcpy(radioinfo->country_str,"AUDE",4); + /* struct wpa_driver_ops * drv = wpa_drivers[0];