Work on ansi and clean Makefiles

FossilOrigin-Name: 0805f78d34219a2aac597a313081ce869c389e6b5d471c65c7f43d0906c0a400
This commit is contained in:
7u83@mail.ru 2018-02-28 08:05:45 +00:00
parent f0e838de0a
commit d8c8bd022e
42 changed files with 147 additions and 1145 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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)
{
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -130,16 +130,7 @@ static inline int bstr16_ncpy(uint8_t *dst,uint8_t*src,uint16_t len)
*/
static inline 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;
}
extern uint8_t * bstr16_create(const uint8_t *data, uint16_t len);
uint8_t * bstr16_create_from_str(const char *s);
extern uint8_t * bstr16_create_from_cfgstr(const char * s);
@ -182,25 +173,10 @@ typedef uint8_t * bstrv_t;
(1+6+(n)*sizeof(uint8_t))
static inline 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;
}
uint8_t * bstrv_create_from_str(uint32_t vendor_id,const char *s);
uint8_t * bstrv_create(uint32_t vendor_id, uint8_t *data, uint8_t len);
//uint8_t * bstr16cfgstr(const char * s);
#endif

13
src/cw/bstr16_create.c Normal file
View File

@ -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;
}

17
src/cw/bstrv_create.c Normal file
View File

@ -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;
}

View File

@ -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 */

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -34,7 +34,7 @@ int conn_prepare_image_data_request(struct conn *conn, struct cwimage_data *data
/* for Cisco APs send image data in "LWAPP format" */
if (conn->capwap_mode == CWMODE_CISCO) {
/* if (conn->capwap_mode == CWMODE_CISCO) {
uint8_t type = 3;
uint16_t checksum = htons(lw_checksum(data->data, data->len));
cwmsg_vaddelem(cwmsg, CW_ELEM_IMAGE_DATA,
@ -44,7 +44,7 @@ int conn_prepare_image_data_request(struct conn *conn, struct cwimage_data *data
NULL);
return 0;
}
*/
/* standard capwap operation */

View File

@ -23,7 +23,7 @@
#include "capwap.h"
#include "cw_util.h"
#include "cw_log.h"
#include "log.h"
/**
* Send a request message and wait for its response
@ -32,6 +32,9 @@
* The message has to be prepared and put to conn->req_msg
*
*/
/*
struct cwrmsg * conn_send_request(struct conn * conn)
{
int i;
@ -58,4 +61,4 @@ struct cwrmsg * conn_send_request(struct conn * conn)
cw_dbg(DBG_MSG_ERR,"Max retransmit's reached, message type=%d,seq=%d",cwmsg->type,cwmsg->seqnum);
return 0;
}
*/

View File

@ -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;
}

View File

@ -27,6 +27,7 @@
#include "cwmsg.h"
#include "conn.h"
/*
uint8_t * cw_addelem(uint8_t * buf,int type, uint8_t *elem, int len)
{
@ -76,4 +77,4 @@ void cw_addelem_capwap_local_ip_addr(struct cwmsg *msg, int sock, int cw_mode)
}
*/

View File

@ -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);
*/
}

View File

@ -24,7 +24,8 @@
#include "capwap.h"
#include "cw_log.h"
#include "log.h"
#include "dbg.h"
#include "cw_util.h"
#include <stdio.h>
@ -54,7 +55,7 @@ static int imgdata_request(void * ptr,int type,uint8_t* msgelem,int len)
cw_dbg_msgelem(CW_MSG_IMAGE_DATA_REQUEST, type, msgelem, len);
cw_dbg(DBG_ALL,"Reading image data req msgelem, type=%d - %s ,len=%d\n",type,cw_strelem(type),len);
//cw_dbg(DBG_ALL,"Reading image data req msgelem, type=%d - %s ,len=%d\n",type,cw_strelem(type),len);
if (cw_readelem_image_identifier(ptr,type,msgelem,len))
return 1;

View File

@ -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;
}

View File

@ -1,4 +1,4 @@
/*
#include "capwap_cisco.h"
#include "cw_log.h"
@ -19,4 +19,7 @@ int cw_readelem_cisco_wtp_radio_cfg(int elem_id,uint8_t *elem, int len,struct ra
ri->beacon_period = lw_get_word(elem+13);
return 1;
}
}
*/

View File

@ -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;
}

View File

@ -1,6 +1,6 @@
#include "capwap.h"
#include "cw_log.h"
#include "dbg.h"
int cw_readelem_statistics_timer(uint16_t *timer, int type, uint8_t * msgelem, int len)
{
@ -8,7 +8,7 @@ int cw_readelem_statistics_timer(uint16_t *timer, int type, uint8_t * msgelem, i
return 0;
if (len!=2){
cw_dbg(DBG_CW_RFC,"Statistics timer msgelem has wrong size, type=%d,len=%d",type,len);
cw_dbg(DBG_RFC,"Statistics timer msgelem has wrong size, type=%d,len=%d",type,len);
return 0;
}
*timer=*((uint16_t*)msgelem);

View File

@ -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 );
}
}

View File

@ -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));
}

View File

