FossilOrigin-Name: 0805f78d34219a2aac597a313081ce869c389e6b5d471c65c7f43d0906c0a400bsdmakefiles
parent
f0e838de0a
commit
d8c8bd022e
@ -1,78 +0,0 @@ |
||||
|
||||
/**
|
||||
* @file |
||||
* @breif defines acinfo_print function |
||||
*/ |
||||
|
||||
#include <string.h> |
||||
#include <stdio.h> |
||||
|
||||
#include "capwap.h" |
||||
#include "sock.h" |
||||
|
||||
#include "acinfo.h" |
||||
|
||||
#include "cw_util.h" |
||||
|
||||
|
||||
/**
|
||||
* Formats an acinfo object. |
||||
* |
||||
*/
|
||||
int acinfo_print(char *str,const struct ac_info *acinfo) |
||||
{ |
||||
char *s = str; |
||||
|
||||
s+=sprintf(s,"\tAC name: %s\n",acinfo->ac_name); |
||||
|
||||
s+=sprintf(s,"\tHardware version: "); |
||||
s+=cw_format_version(s,acinfo->hardware_version,0,"-"); |
||||
s+=sprintf(s,"\n"); |
||||
|
||||
s+=sprintf(s,"\tSoftware version: "); |
||||
s+=cw_format_version(s,acinfo->software_version,0,"-"); |
||||
s+=sprintf(s,"\n"); |
||||
|
||||
s+=sprintf(s,"\tStations: %i\n",acinfo->stations); |
||||
s+=sprintf(s,"\tSation limit: %i\n",acinfo->limit); |
||||
s+=sprintf(s,"\tActive WTPs: %i\n",acinfo->active_wtps); |
||||
s+=sprintf(s,"\tMax WTPs: %i\n",acinfo->max_wtps); |
||||
char help[64]; |
||||
sock_addrtostr((struct sockaddr*)&acinfo->local_ip,help,64); |
||||
s+=sprintf(s,"\tLocal IP: %s\n",help); |
||||
s+=sprintf(s,"\tECN support: %s\n",acinfo->ecn_support==0 ? "limited" : "full"); |
||||
s+=sprintf(s,"\tRMAC support: %s\n",acinfo->rmac==1 ? "supported" : "not supported"); |
||||
|
||||
|
||||
help[0]=0; |
||||
if (acinfo->security & AC_SECURITY_S) |
||||
strcpy(help,"psk"); |
||||
if (acinfo->security & AC_SECURITY_X){ |
||||
if (strlen(help)) |
||||
strcat(help,"/"); |
||||
strcat(help,"X.509"); |
||||
} |
||||
if (!strlen(help)) |
||||
strcpy(help,"None"); |
||||
s+=sprintf(s,"\tSecurity: %s\n",help); |
||||
|
||||
help[0]=0; |
||||
/* if (acinfo->dtls_policy & AC_DTLS_POLICY_D){
|
||||
strcpy(help,"dtls"); |
||||
} |
||||
if (acinfo->dtls_policy & AC_DTLS_POLICY_C){ |
||||
if(strlen(help)) |
||||
strcat(help,"/"); |
||||
strcat(help,"clear"); |
||||
} |
||||
*/ if (!strlen(help)) |
||||
strcpy(help,"Not set"); |
||||
|
||||
s+=sprintf(s,"\tDTLS policy: %s\n",help); |
||||
|
||||
|
||||
return s-str; |
||||
} |
||||
|
||||
|
||||
|
@ -1,69 +0,0 @@ |
||||
/*
|
||||
This file is part of libcapwap. |
||||
|
||||
libcapwap is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
libcapwap is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/ |
||||
|
||||
/**
|
||||
*@file
|
||||
*@brief Implementation of avliter_next |
||||
*/ |
||||
|
||||
#include "avltree.h" |
||||
|
||||
/**
|
||||
* Get the next element within an AVL Tree. |
||||
* @param i pointer to AVL Iterator |
||||
* @return the element or NULL if there is no next elemeent. |
||||
*/
|
||||
void * avliter_next(avliter_t *i) |
||||
{ |
||||
|
||||
while ( i->stack_ptr) { |
||||
i->stack_ptr--; |
||||
i->cur=i->stack[i->stack_ptr]; |
||||
|
||||
if (!i->cur) |
||||
continue; |
||||
|
||||
if ((i->stack_ptr)&1) { |
||||
return i->cur->data; |
||||
} |
||||
break;
|
||||
|
||||
} |
||||
|
||||
|
||||
if (!i->cur){ |
||||
return NULL; |
||||
} |
||||
|
||||
while(i->cur->left) { |
||||
/* push right branch */ |
||||
i->stack[i->stack_ptr++]=i->cur->right; |
||||
|
||||
/* push node */ |
||||
i->stack[i->stack_ptr++]=i->cur; |
||||
|
||||
i->cur=i->cur->left; |
||||
|
||||
} |
||||
|
||||
i->stack[i->stack_ptr++]=i->cur->right; |
||||
|
||||
return i->cur->data; |
||||
} |
||||
|
||||
|
@ -1,39 +0,0 @@ |
||||
/*
|
||||
This file is part of libcapwap. |
||||
|
||||
libcapwap is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
libcapwap is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/ |
||||
|
||||
#include "avltree.h" |
||||
|
||||
int avltree_foreach_rl(struct avlnode *n, int (*callback)(void *,void *),void *cbpriv) |
||||
{ |
||||
if (!n) |
||||
return 1; |
||||
if (!avltree_foreach_rl(n->right,callback,cbpriv)) |
||||
return 0; |
||||
if (!callback(cbpriv,n->data)) |
||||
return 0; |
||||
return avltree_foreach_rl(n->left,callback,cbpriv); |
||||
} |
||||
|
||||
void avltree_foreach(struct avltree *t, int (*callback)(void *,void *),void * cbpriv,int dir) |
||||
{ |
||||
if (dir) |
||||
avltree_foreach_lr(t->root,callback,cbpriv); |
||||
else |
||||
avltree_foreach_rl(t->root,callback,cbpriv); |
||||
} |
||||
|
@ -1,31 +0,0 @@ |
||||
#include "avltree.h" |
||||
|
||||
|
||||
// XXX Function is buggy
|
||||
|
||||
int avltree_foreach_from_lr(struct avltree *t, struct avlnode *n, void *data,int (*callback)(void *,void *),void *cbpriv) |
||||
{ |
||||
if (!n) |
||||
return 1; |
||||
|
||||
int rc=t->cmp(data,n->data); |
||||
if (rc<0){ |
||||
if(!avltree_foreach_from_lr(t,n->left,data,callback,cbpriv)) |
||||
return 0; |
||||
if (!callback(cbpriv,n->data)) |
||||
return 0; |
||||
return avltree_foreach_lr(n->right,callback,cbpriv); |
||||
} |
||||
|
||||
if (rc>0) { |
||||
avltree_foreach_from_lr(t,n->right,data,callback,cbpriv); |
||||
return 0; |
||||
} |
||||
|
||||
if (!callback(cbpriv,n->data)) |
||||
return 0; |
||||
|
||||
return avltree_foreach_lr(n->right,callback,cbpriv); |
||||
} |
||||
|
||||
|
@ -1,17 +0,0 @@ |
||||
#include "avltree.h" |
||||
|
||||
|
||||
|
||||
int avltree_foreach_lr(struct avlnode *n, int (*callback)(void *,void *),void *cbpriv) |
||||
{ |
||||
if (!n) |
||||
return 1; |
||||
if (!avltree_foreach_lr(n->left,callback,cbpriv)) |
||||
return 0; |
||||
if (!callback(cbpriv,n->data)) |
||||
return 0; |
||||
return avltree_foreach_lr(n->right,callback,cbpriv); |
||||
|
||||
} |
||||
|
||||
|
@ -1,33 +0,0 @@ |
||||
|
||||
|
||||
|
||||
int avltree_foreach_lr_node(struct avltree *t, struct avlnode *n, void *data,int (*callback)(void *,void *),void *cbpriv) |
||||
{ |
||||
if (!n) |
||||
return 1; |
||||
|
||||
int rc=t->cmp(data,n->data); |
||||
if (rc<0){ |
||||
avltree_foreach_lr_node(t,n->left,data,callback,cbpriv); |
||||
callback(cbpriv,n->data); |
||||
avltree_foreach_lr(n->right, |
||||
return 0; |
||||
} |
||||
|
||||
if (rc>0) { |
||||
avltree_foreach_lr_node(t,n->right,data,callback,cbpriv); |
||||
return 0; |
||||
} |
||||
|
||||
return callback(cbpriv,n->data); |
||||
|
||||
|
||||
|
||||
|
||||
} |
||||
|
||||
|
||||
int avltree_foreach_2(struct avltree *t,void *data,int (*callback)(void *,void *),void *cbpriv) |
||||
{ |
||||
|
||||
} |
@ -1,18 +0,0 @@ |
||||
|
||||
|
||||
|
||||
|
||||
#include "avltree.h" |
||||
|
||||
int avltree_foreach_rl(struct avlnode *n, int (*callback)(void *,void *),void *cbpriv) |
||||
{ |
||||
if (!n) |
||||
return 1; |
||||
if (!avltree_foreach_rl(n->right,callback,cbpriv)) |
||||
return 0; |
||||
if (!callback(cbpriv,n->data)) |
||||
return 0; |
||||
return avltree_foreach_rl(n->left,callback,cbpriv); |
||||
} |
||||
|
||||
|
@ -1,47 +0,0 @@ |
||||
/*
|
||||
This file is part of libcapwap. |
||||
|
||||
libcapwap is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
libcapwap is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
/**
|
||||
* @file |
||||
* @brief Implementation of avltree_get |
||||
*/
|
||||
|
||||
#include <stdio.h> |
||||
|
||||
#include "avltree.h" |
||||
|
||||
/**
|
||||
* Get an AVL tree element. |
||||
* @param data Element to get |
||||
* @return pointer to element or NULL if not found.
|
||||
*/
|
||||
void * avltree_get(struct avltree *t ,void *data) |
||||
{ |
||||
struct avlnode *n = t->root; |
||||
while(n){ |
||||
int rc=t->cmp(data,n->data); |
||||
if (rc==0) |
||||
return n->data; |
||||
if (rc<0) |
||||
n=n->left; |
||||
else |
||||
n=n->right; |
||||
} |
||||
return NULL; |
||||
} |
||||
|
||||
|
@ -1,39 +0,0 @@ |
||||
/*
|
||||
This file is part of libcapwap. |
||||
|
||||
libcapwap is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
libcapwap is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/ |
||||
|
||||
|
||||
#include <stdio.h> |
||||
|
||||
#include "avltree.h" |
||||
|
||||
|
||||
struct avlnode * avltree_get_node(struct avltree *t ,void *data) |
||||
{ |
||||
struct avlnode *n = t->root; |
||||
while(n){ |
||||
int rc=t->cmp(data,n->data); |
||||
if (rc==0) |
||||
return n; |
||||
if (rc<0) |
||||
n=n->left; |
||||
else |
||||
n=n->right; |
||||
} |
||||
return NULL; |
||||
} |
||||
|
@ -0,0 +1,13 @@ |
||||
#include "bstr.h" |
||||
|
||||
uint8_t * bstr16_create(const uint8_t *data, uint16_t len) |
||||
{ |
||||
uint8_t * str = malloc(2+len*sizeof(uint8_t)); |
||||
if (!str)
|
||||
return 0; |
||||
*((uint16_t*)str)=len; |
||||
memcpy(str+2,data,len); |
||||
return str; |
||||
} |
||||
|
||||
|
@ -0,0 +1,17 @@ |
||||
#include "bstr.h" |
||||
|
||||
uint8_t * bstrv_create(uint32_t vendor_id, uint8_t *data, uint8_t len) |
||||
{ |
||||
uint8_t * str = malloc(bstrv_size(len)); |
||||
if (!str)
|
||||
return 0; |
||||
|
||||
bstrv_set_vendor_id(str,vendor_id); |
||||
bstrv_set_len(str,len); |
||||
memcpy(bstrv_data(str),data,len); |
||||
*(bstrv_data(str)+bstrv_len(str))=0; |
||||
return str; |
||||
|
||||
} |
||||
|
||||
|
@ -1,13 +0,0 @@ |
||||
|
||||
|
||||
#include "capwap80211.h" |
||||
#include "capwap_items.h" |
||||
|
||||
#define CW_ACTION_IN_80211_WTP_RADIO_INFORMATION \ |
||||
CW_ELEM80211_WTP_RADIO_INFORMATION, /* Element ID*/ \
|
||||
cw_in_radio_generic, 0, /* start/end callback */ \
|
||||
MBAG_DWORD, /* Type of element */ \
|
||||
CW_ITEM_LOCATION_DATA, /* ID to use store */ \
|
||||
5, 5 /* min/max length */ |
||||
|
||||
|
@ -1,65 +0,0 @@ |
||||
|
||||
|
||||
#include "action.h" |
||||
#include "capwap_80211_actions.h" |
||||
#include "capwap80211.h" |
||||
#include "capwap.h" |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cw_action_in_t capwap_80211_actions_ac_in[] = { |
||||
|
||||
/* --------------------------------------------------------
|
||||
* Discovery Resquest
|
||||
*/ |
||||
|
||||
{0, 0, CAPWAP_STATE_DISCOVERY, CAPWAP_MSG_DISCOVERY_REQUEST, |
||||
CW_ACTION_IN_80211_WTP_RADIO_INFORMATION, 1} |
||||
, |
||||
/* --------------------------------------------------------
|
||||
* Discovery Resquest
|
||||
*/ |
||||
|
||||
{0, 0, CW_STATE_JOIN, CAPWAP_MSG_JOIN_REQUEST, |
||||
CW_ACTION_IN_80211_WTP_RADIO_INFORMATION, 1} |
||||
, |
||||
|
||||
|
||||
|
||||
{0, 0, 0} |
||||
}; |
||||
|
||||
|
||||
cw_action_out_t capwap_80211_actions_ac_out[]={ |
||||
/* Radio Infos */ |
||||
{CAPWAP_MSG_DISCOVERY_RESPONSE, NULL /*CW_ELEM80211_WTP_RADIO_INFORMATION*/, 0, |
||||
CW_ELEM80211_WTP_RADIO_INFORMATION, NULL,cw_out_radio_infos, NULL,1} |
||||
, |
||||
|
||||
/* Radio Infos */ |
||||
{CAPWAP_MSG_JOIN_RESPONSE, NULL /*CW_ELEM80211_WTP_RADIO_INFORMATION*/, 0, |
||||
CW_ELEM80211_WTP_RADIO_INFORMATION, NULL,cw_out_radio_infos, NULL,1} |
||||
, |
||||
|
||||
{0,0,0} |
||||
}; |
||||
|
||||
|
||||
int cw_register_actions_capwap_80211_ac(struct cw_actiondef *def) |
||||
{ |
||||
|
||||
int rc; |
||||
rc=cw_actionlist_in_register_actions(def->in, capwap_80211_actions_ac_in); |
||||
rc+=cw_actionlist_out_register_actions(def->out, capwap_80211_actions_ac_out); |
||||
|
||||
rc+= cw_strheap_register_strings(def->strelem, capwap_strings_elem80211); |
||||
/*rc += cw_strheap_register_strings(def->strelem, capwap_strings_elem);
|
||||
*/ |
||||
|
||||
|
||||
return rc; |
||||
} |
||||
|
@ -1,64 +0,0 @@ |
||||
|
||||
|
||||
#include "action.h" |
||||
#include "capwap_80211_actions.h" |
||||
#include "capwap80211.h" |
||||
#include "capwap.h" |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cw_action_in_t capwap_80211_actions_wtp_in[] = { |
||||
|
||||
/* Discovery Response */ |
||||
{0, 0, CAPWAP_STATE_DISCOVERY, CAPWAP_MSG_DISCOVERY_RESPONSE, |
||||
CW_ACTION_IN_80211_WTP_RADIO_INFORMATION, 1} |
||||
, |
||||
|
||||
/* Join Response */ |
||||
{0, 0, CW_STATE_JOIN, CAPWAP_MSG_JOIN_RESPONSE, |
||||
CW_ACTION_IN_80211_WTP_RADIO_INFORMATION, 1} |
||||
, |
||||
|
||||
|
||||
{0, 0, 0} |
||||
}; |
||||
|
||||
|
||||
cw_action_out_t capwap_80211_actions_wtp_out[]={ |
||||
|
||||
/* --------------------------------------------------------
|
||||
* Discovery Resquest
|
||||
*/ |
||||
|
||||
/* 802.11 Radio Information */ |
||||
{CAPWAP_MSG_DISCOVERY_REQUEST, CW_ITEM_RADIO_INFOS /*CW_ELEM80211_WTP_RADIO_INFORMATION*/, 0, |
||||
CW_ELEM80211_WTP_RADIO_INFORMATION, NULL,cw_out_radio_infos, NULL,1} |
||||
, |
||||
|
||||
/* --------------------------------------------------------
|
||||
* Join Resquest
|
||||
*/ |
||||
|
||||
/* 802.11 Radio Information */ |
||||
{CAPWAP_MSG_JOIN_REQUEST, CW_ITEM_RADIO_INFOS, 0, |
||||
CW_ELEM80211_WTP_RADIO_INFORMATION, NULL,cw_out_radio_infos, NULL,1}, |
||||
|
||||
|
||||
{0,0,0} |
||||
|
||||
|
||||
}; |
||||
|
||||
|
||||
int cw_register_actions_capwap_80211_wtp(struct cw_actiondef *def) |
||||
{ |
||||
int rc; |
||||
rc=cw_actionlist_in_register_actions(def->in, capwap_80211_actions_wtp_in); |
||||
rc+=cw_actionlist_out_register_actions(def->out, capwap_80211_actions_wtp_out); |
||||
rc+=cw_strheap_register_strings(def->strelem, capwap_strings_elem80211); |
||||
return rc; |
||||
} |
||||
|
@ -1,78 +0,0 @@ |
||||
|
||||
|
||||
#include <stdlib.h> |
||||
#include <string.h> |
||||
#include <errno.h> |
||||
|
||||
#include "conn.h" |
||||
#include "cwrmsg.h" |
||||
#include "cw_log.h" |
||||
#include "capwap.h" |
||||
#include "sock.h" |
||||
#include "cw_util.h" |
||||
|
||||
struct args { |
||||
struct conn *conn; |
||||
struct cwrmsg *cwrmsg; |
||||
}; |
||||
|
||||
static int message_cb(void *p, uint8_t *rawmsg, int len) |
||||
{ |
||||
struct args *args = (struct args *) p; |
||||
struct conn *conn = args->conn; |
||||
memcpy(conn->cwrmsg_buffer, rawmsg, len); |
||||
|
||||
/*
|
||||
|
||||
memcpy(&conn->cwrmsg, cwrmsg, sizeof(struct cwrmsg)); |
||||
conn->cwrmsg.msgelems = conn->cwrmsg_buffer; |
||||
*/ |
||||
args->cwrmsg = &conn->cwrmsg; |
||||
return 0; |
||||
} |
||||
|
||||
|
||||
int conn_msg_processor(struct conn *conn) |
||||
{ |
||||
uint8_t buf[2024]; |
||||
int len = 2024; |
||||
|
||||
int n = conn->read(conn, buf, len); |
||||
if (n<0 )
|
||||
return n; |
||||
|
||||
if (n > 0) |
||||
conn_process_packet(conn, buf, n, cw_process_msg, conn); |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
uint8_t *conn_get_message(struct conn *conn) |
||||
{ |
||||
struct args args; |
||||
args.cwrmsg = 0; |
||||
args.conn = conn; |
||||
uint8_t buf[2024]; |
||||
int len = 2024; |
||||
|
||||
int n = conn->read(conn, buf, len); |
||||
if (n > 0) |
||||
conn_process_packet(conn, buf, n, message_cb, &args); |
||||
|
||||
|
||||
if (args.cwrmsg) { |
||||
cw_dbg(DBG_MSG,"Message recieved from %s",sock_addr2str(&conn->addr)); |
||||
/*
|
||||
cw_dbg(DBG_MSG, |
||||
"Received message from %s, type=%d - %s, seq=%d", |
||||
sock_addr2str(&conn->addr), args.cwrmsg->type, |
||||
cw_msgtostr(args.cwrmsg->type), |
||||
args.cwrmsg->seqnum); |
||||
|
||||
*/ |
||||
} |
||||
|
||||
return conn->cwrmsg_buffer; |
||||
} |
@ -1,37 +0,0 @@ |
||||
|
||||
#include "conn.h" |
||||
#include "cw_util.h" |
||||
|
||||
|
||||
struct cwrmsg * conn_wait_for_message(struct conn * conn, time_t timer) |
||||
{ |
||||
struct cwrmsg * cwrmsg; |
||||
|
||||
|
||||
while (!cw_timer_timeout(timer)){ |
||||
cwrmsg = conn_get_message(conn); |
||||
|
||||
if (!cwrmsg){ |
||||
if (!conn_is_error(conn)) |
||||
continue; |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
if (cwrmsg->type & 1){ |
||||
if (conn->request_handler){ |
||||
if (conn->request_handler(conn->request_handler_param)) |
||||
continue; |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
return cwrmsg; |
||||
|
||||
} |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
|
@ -1,37 +0,0 @@ |
||||
|
||||
#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 radioinfo * radioinfo, struct wtpinfo *wtpinfo) |
||||
{ |
||||
struct cwmsg * cwmsg = &conn->req_msg; |
||||
uint8_t * buffer = conn->req_buffer; |
||||
|
||||
cwmsg_init(cwmsg,buffer,CAPWAP_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_wtp_radio_cfg(cwmsg,&wtpinfo->radioinfo[0]); |
||||
cwmsg_addelem_cisco_wtp_radio_cfg(cwmsg,&wtpinfo->radioinfo[1]); |
||||
|
||||
/*
|
||||
uint8_t mtu[2048]; |
||||
int l = lw_put_cisco_path_mtu(mtu,1485,1701); |
||||
|
||||
printf("Len = %d\n",l); |
||||
|
||||
cwmsg_addelem_vendor_specific_payload(cwmsg,LW_VENDOR_CISCO, |
||||
LW_ELEM_VENDOR_SPECIFIC,mtu,l); |
||||
|
||||
*/ |
||||
} |
@ -1,140 +0,0 @@ |
||||
/*
|
||||
This file is part of libcapwap. |
||||
|
||||
libcapwap is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
libcapwap is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/ |
||||
|
||||
/**
|
||||
* @file |
||||
* @brief cw_readelem_ac_descriptor is implemented here. |
||||
*/ |
||||
|
||||
#include "capwap.h" |
||||
#include "acinfo.h" |
||||
#include "bstr.h" |
||||
#include "cw_log.h" |
||||
|
||||
|
||||
static int read_subelem_cisco(struct ac_info* acinfo,int subtype,uint8_t * elem, int len) |
||||
{ |
||||
switch (subtype) { |
||||
case 0: |
||||
/* hardware version */ |
||||
bstr_replace(&acinfo->hardware_version,bstr_create(elem,len)); |
||||
break; |
||||
case 1:
|
||||
/* software version */ |
||||
bstr_replace(&acinfo->software_version,bstr_create(elem,len)); |
||||
break; |
||||
|
||||
default: |
||||
//printf("What? %d\n",subtype);
|
||||
break; |
||||
|
||||
} |
||||
|
||||
return 1; |
||||
} |
||||
|
||||
|
||||
static int read_subelem(struct ac_info* acinfo,int subtype,uint8_t *elem, int len) |
||||
{ |
||||
switch (subtype){ |
||||
case 4: |
||||
/* hardware version */ |
||||
bstr_replace(&acinfo->hardware_version,bstr_create(elem,len)); |
||||
break; |
||||
case 5: |
||||
/* software version */ |
||||
bstr_replace(&acinfo->software_version,bstr_create(elem,len)); |
||||
break; |
||||
} |
||||
|
||||
return 1; |
||||
} |
||||
|
||||
/**
|
||||
* Read CAPWAP message elment: AC Descriptor |
||||
* @param acinfo pointer to acinfo where the result is stored |
||||
* @param type message element type
|
||||
* @param msgelem pointer to message element |
||||
* @param len length of message element |
||||
* @return 1 AC descriptor sucessfull read \n |
||||
* 0 not an ac descriptor message\n |
||||
* -1 an error has occured |
||||
*/ |
||||
int cw_readelem_ac_descriptor(struct ac_info * acinfo,int type, uint8_t *msgelem, int len) |
||||
{ |
||||
if (type != CAPWAP_ELEM_AC_DESCRIPTOR) |
||||
return 0; |
||||
|
||||
if (len<12) |
||||
return -1; |
||||
|
||||
uint32_t val; |
||||
|
||||
/* read stations and limit */ |
||||
val = ntohl(*((uint32_t*)msgelem)); |
||||
acinfo->stations = val>>16; |
||||
acinfo->limit = val&0xffff; |
||||
|
||||
|
||||
/* read active wtps and max wtps */ |
||||
val = ntohl(*((uint32_t*)(msgelem+4))); |
||||
acinfo->active_wtps = val>>16; |
||||
acinfo->max_wtps = val&0xffff; |
||||
|
||||
/* read active wtps and max wtps */ |
||||
val = ntohl(*((uint32_t*)(msgelem+8))); |
||||
acinfo->security = val >>24; |
||||
acinfo->rmac= (val >> 16)&0xff; |
||||
acinfo->dtls_policy=val&0xf; |
||||
|
||||
int sub=12; |
||||
int sublen; |
||||
|
||||
|
||||
while (sub<len){ |
||||
if (len-sub<8) |
||||
return -1; |
||||
|
||||
uint32_t vendor = ntohl(*((uint32_t*)(msgelem+sub))); |
||||
val = ntohl(*((uint32_t*)(msgelem+sub+4))); |
||||
sublen = val&0xffff; |
||||
sub+=8; |
||||
int subtype = val>>16; |
||||
|
||||
cw_dbg(DBG_ELEM,"AC Descriptor sub-element vendor: %d, type:%d, len: %d",vendor,subtype,sublen); |
||||
switch (vendor) { |
||||
case 0: |
||||
read_subelem(acinfo,subtype,msgelem+sub,sublen); |
||||
break; |
||||
|
||||
case CW_VENDOR_ID_CISCO: |
||||
read_subelem_cisco(acinfo,subtype,msgelem+sub,sublen); |
||||
break; |
||||
|
||||
} |
||||
|
||||
if (sub+sublen>len) |
||||
return -1; |
||||
|
||||
sub+=sublen; |
||||
} |
||||
|
||||
return 1;
|
||||
} |
||||
|
||||
|
@ -1,37 +0,0 @@ |
||||
/*
|
||||
This file is part of libcapwap. |
||||
|
||||
libcapwap is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
libcapwap is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/ |
||||
|
||||
#include "capwap.h" |
||||
#include "cw_util.h" |
||||
#include "log.h" |
||||
|
||||
int cw_readelem_maximum_message_length(uint16_t *dst, int type,uint8_t *msgelem, int len) |
||||
{ |
||||
if (type != CWMSGELEM_MAXIMUM_MESSAGE_LENGTH) |
||||
return 0; |
||||
|
||||
if (len!=2){ |
||||
cw_dbg(DBG_CW_RFC,"Discarding MAXIMUM_MESSAGE_LENTGH msgelem, wrong size, type=%d,len=%d",type,len); |
||||
return 0; |
||||
} |
||||
|
||||
*dst = ntohs(* ((uint16_t*)msgelem)); |
||||
return 1; |
||||
} |
||||
|
||||
|
@ -1,22 +0,0 @@ |
||||
#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(CAPWAP_MSG_CONFIGURATION_STATUS_REQUEST, type, data, len); |
||||
|
||||
|
||||
// cw_readelem_vendor_specific_payload(elem,CW_MSG_CONFIGURATION_STATUS_RESPONSE, type,data,len );
|
||||
|
||||
} |
||||
|
||||
|
||||
} |
@ -1,102 +0,0 @@ |
||||
/*
|
||||
This file is part of libcapwap. |
||||
|
||||
libcapwap is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
libcapwap is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/ |
||||
|
||||
|
||||
/**
|
||||
* @file |
||||
* @breif send image file |
||||
*/ |
||||
|
||||
#include <stdio.h> |
||||
#include <errno.h> |
||||
#include <string.h> |
||||
|
||||
|
||||
#include "capwap.h" |
||||
#include "lwapp.h" |
||||
|
||||
#include "sock.h" |
||||
#include "cw_log.h" |
||||
|
||||
|
||||
/**
|
||||
* Send an image file to an AP |
||||
*
|
||||
*/
|
||||
void cw_send_image_file(struct conn *conn) |
||||
{ |
||||
|
||||
/*
|
||||
FILE *infile; |
||||
infile = fopen(filename, "rb"); |
||||
if (!infile) { |
||||
cw_log(LOG_ERR, "Can't open image file %s:%s", filename, strerror(errno)); |
||||
return; |
||||
} |
||||
|
||||
|
||||
cw_log(LOG_INFO, "Sending image file %s to %s", filename, sock_addr2str(&conn->addr)); |
||||
*/ |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
uint8_t buffer[1024]; /* buffer MUST be 1024 */ |
||||
|
||||
|
||||
struct cwimage_data data; |
||||
memset(&data,0,sizeof(struct cwimage_data)); |
||||
data.data = buffer; |
||||
|
||||
|
||||
/*
|
||||
conn->request_handler = cw_handle_echo_request; |
||||
conn->request_handler_param = conn; |
||||
*/ |
||||
|
||||
int bl = 0; |
||||
|
||||
do { |
||||
|
||||
data.len = fread(buffer, 1, sizeof(buffer), infile); |
||||
|
||||
if (feof(infile)) |
||||
data.type = 2; |
||||
else |
||||
data.type = 1; |
||||
|
||||
cw_dbg(DBG_CW_IMG_DTL, "Sending img data request, block=%d, len=%d, ch=%d\n", bl, |
||||
data.len, lw_checksum(data.data, data.len)); |
||||
|
||||
|
||||
bl++; |
||||
|
||||
// conn_prepare_image_data_request(conn, &data, 0);
|
||||
// cwrmsg = conn_send_request(conn);
|
||||
|
||||
if (!cwrmsg) { |
||||
cw_log(LOG_ERR,"Error sneding image file to %s",sock_addr2str(&conn->addr)); |
||||
break; |
||||
} |
||||
|
||||
|
||||
} while (!feof(infile)); |
||||
|
||||
} |
@ -1,16 +0,0 @@ |
||||
|
||||
#include "capwap_items.h" |
||||
#include "strheap.h" |
||||
|
||||
struct cw_str cw_item_strings[] = { |
||||
{ CW_ITEM_WTP_HARDWARE_VERSION,"WTP Hardware Version"}, |
||||
{ CW_ITEM_WTP_NAME, "WTP Name "}, |
||||
{ CW_ITEM_AC_NAME, "AC Name "}, |
||||
{ CW_ITEM_WTP_BOARD_VENDOR, "WTP Board Vendor"}, |
||||
{ CW_ITEM_WTP_BOARD_MODELNO,"WTP Board Model No."}, |
||||
{ CW_ITEM_WTP_BOARD_MACADDRESS, "WTP Board MAC Address"}, |
||||
{ CW_ITEM_WTP_BOARD_ID,"WTP Board ID"}, |
||||
{ CW_ITEM_WTP_GROUP_NAME,"WTP Group Name"}, |
||||
{ CW_STR_STOP,"Unknown"} |
||||
|
||||
}; |