New files ...
FossilOrigin-Name: efdcfcb0f44a532e2176b496533c4f3f0ee42b6bd8d62f66ac61d61be22437be
This commit is contained in:
parent
08f7697ccc
commit
0db50b3be4
78
src/capwap/conn_wait_for_request.c
Normal file
78
src/capwap/conn_wait_for_request.c
Normal file
@ -0,0 +1,78 @@
|
||||
|
||||
#include "conn.h"
|
||||
#include "cw_log.h"
|
||||
#include "sock.h"
|
||||
#include "cw_util.h"
|
||||
|
||||
struct rh_param{
|
||||
struct conn * conn;
|
||||
int *msglist;
|
||||
|
||||
};
|
||||
|
||||
|
||||
static int conn_rh(void *param)
|
||||
{
|
||||
struct rh_param * p = (struct rh_param*)param;
|
||||
int i;
|
||||
int *msglist=p->msglist;
|
||||
|
||||
|
||||
printf("Param %p\n",param);
|
||||
|
||||
|
||||
for (i=0; msglist[i]!=-1; i++){
|
||||
if (msglist[i] == p->conn->cwrmsg.type )
|
||||
return 0;
|
||||
|
||||
}
|
||||
/* unexpected response here */
|
||||
cw_log(LOG_ERR,"Unexpected message from %s",sock_addr2str(&p->conn->addr));
|
||||
cwsend_unknown_response(p->conn,p->conn->cwrmsg.seqnum,p->conn->cwrmsg.type);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
struct cwrmsg * conn_wait_for_request(struct conn * conn, int *msglist, time_t timer)
|
||||
{
|
||||
int (*request_handler_save) (void*);
|
||||
void * request_handler_param_save;
|
||||
|
||||
struct rh_param rh_param;
|
||||
|
||||
|
||||
if (msglist){
|
||||
request_handler_save=conn->request_handler;
|
||||
request_handler_param_save=conn->request_handler_param;
|
||||
rh_param.conn=conn;
|
||||
rh_param.msglist=msglist;
|
||||
conn->request_handler=conn_rh;
|
||||
conn->request_handler_param=&rh_param;
|
||||
}
|
||||
|
||||
|
||||
struct cwrmsg * cwrmsg;
|
||||
while (!cw_timer_timeout(timer)){
|
||||
cwrmsg = conn_wait_for_message(conn,timer);
|
||||
if (!cwrmsg){
|
||||
if (!conn_is_error(conn))
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
/* response message? no action*/
|
||||
if (! (cwrmsg->type & 1) )
|
||||
continue;
|
||||
|
||||
/* it's a request message */
|
||||
break;
|
||||
}
|
||||
|
||||
if (msglist){
|
||||
conn->request_handler=request_handler_save;
|
||||
conn->request_handler_param=request_handler_param_save;
|
||||
}
|
||||
|
||||
return cwrmsg;
|
||||
}
|
||||
|
26
src/capwap/cw_addelem_cisco_wtp_radio_cfg.c
Normal file
26
src/capwap/cw_addelem_cisco_wtp_radio_cfg.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include "capwap.h"
|
||||
#include "capwap_cisco.h"
|
||||
|
||||
int cw_addelem_cisco_wtp_radio_cfg(uint8_t*dst,struct radioinfo *ri)
|
||||
{
|
||||
cw_put_byte(dst+10,ri->rid);
|
||||
cw_put_byte(dst+10+1,0);
|
||||
cw_put_word(dst+10+2,ri->occupancy_limit);
|
||||
cw_put_byte(dst+10+4,ri->cfp_period);
|
||||
cw_put_word(dst+10+5,ri->cfp_max_duration);
|
||||
|
||||
/* XXX catch rmac shorter or longer than 6*/
|
||||
|
||||
cw_put_bstr(dst+10+7,ri->rmac); /* length MUST be 6 */
|
||||
|
||||
cw_put_word(dst+10+13,ri->beacon_period);
|
||||
cw_put_data(dst+10+15,ri->country_str,3);
|
||||
cw_put_data(dst+10+18,ri->country_str2,3);
|
||||
|
||||
cw_put_byte(dst+10+21,10); // gPeriod
|
||||
|
||||
cw_put_dword(dst+10+22,0x3538); // ?
|
||||
|
||||
return 28+cw_put_elem_vendor_hdr(dst,CW_VENDOR_ID_CISCO,CW_CISCO_WTP_RADIO_CFG,28);
|
||||
}
|
||||
|
19
src/capwap/cw_prepare_change_state_event_request.c
Normal file
19
src/capwap/cw_prepare_change_state_event_request.c
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
#include "capwap.h"
|
||||
#include "radioinfo.h"
|
||||
|
||||
|
||||
|
||||
void cw_prepare_change_state_event_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_CHANGE_STATE_EVENT_REQUEST,conn_get_next_seqnum(conn),radioinfo);
|
||||
cwmsg->capwap_mode=conn->capwap_mode;
|
||||
|
||||
cwmsg_addelem_radio_operational_state(cwmsg,&wtpinfo->radioinfo[0]);
|
||||
cwmsg_addelem_radio_operational_state(cwmsg,&wtpinfo->radioinfo[1]);
|
||||
|
||||
cwmsg_addelem_result_code(cwmsg,0);
|
||||
}
|
22
src/capwap/cw_readelem_cisco_wtp_radio_cfg.c
Normal file
22
src/capwap/cw_readelem_cisco_wtp_radio_cfg.c
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
|
||||
#include "capwap_cisco.h"
|
||||
#include "cw_log.h"
|
||||
|
||||
int cw_readelem_cisco_wtp_radio_cfg(int elem_id,uint8_t *elem, int len,struct radioinfo *ri)
|
||||
{
|
||||
if (elem_id != CW_CISCO_WTP_RADIO_CFG)
|
||||
return 0;
|
||||
|
||||
if (len!=24){
|
||||
cw_dbg(DBG_ELEM,"LWAPP Radio Cfg element too short, %d < 21",len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ri->rid = lw_get_byte(elem);
|
||||
ri->occupancy_limit = lw_get_word(elem+2);
|
||||
bstr_replace(&ri->bssid,bstr_create(elem+7,6));
|
||||
ri->beacon_period = lw_get_word(elem+13);
|
||||
|
||||
return 1;
|
||||
}
|
22
src/capwap/cw_readmsg_configuration_status_request.c
Normal file
22
src/capwap/cw_readmsg_configuration_status_request.c
Normal file
@ -0,0 +1,22 @@
|
||||
#include "capwap.h"
|
||||
#include "cw_log.h"
|
||||
|
||||
int cw_readmsg_configuration_update_request(uint8_t *elems,int elems_len)
|
||||
{
|
||||
uint8_t * elem;
|
||||
|
||||
cw_foreach_elem(elem,elems,elems_len){
|
||||
|
||||
int type = cw_get_elem_type(elem);
|
||||
int len = cw_get_elem_len(elem);
|
||||
uint8_t *data = cw_get_elem_data(elem);
|
||||
|
||||
cw_dbg_msgelem(CW_MSG_CONFIGURATION_STATUS_REQUEST, type, data, len);
|
||||
|
||||
|
||||
// cw_readelem_vendor_specific_payload(elem,CW_MSG_CONFIGURATION_STATUS_RESPONSE, type,data,len );
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
14
src/capwap/cw_send_configuration_update_response.c
Normal file
14
src/capwap/cw_send_configuration_update_response.c
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
|
||||
#include "capwap.h"
|
||||
|
||||
int cw_send_configuration_update_response(struct conn * conn,int seqnum,struct radioinfo * radioinfo)
|
||||
{
|
||||
struct cwmsg * cwmsg = &conn->resp_msg;
|
||||
cwmsg_init(cwmsg,conn->resp_buffer,CW_MSG_CONFIGURATION_UPDATE_RESPONSE,seqnum,radioinfo);
|
||||
|
||||
cwmsg_addelem_result_code(cwmsg,0);
|
||||
|
||||
conn_send_response(conn,cwmsg,seqnum);
|
||||
return 1;
|
||||
}
|
57
src/capwap/lw_elem_id_to_str.c
Normal file
57
src/capwap/lw_elem_id_to_str.c
Normal file
@ -0,0 +1,57 @@
|
||||
|
||||
#include "lwapp.h"
|
||||
|
||||
|
||||
|
||||
const char * lw_elem_id_to_str(int elem_id)
|
||||
{
|
||||
|
||||
switch (elem_id){
|
||||
case LW_ELEM_AC_ADDRESS:
|
||||
return "AC Address";
|
||||
|
||||
case LW_ELEM_WTP_DESCRIPTOR:
|
||||
return "WTP Descriptor";
|
||||
|
||||
case LW_ELEM_WTP_NAME:
|
||||
return "WTP Name";
|
||||
|
||||
case LW_ELEM_AC_DESCRIPTOR:
|
||||
return "AC Descriptor";
|
||||
|
||||
case LW_ELEM_AC_NAME:
|
||||
return "AC Name";
|
||||
|
||||
|
||||
case LW_ELEM_SUPPORTED_RATES:
|
||||
return "Supported Rates";
|
||||
|
||||
case LW_ELEM_TEST:
|
||||
return "Test";
|
||||
|
||||
|
||||
case LW_ELEM_CERTIFICATE:
|
||||
return "Certificate";
|
||||
|
||||
case LW_ELEM_WTP_BOARD_DATA:
|
||||
return "WTP Board Data";
|
||||
|
||||
case LW_ELEM_AP_IP_ADDR:
|
||||
return "AP IP Addr";
|
||||
|
||||
case LW_ELEM_VENDOR_SPECIFIC:
|
||||
return "Vendor Specific";
|
||||
|
||||
|
||||
case LW_ELEM_80211_WTP_WLAN_RADIO_CONFIGURATION:
|
||||
return "80211 WTP Wlan Radio Configuration";
|
||||
|
||||
|
||||
|
||||
default:
|
||||
return "Unknown";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
18
src/capwap/lw_msg_id_to_str.c
Normal file
18
src/capwap/lw_msg_id_to_str.c
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
|
||||
#include "lwapp.h"
|
||||
|
||||
|
||||
const char * lw_msg_id_to_str(int msg_id)
|
||||
{
|
||||
switch (msg_id){
|
||||
|
||||
|
||||
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user