From d8c8bd022e50b7173b5b47d0782fdf18cdde935b Mon Sep 17 00:00:00 2001 From: "7u83@mail.ru" <7u83@mail.ru@noemail.net> Date: Wed, 28 Feb 2018 08:05:45 +0000 Subject: [PATCH] Work on ansi and clean Makefiles FossilOrigin-Name: 0805f78d34219a2aac597a313081ce869c389e6b5d471c65c7f43d0906c0a400 --- src/cw/acinfo_print.c | 78 ---------- src/cw/avliter_next.c | 69 --------- src/cw/avltree_foreach.c | 39 ----- src/cw/avltree_foreach_from_lr.c | 31 ---- src/cw/avltree_foreach_lr.c | 17 --- src/cw/avltree_foreach_node.c | 33 ----- src/cw/avltree_foreach_rl.c | 18 --- src/cw/avltree_get.c | 47 ------ src/cw/avltree_get_node.c | 39 ----- src/cw/bstr.h | 28 +--- src/cw/bstr16_create.c | 13 ++ src/cw/bstrv_create.c | 17 +++ src/cw/capwap_80211_actions.h | 13 -- src/cw/capwap_80211_actions_ac.c | 65 -------- src/cw/capwap_80211_actions_wtp.c | 64 -------- src/cw/conn_get_message.c | 78 ---------- src/cw/conn_prepare_image_data_request.c | 4 +- src/cw/conn_send_request.c | 7 +- src/cw/conn_wait_for_message.c | 37 ----- src/cw/cw_addelem_capwap_local_ip_addr.c | 3 +- .../cw_prepare_configuration_status_request.c | 37 ----- src/cw/cw_read_image_data_request.c | 5 +- src/cw/cw_readelem_ac_descriptor.c | 140 ------------------ src/cw/cw_readelem_cisco_wtp_radio_cfg.c | 7 +- src/cw/cw_readelem_maximum_message_length.c | 37 ----- src/cw/cw_readelem_statistics_timer.c | 4 +- .../cw_readmsg_configuration_status_request.c | 22 --- src/cw/cw_send_image_file.c | 102 ------------- src/cw/cwmsg_addelem_mtu_discovery_padding.c | 2 +- src/cw/item_strings.c | 16 -- ...w_put_80211_wtp_wlan_radio_configuration.c | 9 +- src/cw/lw_readelem_wtp_board_data.c | 4 +- src/cw/lw_readelem_wtp_name.c | 3 +- src/cw/mavl.h | 60 +------- src/cw/mavl_destroy.c | 9 ++ src/cw/mavl_replace.c | 12 ++ src/cw/mavl_replace_data.c | 12 ++ src/cw/mavliter_get.c | 14 ++ src/cw/mavliter_init.c | 19 +++ src/cw/mavliter_seek_set.c | 10 ++ src/cw/sock_getifaddr.c | 9 +- src/cw/wtpinfo_lwreadelem_wtp_descriptor.c | 59 -------- 42 files changed, 147 insertions(+), 1145 deletions(-) delete mode 100644 src/cw/acinfo_print.c delete mode 100644 src/cw/avliter_next.c delete mode 100644 src/cw/avltree_foreach.c delete mode 100644 src/cw/avltree_foreach_from_lr.c delete mode 100644 src/cw/avltree_foreach_lr.c delete mode 100644 src/cw/avltree_foreach_node.c delete mode 100644 src/cw/avltree_foreach_rl.c delete mode 100644 src/cw/avltree_get.c delete mode 100644 src/cw/avltree_get_node.c create mode 100644 src/cw/bstr16_create.c create mode 100644 src/cw/bstrv_create.c delete mode 100644 src/cw/capwap_80211_actions.h delete mode 100644 src/cw/capwap_80211_actions_ac.c delete mode 100644 src/cw/capwap_80211_actions_wtp.c delete mode 100644 src/cw/conn_get_message.c delete mode 100644 src/cw/conn_wait_for_message.c delete mode 100644 src/cw/cw_prepare_configuration_status_request.c delete mode 100644 src/cw/cw_readelem_ac_descriptor.c delete mode 100644 src/cw/cw_readelem_maximum_message_length.c delete mode 100644 src/cw/cw_readmsg_configuration_status_request.c delete mode 100644 src/cw/cw_send_image_file.c delete mode 100644 src/cw/item_strings.c create mode 100644 src/cw/mavl_destroy.c create mode 100644 src/cw/mavl_replace.c create mode 100644 src/cw/mavl_replace_data.c create mode 100644 src/cw/mavliter_get.c create mode 100644 src/cw/mavliter_init.c create mode 100644 src/cw/mavliter_seek_set.c delete mode 100644 src/cw/wtpinfo_lwreadelem_wtp_descriptor.c diff --git a/src/cw/acinfo_print.c b/src/cw/acinfo_print.c deleted file mode 100644 index 5dbebf36..00000000 --- a/src/cw/acinfo_print.c +++ /dev/null @@ -1,78 +0,0 @@ - -/** - * @file - * @breif defines acinfo_print function - */ - -#include -#include - -#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; -} - - - diff --git a/src/cw/avliter_next.c b/src/cw/avliter_next.c deleted file mode 100644 index 5e97f332..00000000 --- a/src/cw/avliter_next.c +++ /dev/null @@ -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 . - -*/ - -/** - *@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; -} - - diff --git a/src/cw/avltree_foreach.c b/src/cw/avltree_foreach.c deleted file mode 100644 index 795e7b77..00000000 --- a/src/cw/avltree_foreach.c +++ /dev/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 . - -*/ - -#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); -} - diff --git a/src/cw/avltree_foreach_from_lr.c b/src/cw/avltree_foreach_from_lr.c deleted file mode 100644 index f5d4cb22..00000000 --- a/src/cw/avltree_foreach_from_lr.c +++ /dev/null @@ -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); -} - - diff --git a/src/cw/avltree_foreach_lr.c b/src/cw/avltree_foreach_lr.c deleted file mode 100644 index 599d7bd0..00000000 --- a/src/cw/avltree_foreach_lr.c +++ /dev/null @@ -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); - -} - - diff --git a/src/cw/avltree_foreach_node.c b/src/cw/avltree_foreach_node.c deleted file mode 100644 index 5e0ada87..00000000 --- a/src/cw/avltree_foreach_node.c +++ /dev/null @@ -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) -{ - -} diff --git a/src/cw/avltree_foreach_rl.c b/src/cw/avltree_foreach_rl.c deleted file mode 100644 index 7ee82a8f..00000000 --- a/src/cw/avltree_foreach_rl.c +++ /dev/null @@ -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); -} - - diff --git a/src/cw/avltree_get.c b/src/cw/avltree_get.c deleted file mode 100644 index 62950050..00000000 --- a/src/cw/avltree_get.c +++ /dev/null @@ -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 . -*/ - -/** - * @file - * @brief Implementation of avltree_get - */ - -#include - -#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; -} - - diff --git a/src/cw/avltree_get_node.c b/src/cw/avltree_get_node.c deleted file mode 100644 index 8d3d3ff5..00000000 --- a/src/cw/avltree_get_node.c +++ /dev/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 . - -*/ - - -#include - -#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; -} - diff --git a/src/cw/bstr.h b/src/cw/bstr.h index 779656b4..3351a3db 100644 --- a/src/cw/bstr.h +++ b/src/cw/bstr.h @@ -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 diff --git a/src/cw/bstr16_create.c b/src/cw/bstr16_create.c new file mode 100644 index 00000000..4738e1b1 --- /dev/null +++ b/src/cw/bstr16_create.c @@ -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; +} + + diff --git a/src/cw/bstrv_create.c b/src/cw/bstrv_create.c new file mode 100644 index 00000000..17bdadc3 --- /dev/null +++ b/src/cw/bstrv_create.c @@ -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; + +} + + diff --git a/src/cw/capwap_80211_actions.h b/src/cw/capwap_80211_actions.h deleted file mode 100644 index 09bbfa99..00000000 --- a/src/cw/capwap_80211_actions.h +++ /dev/null @@ -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 */ - - diff --git a/src/cw/capwap_80211_actions_ac.c b/src/cw/capwap_80211_actions_ac.c deleted file mode 100644 index 5f66d457..00000000 --- a/src/cw/capwap_80211_actions_ac.c +++ /dev/null @@ -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; -} - diff --git a/src/cw/capwap_80211_actions_wtp.c b/src/cw/capwap_80211_actions_wtp.c deleted file mode 100644 index fdc7147b..00000000 --- a/src/cw/capwap_80211_actions_wtp.c +++ /dev/null @@ -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; -} - diff --git a/src/cw/conn_get_message.c b/src/cw/conn_get_message.c deleted file mode 100644 index ad3e25e6..00000000 --- a/src/cw/conn_get_message.c +++ /dev/null @@ -1,78 +0,0 @@ - - -#include -#include -#include - -#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; -} diff --git a/src/cw/conn_prepare_image_data_request.c b/src/cw/conn_prepare_image_data_request.c index 39fadd98..7259b3ab 100644 --- a/src/cw/conn_prepare_image_data_request.c +++ b/src/cw/conn_prepare_image_data_request.c @@ -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 */ diff --git a/src/cw/conn_send_request.c b/src/cw/conn_send_request.c index 48bc426b..634766a5 100644 --- a/src/cw/conn_send_request.c +++ b/src/cw/conn_send_request.c @@ -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; } - +*/ diff --git a/src/cw/conn_wait_for_message.c b/src/cw/conn_wait_for_message.c deleted file mode 100644 index 7c00aa95..00000000 --- a/src/cw/conn_wait_for_message.c +++ /dev/null @@ -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; -} - - diff --git a/src/cw/cw_addelem_capwap_local_ip_addr.c b/src/cw/cw_addelem_capwap_local_ip_addr.c index deeb0b1a..a871193b 100644 --- a/src/cw/cw_addelem_capwap_local_ip_addr.c +++ b/src/cw/cw_addelem_capwap_local_ip_addr.c @@ -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) } - +*/ diff --git a/src/cw/cw_prepare_configuration_status_request.c b/src/cw/cw_prepare_configuration_status_request.c deleted file mode 100644 index d83eb581..00000000 --- a/src/cw/cw_prepare_configuration_status_request.c +++ /dev/null @@ -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); - -*/ -} diff --git a/src/cw/cw_read_image_data_request.c b/src/cw/cw_read_image_data_request.c index c6cfd8c9..e7deeaf4 100644 --- a/src/cw/cw_read_image_data_request.c +++ b/src/cw/cw_read_image_data_request.c @@ -24,7 +24,8 @@ #include "capwap.h" -#include "cw_log.h" +#include "log.h" +#include "dbg.h" #include "cw_util.h" #include @@ -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; diff --git a/src/cw/cw_readelem_ac_descriptor.c b/src/cw/cw_readelem_ac_descriptor.c deleted file mode 100644 index 362700f6..00000000 --- a/src/cw/cw_readelem_ac_descriptor.c +++ /dev/null @@ -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 . - -*/ - -/** - * @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>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; -} - - diff --git a/src/cw/cw_readelem_cisco_wtp_radio_cfg.c b/src/cw/cw_readelem_cisco_wtp_radio_cfg.c index 2e962f00..a4879fde 100644 --- a/src/cw/cw_readelem_cisco_wtp_radio_cfg.c +++ b/src/cw/cw_readelem_cisco_wtp_radio_cfg.c @@ -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; -} +} + + +*/ diff --git a/src/cw/cw_readelem_maximum_message_length.c b/src/cw/cw_readelem_maximum_message_length.c deleted file mode 100644 index dcf6bb53..00000000 --- a/src/cw/cw_readelem_maximum_message_length.c +++ /dev/null @@ -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 . - -*/ - -#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; -} - - diff --git a/src/cw/cw_readelem_statistics_timer.c b/src/cw/cw_readelem_statistics_timer.c index dc26c9c9..382e0d30 100644 --- a/src/cw/cw_readelem_statistics_timer.c +++ b/src/cw/cw_readelem_statistics_timer.c @@ -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); diff --git a/src/cw/cw_readmsg_configuration_status_request.c b/src/cw/cw_readmsg_configuration_status_request.c deleted file mode 100644 index 41792941..00000000 --- a/src/cw/cw_readmsg_configuration_status_request.c +++ /dev/null @@ -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 ); - - } - - -} diff --git a/src/cw/cw_send_image_file.c b/src/cw/cw_send_image_file.c deleted file mode 100644 index 3e45bbf6..00000000 --- a/src/cw/cw_send_image_file.c +++ /dev/null @@ -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 . - -*/ - - -/** - * @file - * @breif send image file - */ - -#include -#include -#include - - -#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)); - -} diff --git a/src/cw/cwmsg_addelem_mtu_discovery_padding.c b/src/cw/cwmsg_addelem_mtu_discovery_padding.c index d0e29ce9..560e7f52 100644 --- a/src/cw/cwmsg_addelem_mtu_discovery_padding.c +++ b/src/cw/cwmsg_addelem_mtu_discovery_padding.c @@ -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; diff --git a/src/cw/item_strings.c b/src/cw/item_strings.c deleted file mode 100644 index b0b47ba5..00000000 --- a/src/cw/item_strings.c +++ /dev/null @@ -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"} - -}; diff --git a/src/cw/lw_put_80211_wtp_wlan_radio_configuration.c b/src/cw/lw_put_80211_wtp_wlan_radio_configuration.c index 4e871379..04060f14 100644 --- a/src/cw/lw_put_80211_wtp_wlan_radio_configuration.c +++ b/src/cw/lw_put_80211_wtp_wlan_radio_configuration.c @@ -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; } - +*/ diff --git a/src/cw/lw_readelem_wtp_board_data.c b/src/cw/lw_readelem_wtp_board_data.c index 1c0c0ab5..133a3409 100644 --- a/src/cw/lw_readelem_wtp_board_data.c +++ b/src/cw/lw_readelem_wtp_board_data.c @@ -6,7 +6,7 @@ #include #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; } diff --git a/src/cw/lw_readelem_wtp_name.c b/src/cw/lw_readelem_wtp_name.c index e9d57f8b..a8a80bfe 100644 --- a/src/cw/lw_readelem_wtp_name.c +++ b/src/cw/lw_readelem_wtp_name.c @@ -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; } diff --git a/src/cw/mavl.h b/src/cw/mavl.h index b0bd15b7..26590884 100644 --- a/src/cw/mavl.h +++ b/src/cw/mavl.h @@ -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); diff --git a/src/cw/mavl_destroy.c b/src/cw/mavl_destroy.c new file mode 100644 index 00000000..391fa649 --- /dev/null +++ b/src/cw/mavl_destroy.c @@ -0,0 +1,9 @@ +#include "mavl.h" + +void mavl_destroy(struct mavl *t) +{ + mavl_del_all(t); + free (t); +} + + diff --git a/src/cw/mavl_replace.c b/src/cw/mavl_replace.c new file mode 100644 index 00000000..c6ea7037 --- /dev/null +++ b/src/cw/mavl_replace.c @@ -0,0 +1,12 @@ +#include "mavl.h" + +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); +} + + diff --git a/src/cw/mavl_replace_data.c b/src/cw/mavl_replace_data.c new file mode 100644 index 00000000..4e8e8c7f --- /dev/null +++ b/src/cw/mavl_replace_data.c @@ -0,0 +1,12 @@ +#include "mavl.h" + +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; +} + + diff --git a/src/cw/mavliter_get.c b/src/cw/mavliter_get.c new file mode 100644 index 00000000..66818d97 --- /dev/null +++ b/src/cw/mavliter_get.c @@ -0,0 +1,14 @@ +#include "mavl.h" + +/** + * Get the element, where AVL Iterator currently is positioned. + * @param i AVL Iterator + * @return element or NULL if not found. + */ +void * mavliter_get(mavliter_t *i){ + if(!i->cur) + return NULL; + return i->cur->data; +} + + diff --git a/src/cw/mavliter_init.c b/src/cw/mavliter_init.c new file mode 100644 index 00000000..b9c83f51 --- /dev/null +++ b/src/cw/mavliter_init.c @@ -0,0 +1,19 @@ +#include "mavl.h" + +/** + * 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, + */ +void mavliter_init(mavliter_t *i, mavl_t t){ + i->root = t->root; + i->stack_ptr=0; + i->cmp=t->cmp; +} + + diff --git a/src/cw/mavliter_seek_set.c b/src/cw/mavliter_seek_set.c new file mode 100644 index 00000000..ca634c72 --- /dev/null +++ b/src/cw/mavliter_seek_set.c @@ -0,0 +1,10 @@ +#include "mavl.h" + +void * mavliter_seek_set(struct mavliter *i) +{ + i->stack_ptr=0; + i->cur=i->root; + return mavliter_next(i); +} + + diff --git a/src/cw/sock_getifaddr.c b/src/cw/sock_getifaddr.c index 5942dbe9..79ce5e2b 100644 --- a/src/cw/sock_getifaddr.c +++ b/src/cw/sock_getifaddr.c @@ -52,11 +52,10 @@ int sock_getifaddr(const char * ifname,int family, int type,struct sockaddr * sa memcpy (sa, ifa->ifa_addr, sock_addrlen(ifa->ifa_addr)); rc=1; break; - case IFF_BROADCAST: -// memcpy (sa, ifa->ifa_ifu.ifu_broadaddr, sock_addrlen(ifa->ifa_addr)); - memcpy (sa, ifa->ifa_broadaddr, sock_addrlen(ifa->ifa_addr)); - rc=1; - break; +// case IFF_BROADCAST: +// memcpy (sa, ifa->ifa_broadaddr, sock_addrlen(ifa->ifa_addr)); +// rc=1; +// break; default: break; diff --git a/src/cw/wtpinfo_lwreadelem_wtp_descriptor.c b/src/cw/wtpinfo_lwreadelem_wtp_descriptor.c deleted file mode 100644 index abadcafd..00000000 --- a/src/cw/wtpinfo_lwreadelem_wtp_descriptor.c +++ /dev/null @@ -1,59 +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 . - -*/ - -#include -#include - -#include "capwap.h" -#include "lwapp.h" - -#include "wtpinfo.h" - -#include "cw_util.h" - -int wtpinfo_lwreadelem_wtp_descriptor(struct wtpinfo * wtpinfo, int type, uint8_t *msgelem, int len) -{ - if (type != LW_ELEM_WTP_DESCRIPTOR) - return 0; - -/* if (len!=16) - return -1; -*/ - - char str[64]; - uint32_t hwversion=ntohl(*((uint32_t*)(msgelem))); - sprintf(str,"%08X",hwversion); - cw_setstr(&wtpinfo->hardware_version,(uint8_t*)str,strlen(str)); - - uint32_t swversion=ntohl(*((uint32_t*)(msgelem+4))); - sprintf(str,"%08X",swversion); - cw_setstr(&wtpinfo->software_version,(uint8_t*)str,strlen(str)); - - uint32_t btversion=ntohl(*((uint32_t*)(msgelem+8))); - sprintf(str,"%08X",btversion); - cw_setstr(&wtpinfo->bootloader_version,(uint8_t*)str,strlen(str)); - - uint32_t l=ntohl(*((uint32_t*)(msgelem+12))); - - wtpinfo->max_radios = l >> 24; - wtpinfo->radios_in_use = (l>>16) & 0xff; - - - return 1; -} -