More Cisco support (LWAPP)

FossilOrigin-Name: 0c04ab44846547da7a311be84cd0cc753ef61b5204ebbcea4b19408b8a7d3fe9
This commit is contained in:
7u83@mail.ru 2015-03-23 21:26:05 +00:00
parent 908afe182d
commit c809225c83
10 changed files with 114 additions and 44 deletions

View File

@ -443,7 +443,7 @@ static void wtpman_run_run(void *arg)
cwmsg_addelem(&conn->req_msg,CWMSGELEM_WTP_NAME,(uint8_t*)"Tube7u83",strlen("Tube7u83")+1); cwmsg_addelem(&conn->req_msg,CWMSGELEM_WTP_NAME,(uint8_t*)"Tube7u83",strlen("Tube7u83")+1);
cwmsg_addelem(&conn->req_msg,CWMSGELEM_LOCATION_DATA,(uint8_t*)"Berlin",strlen("Berlin")+1); cwmsg_addelem(&conn->req_msg,CWMSGELEM_LOCATION_DATA,(uint8_t*)"Berlin",strlen("Berlin")+1);
cwmsg_addelem_vendor_specific_payload(&conn->req_msg,CW_VENDOR_ID_CISCO,CWVENDOR_CISCO_RAD_NAME,(uint8_t*)"Schlumpf",strlen("Schlumpf")); cwmsg_addelem_vendor_specific_payload(&conn->req_msg,CW_VENDOR_ID_CISCO,CW_CISCO_RAD_NAME,(uint8_t*)"Schlumpf",strlen("Schlumpf"));
cwrmsg = conn_send_request(conn); cwrmsg = conn_send_request(conn);

View File

@ -61,6 +61,7 @@ UTILOBJS= \
# LWAPP objs # LWAPP objs
LWAPPOBJS = \ LWAPPOBJS = \
lw_checksum.o \ lw_checksum.o \
lw_put_ac_descriptor.o \
lw_readelem_wtp_name.o \ lw_readelem_wtp_name.o \
# LWAPP cisco vendor specific objs # LWAPP cisco vendor specific objs
@ -86,7 +87,7 @@ CAPWAPOBJS= \
cwmsg_addelem_mtu_discovery_padding.o \ cwmsg_addelem_mtu_discovery_padding.o \
cwmsg_addelem_result_code.o \ cwmsg_addelem_result_code.o \
cwmsg_addelem_ac_timestamp.o \ cwmsg_addelem_ac_timestamp.o \
cwmsg_addelem_vendor_specific_payload.o \ cw_addelem_vendor_specific_payload.o \
cwmsg_addelem_maximum_message_length.o \ cwmsg_addelem_maximum_message_length.o \
cwmsg_addelem_image_identifier.o \ cwmsg_addelem_image_identifier.o \
cwmsg_addelem_radio_operational_state.o \ cwmsg_addelem_radio_operational_state.o \
@ -145,9 +146,11 @@ CAPWAPOBJS= \
cw_readelem_vendor_specific_payload.o \ cw_readelem_vendor_specific_payload.o \
cw_readelem_capwap_local_ip_addr.o \ cw_readelem_capwap_local_ip_addr.o \
cw_readelem_wtp_reboot_statistics.o\ cw_readelem_wtp_reboot_statistics.o\
cwmsg_addelem_vendor_cisco_ap_timesync.o \
cwmsg_addelem_vendor_cisco_mwar_addr.o \ cwmsg_addelem_vendor_cisco_mwar_addr.o \
lw_readelem_wtp_board_data.o \ lw_readelem_wtp_board_data.o
# cwmsg_addelem_vendor_cisco_ap_timesync.o \
# cwmsg_addelem_vendor_specific_payload.o \
#cwmsg_addelem_session_id.o #cwmsg_addelem_session_id.o
# process_msgelems_discovery_request.o \ # process_msgelems_discovery_request.o \

View File

