diff --git a/actube.workspace b/actube.workspace index b8870938..e0162c79 100644 --- a/actube.workspace +++ b/actube.workspace @@ -3,9 +3,9 @@ - + - + diff --git a/libcw.project b/libcw.project index 73be1e58..e0411581 100644 --- a/libcw.project +++ b/libcw.project @@ -270,7 +270,6 @@ - diff --git a/src/cw/bstr.h b/src/cw/bstr.h index 3351a3db..c45d7be6 100644 --- a/src/cw/bstr.h +++ b/src/cw/bstr.h @@ -154,6 +154,7 @@ typedef uint8_t * bstrv_t; *@} */ +/* #define bstrv_get_vendor_id(str)\ ( *((uint32_t*)((str)+2))) @@ -171,7 +172,7 @@ typedef uint8_t * bstrv_t; #define bstrv_size(n)\ (1+6+(n)*sizeof(uint8_t)) - +*/ 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); diff --git a/src/cw/bstrv_create.c b/src/cw/bstrv_create.c index 17bdadc3..2175f24b 100644 --- a/src/cw/bstrv_create.c +++ b/src/cw/bstrv_create.c @@ -1,5 +1,6 @@ #include "bstr.h" +/* uint8_t * bstrv_create(uint32_t vendor_id, uint8_t *data, uint8_t len) { uint8_t * str = malloc(bstrv_size(len)); @@ -14,4 +15,4 @@ uint8_t * bstrv_create(uint32_t vendor_id, uint8_t *data, uint8_t len) } - +*/ diff --git a/src/cw/capwap_items.c b/src/cw/capwap_items.c index 7ff97e12..b3a15344 100644 --- a/src/cw/capwap_items.c +++ b/src/cw/capwap_items.c @@ -124,10 +124,10 @@ struct cw_itemdef capwap_itemdefs[] = { {CW_ITEM_CAPWAP_TRANSPORT_PROTOCOL,CW_ITEM_NONE,MBAG_BYTE}, {CW_ITEM_LOCATION_DATA,CW_ITEM_NONE,MBAG_STR}, -{CW_ITEM_WTP_HARDWARE_VERSION,CW_ITEM_NONE,MBAG_VENDORSTR}, -{CW_ITEM_WTP_SOFTWARE_VERSION,CW_ITEM_NONE,MBAG_VENDORSTR}, -{CW_ITEM_WTP_BOOT_VERSION,CW_ITEM_NONE,MBAG_VENDORSTR}, -{CW_ITEM_WTP_OTHER_VERSION,CW_ITEM_NONE,MBAG_VENDORSTR}, + + + + //{CW_ITEM_WTP_GROUP_NAME,CW_ITEM_NONE,MBAG_STR}, {CW_ITEM_MAXIMUM_MESSAGE_LENGTH,CW_ITEM_NONE,MBAG_WORD}, {CW_ITEM_STATISTICS_TIMER,CW_ITEM_NONE,MBAG_WORD}, diff --git a/src/cw/cw_dbg_elem.c b/src/cw/cw_dbg_elem.c index 985c277c..6ee66a7b 100644 --- a/src/cw/cw_dbg_elem.c +++ b/src/cw/cw_dbg_elem.c @@ -17,7 +17,7 @@ void cw_dbg_elem(int level, struct conn *conn, int msg, { - const char *elemname; +/* const char *elemname;*/ char vendorname[256]; char vendor_details[265]; diff --git a/src/cw/cw_in_cisco_image_identifier.c b/src/cw/cw_in_cisco_image_identifier.c index 7a119843..7145454c 100644 --- a/src/cw/cw_in_cisco_image_identifier.c +++ b/src/cw/cw_in_cisco_image_identifier.c @@ -31,7 +31,7 @@ int cw_in_cisco_image_identifier(struct conn *conn,struct cw_action_in * a,uint8 } // mbag_set(conn->remote,a->item_id,a->itemtype,data+dstart,len); - mbag_set_bstrv(conn->incomming,a->item_id,vendor_id,data+dstart,len); +// mbag_set_bstrv(conn->incomming,a->item_id,vendor_id,data+dstart,len); return 1; } diff --git a/src/cw/cw_put_mbag_item.c b/src/cw/cw_put_mbag_item.c index 8422276f..3bbed65f 100644 --- a/src/cw/cw_put_mbag_item.c +++ b/src/cw/cw_put_mbag_item.c @@ -26,6 +26,7 @@ int cw_put_mbag_item(uint8_t * dst, struct mbag_item *item) { +/* if (item->type->put){ cw_dbg(DBG_X,"User put method to put "); return item->type->put(item,dst); @@ -72,7 +73,7 @@ int cw_put_mbag_item(uint8_t * dst, struct mbag_item *item) cw_log(LOG_ERR,"No method to put items of type %s",item->type->name); - +*/ return 0; } diff --git a/src/cw/cw_save_file.c b/src/cw/cw_save_file.c index 6cc8a632..d0be813c 100644 --- a/src/cw/cw_save_file.c +++ b/src/cw/cw_save_file.c @@ -36,11 +36,12 @@ */ int cw_save_file(const char *filename, char *data, int len) { + int bytes; FILE *outfile = fopen(filename, "wb"); if (!outfile) return 0; - int bytes = fwrite(data, 1, len, outfile); + bytes = fwrite(data, 1, len, outfile); fclose(outfile); return bytes; } diff --git a/src/cw/cw_type_bstr16.c b/src/cw/cw_type_bstr16.c index 2a010909..dee17d46 100644 --- a/src/cw/cw_type_bstr16.c +++ b/src/cw/cw_type_bstr16.c @@ -35,7 +35,7 @@ static struct cw_KVT *get ( struct cw_KVT * data, const uint8_t * src, int len ) if ( !s ) return NULL; - + data->type = &cw_type_bstr16; data->val.ptr = s; return data; diff --git a/src/cw/cw_type_byte.c b/src/cw/cw_type_byte.c index 27afeadf..ec99c6b3 100644 --- a/src/cw/cw_type_byte.c +++ b/src/cw/cw_type_byte.c @@ -28,7 +28,7 @@ static cw_KVT_t *get(cw_KVT_t * data, const uint8_t * src, int len) return data; } -static int put(cw_KVT_t *data, uint8_t * dst) +static int put(const cw_KVT_t *data, uint8_t * dst) { return cw_put_byte(dst, data->val.byte); } diff --git a/src/cw/cw_type_dword.c b/src/cw/cw_type_dword.c index 376a742f..66fa08e5 100644 --- a/src/cw/cw_type_dword.c +++ b/src/cw/cw_type_dword.c @@ -28,7 +28,7 @@ static struct cw_KVT *get(struct cw_KVT * data, const uint8_t * src, int len) return data; } -static int put(struct cw_KVT *data, uint8_t * dst) +static int put(const struct cw_KVT *data, uint8_t * dst) { return cw_put_dword(dst, data->val.dword); } diff --git a/src/cw/cw_type_word.c b/src/cw/cw_type_word.c index 852aecc3..0779ed4f 100644 --- a/src/cw/cw_type_word.c +++ b/src/cw/cw_type_word.c @@ -29,7 +29,7 @@ static struct cw_KVT *get(struct cw_KVT * data, const uint8_t * src, int len) return data; } -static int put(cw_KVT_t *data, uint8_t * dst) +static int put(const cw_KVT_t *data, uint8_t * dst) { return cw_put_word(dst, data->val.word); } diff --git a/src/cw/dbg.c b/src/cw/dbg.c index 821aaa86..cfaa485d 100644 --- a/src/cw/dbg.c +++ b/src/cw/dbg.c @@ -336,6 +336,8 @@ void cw_dbg_msg(int level, struct conn *conn, uint8_t * packet, int len, cw_dbg(level, "%s", buf); } +/* + static int cw_format_vendor(char *dst, uint32_t vendor_id, int elem_id, const uint8_t * elem_data) { @@ -349,7 +351,7 @@ static int cw_format_vendor(char *dst, uint32_t vendor_id, int elem_id, } - /* dive into LWAPP vendor specific decoding */ + // dive into LWAPP vendor specific decoding lw_elem_id = lw_get_word(elem_data + 4 + 6); return sprintf(dst, "%d/LWAPP Vendor: %d - %s", elem_id, @@ -371,7 +373,7 @@ static int cw_format_vendor(char *dst, uint32_t vendor_id, int elem_id, return 0; } - +*/ diff --git a/src/cw/dtls_openssl_connect.c b/src/cw/dtls_openssl_connect.c index f3fe0c8f..7b527b68 100644 --- a/src/cw/dtls_openssl_connect.c +++ b/src/cw/dtls_openssl_connect.c @@ -28,15 +28,13 @@ static BIO_METHOD bio_methods = { unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len) { - + int l; BIO *b = SSL_get_rbio(ssl); struct conn *conn = b->ptr; -// printf("KEYY: %s\n",conn->dtls_psk); - snprintf(identity, max_identity_len, "CLient_identity"); - int l = conn->dtls_psk_len < max_psk_len ? conn->dtls_psk_len : max_psk_len; + l = conn->dtls_psk_len < max_psk_len ? conn->dtls_psk_len : max_psk_len; memcpy(psk, conn->dtls_psk, l); return l; @@ -45,22 +43,27 @@ static BIO_METHOD bio_methods = { int dtls_openssl_connect(struct conn *conn) { + struct dtls_openssl_data *d; + int rc; + time_t timer; + if (!conn->dtls_data) conn->dtls_data = dtls_openssl_data_create(conn, DTLSv1_client_method(), dtls_openssl_bio_method()); - struct dtls_openssl_data *d = (struct dtls_openssl_data *) conn->dtls_data; + d = (struct dtls_openssl_data *) conn->dtls_data; if (!d) return 0; +/* // if (conn->dtls_psk) // SSL_set_psk_client_callback(d->ssl, psk_client_cb); +*/ - int rc; errno =0; - time_t timer = cw_timer_start(10); + timer = cw_timer_start(10); do { rc = SSL_connect(d->ssl); }while(rc!=1 && errno==EAGAIN && !cw_timer_timeout(timer)); diff --git a/src/cw/dtls_openssl_get_cipher.c b/src/cw/dtls_openssl_get_cipher.c index dc752064..887327a4 100644 --- a/src/cw/dtls_openssl_get_cipher.c +++ b/src/cw/dtls_openssl_get_cipher.c @@ -21,14 +21,16 @@ const char * dtls_openssl_get_cipher(struct conn * conn) { + struct dtls_openssl_data * d; + const SSL_CIPHER * c; if (!conn->dtls_data) return "None"; - struct dtls_openssl_data * d = (struct dtls_openssl_data*)conn->dtls_data; + d = (struct dtls_openssl_data*)conn->dtls_data; if ( !d->ssl ) return "None"; - const SSL_CIPHER * c = SSL_get_current_cipher(d->ssl); + c = SSL_get_current_cipher(d->ssl); return SSL_CIPHER_get_name(c); } diff --git a/src/cw/fragman.c b/src/cw/fragman.c index c88a61b3..47423f60 100644 --- a/src/cw/fragman.c +++ b/src/cw/fragman.c @@ -85,7 +85,7 @@ static struct frag * frag_new(struct frag * frags, int fragid) int i; for (i=0; iFRAG_TTL) ){ - // printf("******************************new frag, %p\n",frags[i].buffer); + frags[i].buffer=realloc(frags[i].buffer,FRAG_MAXSIZE); if (frags[i].buffer==NULL) diff --git a/src/cw/kvt.h b/src/cw/kvt.h index 30276a21..f5fb7fc5 100644 --- a/src/cw/kvt.h +++ b/src/cw/kvt.h @@ -26,7 +26,7 @@ struct cw_Type { void (*del) (struct cw_KVT * data); /** A method to put this object to a buffer */ - int (*put) (struct cw_KVT * data, uint8_t * dst); + int (*put) (const struct cw_KVT * data, uint8_t * dst); /** The get method */ struct cw_KVT *(*get) (struct cw_KVT * data, const uint8_t * src, int len); diff --git a/src/cw/mbag.c b/src/cw/mbag.c index f0e74dd3..4394939d 100644 --- a/src/cw/mbag.c +++ b/src/cw/mbag.c @@ -332,7 +332,7 @@ int mbag_set_data(mbag_t s, const char *id, const struct mbag_typedef *type, voi } - +/* bstrv_t mbag_set_bstrv(mbag_t s, const char *id, uint32_t vendor_id, uint8_t * version, int len) { @@ -346,7 +346,7 @@ bstrv_t mbag_set_bstrv(mbag_t s, const char *id, uint32_t vendor_id, } - +*/ diff --git a/src/cw/mbag.h b/src/cw/mbag.h index c5969e21..878b54ee 100644 --- a/src/cw/mbag.h +++ b/src/cw/mbag.h @@ -114,7 +114,7 @@ extern const struct mbag_typedef mtype_dword; extern const struct mbag_typedef mbag_type_mbag; extern const struct mbag_typedef mbag_type_bstr; extern const struct mbag_typedef mbag_type_bstr16; -extern const struct mbag_typedef mbag_type_bstrv; + extern const struct mbag_typedef mbag_type_str; extern const struct mbag_typedef mbag_type_ptr; extern const struct mbag_typedef mbag_type_avltree; @@ -151,8 +151,6 @@ extern const struct mbag_typedef mbag_type_data; #define MBAG_DATA (&mbag_type_data) #define MBAG_BIN MBAG_DATA -/** MBAG_BSTRV holds a #bstr_t value */ -#define MBAG_VENDORSTR (&mbag_type_bstrv) /** MBAG_STR holds a zero terminated string */ #define MBAG_STR (&mbag_type_str) /** diff --git a/src/cw/mbag_set_from_buf.c b/src/cw/mbag_set_from_buf.c index 6029ac36..89504ec8 100644 --- a/src/cw/mbag_set_from_buf.c +++ b/src/cw/mbag_set_from_buf.c @@ -3,7 +3,7 @@ int mbag_set_from_buf(mbag_t dst, mbagtype_t type, const char *item_id, uint8_t *data, int len) { - +/* if (type == MBAG_BYTE) { mbag_set_byte(dst, item_id, *data); return 1; @@ -46,7 +46,7 @@ int mbag_set_from_buf(mbag_t dst, mbagtype_t type, const char *item_id, uint8_t } - +*/ return 0; } diff --git a/src/cw/mbag_type_vendorstr.c b/src/cw/mbag_type_vendorstr.c deleted file mode 100644 index c7234271..00000000 --- a/src/cw/mbag_type_vendorstr.c +++ /dev/null @@ -1,80 +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 mbag_type bstrv - *@addtogroup MbagFunctions - *@{ - */ - -#include "mbag.h" -#include "format.h" - - -static int to_str(void *item,char *dst) -{ - - mbag_item_t *i= item; - - char *d=dst; - d+=sprintf(d,"%d,",bstrv_get_vendor_id(i->u2.data)); - - if (format_is_utf8(bstrv_data(i->u2.data), bstrv_len(i->u2.data))) { - d += sprintf(d, "%.*s", bstrv_len(i->u2.data), - bstrv_data(i->u2.data)); - } else { - d += sprintf(d, ".x"); - d += format_hex(d, bstrv_data(i->u2.data), bstrv_len(i->u2.data)); - } - - return d-dst; -} - - -static struct mbag_item * from_str(const char *src) -{ - mbag_item_t * i = mbag_item_new(MBAG_VENDORSTR); - if (!i) - return NULL; - - uint32_t vendor_id=atoi(src); - const char *s = strchr(src,','); - - - if (s){ - i->u2.data=bstrv_create_from_str(vendor_id,s+1); - } - else{ - i->u2.data=bstrv_create_from_str(vendor_id,""); - } - - return i; -} - -/** - * Defines the VendorStr type. - * - * MBAG items of this type containing a variable of type #bstrv_t. - */ -const struct mbag_typedef mbag_type_bstrv = { - "VendorStr",free,to_str,from_str -}; - - -/**@}*/ diff --git a/src/cw/sock_mwait.c b/src/cw/sock_mwait.c index d14bb2bf..35a50fd5 100644 --- a/src/cw/sock_mwait.c +++ b/src/cw/sock_mwait.c @@ -23,11 +23,11 @@ int sock_mwait(int * socklist, int socklistlen,fd_set * fset) { - int i; + int i,max,n; FD_ZERO(fset); - int max = 0; + max = 0; for (i=0; i