From 3cbe9445c2ac1689faeb63b4666a88568594b128 Mon Sep 17 00:00:00 2001 From: "7u83@mail.ru" <7u83@mail.ru@noemail.net> Date: Thu, 1 Mar 2018 19:11:37 +0000 Subject: [PATCH] Some ansi work FossilOrigin-Name: 10506b615d76f4567d9de61f08327ffb056500265600b8666ce1e0f15cd1f74b --- src/ac/Makefile | 2 +- src/cw/Makefile | 2 +- src/cw/conn_prepare_image_data_request.c | 12 +- src/cw/cw_addelem_vendor_specific_payload.c | 48 ---- src/cw/cw_in_wtp_descriptor.c | 254 -------------------- src/cw/cw_read_wtp_descriptor.c | 48 ---- src/cw/hdr_print.c | 4 +- src/cw/lw_readelem_wtp_board_data.c | 39 --- src/cw/sock_get_primary_if.c | 3 +- 9 files changed, 13 insertions(+), 399 deletions(-) delete mode 100644 src/cw/cw_addelem_vendor_specific_payload.c delete mode 100644 src/cw/cw_in_wtp_descriptor.c delete mode 100644 src/cw/cw_read_wtp_descriptor.c delete mode 100644 src/cw/lw_readelem_wtp_board_data.c diff --git a/src/ac/Makefile b/src/ac/Makefile index 53bfbe2b..7b159270 100644 --- a/src/ac/Makefile +++ b/src/ac/Makefile @@ -80,7 +80,7 @@ all: $(AC_NAME) $(AC_NAME): $(AC_OBJS) # $(CC) $(AC_OBJS) ../mod/modload_ac.o -o $(AC_NAME) $(LDFLAGS) $(LIBS) - $(CC) $(AC_OBJS) -o $(AC_NAME) $(LDFLAGS) $(LIBS) + $(CC) $(AC_OBJS) -v -o $(AC_NAME) $(LDFLAGS) $(LIBS) clean: diff --git a/src/cw/Makefile b/src/cw/Makefile index f3968ec1..8e424f62 100644 --- a/src/cw/Makefile +++ b/src/cw/Makefile @@ -24,7 +24,7 @@ all: $(SNAME) $(DNAME) #CFLAGS = -D_XOPEN_SOURCE=500 -std=c90 -pedantic -Wall -fPIC -g -O0 -D_REENTRANT -DWITH_IPV6 -DWITH_RMAC_SUPPORT -I /usr/local/include -I../ -CFLAGS = -D_XOPEN_SOURCE=500 -Wall -fPIC -g -O0 -D_REENTRANT -DWITH_IPV6 -DWITH_RMAC_SUPPORT -I /usr/local/include -I../ +CFLAGS = -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wall -fPIC -g -O0 -D_REENTRANT -DWITH_IPV6 -DWITH_RMAC_SUPPORT -I /usr/local/include -I../ CFLAGS += $(GNUTLS_CFLAGS) \ -DWITH_CW_LOG \ diff --git a/src/cw/conn_prepare_image_data_request.c b/src/cw/conn_prepare_image_data_request.c index 7259b3ab..0b6d88de 100644 --- a/src/cw/conn_prepare_image_data_request.c +++ b/src/cw/conn_prepare_image_data_request.c @@ -19,7 +19,7 @@ #include "capwap.h" #include "lwapp.h" - +/* int conn_prepare_image_data_request(struct conn *conn, struct cwimage_data *data, struct image_identifier *id) @@ -33,8 +33,8 @@ 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) { + // for Cisco APs send image data in "LWAPP format" + 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,9 +44,9 @@ int conn_prepare_image_data_request(struct conn *conn, struct cwimage_data *data NULL); return 0; } -*/ - /* standard capwap operation */ + + // standard capwap operation cwmsg_vaddelem(cwmsg,CW_ELEM_IMAGE_DATA, &data->type, sizeof(data->type), @@ -57,3 +57,5 @@ int conn_prepare_image_data_request(struct conn *conn, struct cwimage_data *data return 0; } + +*/ diff --git a/src/cw/cw_addelem_vendor_specific_payload.c b/src/cw/cw_addelem_vendor_specific_payload.c deleted file mode 100644 index a6ea93e8..00000000 --- a/src/cw/cw_addelem_vendor_specific_payload.c +++ /dev/null @@ -1,48 +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_addelem_vendor_specific_payload - */ - -#include "capwap.h" - -/** - * Add a Vendor Specific Payload message element to a buffer - * @param dst destination buffer - * @param vendor_id the vendor id - * @param type vendor specific message type - * @data pointer to data the will be put - * @len length of data - */ -int cw_addelem_vendor_specific_payload(uint8_t * dst, uint32_t vendor_id, - uint16_t type, uint8_t * data, uint16_t len) -{ - uint8_t *d = dst + 4; - - d += cw_put_dword(d, vendor_id); - d += cw_put_word(d, type); - d += cw_put_data(d, data, len); - - int l = d - dst; - cw_put_elem_hdr(dst, CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD, l - 4); - return l; - -} diff --git a/src/cw/cw_in_wtp_descriptor.c b/src/cw/cw_in_wtp_descriptor.c deleted file mode 100644 index 11ad24b7..00000000 --- a/src/cw/cw_in_wtp_descriptor.c +++ /dev/null @@ -1,254 +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 "capwap_items.h" - - -#include "cw_util.h" -#include "dbg.h" - -#include "sock.h" - - -static int _cw_read_wtp_descriptor_versions(mbag_t mbag, uint8_t * data, - int len, int silent) -{ - int i = 0; - while (i len) { - if (!silent) - cw_dbg(DBG_ELEM_ERR, - "WTP descriptor subelement to long, length=%d>%d", - i + 8, len); - return 0; - } - - uint32_t vendor_id = cw_get_dword(data + i); - uint32_t val = cw_get_dword(data + i + 4); - - int subtype = (val >> 16) & 0xffff; - int sublen = val & 0xffff; - i += 8; - - if (sublen + i > len) { - if (!silent) - cw_dbg(DBG_ELEM_ERR, - "WTP Descriptor sub-element too long, length = %d", - sublen); - return 0; - } - - if (!silent) { - char *dmp; - char *dmpmem = NULL; - if (cw_dbg_is_level(DBG_SUBELEM_DMP)) { - dmpmem = cw_dbg_mkdmp(data + i, sublen); - dmp = dmpmem; - } else - dmp = ""; - cw_dbg(DBG_SUBELEM, "WTP Descriptor subtype=%d,len=%d%s", subtype, - sublen, dmp); - - if (dmpmem) - free(dmpmem); - } - - switch (subtype) { - case CW_SUBELEM_WTP_HARDWARE_VERSION: -/* - mbag_set_dword(mbag, - CW_ITEM_WTP_HARDWARE_VENDOR, - vendor_id); - mbag_set_bstrn(mbag, - CW_ITEM_WTP_HARDWARE_VERSION, - data + i, sublen); -*/ - - mbag_set_bstrv(mbag, - CW_ITEM_WTP_HARDWARE_VERSION, - vendor_id, data + i, sublen); - - break; - case CW_SUBELEM_WTP_SOFTWARE_VERSION: - - mbag_set_bstrv(mbag, - CW_ITEM_WTP_SOFTWARE_VERSION, - vendor_id, data + i, sublen); -/* - mbag_set_dword(mbag, - CW_ITEM_WTP_SOFTWARE_VENDOR, - vendor_id); - mbag_set_bstrn(mbag, - CW_ITEM_WTP_SOFTWARE_VERSION, - data + i, sublen); - -*/ - break; - case CW_SUBELEM_WTP_BOOTLOADER_VERSION: - - mbag_set_bstrv(mbag, - CW_ITEM_WTP_BOOTLOADER_VERSION, - vendor_id, data + i, sublen); - -/* - mbag_set_dword(mbag, - CW_ITEM_WTP_BOOTLOADER_VENDOR, - vendor_id); - mbag_set_bstrn(mbag, - CW_ITEM_WTP_BOOTLOADER_VERSION, - data + i, sublen); -*/ - break; - default: - if (!silent) - cw_dbg(DBG_ELEM_ERR, - "Unknown WTP descriptor subelement, type = %d", - subtype); - break; - } - i += sublen; - - } //while (i < len); - - return 1; - -} - -static int cw_read_wtp_descriptor(mbag_t mbag, struct conn *conn, - struct cw_action_in *a, uint8_t * data, int len, - int silent) -{ - - - mbag_set_byte(mbag, CW_ITEM_WTP_MAX_RADIOS, cw_get_byte(data)); - mbag_set_byte(mbag, CW_ITEM_WTP_RADIOS_IN_USE, - cw_get_byte(data + 1)); - - - /* Get number of encryption elements */ - int ncrypt = cw_get_byte(data + 2); - if (ncrypt == 0) { - if (conn->strict_capwap) { - if (!silent) - cw_dbg(DBG_ELEM_ERR, - "Bad WTP Descriptor, number of encryption elements is 0."); - return 0; - } - if (!silent) - cw_dbg(DBG_RFC, - "Non standard conform WTP Descriptor, number of encryptoin elements is 0."); - } - - int pos = 3; - int i; - for (i = 0; i < ncrypt; i++) { - // It's a dummy for now - pos += 3; - } - - return _cw_read_wtp_descriptor_versions(mbag, data + pos, len - pos, silent); - -} - - - -/** - * Read WTP Descriptor in Cisco-Style (Draft 7) - */ - -static int cw_read_cisco_wtp_descriptor(mbag_t mbag, struct conn *conn, - struct cw_action_in *a, uint8_t * data, int len, - int silent) -{ - - mbag_set_byte(mbag, CW_ITEM_WTP_MAX_RADIOS, cw_get_byte(data)); - mbag_set_byte(mbag, CW_ITEM_WTP_RADIOS_IN_USE, - cw_get_byte(data + 1)); - - - int pos = 2; - - /* Encryption element, for now dumy XXX */ - cw_get_word(data + pos + 2); - pos += 2; - - return _cw_read_wtp_descriptor_versions(mbag, data + pos, len - pos, silent); - -} - - - - - - - - -int cw_in_wtp_descriptor(struct conn *conn, struct cw_action_in *a, uint8_t * data, - int len, struct sockaddr *from) -{ - mbag_t mbag = conn->incomming; - - return cw_read_wtp_descriptor(mbag, conn, a, data, len, 0); -} - - - -int cw_in_cipwap_wtp_descriptor(struct conn *conn, struct cw_action_in *a, uint8_t * data, - int len, struct sockaddr *from) -{ - mbag_t mbag = conn->incomming; - - switch (conn->capwap_mode) { - case CW_MODE_CISCO: - return cw_read_cisco_wtp_descriptor(mbag, conn, a, data, len, - 0); - case CW_MODE_CIPWAP: - { - /* try to get the right WTP Descriptor */ - int rc; - rc = cw_read_wtp_descriptor(mbag, conn, a, data, len, - 1); - - if (rc) { - return cw_read_wtp_descriptor(mbag, conn, a, - data, len, 0); - } - - rc = cw_read_cisco_wtp_descriptor(mbag, conn, a, - data, len, 0); - if (rc) { - return cw_read_cisco_wtp_descriptor(mbag, - conn, a, data, - len, 0); - } - - return cw_read_wtp_descriptor(mbag, conn, a, data, - len, 0); - - } - default: - return cw_read_wtp_descriptor(mbag, conn, a, data, len, 0); - - - } - - return 0; -} diff --git a/src/cw/cw_read_wtp_descriptor.c b/src/cw/cw_read_wtp_descriptor.c deleted file mode 100644 index 152c938a..00000000 --- a/src/cw/cw_read_wtp_descriptor.c +++ /dev/null @@ -1,48 +0,0 @@ -#include "cw.h" - -#include "capwap.h" -#include "capwap_items.h" -#include "dbg.h" - - -int cw_read_wtp_descriptor(mbag_t mbag, struct conn *conn, - struct cw_action_in *a, uint8_t * data, int len,struct cw_descriptor_subelem_def *allowed) -{ - - mbag_set_byte(mbag, CW_ITEM_WTP_MAX_RADIOS, cw_get_byte(data)); - mbag_set_byte(mbag, CW_ITEM_WTP_RADIOS_IN_USE, cw_get_byte(data + 1)); - - - /* Get number of encryption elements */ - int ncrypt = cw_get_byte(data + 2); - if (ncrypt == 0) { - if (conn->strict_capwap) { - cw_dbg(DBG_ELEM_ERR, - "Bad WTP Descriptor, number of encryption elements is 0."); - return 0; - } - cw_dbg(DBG_RFC, - "Non standard conform WTP Descriptor, number of encryptoin elements is 0."); - } - - int pos = 3; - int i; - for (i = 0; i < ncrypt; i++) { - // It's a dummy for now - pos += 3; - } - - static struct cw_descriptor_subelem_def allowed_default[] = { - {0,CW_SUBELEM_WTP_HARDWARE_VERSION, CW_ITEM_WTP_HARDWARE_VERSION, 1024,1}, - {0,CW_SUBELEM_WTP_SOFTWARE_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024,1}, - {0,CW_SUBELEM_WTP_BOOTLOADER_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024,1}, - {0,CW_SUBELEM_WTP_OTHERSOFTWARE_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024,0}, - {0,0, NULL, 0,0} - }; - - if (!allowed) { - allowed=allowed_default; - } - - return cw_read_descriptor_subelems(conn->incomming, data + pos, len - pos, allowed); -} diff --git a/src/cw/hdr_print.c b/src/cw/hdr_print.c index d269cf69..cdb09a13 100644 --- a/src/cw/hdr_print.c +++ b/src/cw/hdr_print.c @@ -23,7 +23,7 @@ #include "capwap.h" #include "sock.h" - +/* int hdr_print(char *str, uint8_t *packet, int len) { @@ -119,3 +119,5 @@ int hdr_print(char *str, uint8_t *packet, int len) return s-str; } + +*/ diff --git a/src/cw/lw_readelem_wtp_board_data.c b/src/cw/lw_readelem_wtp_board_data.c deleted file mode 100644 index 133a3409..00000000 --- a/src/cw/lw_readelem_wtp_board_data.c +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @file - * @brief Implementation of lw_readelem_wtp_board_data - */ - -#include - -#include "log.h" -//#include "wtpinfo.h" - -#include "lwapp.h" - - -/** - * Read LWAPP board data element - * @param wtpinfo results are stored here - * @param type type of msg element (must be LWMSGELEM_WTP_BOARD_DATA) - * @param msgelem msg element data - * @param len length of msg element - * @return 0 if msg is not wtp board data\n - * 1 board data successful read - */ -int lw_readelem_wtp_board_data(struct wtpinfo *wtpinfo, int type, uint8_t *msgelem, int len) -{ - if (type != LW_ELEM_WTP_BOARD_DATA) - return 0; - - if ( len != 46 ) { -// cw_dbg(DBG_MSG_ERR,"LWAPP msg size wrong. (WTP BOARD DATA) must be 46"); - return -1; - } - -// uint16_t card_id = htonl( * ( (uint16_t*)(msgelem) ) ); -// uint16_t card_rev = htonl( * ( (uint16_t*)(msgelem +2 ) ) ); - - return 1; -} - - diff --git a/src/cw/sock_get_primary_if.c b/src/cw/sock_get_primary_if.c index 5edeff2f..d46502f0 100644 --- a/src/cw/sock_get_primary_if.c +++ b/src/cw/sock_get_primary_if.c @@ -24,7 +24,7 @@ #include "sock.h" -/* + char * sock_get_primary_if(int family) { struct ifaddrs *ifap,*ifa; @@ -53,4 +53,3 @@ char * sock_get_primary_if(int family) return r; } -*/