@ -16,6 +16,12 @@
*/ */
/**
* @file
* @brief CAPWAP desfinitions
*/
#ifndef __CAPWAP_H #ifndef __CAPWAP_H
#define __CAPWAP_H #define __CAPWAP_H
@ -517,53 +523,106 @@ extern void cw_send_image_file(struct conn *conn, FILE * infile);
/* Use some macros from LWAPP */ /* Use some macros from LWAPP */
#define cw_put_dword lw_put_dword #define cw_put_byte lw_put_byte
#define cw_put_word lw_put_word #define cw_put_word lw_put_word
#define cw_put_dword lw_put_dword
#define cw_put_data lw_put_data
static inline int cw_put_elem_hdr(uint8_t * dst, uint16_t type, uint16_t len) /**
{ * Put a message element headder to buffer
*((uint32_t *) (dst)) = htonl(type << 16 | len); * @param dst pointer to buffer (uint8_t)
return 4 + len; * @param type tpe of message element
} * @param len length of message element data
* @return the number bytes put (always 4)
*/
static inline int cw_addelem(uint8_t *dst, uint16_t type,uint8_t*data,uint16_t len)
{
memcpy(dst+4,data,len);
return cw_put_elem_hdr(dst,type,len);
}
#define cw_put_elem_hdr(dst,type,len) \
(cw_put_dword(dst, (((uint32_t)type)<<16) | (len)),4)
/* /*
static inline int cw_addbyteelem(uint8_t *dst, uint16_t type, uint8_t byte) static inline int cw_put_elem_hdr(uint8_t * dst, uint8_t type, uint16_t len)
{ {
// *(dst+3)=byte; cw_put_word(dst, type);
// return cw_put_elem_hdr( cw_put_word(dst + 4, len);
return 4;
} }
*/ */
static inline int cw_addelem_vendor_specific_payload(uint8_t * dst, uint32_t vendor_id, uint16_t type,
uint8_t * data, uint16_t len) /**
{ * Put a message element header for a message to contain a vendor specific payload
cw_put_dword(dst+4, vendor_id); * @param dst pointer to destination buffer
cw_put_word(dst + 8, type); * @param vendorid vendorid
memcpy(dst + 10, data, len); * @param elementid element id of vendor specific data
return cw_put_elem_hdr(dst, CW_ELEM_VENDOR_SPECIFIC_PAYLOAD, len + 10-4); * @len length of vendor specific data
* @return the number of bytes put (always 10)
*/
static inline int cw_put_elem_vendor_hdr(uint8_t *dst,uint32_t vendorid,uint16_t elemid,uint16_t len){
cw_put_elem_hdr(dst,CW_ELEM_VENDOR_SPECIFIC_PAYLOAD,len+6);
cw_put_dword(dst+4,vendorid);
cw_put_word(dst+8,elemid);
return 10;
} }
/**
* Add a message element to a buffer
* @param dst pointer to buffer
* @type message element type
* @data pointer to data
* @length of message element
* @return the number of bytes put
*/
static inline int cw_addelem(uint8_t * dst, uint16_t type, uint8_t * data, uint16_t len)
{
int l = cw_put_elem_hdr(dst, type, len);
return l + cw_put_data(dst+l, data, len);
}
static inline int cw_addelem_bstr(uint8_t *dst, uint16_t type, const bstr_t bstr)
{
return cw_addelem(dst,type,bstr_data(bstr),bstr_len(bstr));
}
/*
#define cw_put_elem_vendor_hdr(dst,vendorid,elemid,len)\
(cw_put_elem_hdr(dst,CW_ELEM_VENDOR_SPECIFIC_PAYLOAD, \
cw_put_dword(dst+4,vendorid) + cw_put_word(dst+8,elemid) +len ))
#define cw_addelem(dst,type,data,len)\
(cw_put_elem_hdr(dst,type,len)+cw_put_data(dst+4,data,len))
*/
/*
#define cw_addelem_vendor_specific_payload(dst,vendorid,elemid,data,len)\
(cw_put_elem_vendor_hdr(dst,vendorid,elemid,len) + \
cw_put_data(dst+10,data,len))
*/
extern int cw_addelem_vendor_specific_payload(uint8_t * dst, uint32_t vendorid, uint16_t elemid,
uint8_t * data, uint16_t len);
#define cw_addelem_ac_name(dst,name) \ #define cw_addelem_ac_name(dst,name) \
cw_addelem(dst,CW_ELEM_AC_NAME,name,strlen((char*)(name))) cw_addelem(dst,CW_ELEM_AC_NAME,name,strlen((char*)(name)))
#define cw_addelem_session_id(dst,sessid)\ #define cw_addelem_session_id(dst,sessid)\
cw_addelem(dst,CW_ELEM_SESSION_ID,bstr_data(sessid),bstr_len(sessid)) cw_addelem_bstr(dst,CW_ELEM_SESSION_ID,sessid)
/* cwmsg methods */ /* cwmsg methods */
#define cwmsg_addelem_vendor_s_payload(cwmsg,vendor_id, type, data,len) \ #define cwmsg_addelem_vendor_specific_payload(cwmsg,vendor_id, type, data,len) \
(cwmsg)->pos+=cw_addelem_vendor_specific_payload((cwmsg)->msgelems+(cwmsg)->pos,vendor_id,type,data,len) (cwmsg)->pos+=cw_addelem_vendor_specific_payload((cwmsg)->msgelems+(cwmsg)->pos,vendor_id,type,data,len)
#define cwmsg_addelem_ac_name(cwmsg,name) \ #define cwmsg_addelem_ac_name(cwmsg,name) \