@ -33,7 +33,7 @@ printf("MTU discovery len %d %d and pos %d:\n",conn->mtu,len,msg->pos);
if (len < 0 )
return;
uint32_t val = CWMSGELEM_MTU_DISCOVERY_PADDING<<16|len;
uint32_t val = CW_ELEM_MTU_DISCOVERY_PADDING<<16|len;
*((uint32_t*)(msg->msgelems+msg->pos))=htonl(val);
memset(msg->msgelems+4+msg->pos,0xff,len);
msg->pos+=4+len;

View File

@ -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"}
};

View File

@ -1,6 +1,7 @@
#include "lwapp.h"
/*
int lw_put_80211_wtp_wlan_radio_configuration(uint8_t*dst,struct radioinfo *ri)
{
lw_put_byte(dst,ri->rid);
@ -9,18 +10,18 @@ int lw_put_80211_wtp_wlan_radio_configuration(uint8_t*dst,struct radioinfo *ri)
lw_put_byte(dst+4,ri->cfp_period);
lw_put_word(dst+5,ri->cfp_max_duration);
/* XXX catch rmac shorter or longer than 6*/
// XXX catch rmac shorter or longer than 6
lw_put_bstr(dst+7,ri->rmac); /* length MUST be 6 */
lw_put_bstr(dst+7,ri->rmac); // length MUST be 6
lw_put_word(dst+13,ri->beacon_period);
lw_put_byte(dst+15,ri->dtim_period);
lw_put_data(dst+16,ri->country_str,4);
lw_put_byte(dst+20,ri->max_bssid);
/* XXX not LWAP conform */
// XXX not LWAP conform
lw_put_data(dst+21,(uint8_t*)"DEAU990",7);
return 21+7;
}
*/

View File

@ -6,7 +6,7 @@
#include <arpa/inet.h>
#include "log.h"
#include "wtpinfo.h"
//#include "wtpinfo.h"
#include "lwapp.h"
@ -26,7 +26,7 @@ int lw_readelem_wtp_board_data(struct wtpinfo *wtpinfo, int type, uint8_t *msgel
return 0;
if ( len != 46 ) {
cw_dbg(DBG_MSG_ERR,"LWAPP msg size wrong. (WTP BOARD DATA) must be 46");
// cw_dbg(DBG_MSG_ERR,"LWAPP msg size wrong. (WTP BOARD DATA) must be 46");
return -1;
}

View File

@ -26,6 +26,7 @@
#include "cw_util.h"
#include "log.h"
#include "dbg.h"
/**
* Reads the LWAPP message element WTP Name
@ -42,7 +43,7 @@ int lw_readelem_wtp_name(uint8_t ** dst, int type, uint8_t * msgelem, int len)
if (len>254){
cw_dbg(DBG_MSG_ERR,"Truncating WTP_NAME msgelem to 254, wrong size, type=%d,len=%d",type,len);
cw_dbg(DBG_ELEM_ERR,"Truncating WTP_NAME msgelem to 254, wrong size, type=%d,len=%d",type,len);
len=254;
}

View File

@ -117,31 +117,12 @@ int mavl_foreach_from_lr(struct mavl *t, struct mavlnode *n, void *data,
//extern void mavl_foreach(struct mavl *t, int (*callback)(void *,void*),void *cbpriv,int dir);
static inline void *mavl_replace_data(struct mavl *t, void *data, int len)
{
void *df = mavl_get(t, data);
if (!df)
return NULL;
memcpy(df, data, len);
return df;
}
void *mavl_replace_data(struct mavl *t, void *data, int len);
static inline void *mavl_replace(struct mavl *t,void *data){
struct mavlnode * node = mavl_get_node(t,data);
if (node){
t->del(node->data);
return node->data=data;
}
return mavl_add(t,data);
}
void *mavl_replace(struct mavl *t,void *data);
static inline void mavl_destroy(struct mavl *t)
{
mavl_del_all(t);
free (t);
}
void mavl_destroy(struct mavl *t);
@ -169,41 +150,12 @@ typedef struct mavliter mavliter_t;
void * mavliter_next(mavliter_t *i);
static inline void * mavliter_seek_set(struct mavliter *i)
{
i->stack_ptr=0;
i->cur=i->root;
return mavliter_next(i);
}
void * mavliter_seek_set(struct mavliter *i);
/**
* Init an AVL Tree Iterator.
*
* After initialization #mavliter_next would return the first element.
* The behavior of #mavliter_get would still be undefined.
* @param i AVL Iterator to initialize
* @param t correspondending AVL Tree
*
* @See mavliter_t,
*/
static inline void mavliter_init(mavliter_t *i, mavl_t t){
i->root = t->root;
i->stack_ptr=0;
i->cmp=t->cmp;
}
void mavliter_init(mavliter_t *i, mavl_t t);
/**
* Get the element, where AVL Iterator currently is positioned.
* @param i AVL Iterator
* @return element or NULL if not found.
*/
static inline void * mavliter_get(mavliter_t *i){
if(!i->cur)
return NULL;
return i->cur->data;
}
void * mavliter_get(mavliter_t *i);
extern void * mavliter_seek(mavliter_t *i,void *d);

9
src/cw/mavl_destroy.c Normal file
View File

@ -0,0 +1,9 @@
#include "mavl.h"
void mavl_destroy(struct mavl *t)
{
mavl_del_all(t);
free (t);
}