diff --git a/libcw.project b/libcw.project index bdcac7d3..ac274e1f 100644 --- a/libcw.project +++ b/libcw.project @@ -22,7 +22,6 @@ - @@ -38,7 +37,6 @@ - @@ -75,7 +73,6 @@ - @@ -95,7 +92,6 @@ - @@ -134,8 +130,6 @@ - - @@ -154,7 +148,6 @@ - @@ -206,7 +199,6 @@ - @@ -240,11 +232,9 @@ - - @@ -300,7 +290,6 @@ - @@ -328,6 +317,7 @@ + diff --git a/src/cw/aciplist.c b/src/cw/aciplist.c index 0606ace4..4ddd80dc 100644 --- a/src/cw/aciplist.c +++ b/src/cw/aciplist.c @@ -28,14 +28,14 @@ #include #include "aciplist.h" -#include "avltree.h" +#include "mavl.h" #include "sock.h" -static int acip_cmp(const void *x1, const void *x2) +static int acip_cmp(const mavldata_t *x1, const mavldata_t *x2) { - struct cw_acip *ip1 = (struct cw_acip *) x1; - struct cw_acip *ip2 = (struct cw_acip *) x2; + struct cw_acip *ip1 = (struct cw_acip *) x1->ptr; + struct cw_acip *ip2 = (struct cw_acip *) x2->ptr; int r = ip1->index - ip2->index; if (r!=0) @@ -68,9 +68,9 @@ static int acip_cmp(const void *x1, const void *x2) return -1; } -static void acip_del(void *d) +static void acip_del(mavldata_t *d) { - free(d); + free(d->ptr); } /** @@ -79,6 +79,6 @@ static void acip_del(void *d) */ cw_aciplist_t cw_aciplist_create() { - return avltree_create(acip_cmp, acip_del); + return mavl_create(acip_cmp, acip_del); } diff --git a/src/cw/action.c b/src/cw/action.c index 0874e004..2f9ad6ea 100644 --- a/src/cw/action.c +++ b/src/cw/action.c @@ -100,7 +100,7 @@ cw_action_in_t *cw_actionlist_in_add(cw_actionlist_in_t t, struct cw_action_in * */ struct cw_action_in *cw_actionlist_in_get(cw_actionlist_in_t t, struct cw_action_in *a) { - return avltree_get(t, a); + return mavl_get(t, a); } @@ -260,7 +260,7 @@ int cw_actionlist_out_register_actions(cw_actionlist_out_t t, cw_action_out_t * * @param s size of element to add * @return pointer to added element or NULL if an error has opccured */ -void *cw_actionlist_add(struct avltree *t, void *a, size_t s) +void *cw_actionlist_add(struct mavl *t, void *a, size_t s) { void *r = mavl_replace_data(t, a, s); //sizeof(struct cw_action_in)); @@ -273,7 +273,7 @@ void *cw_actionlist_add(struct avltree *t, void *a, size_t s) return NULL; memcpy(an, a, s); - return avltree_add(t, an); + return mavl_add(t, an); } diff --git a/src/cw/avltree.h b/src/cw/avltree.h deleted file mode 100644 index 3acb28df..00000000 --- a/src/cw/avltree.h +++ /dev/null @@ -1,45 +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 . - -*/ - -#ifndef __AVLTREE_H -#define __AVLTREE_H - -#include "mavl.h" - -#define avltree mavl -#define avltree_get mavl_get -#define avltree_destroy mavl_destroy -#define avltree_create mavl_create -#define avltree_add mavl_add -#define avltree_del mavl_del -#define avltree_replace mavl_replace -#define avliter_foreach_from mavliter_foreach_from -#define avliter_foreach mavliter_foreach -#define avltree_foreach_asc mavl_foreach_asc -#define avliter_get mavliter_get -#define avltree_replace_data mavl_replace_data -#define avliter_seek mavliter_seek -#define avliter_seek_set mavliter_seek_set -#define avliter_next mavliter_next -#define avltree_del_all mavl_del_all - -#define DEFINE_AVLITER MAVLITER_DEFINE - -#endif - - diff --git a/src/cw/bstr16_create_from_str.c b/src/cw/bstr16_create_from_str.c index abb099f0..27f96596 100644 --- a/src/cw/bstr16_create_from_str.c +++ b/src/cw/bstr16_create_from_str.c @@ -24,7 +24,7 @@ uint8_t * bstr16_create_from_str(const char *s) msize++; uint8_t * mem = malloc(2+msize); *((uint16_t*)mem)=msize; - format_scan_hex_bytes(mem+2,s+2,l); + cw_format_scan_hex_bytes(mem+2,s+2,l); return mem; } diff --git a/src/cw/bstr_create_from_str.c b/src/cw/bstr_create_from_str.c index 6f01ab99..6fde0e25 100644 --- a/src/cw/bstr_create_from_str.c +++ b/src/cw/bstr_create_from_str.c @@ -24,7 +24,7 @@ uint8_t * bstr_create_from_str(const char *s) msize++; uint8_t * mem = malloc(1+msize); *((uint8_t*)mem)=msize; - format_scan_hex_bytes(mem+2,s+2,l); + cw_format_scan_hex_bytes(mem+2,s+2,l); return mem; } diff --git a/src/cw/bstrv_create_from_str.c b/src/cw/bstrv_create_from_str.c index 7acd469c..d841c567 100644 --- a/src/cw/bstrv_create_from_str.c +++ b/src/cw/bstrv_create_from_str.c @@ -58,7 +58,7 @@ uint8_t * bstrv_create_from_str(uint32_t vendor_id,const char *s) bstrv_set_vendor_id(mem,vendor_id); bstrv_set_len(mem,msize); - format_scan_hex_bytes(bstrv_data(mem),s+2,l); + cw_format_scan_hex_bytes(bstrv_data(mem),s+2,l); return mem; } diff --git a/src/cw/capwap80211.h b/src/cw/capwap80211.h index 07329ac2..8948d8fa 100644 --- a/src/cw/capwap80211.h +++ b/src/cw/capwap80211.h @@ -125,10 +125,13 @@ struct cw_wlan { int cw_out_radio_infos(struct conn *conn, struct cw_action_out *a, uint8_t * dst); - +/* //extern int cw_register_actions_capwap_80211_wtp(struct cw_actiondef *def); + */ extern struct cw_strlist_elem capwap_strings_elem80211[]; +/* //extern int cw_register_actions_capwap_80211_ac(struct cw_actiondef *def); +*/ /** *@} diff --git a/src/cw/cw_in_capwap_control_ip_address.c b/src/cw/cw_in_capwap_control_ip_address.c index 0528363f..ba4f0d72 100644 --- a/src/cw/cw_in_capwap_control_ip_address.c +++ b/src/cw/cw_in_capwap_control_ip_address.c @@ -43,6 +43,7 @@ int cw_in_capwap_control_ip_address(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,struct sockaddr *from) { + cw_acip_t * acip; cw_aciplist_t list = mbag_get_mavl_c(conn->incomming,a->item_id,cw_aciplist_create); @@ -51,7 +52,7 @@ int cw_in_capwap_control_ip_address(struct conn *conn, struct cw_action_in *a, return 0; } - cw_acip_t * acip; + acip = malloc(sizeof(cw_acip_t)); if (!acip) { cw_log(LOG_ERR,"Can't allocate memory for acv4ip: %s",strerror(errno)); diff --git a/src/cw/cw_in_vendor_specific_payload.c b/src/cw/cw_in_vendor_specific_payload.c index 63cdbf23..2651472c 100644 --- a/src/cw/cw_in_vendor_specific_payload.c +++ b/src/cw/cw_in_vendor_specific_payload.c @@ -22,9 +22,10 @@ int cw_in_vendor_specific_payload(struct conn *conn, struct cw_action_in *a, as.vendor_id = cw_get_dword(data); as.elem_id = cw_get_word(data + 4); +/* // TODO XXXX // af = cw_actionlist_in_get(conn->actions->in, &as); - af = 0; +*/ af = 0; if (!af) { cw_dbg(DBG_WARN, diff --git a/src/cw/cw_in_wtp_reboot_statistics.c b/src/cw/cw_in_wtp_reboot_statistics.c index 197c3bff..d05be8f7 100644 --- a/src/cw/cw_in_wtp_reboot_statistics.c +++ b/src/cw/cw_in_wtp_reboot_statistics.c @@ -47,3 +47,4 @@ int cw_in_wtp_reboot_statistics(struct conn *conn, struct cw_action_in *a, uint8 } + diff --git a/src/cw/cw_iplist.c b/src/cw/cw_iplist.c deleted file mode 100644 index e69de29b..00000000 diff --git a/src/cw/cw_load_file.c b/src/cw/cw_load_file.c index 083777a6..3660efe5 100644 --- a/src/cw/cw_load_file.c +++ b/src/cw/cw_load_file.c @@ -32,24 +32,26 @@ * The memory allocated returned in data must be freed using free. * * Eexample: - * \code + * \code{.c} #include "capwap/file.h" size_t bytes; char * data = cw_load_file("file.txt",&bytes); if (data){ - // Do something with data ... + @startcomment Do something with data ... @endcomment free (data); } \endcode */ char *cw_load_file(const char *filename, size_t * size) { - FILE *infile = fopen(filename, "rb"); + char *buf; + FILE *infile; + infile = fopen(filename, "rb"); if (!infile) return NULL; fseek(infile, 0, SEEK_END); *size = ftell(infile); - char *buf = malloc(*size); + buf = malloc(*size); if (!buf) goto errX; diff --git a/src/cw/cw_out_image_data.c b/src/cw/cw_out_image_data.c index 10d5aed1..d998813b 100644 --- a/src/cw/cw_out_image_data.c +++ b/src/cw/cw_out_image_data.c @@ -19,6 +19,7 @@ int cw_out_image_data(struct conn *conn, struct cw_action_out *a, uint8_t * dst) { + /* mbag_item_t * item = mbag_get(conn->outgoing,CW_ITEM_IMAGE_FILEHANDLE); if (!item) { cw_log(LOG_ERR,"Can't put element Image Data, no image filehandle found"); @@ -51,5 +52,7 @@ int cw_out_image_data(struct conn *conn, struct cw_action_out *a, uint8_t * dst) } return bytes + cw_put_elem_hdr(dst,a->elem_id,bytes); + */ + return 0; } diff --git a/src/cw/cw_put_local_ip_address.c b/src/cw/cw_put_local_ip_address.c index 65bc502b..574c9198 100644 --- a/src/cw/cw_put_local_ip_address.c +++ b/src/cw/cw_put_local_ip_address.c @@ -11,6 +11,8 @@ int cw_put_local_ip_address(int sock, uint8_t *dst, int ipv4elem_id, int ipv6elem_id) { struct sockaddr_storage a; + int id; + socklen_t alen = sizeof(struct sockaddr_storage); int rc = getsockname(sock, (struct sockaddr *) &a, &alen); @@ -20,7 +22,6 @@ int cw_put_local_ip_address(int sock, uint8_t *dst, int ipv4elem_id, int ipv6ele } - int id; switch (((struct sockaddr *) &a)->sa_family) { case AF_INET: @@ -33,8 +34,9 @@ int cw_put_local_ip_address(int sock, uint8_t *dst, int ipv4elem_id, int ipv6ele case AF_INET6: { + struct sockaddr_in6 *sain; id = ipv6elem_id; - struct sockaddr_in6 *sain = (struct sockaddr_in6 *) &a; + sain = (struct sockaddr_in6 *) &a; cw_put_data(dst + 4, (uint8_t *) & sain->sin6_addr, 16); return 16 + cw_put_elem_hdr(dst, id, 16); diff --git a/src/cw/cw_put_msg.c b/src/cw/cw_put_msg.c index 6ac76bae..8d5a6792 100644 --- a/src/cw/cw_put_msg.c +++ b/src/cw/cw_put_msg.c @@ -29,6 +29,7 @@ #include "dbg.h" + /** * Put a message to a buffer * This functions assumes, that a message header is @@ -156,10 +157,10 @@ int cw_put_custom_msg(struct conn *conn, uint8_t * rawout, mavl_conststr_t elems /// TODO XXXX // DEFINE_AVLITER(i,conn->actions->out); -DEFINE_AVLITER(i,0); +MAVLITER_DEFINE(i,0); cw_action_out_t *am; - if (! (am=avliter_seek(&i,&as))){ + if (! (am=mavliter_seek(&i,&as))){ cw_log(LOG_ERR,"Error: Can't create message of type %d (%s) - no definition found.", as.msg_id,cw_strmsg(as.msg_id)); return -1; @@ -167,7 +168,7 @@ DEFINE_AVLITER(i,0); cw_action_out_t *ae; int len = 0; - while(NULL != (ae=avliter_next(&i))) { + while(NULL != (ae=mavliter_next(&i))) { // DBGX("Put %d %i %p\n",ae->msg_id,ae->elem_id,ae->item_id); // DBGX("Elem ID %s",ae->item_id); diff --git a/src/cw/cw_rand.c b/src/cw/cw_rand.c index 044da35d..d0e2f1f4 100644 --- a/src/cw/cw_rand.c +++ b/src/cw/cw_rand.c @@ -67,6 +67,8 @@ int cw_rand_r(uint8_t * dst, int len) int cw_rand(uint8_t * dst, int len) { static uint32_t rinit = 0; + int i; + if (!rinit) { int l = cw_rand_r((uint8_t *) (&rinit), sizeof(uint32_t)); @@ -79,7 +81,7 @@ int cw_rand(uint8_t * dst, int len) srand(rinit); } - int i; + for (i = 0; i < len; i++) { dst[i] = rand(); } diff --git a/src/cw/dbg_strings.c b/src/cw/dbg_strings.c index a1178659..4488d8c2 100644 --- a/src/cw/dbg_strings.c +++ b/src/cw/dbg_strings.c @@ -21,7 +21,6 @@ *@brief */ -//#include #include "mbag.h" #include "dbg.h" diff --git a/src/cw/dtls_gnutls_get_peers_cert.c b/src/cw/dtls_gnutls_get_peers_cert.c index 40e25580..865108ef 100644 --- a/src/cw/dtls_gnutls_get_peers_cert.c +++ b/src/cw/dtls_gnutls_get_peers_cert.c @@ -10,13 +10,13 @@ struct dtls_ssl_cert dtls_gnutls_get_peers_cert(struct conn * conn,unsigned int n) { struct dtls_gnutls_data *d; + const gnutls_datum_t * clist; + struct dtls_ssl_cert cert; + unsigned int len; + + d=(struct dtls_gnutls_data*)conn->dtls_data; - const gnutls_datum_t * clist; - - struct dtls_ssl_cert cert; - - unsigned int len; clist = gnutls_certificate_get_peers(d->session,&len); cert.size = clist[n].size; diff --git a/src/cw/format.c b/src/cw/format.c index 704ffe4d..a5efa782 100644 --- a/src/cw/format.c +++ b/src/cw/format.c @@ -62,55 +62,6 @@ int format_hex_bytes(char *dst, const char *format, const char *delim, -/** - * Read hex bytes from a string to an uint8_t array - * @param dst destination array - * @param s string to read - * @param len length of string - * @return 0 if all was ok \n 1 if an error has occured. - */ - -int format_scan_hex_bytes(uint8_t *dst,const char *s, int len) -{ - int rc ; - int err=0; - int val; - int c; - int i; - - if ( len & 1){ - rc = sscanf(s,"%01X",&c); - if (rc!=1){ - c=0; - err=1; - } - *dst++=c; - s++; - len--; - } - - - for (i=0; iu2.data=mem; return i; diff --git a/src/cw/radio.h b/src/cw/radio.h index 6fc73a14..196acdd8 100644 --- a/src/cw/radio.h +++ b/src/cw/radio.h @@ -7,9 +7,10 @@ - +/* //extern const char CW_RADIO_ADMIN_STATE[]; //extern const char CW_RADIO_OPER_STATE[]; +*/ extern const char CW_RADIO_SUPPORTED_RATES[]; diff --git a/src/cw/stravltree.c b/src/cw/stravltree.c index 61febb3c..14d794d5 100644 --- a/src/cw/stravltree.c +++ b/src/cw/stravltree.c @@ -18,7 +18,7 @@ static void del(void* d) struct avltree * stravltree_create() { - return avltree_create(cmp,del); + return mavl_create(cmp,del); } const char * stravltree_add(struct avltree * t, const char * str) @@ -26,5 +26,5 @@ const char * stravltree_add(struct avltree * t, const char * str) char * s = strdup(str); if (!s) return 0; - return avltree_add(t,s); + return mavl_add(t,s); } diff --git a/src/cw/stravltree.h b/src/cw/stravltree.h index 81e81074..53d91c83 100644 --- a/src/cw/stravltree.h +++ b/src/cw/stravltree.h @@ -1,11 +1,11 @@ #ifndef __STRAVLTREE_H #define __STRAVLTREE_H -#include "avltree.h" +#include "mavl.h" extern struct avltree * stravltree_create(); const char * stravltree_add(struct avltree * t, const char * str); -#define stravltree_destroy(t) avltree_destroy(t) +#define stravltree_destroy(t) mavl_destroy(t) #define stravltree_foreach_asc(t,f,p) avltree_foreach_asc(t,f,p) #define stravltree_foreach_desc(t,f,p) avltree_foreach_desc(t,f,p) diff --git a/src/cw/strheap.c b/src/cw/strheap.c index 0bb8d44e..2518a091 100644 --- a/src/cw/strheap.c +++ b/src/cw/strheap.c @@ -39,7 +39,7 @@ int cw_strheap_register_strings(cw_strheap_t h, struct cw_strlist_elem *s) const char * cw_strheap_get(cw_strheap_t h, int id) { struct cw_strlist_elem s; s.id=id; - struct cw_strlist_elem *r = avltree_get(h,&s); + struct cw_strlist_elem *r = mavl_get(h,&s); if (r) return r->str; return NULL; diff --git a/src/cw/strheap.h b/src/cw/strheap.h index 0809bc99..90e9c17f 100644 --- a/src/cw/strheap.h +++ b/src/cw/strheap.h @@ -4,10 +4,10 @@ #include #include "strlist.h" -#include "avltree.h" +#include "mavl.h" -typedef struct avltree * cw_strheap_t; +typedef struct mavl * cw_strheap_t; extern cw_strheap_t cw_strheap_create();