View File

@ -21,7 +21,7 @@ void cwmsg_addelem_vendor_cisco_mwar_addr(struct cwmsg *msg, struct conn *conn)
switch (((struct sockaddr*)&conn->addr)->sa_family){ switch (((struct sockaddr*)&conn->addr)->sa_family){
case AF_INET: case AF_INET:
{ {
data[0]=1; /* mwar type */ data[0]=2; /* mwar type */
data[5]=0; data[5]=0;
data[6]=0; data[6]=0;

View File

@ -66,7 +66,7 @@ int cwsend_discovery_request(struct conn *conn, struct radioinfo *radioinfo,
switch (cwmsg.capwap_mode) { switch (cwmsg.capwap_mode) {
case CWMODE_CISCO: case CWMODE_CISCO:
cwmsg_addelem_vendor_cisco_rad_name(&cwmsg, (uint8_t *) wtpinfo->name); cwmsg_addelem_cisco_rad_name(&cwmsg, (uint8_t *) wtpinfo->name);
uint8_t data207[4] = {1,1,0,1}; uint8_t data207[4] = {1,1,0,1};
cwmsg_addelem_vendor_specific_payload(&cwmsg,CW_VENDOR_ID_CISCO, cwmsg_addelem_vendor_specific_payload(&cwmsg,CW_VENDOR_ID_CISCO,

View File

@ -53,9 +53,9 @@ void cwsend_discovery_response(struct conn *conn, int seqnum, struct radioinfo *
case CWMODE_CISCO: case CWMODE_CISCO:
case CWMODE_CIPWAP: case CWMODE_CIPWAP:
{ {
cwmsg_addelem_vendor_cisco_ap_timesync(cwmsg); cwmsg_addelem_cisco_ap_timesync(cwmsg,time(NULL),0);
uint8_t mwtype=1; //uint8_t mwtype=1;
cwmsg_addelem_vendor_s_payload(cwmsg,CW_VENDOR_ID_CISCO,CW_CISCO_MWAR_TYPE,&mwtype,1); //cwmsg_addelem_vendor_s_payload(cwmsg,CW_VENDOR_ID_CISCO,CW_CISCO_MWAR_TYPE,&mwtype,1);
break; break;
} }
default: default:

View File

@ -100,7 +100,7 @@ int cwsend_join_request(struct conn *conn, struct radioinfo *radioinfo, struct w
*/ */
cwmsg_addelem_vendor_s_payload(&cwmsg, CW_VENDOR_ID_CISCO, cwmsg_addelem_vendor_specific_payload(&cwmsg, CW_VENDOR_ID_CISCO,
CW_CISCO_AP_GROUP_NAME,(uint8_t *)"default-group",strlen("default-group")); CW_CISCO_AP_GROUP_NAME,(uint8_t *)"default-group",strlen("default-group"));
@ -121,17 +121,18 @@ int cwsend_join_request(struct conn *conn, struct radioinfo *radioinfo, struct w
case CWMODE_CISCO: case CWMODE_CISCO:
{ {
uint8_t mtu[2048]; uint8_t mtu[2048];
int l = lw_put_cisco_path_mtu(mtu,1485,1101); int l = lw_put_cisco_path_mtu(mtu,1485,11);
printf("Len = %d\n",l); // printf("Len = %d\n",l);
// cwmsg_addelem_vendor_specific_payload(&cwmsg,LW_VENDOR_CISCO, // cwmsg_addelem_vendor_specific_payload(&cwmsg,LW_VENDOR_CISCO,
// LW_ELEM_VENDOR_SPECIFIC,mtu,l); // LW_ELEM_VENDOR_SPECIFIC,mtu,l);
// (&cwmsg)->pos+=4; // (&cwmsg)->pos+=4;
struct ac_info acinfo; printf("Adding mwar\n");
extern struct ac_info wtp_acinfo; extern struct ac_info wtp_acinfo;
// cwmsg_addelem_cisco_mwar(&cwmsg,&wtp_acinfo);
// memset(&acinfo,0,sizeof(struct ac_info)); // memset(&acinfo,0,sizeof(struct ac_info));
// cwmsg_addelem_ac_descriptor(&cwmsg,&wtp_acinfo,wtpinfo); // cwmsg_addelem_ac_descriptor(&cwmsg,&wtp_acinfo,wtpinfo);

View File

@ -3,11 +3,13 @@
int configure() int configure()
{ {
sleep(10);
struct conn * conn = get_conn(); struct conn * conn = get_conn();
struct wtpinfo * wtpinfo = get_wtpinfo(); struct wtpinfo * wtpinfo = get_wtpinfo();
cw_prepare_configuration_status_request(conn,wtpinfo); cw_prepare_configuration_status_request(conn,wtpinfo);
conn_send_request(conn); conn_send_request(conn);
exit(0);
} }

View File

@ -39,11 +39,11 @@ int join_state(struct conn * conn)
struct radioinfo *rip = &(wtpinfo->radioinfo[0]); struct radioinfo *rip = &(wtpinfo->radioinfo[0]);
#ifdef WITH_CW_LOG_DEBUG //#ifdef WITH_CW_LOG_DEBUG
char str[64]; // char str[64];
sock_addrtostr(&conn->addr,str,64); // sock_addrtostr(&conn->addr,str,64);
// cw_log_debug0("Sending join request to %s",str); // cw_log_debug0("Sending join request to %s",str);
#endif //#endif
printf("Seqnum before = %i\n",conn->seqnum); printf("Seqnum before = %i\n",conn->seqnum);
rc = cwsend_join_request(conn,rip,wtpinfo); rc = cwsend_join_request(conn,rip,wtpinfo);
printf("Seqnum after = %i\n",conn->seqnum); printf("Seqnum after = %i\n",conn->seqnum);

View File

@ -82,8 +82,13 @@ int do_connect(void *priv,void *data)
return 1; return 1;
printf("Sleep after oin\n"); printf("Sleep after oin\n");
sleep(5);
printf("Go conf\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);
// join_state(conn);
// rc = join(&ip->ip); // rc = join(&ip->ip);