Merge branch 'ansi' into actubent
FossilOrigin-Name: 13109aed4a54c27b25176c984051f70a934263dbd30dd80610a54bcd420f7c94
This commit is contained in:
commit
6de685e665
@ -19,7 +19,32 @@ endif
|
|||||||
|
|
||||||
|
|
||||||
ifndef ARCH
|
ifndef ARCH
|
||||||
ARCH = $(shell $(CC) -dumpmachine)
|
ARCH = $(shell uname -m)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
ifeq ($(CC),clang)
|
||||||
|
LDFLAGS += -g -L/usr/local/lib
|
||||||
|
CFLAGS += -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -fPIC -g -O0 -D_REENTRANT -I /usr/local/include -I../
|
||||||
|
LD = gcc
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CC),gcc)
|
||||||
|
LDFLAGS += -g -L/usr/local/lib
|
||||||
|
CFLAGS += -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -fPIC -g -O0 -D_REENTRANT -I /usr/local/include -I../
|
||||||
|
LD = gcc
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CC),tcc)
|
||||||
|
LDFLAGS += -g -L/usr/local/lib
|
||||||
|
CFLAGS += -Wall -Wunusupported -Wimplicit-function-declaration -I /usr/local/include -I../
|
||||||
|
LD = tcc
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CFLAGS += -DWITH_IPV6 -DWITH_RMAC_SUPPORT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
include ../Macros.mak
|
|
||||||
include ../Config.mak
|
include ../Config.mak
|
||||||
include ../ACConfig.mak
|
include ../ACConfig.mak
|
||||||
-include ../Config.local.mak
|
-include ../Config.local.mak
|
||||||
|
-include ../ACConfig.local.mak
|
||||||
|
include ../Macros.mak
|
||||||
|
|
||||||
|
|
||||||
LIBARCHDIR=../../lib/$(ARCH)
|
LIBARCHDIR=../../lib/$(ARCH)
|
||||||
|
|
||||||
LDFLAGS+=-g -D_REENTRANT -L/usr/local/lib -L$(LIBARCHDIR)
|
LDFLAGS+=-g -L/usr/local/lib -L$(LIBARCHDIR)
|
||||||
CFLAGS += -W -g -O0 -D_REENTRANT -DIPV6 -I/usr/local/include -I../ -DSYS_ARCH=\"${ARCH}\"
|
CFLAGS += -W -g -O0 -D_REENTRANT -DIPV6 -I/usr/local/include -I../ -DSYS_ARCH=\"${ARCH}\"
|
||||||
|
|
||||||
|
|
||||||
@ -80,7 +81,7 @@ all: $(AC_NAME)
|
|||||||
|
|
||||||
$(AC_NAME): $(AC_OBJS)
|
$(AC_NAME): $(AC_OBJS)
|
||||||
# $(CC) $(AC_OBJS) ../mod/modload_ac.o -o $(AC_NAME) $(LDFLAGS) $(LIBS)
|
# $(CC) $(AC_OBJS) ../mod/modload_ac.o -o $(AC_NAME) $(LDFLAGS) $(LIBS)
|
||||||
$(CC) $(AC_OBJS) -o $(AC_NAME) $(LDFLAGS) $(LIBS)
|
$(LD) $(AC_OBJS) -o $(AC_NAME) $(LDFLAGS) $(LIBS)
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@ -90,6 +91,6 @@ clean_deps:
|
|||||||
$(AC_DEPS)
|
$(AC_DEPS)
|
||||||
|
|
||||||
deps: $(AC_SRC)
|
deps: $(AC_SRC)
|
||||||
$(CC) -MD -E $(AC_SRCS) $(CFLAGS) >/dev/null
|
$(LD) -MD -E $(AC_SRCS) $(CFLAGS) >/dev/null
|
||||||
|
|
||||||
-include $(AC_DEPS)
|
-include $(AC_DEPS)
|
||||||
|
310
src/cw/Makefile
310
src/cw/Makefile
@ -1,6 +1,6 @@
|
|||||||
include ../Macros.mak
|
|
||||||
include ../CWConfig.mak
|
include ../CWConfig.mak
|
||||||
-include ../Config.local.mak
|
-include ../Config.local.mak
|
||||||
|
include ../Macros.mak
|
||||||
|
|
||||||
|
|
||||||
LIBDIR := ../../lib
|
LIBDIR := ../../lib
|
||||||
@ -10,192 +10,6 @@ OBJDIR := ../../obj/cw/$(ARCH)
|
|||||||
SNAME := $(LIBARCHDIR)/libcw.a
|
SNAME := $(LIBARCHDIR)/libcw.a
|
||||||
DNAME := $(LIBARCHDIR)/libcw.so
|
DNAME := $(LIBARCHDIR)/libcw.so
|
||||||
|
|
||||||
LDFLAGS+=-g -D_REENTRANT -L/usr/local/lib
|
|
||||||
|
|
||||||
|
|
||||||
SOCKOBJS=\
|
|
||||||
sock_create.o\
|
|
||||||
sock_copyaddr.o\
|
|
||||||
sock_strtoaddr.o\
|
|
||||||
sock_cmpaddr.o\
|
|
||||||
sock_addrlen.o \
|
|
||||||
sock_mwait.o\
|
|
||||||
sock_addrtostr.o \
|
|
||||||
sock_setport.o \
|
|
||||||
sock_getport.o \
|
|
||||||
sock_getifaddr.o \
|
|
||||||
sock_getifhwaddr.o \
|
|
||||||
sock_hwaddrtostr.o \
|
|
||||||
sock_set_recvtimeout.o \
|
|
||||||
sock_getbroadcastaddr.o \
|
|
||||||
sock_addrinit.o \
|
|
||||||
sock_set_dontfrag.o \
|
|
||||||
sock_get_primary_if.o \
|
|
||||||
sock_receive.o \
|
|
||||||
sock_getifinfo.o \
|
|
||||||
|
|
||||||
|
|
||||||
LOGOBJS=log.o \
|
|
||||||
log_syslog.o \
|
|
||||||
log_file.o \
|
|
||||||
dbg_strings.o\
|
|
||||||
dbg.o \
|
|
||||||
|
|
||||||
|
|
||||||
WTPINFOOBJS =\
|
|
||||||
#wtpinfo_print.o
|
|
||||||
#wtpinfo_set_location.o \
|
|
||||||
wtpinfo_lwreadelem_wtp_descriptor.o \
|
|
||||||
|
|
||||||
UTILOBJS= \
|
|
||||||
cw_setstr.o \
|
|
||||||
cw_is_printable.o \
|
|
||||||
cw_rand.o \
|
|
||||||
stravltree.o \
|
|
||||||
intavltree.o \
|
|
||||||
cw_util.o \
|
|
||||||
send.o \
|
|
||||||
cw_read_wtp_descriptor.o \
|
|
||||||
cw_read_wtp_descriptor_7.o \
|
|
||||||
cw_read_wtp_descriptor_versions.o \
|
|
||||||
cw_read_descriptor_subelems.o \
|
|
||||||
cw_out_80211_supported_rates.o
|
|
||||||
|
|
||||||
MAVLOBJS= \
|
|
||||||
mavl_del.o \
|
|
||||||
mavl_add.o \
|
|
||||||
mavl_create.o\
|
|
||||||
mavl_get.o\
|
|
||||||
mavl_del_all.o\
|
|
||||||
mavliter_seek.o \
|
|
||||||
mavliter_next.o \
|
|
||||||
mavl_get_node.o \
|
|
||||||
mavl_foreach.o \
|
|
||||||
mavl_foreach_lr.o \
|
|
||||||
mavl_merge.o \
|
|
||||||
mavl_create_conststr.o \
|
|
||||||
mlist.o \
|
|
||||||
cw_load_file.o \
|
|
||||||
cw_save_file.o \
|
|
||||||
cw_filename.o \
|
|
||||||
message_set.o
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FORMATOBJS = \
|
|
||||||
format_is_utf8.o \
|
|
||||||
format_dot11_fc.o \
|
|
||||||
|
|
||||||
# lw_readelem_vendor_specific.o \
|
|
||||||
|
|
||||||
|
|
||||||
# LWAPP objs
|
|
||||||
LWAPPOBJS = \
|
|
||||||
lw_checksum.o \
|
|
||||||
lw_put_ac_descriptor.o \
|
|
||||||
lw_put_cisco_path_mtu.o \
|
|
||||||
lw_elem_id_to_str.o \
|
|
||||||
lw_msg_id_to_str.o \
|
|
||||||
lw_cisco_id_to_str.o \
|
|
||||||
lw_put_sockaddr.o \
|
|
||||||
lw_put_image_data.o \
|
|
||||||
lw_in_vendor_specific.o
|
|
||||||
|
|
||||||
|
|
||||||
#lw_put_80211_wtp_wlan_radio_configuration.o \
|
|
||||||
# lw_readelem_wtp_name.o \
|
|
||||||
lw_readelem_wtp_board_data.o \
|
|
||||||
cw_log_debug.o \
|
|
||||||
lw_vendor_id_to_str.o \
|
|
||||||
|
|
||||||
|
|
||||||
# LWAPP cisco vendor specific objs
|
|
||||||
#//#LWAPPCISCOOBJS = \
|
|
||||||
# lw_addelem.o
|
|
||||||
|
|
||||||
|
|
||||||
# cw_tohex.o\
|
|
||||||
#capwap_parse_ctrlhdr.o \
|
|
||||||
|
|
||||||
# hdr_print.o \
|
|
||||||
|
|
||||||
CAPWAPOBJS= \
|
|
||||||
cw_iplist.o \
|
|
||||||
aciplist.o \
|
|
||||||
lwmsg_init.o \
|
|
||||||
cw_cisco_id_to_str.o\
|
|
||||||
cw_strlist_get_str.o \
|
|
||||||
cw_strlist_get_id.o \
|
|
||||||
capwap_strings_msg.o \
|
|
||||||
capwap_strings_elem80211.o\
|
|
||||||
acpriolist.o\
|
|
||||||
capwap_strings_state.o \
|
|
||||||
capwap_strings_vendor.o \
|
|
||||||
capwap_strings_elem.o \
|
|
||||||
cw_in_vendor_specific_payload.o \
|
|
||||||
cw_in_mtu_discovery_padding.o\
|
|
||||||
cw_in_wtp_board_data.o \
|
|
||||||
cw_in_check_disc_req.o \
|
|
||||||
cw_in_check_chng_state_evnt_req.o\
|
|
||||||
cw_in_check_disc_resp.o\
|
|
||||||
cw_in_check_cfg_update_req.o\
|
|
||||||
cw_in_check_join_req.o \
|
|
||||||
cw_in_check_cipwap_join_req.o \
|
|
||||||
cw_in_check_join_resp.o \
|
|
||||||
cw_in_check_img_data_req_ac.o \
|
|
||||||
cw_in_check_img_data_req_wtp.o \
|
|
||||||
cw_in_check_img_data_resp.o \
|
|
||||||
cw_in_check_generic_resp.o \
|
|
||||||
cw_in_check_generic_req.o \
|
|
||||||
cw_in_80211_mac_operation.o \
|
|
||||||
cw_read_80211_mac_operation.o \
|
|
||||||
cw_out_generic.o \
|
|
||||||
cw_out_wtp_descriptor.o \
|
|
||||||
cw_out_wtp_reboot_statistics.o \
|
|
||||||
cw_in_wtp_reboot_statistics.o\
|
|
||||||
cw_in_cisco_image_identifier.o\
|
|
||||||
cw_put_radio_operational_states.o \
|
|
||||||
cw_put_ac_status.o \
|
|
||||||
cw_in_ac_descriptor.o\
|
|
||||||
cw_read_ac_descriptor.o\
|
|
||||||
cw_out_capwap_local_ip_address.o\
|
|
||||||
cw_out_wtp_ip_address.o\
|
|
||||||
cw_out_capwap_control_ip_addr_list.o \
|
|
||||||
cw_in_capwap_control_ip_address.o\
|
|
||||||
cw_in_capwap_local_ipv4_address.o \
|
|
||||||
cw_in_capwap_local_ipv6_address.o \
|
|
||||||
cw_in_radio_administrative_state.o \
|
|
||||||
cw_in_radio_administrative_state_wtp.o \
|
|
||||||
cw_radio_set_admin_state.o \
|
|
||||||
cw_put_elem_radio_administrative_state.o\
|
|
||||||
cw_put_elem_radio_operational_state.o \
|
|
||||||
cw_out_radio_administrative_states.o\
|
|
||||||
strheap.o \
|
|
||||||
cw_check_missing_mand.o \
|
|
||||||
md5sum.o \
|
|
||||||
format.o \
|
|
||||||
# action_sources.o \
|
|
||||||
# cw_in_cisco_add_wlan.o
|
|
||||||
# cw_in_radio_operational_state.o\
|
|
||||||
|
|
||||||
DOT11OBJS = \
|
|
||||||
dot11.o \
|
|
||||||
dot11_beacon.o
|
|
||||||
|
|
||||||
# cw_out_ac_descriptor.o \
|
|
||||||
|
|
||||||
|
|
||||||
CAPWAP80211OBJS=\
|
|
||||||
capwap80211_items.o\
|
|
||||||
capwap80211_type_rateset.o \
|
|
||||||
|
|
||||||
# cw_out_radio_operational_states.o\
|
|
||||||
# cw_out_radio_operational_states_7.o\
|
|
||||||
|
|
||||||
#
|
|
||||||
# SSL objects
|
|
||||||
#
|
|
||||||
|
|
||||||
LIBS=
|
LIBS=
|
||||||
|
|
||||||
ifeq ($(WITH_OPENSSL),1)
|
ifeq ($(WITH_OPENSSL),1)
|
||||||
@ -221,122 +35,19 @@ DTLSOBJS+= dtls_gnutls.o \
|
|||||||
LIBS+=-lgnutls
|
LIBS+=-lgnutls
|
||||||
endif
|
endif
|
||||||
|
|
||||||
DTLSOBJS+=dtls_bio.o
|
|
||||||
|
|
||||||
CONNOBJS= conn_create.o \
|
|
||||||
conn_process_packet.o \
|
|
||||||
conn_q_add_packet.o \
|
|
||||||
conn_q_get_packet.o \
|
|
||||||
conn_q_recv_packet.o \
|
|
||||||
conn_recv_packet.o \
|
|
||||||
conn_destroy.o \
|
|
||||||
connlist.o \
|
|
||||||
conn_create_noq.o \
|
|
||||||
conn_init.o \
|
|
||||||
conn_send_packet.o \
|
|
||||||
conn_send_data_packet.o \
|
|
||||||
netconn.o \
|
|
||||||
cw_init_data_keep_alive_msg.o \
|
|
||||||
conn_clear_upd.o
|
|
||||||
|
|
||||||
|
|
||||||
# conn_send_msg.o
|
|
||||||
#conn_get_message.o \
|
|
||||||
# conn_send_response.o \
|
|
||||||
# cw_prepare_configuration_status_request.o \
|
|
||||||
# cw_prepare_change_state_event_request.o \
|
|
||||||
conn_prepare_configuration_update_request.o \
|
|
||||||
|
|
||||||
|
|
||||||
#bstr_to_str.o \
|
|
||||||
|
|
||||||
BSTROBJS= bstr_create.o \
|
|
||||||
bstr_create_from_cfgstr.o \
|
|
||||||
bstr16_create_from_cfgstr.o \
|
|
||||||
bstr_replace.o \
|
|
||||||
bstr16cfgstr.o \
|
|
||||||
bstr16_create_from_str.o \
|
|
||||||
bstr_create_from_str.o \
|
|
||||||
bstrv_create_from_str.o
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FRAGOBJS=fragman.o
|
|
||||||
|
|
||||||
CWACTION=action.o \
|
|
||||||
cw_in_generic.o \
|
|
||||||
cw_in_generic2.o \
|
|
||||||
cw_out_wtp_board_data.o \
|
|
||||||
cw_out_ac_name_with_priority.o \
|
|
||||||
cw_in_ac_name_with_priority.o \
|
|
||||||
cw_out_image_data.o \
|
|
||||||
cipwap_strings_elem.o \
|
|
||||||
capwap_strings_result.o\
|
|
||||||
capwap_strings_board.o \
|
|
||||||
cw_put_msg.o \
|
|
||||||
cw_put_mbag_item.o \
|
|
||||||
cw_put_local_ip_address.o \
|
|
||||||
capwap_action_helpers.o \
|
|
||||||
cw_put_image_data.o \
|
|
||||||
cisco.o \
|
|
||||||
radio.o \
|
|
||||||
cw_in_radio_generic.o\
|
|
||||||
cw_out_radio_generic.o \
|
|
||||||
cw_out_radio_info.o \
|
|
||||||
capwap_items.o \
|
|
||||||
item.o \
|
|
||||||
mod.o
|
|
||||||
|
|
||||||
# cw_process_msg.o \
|
|
||||||
# item_strings.o \
|
|
||||||
#
|
|
||||||
|
|
||||||
MBAGOBJS = \
|
|
||||||
mbag.o\
|
|
||||||
mbag_type_word.o\
|
|
||||||
mbag_type_byte.o\
|
|
||||||
mbag_type_vendorstr.o\
|
|
||||||
mbag_type_sockaddr.o\
|
|
||||||
mbag_type_dword.o\
|
|
||||||
mbag_type_bstr16.o\
|
|
||||||
mbag_type_mbag.o\
|
|
||||||
mbag_set_from_buf.o\
|
|
||||||
mbag_type_str.o \
|
|
||||||
mbag_type_ptr.o \
|
|
||||||
mbag_type_data.o \
|
|
||||||
mbag_get_upd.o
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
OBJS=$(CONNOBJS) $(FRAGOBJS) $(SOCKOBJS) $(CAPWAPOBJS) $(WTPINFOOBJS) \
|
|
||||||
$(LOGOBJS) $(UTILOBJS) $(DTLSOBJS) $(BSTROBJS) \
|
|
||||||
$(LWAPPOBJS) \
|
|
||||||
$(LWAPPCISCOOBJS) \
|
|
||||||
$(CWACTION) \
|
|
||||||
$(MAVLOBJS) \
|
|
||||||
$(FORMATOBJS) \
|
|
||||||
$(DOT11OBJS) \
|
|
||||||
$(MBAGOBJS) \
|
|
||||||
$(CAPWAP80211OBJS)
|
|
||||||
|
|
||||||
O:=$(OBJS);
|
|
||||||
|
|
||||||
|
SRC=$(wildcard *.c)
|
||||||
|
OBJS=$(patsubst %.c,%.o,$(SRC))
|
||||||
OBJS:=$(patsubst %.o,$(OBJDIR)/%.o,$(OBJS))
|
OBJS:=$(patsubst %.o,$(OBJDIR)/%.o,$(OBJS))
|
||||||
|
|
||||||
|
|
||||||
all: $(SNAME) $(DNAME)
|
all: $(SNAME) $(DNAME)
|
||||||
|
|
||||||
|
|
||||||
CFLAGS = -Wall -fPIC -g -O0 -D_REENTRANT -DWITH_IPV6 -DWITH_RMAC_SUPPORT -I /usr/local/include -I../
|
|
||||||
|
|
||||||
CFLAGS += $(GNUTLS_CFLAGS) \
|
CFLAGS += $(GNUTLS_CFLAGS) \
|
||||||
-DWITH_CW_LOG \
|
-DWITH_CW_LOG \
|
||||||
-DWITH_CW_LOG_DEBUG \
|
-DWITH_CW_LOG_DEBUG \
|
||||||
-DWITH_DTLS \
|
-DWITH_DTLS
|
||||||
$(XINCLUDE)\
|
|
||||||
-I $(OPENSSLINC)\
|
|
||||||
-Werror
|
|
||||||
|
|
||||||
|
|
||||||
$(OBJDIR)/%.o:%.c
|
$(OBJDIR)/%.o:%.c
|
||||||
@ -344,16 +55,15 @@ $(OBJDIR)/%.o:%.c
|
|||||||
@echo " $(CC) "$<
|
@echo " $(CC) "$<
|
||||||
@$(CC) -c $(CFLAGS) $< -o $@
|
@$(CC) -c $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
$(SNAME) : $(OBJS) $(MODOBJS)
|
$(SNAME) : $(OBJS)
|
||||||
@mkdir -p $(LIBARCHDIR)
|
@mkdir -p $(LIBARCHDIR)
|
||||||
@echo " AR $(SNAME)"
|
@echo " $(AR) $(SNAME)"
|
||||||
@$(AR) rcs $(SNAME) $(OBJS) $(MODOBJS)
|
@$(AR) rcs $(SNAME) $(OBJS)
|
||||||
|
|
||||||
$(DNAME) : $(OBJS) $(MODOBJS)
|
$(DNAME) : $(OBJS)
|
||||||
@mkdir -p $(LIBARCHDIR)
|
@mkdir -p $(LIBARCHDIR)
|
||||||
@echo " $(CC) $(DNAME)"
|
@echo " $(LD) $(DNAME)"
|
||||||
@$(CC) $(LDFLAGS) -shared -o $(DNAME) $(OBJS) $(MODOBJS) $(LIBS)
|
@$(LD) $(LDFLAGS) -shared -o $(DNAME) $(OBJS) $(LIBS)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SRCS = $(OBJS:.o=.c)
|
SRCS = $(OBJS:.o=.c)
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,66 +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_seek
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "avltree.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set an AVL Iterator to a specific position.
|
|
||||||
* @param i AVL Iterator
|
|
||||||
* @param d element to search for
|
|
||||||
* @return element found or NULL if not found
|
|
||||||
*/
|
|
||||||
void * avliter_seek(avliter_t *i,void *d)
|
|
||||||
{
|
|
||||||
if (!i->root)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
i->cur=i->root;
|
|
||||||
i->stack_ptr=0;
|
|
||||||
|
|
||||||
int rc;
|
|
||||||
while(i->cur) {
|
|
||||||
|
|
||||||
rc = i->cmp(d,i->cur->data);
|
|
||||||
if (rc==0){
|
|
||||||
i->stack[i->stack_ptr++]=i->cur->right;
|
|
||||||
i->stack[i->stack_ptr++]=i->cur;
|
|
||||||
return avliter_next(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rc<0) {
|
|
||||||
i->stack[i->stack_ptr++]=i->cur->right;
|
|
||||||
i->stack[i->stack_ptr++]=i->cur;
|
|
||||||
|
|
||||||
i->cur=i->cur->left;
|
|
||||||
|
|
||||||
}
|
|
||||||
if (rc>0) {
|
|
||||||
|
|
||||||
i->cur=i->cur->right;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 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 <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);
|
|
||||||
}
|
|
||||||
|
|
@ -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -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);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -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)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
@ -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
@ -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)
|
extern 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t * bstr16_create_from_str(const char *s);
|
uint8_t * bstr16_create_from_str(const char *s);
|
||||||
extern uint8_t * bstr16_create_from_cfgstr(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))
|
(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_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
|
#endif
|
||||||
|
|
||||||
|
13
src/cw/bstr16_create.c
Normal file
13
src/cw/bstr16_create.c
Normal 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
17
src/cw/bstrv_create.c
Normal 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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -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 */
|
|
||||||
|
|
||||||
|
|
@ -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, CAPWAP_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;
|
|
||||||
}
|
|
||||||
|
|
@ -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, CAPWAP_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;
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
|||||||
struct cw_str capwap_strings_item[] = {
|
|
||||||
|
|
||||||
{CW_ITEM_AC_DESCRIPTOR, "AC Descriptor"},
|
|
||||||
{CW_ITEM_AC_IPV4_LIST, "AC IPv4 List"},
|
|
||||||
{CW_ITEM_WTP_DESCRIPTOR,"WTP Descriptor"},
|
|
||||||
|
|
||||||
{CW_STR_STOP,"Unknown"}
|
|
||||||
|
|
||||||
}
|
|
@ -1,35 +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 "wtpinfo.h"
|
|
||||||
#include "conn.h"
|
|
||||||
#include "log.h"
|
|
||||||
#include "sock.h"
|
|
||||||
|
|
||||||
void conn_detect_capwap(struct conn * conn, struct wtpinfo * wtpinfo)
|
|
||||||
{
|
|
||||||
if (wtpinfo->software_vendor_id == CW_VENDOR_ID_CISCO){
|
|
||||||
cw_dbg(DBG_CW_INFO,"Setting capwap mode *Cisco* on connection %s",sock_addr2str(&conn->addr));
|
|
||||||
conn->capwap_mode = CWMODE_CISCO;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
conn->capwap_mode = CWMODE_STD;
|
|
||||||
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
|
|
||||||
#include "capwap.h"
|
|
||||||
#include "cw_log.h"
|
|
||||||
#include "sock.h"
|
|
||||||
#include "cw_util.h"
|
|
||||||
|
|
||||||
|
|
||||||
struct cwrmsg * conn_get_response(struct conn * conn)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
struct cwmsg * cwmsg = &conn->req_msg;
|
|
||||||
|
|
||||||
int type = cwmsg->type+1;
|
|
||||||
|
|
||||||
struct cwrmsg * cwrmsg;
|
|
||||||
|
|
||||||
int i;
|
|
||||||
for (i=0; i<conn->max_retransmit; i++) {
|
|
||||||
|
|
||||||
time_t r_timer = cw_timer_start(conn->retransmit_interval);
|
|
||||||
|
|
||||||
while(!cw_timer_timeout(r_timer)){
|
|
||||||
cwrmsg = conn_get_message(conn);
|
|
||||||
if (cwrmsg){
|
|
||||||
cw_dbg(DBG_MSG,"Received message from %s, type=%d - %s"
|
|
||||||
,sock_addr2str(&conn->addr),cwrmsg->type,cw_msgtostr(cwrmsg->type));
|
|
||||||
if (cwrmsg->type == type){
|
|
||||||
return cwrmsg;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (conn->dtls_error)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
cw_dbg(DBG_MSG_ERR,"Retransmitting message, type=%d,seq=%d",cwmsg->type,cwmsg->seqnum);
|
|
||||||
conn_send_cwmsg(conn,&conn->req_msg);
|
|
||||||
|
|
||||||
}
|
|
||||||
cw_dbg(DBG_MSG_ERR,"Max retransmit's reached, message type=%d,seq=%d",cwmsg->type,cwmsg->seqnum);
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "conn.h"
|
|
||||||
#include "capwap.h"
|
|
||||||
|
|
||||||
|
|
||||||
void conn_prepare_configuration_update_request(struct conn * conn)
|
|
||||||
{
|
|
||||||
struct cwmsg * cwmsg = &conn->req_msg;
|
|
||||||
uint8_t * buffer = conn->req_buffer;
|
|
||||||
cwmsg_init(cwmsg,buffer,CW_MSG_CONFIGURATION_UPDATE_REQUEST,conn_get_next_seqnum(conn),0);
|
|
||||||
}
|
|
@ -19,7 +19,7 @@
|
|||||||
#include "capwap.h"
|
#include "capwap.h"
|
||||||
#include "lwapp.h"
|
#include "lwapp.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
int conn_prepare_image_data_request(struct conn *conn, struct cwimage_data *data,
|
int conn_prepare_image_data_request(struct conn *conn, struct cwimage_data *data,
|
||||||
struct image_identifier *id)
|
struct image_identifier *id)
|
||||||
@ -33,7 +33,7 @@ int conn_prepare_image_data_request(struct conn *conn, struct cwimage_data *data
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* for Cisco APs send image data in "LWAPP format" */
|
// 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;
|
uint8_t type = 3;
|
||||||
uint16_t checksum = htons(lw_checksum(data->data, data->len));
|
uint16_t checksum = htons(lw_checksum(data->data, data->len));
|
||||||
@ -46,7 +46,7 @@ int conn_prepare_image_data_request(struct conn *conn, struct cwimage_data *data
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* standard capwap operation */
|
// standard capwap operation
|
||||||
|
|
||||||
cwmsg_vaddelem(cwmsg,CW_ELEM_IMAGE_DATA,
|
cwmsg_vaddelem(cwmsg,CW_ELEM_IMAGE_DATA,
|
||||||
&data->type, sizeof(data->type),
|
&data->type, sizeof(data->type),
|
||||||
@ -57,3 +57,5 @@ int conn_prepare_image_data_request(struct conn *conn, struct cwimage_data *data
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
#include "conn.h"
|
|
||||||
#include "capwap.h"
|
|
||||||
|
|
||||||
void conn_prepare_request(struct conn * conn, int type)
|
|
||||||
{
|
|
||||||
struct cwmsg * cwmsg = &conn->req_msg;
|
|
||||||
uint8_t * buffer = conn->req_buffer;
|
|
||||||
cwmsg_init(cwmsg,buffer,type,conn_get_next_seqnum(conn),0);
|
|
||||||
cwmsg->capwap_mode=conn->capwap_mode;
|
|
||||||
}
|
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "capwap.h"
|
#include "capwap.h"
|
||||||
#include "cw_util.h"
|
#include "cw_util.h"
|
||||||
#include "cw_log.h"
|
#include "log.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a request message and wait for its response
|
* 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
|
* The message has to be prepared and put to conn->req_msg
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
struct cwrmsg * conn_send_request(struct conn * conn)
|
struct cwrmsg * conn_send_request(struct conn * conn)
|
||||||
{
|
{
|
||||||
int i;
|
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);
|
cw_dbg(DBG_MSG_ERR,"Max retransmit's reached, message type=%d,seq=%d",cwmsg->type,cwmsg->seqnum);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,78 +0,0 @@
|
|||||||
|
|
||||||
#include "conn.h"
|
|
||||||
#include "cw_log.h"
|
|
||||||
#include "sock.h"
|
|
||||||
#include "cw_util.h"
|
|
||||||
|
|
||||||
struct rh_param{
|
|
||||||
struct conn * conn;
|
|
||||||
int *msglist;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static int conn_rh(void *param)
|
|
||||||
{
|
|
||||||
struct rh_param * p = (struct rh_param*)param;
|
|
||||||
int i;
|
|
||||||
int *msglist=p->msglist;
|
|
||||||
|
|
||||||
|
|
||||||
printf("Param %p\n",param);
|
|
||||||
|
|
||||||
|
|
||||||
for (i=0; msglist[i]!=-1; i++){
|
|
||||||
if (msglist[i] == p->conn->cwrmsg.type )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
/* unexpected response here */
|
|
||||||
cw_log(LOG_ERR,"Unexpected message from %s",sock_addr2str(&p->conn->addr));
|
|
||||||
cwsend_unknown_response(p->conn,p->conn->cwrmsg.seqnum,p->conn->cwrmsg.type);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct cwrmsg * conn_wait_for_request(struct conn * conn, int *msglist, time_t timer)
|
|
||||||
{
|
|
||||||
int (*request_handler_save) (void*);
|
|
||||||
void * request_handler_param_save;
|
|
||||||
|
|
||||||
struct rh_param rh_param;
|
|
||||||
|
|
||||||
|
|
||||||
if (msglist){
|
|
||||||
request_handler_save=conn->request_handler;
|
|
||||||
request_handler_param_save=conn->request_handler_param;
|
|
||||||
rh_param.conn=conn;
|
|
||||||
rh_param.msglist=msglist;
|
|
||||||
conn->request_handler=conn_rh;
|
|
||||||
conn->request_handler_param=&rh_param;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct cwrmsg * cwrmsg;
|
|
||||||
while (!cw_timer_timeout(timer)){
|
|
||||||
cwrmsg = conn_wait_for_message(conn,timer);
|
|
||||||
if (!cwrmsg){
|
|
||||||
if (!conn_is_error(conn))
|
|
||||||
continue;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* response message? no action*/
|
|
||||||
if (! (cwrmsg->type & 1) )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* it's a request message */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msglist){
|
|
||||||
conn->request_handler=request_handler_save;
|
|
||||||
conn->request_handler_param=request_handler_param_save;
|
|
||||||
}
|
|
||||||
|
|
||||||
return cwrmsg;
|
|
||||||
}
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
|||||||
#include "cwmsg.h"
|
#include "cwmsg.h"
|
||||||
#include "conn.h"
|
#include "conn.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
uint8_t * cw_addelem(uint8_t * buf,int type, uint8_t *elem, int len)
|
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)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*@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;
|
|
||||||
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
#include "mod.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
|
|
||||||
struct cw_Mod *(*mods_ac[])() = MODS_AC;
|
|
||||||
|
|
||||||
|
|
||||||
struct cw_Mod * cw_get_mod_ac(const char *name)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i=0; mods_ac[i];i++){
|
|
||||||
|
|
||||||
struct cw_Mod * m = mods_ac[i]();
|
|
||||||
if (strcmp(m->name,name)==0)
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
return 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 <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#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 (i + 8 > 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;
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
|
|
||||||
#include "conn.h"
|
|
||||||
#include "capwap.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cw_init(struct conn * conn, uint8_t *buffer, int type, int seqnum, struct radioinfo * radioinfo)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cw_init_response(struct conn * conn, uint8_t *req)
|
|
||||||
{
|
|
||||||
uint8_t *buffer=conn->resp_buffer;
|
|
||||||
int shbytes = cw_get_hdr_msg_offset(req);
|
|
||||||
int dhbytes;
|
|
||||||
memcpy(buffer,req,shbytes);
|
|
||||||
cw_set_hdr_hlen(buffer,2);
|
|
||||||
cw_set_hdr_flags(buffer,CAPWAP_FLAG_HDR_M,1);
|
|
||||||
dhbytes = cw_get_hdr_msg_offset(buffer);
|
|
||||||
|
|
||||||
uint8_t * msgptr = req+shbytes;
|
|
||||||
uint8_t * dmsgptr = buffer+dhbytes;
|
|
||||||
|
|
||||||
cw_set_msg_type(dmsgptr,cw_get_msg_type(msgptr)+1);
|
|
||||||
cw_set_msg_seqnum(dmsgptr,cw_get_msg_seqnum(msgptr));
|
|
||||||
cw_set_msg_flags(dmsgptr,0);
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
#include "capwap.h"
|
|
||||||
#include "capwap_cisco.h"
|
|
||||||
|
|
||||||
#include "itemstore.h"
|
|
||||||
|
|
||||||
int cw_put_cisco_wtp_radio_cfg(uint8_t *dst, int rid, cw_itemstore radio)
|
|
||||||
{
|
|
||||||
|
|
||||||
cw_put_byte(dst,rid);
|
|
||||||
|
|
||||||
cw_put_byte(dst+1,0); //?
|
|
||||||
cw_put_word(dst+2,cw_istore_get_word(radio,CW_RADIO_OCCUPANCY_LIMIT);
|
|
||||||
cw_put_byte(dst+4,cw_istore_get_byte(radio,CW_RADIO_CFP_PERIOD));
|
|
||||||
|
|
||||||
cw_put_word(dst+5,cw_istore_get_word(radio,CW_RADIO_CFP_MAX_DURATION,200);
|
|
||||||
|
|
||||||
/* XXX catch rmac shorter or longer than 6*/
|
|
||||||
|
|
||||||
cw_put_bstr(dst+7,cw_istore_get_datari->rmac); /* length MUST be 6 */
|
|
||||||
|
|
||||||
cw_put_word(dst+13,200); // beacon period
|
|
||||||
cw_put_data(dst+15,cw_itemstore_get_datari->country_str,3);
|
|
||||||
cw_put_data(dst+18,ri->country_str2,3);
|
|
||||||
|
|
||||||
cw_put_byte(dst+10+21,10); // gPeriod
|
|
||||||
|
|
||||||
cw_put_dword(dst+10+22,0x3538); // ?
|
|
||||||
|
|
||||||
return 28; //+cw_put_elem_vendor_hdr(dst,CW_VENDOR_ID_CISCO,CW_CISCO_WTP_RADIO_CFG,28);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int cw_out_cisco_wtp_radio_cfg(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
|
|
||||||
{
|
|
||||||
uint8_t *d = dst;
|
|
||||||
|
|
||||||
|
|
||||||
return 28+cw_put_elem_vendor_hdr(dst,CW_VENDOR_ID_CISCO,CW_CISCO_WTP_RADIO_CFG,28);
|
|
||||||
}
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "capwap.h"
|
|
||||||
#include "capwap_items.h"
|
|
||||||
|
|
||||||
#include "log.h"
|
|
||||||
#include "rand.h"
|
|
||||||
|
|
||||||
int cw_out_init_session_id(struct conn *conn,struct cw_action_out * a,uint8_t *dst)
|
|
||||||
{
|
|
||||||
printf("Vendor ID: %d\n", a->vendor_id);
|
|
||||||
uint8_t session_id[16];
|
|
||||||
int l = cw_rand(session_id,16);
|
|
||||||
if ( l!=16 ) {
|
|
||||||
cw_log(LOG_ERR,"Can't init session ID.");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
cw_itemstore_set_bstrn(conn->local,CW_ITEM_SESSION_ID,session_id,16);
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -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);
|
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
|
@ -1,75 +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 Image Data handling
|
|
||||||
*/
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "capwap.h"
|
|
||||||
|
|
||||||
#include "cw_log.h"
|
|
||||||
#include "cw_util.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int cw_readelem_image_identifier(struct cwimage_data *data, int type,uint8_t *msgelem, int len)
|
|
||||||
{
|
|
||||||
if (type != CW_ELEM_IMAGE_IDENTIFIER)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
data->vendor_id = ntohl(*((uint32_t*)msgelem));
|
|
||||||
|
|
||||||
if (len >= 1024) {
|
|
||||||
cw_dbg(DBG_MSG_ERR,"Image identifier too long (>1024), truncating");
|
|
||||||
len = 1024;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( data->identifier ){
|
|
||||||
memcpy(data->identifier,msgelem,len);
|
|
||||||
*(data->identifier+len)=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
if (cw_readelem_image_identifier(ptr,type,msgelem,len))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Read an image data request message
|
|
||||||
*/
|
|
||||||
void cw_read_image_data_request(struct cwimage_data *data, uint8_t * msg, int len)
|
|
||||||
{
|
|
||||||
cw_foreach_msgelem(msg,len,imgdata_request,data);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,51 +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 <arpa/inet.h>
|
|
||||||
|
|
||||||
#include "wtpinfo.h"
|
|
||||||
#include "capwap_80211.h"
|
|
||||||
|
|
||||||
#include "cw_log.h"
|
|
||||||
|
|
||||||
|
|
||||||
int cw_readelem_80211_wtp_radio_info(void *dst,int type,uint8_t *msgelem, int len)
|
|
||||||
{
|
|
||||||
if (type != CWMSGELEM_80211_WTP_RADIO_INFO)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (len!=5){
|
|
||||||
cw_dbg(DBG_MSG_ERR,"Discarding msgelem 80211_WTP_RADIO_INFO, wrong size, len=%d\n",len);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*msgelem <1 || *msgelem>31){
|
|
||||||
cw_dbg(DBG_CW_RFC,"Non-standard conform radio id, val=%d (must be between 1 to 31, See RFC 5415");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// int rid=*msgelem & 0x1f;
|
|
||||||
|
|
||||||
/*
|
|
||||||
wtpinfo->radioinfo[rid].set=1;
|
|
||||||
wtpinfo->radioinfo[rid].rid=rid;
|
|
||||||
wtpinfo->radioinfo[rid].type=ntohl(*(uint32_t*)(msgelem+1));
|
|
||||||
*/
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
#include "capwap_cisco.h"
|
#include "capwap_cisco.h"
|
||||||
#include "cw_log.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);
|
ri->beacon_period = lw_get_word(elem+13);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "capwap.h"
|
|
||||||
#include "cw_log.h"
|
|
||||||
|
|
||||||
int cw_readelem_radio_operational_state(struct radioinfo * radioinfo, int type,uint8_t *msgelem, int len)
|
|
||||||
{
|
|
||||||
if (type != CW_ELEM_RADIO_OPERATIONAL_STATE)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (len<3)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (len!=3){
|
|
||||||
cw_dbg(DBG_CW_RFC,"Radio operational state size != 3, RFC 5415");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int radioid = msgelem[0];
|
|
||||||
radioid&=0x1f;
|
|
||||||
radioinfo[radioid].state=msgelem[1];
|
|
||||||
radioinfo[radioid].cause=msgelem[2];
|
|
||||||
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
#include "capwap.h"
|
#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)
|
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;
|
return 0;
|
||||||
|
|
||||||
if (len!=2){
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
*timer=*((uint16_t*)msgelem);
|
*timer=*((uint16_t*)msgelem);
|
||||||
|
@ -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 );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -33,8 +33,8 @@
|
|||||||
int cw_send_echo_response(struct conn * conn,int seqnum,struct radioinfo * radioinfo)
|
int cw_send_echo_response(struct conn * conn,int seqnum,struct radioinfo * radioinfo)
|
||||||
{
|
{
|
||||||
struct cwmsg * cwmsg = &conn->resp_msg;
|
struct cwmsg * cwmsg = &conn->resp_msg;
|
||||||
cwmsg_init(cwmsg,conn->resp_buffer,CW_MSG_ECHO_RESPONSE,seqnum,radioinfo);
|
// cwmsg_init(cwmsg,conn->resp_buffer,CW_MSG_ECHO_RESPONSE,seqnum,radioinfo);
|
||||||
|
|
||||||
conn_send_response(conn,cwmsg,seqnum);
|
// conn_send_response(conn,cwmsg,seqnum);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -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));
|
|
||||||
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
/**
|
|
||||||
* @file
|
|
||||||
* @brief add wlan msg element implementation
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "capwap.h"
|
|
||||||
#include "capwap_80211.h"
|
|
||||||
|
|
||||||
#include "cwmsg.h"
|
|
||||||
|
|
||||||
#include "bstr.h"
|
|
||||||
|
|
||||||
|
|
||||||
void cwmsg_addelem_80211_add_wlan(struct cwmsg *cwmsg,struct cwwlan *wlan)
|
|
||||||
{
|
|
||||||
|
|
||||||
uint16_t capab=htons(wlan->capab);
|
|
||||||
uint16_t keylen=htons(wlan->key_length);
|
|
||||||
|
|
||||||
cwmsg_vaddelem(cwmsg,CW_ELEM_80211_ADD_WLAN,
|
|
||||||
&wlan->rid,1,
|
|
||||||
&wlan->wid,1,
|
|
||||||
&capab,2,
|
|
||||||
&wlan->key_index,1,
|
|
||||||
&wlan->key_status,1,
|
|
||||||
&keylen,2,
|
|
||||||
wlan->key,wlan->key_length,
|
|
||||||
wlan->group_tsc,6,
|
|
||||||
&wlan->qos,1,
|
|
||||||
&wlan->auth_type,1,
|
|
||||||
&wlan->mac_mode,1,
|
|
||||||
&wlan->tunnel_mode,1,
|
|
||||||
&wlan->suppress_ssid,1,
|
|
||||||
bstr_data(wlan->ssid),bstr_len(wlan->ssid),
|
|
||||||
NULL
|
|
||||||
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -33,7 +33,7 @@ printf("MTU discovery len %d %d and pos %d:\n",conn->mtu,len,msg->pos);
|
|||||||
if (len < 0 )
|
if (len < 0 )
|
||||||
return;
|
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);
|
*((uint32_t*)(msg->msgelems+msg->pos))=htonl(val);
|
||||||
memset(msg->msgelems+4+msg->pos,0xff,len);
|
memset(msg->msgelems+4+msg->pos,0xff,len);
|
||||||
msg->pos+=4+len;
|
msg->pos+=4+len;
|
||||||
|
@ -1,58 +0,0 @@
|
|||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
#include "capwap.h"
|
|
||||||
#include "capwap_cisco.h"
|
|
||||||
|
|
||||||
#include "cwmsg.h"
|
|
||||||
#include "conn.h"
|
|
||||||
|
|
||||||
|
|
||||||
#include "sock.h"
|
|
||||||
|
|
||||||
void cwmsg_addelem_vendor_cisco_mwar_addr(struct cwmsg *msg, struct conn *conn)
|
|
||||||
{
|
|
||||||
uint8_t data [7];
|
|
||||||
|
|
||||||
switch (((struct sockaddr*)&conn->addr)->sa_family){
|
|
||||||
case AF_INET:
|
|
||||||
{
|
|
||||||
data[0]=2; /* mwar type */
|
|
||||||
data[5]=0;
|
|
||||||
data[6]=0;
|
|
||||||
|
|
||||||
printf("Adding mwar addr %s\n",sock_addr2str(&conn->addr));
|
|
||||||
|
|
||||||
struct sockaddr_in * sain = (struct sockaddr_in*)&conn->addr;
|
|
||||||
memcpy(data+1,(uint8_t*)&sain->sin_addr,4);
|
|
||||||
cwmsg_addelem_vendor_specific_payload(msg, CW_VENDOR_ID_CISCO,
|
|
||||||
CW_CISCO_MWAR_ADDR,
|
|
||||||
data,7);
|
|
||||||
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* case AF_INET6:
|
|
||||||
{
|
|
||||||
int id;
|
|
||||||
if (cw_mode == CWMODE_CISCO)
|
|
||||||
id = CWMSGELEM_WTP_IPV6_IP_ADDR;
|
|
||||||
else
|
|
||||||
id = CWMSGELEM_CAPWAP_LOCAL_IPV6_ADDRESS;
|
|
||||||
struct sockaddr_in6 * sain = (struct sockaddr_in6*)&a;
|
|
||||||
return cwmsg_addelem(msg,id,(uint8_t*)&sain->sin6_addr,16);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -25,6 +25,7 @@
|
|||||||
* @file Debugging Functions
|
* @file Debugging Functions
|
||||||
* @brief Various debug functions.
|
* @brief Various debug functions.
|
||||||
*/
|
*/
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include "capwap.h"
|
#include "capwap.h"
|
||||||
#include "dbg.h"
|
#include "dbg.h"
|
||||||
@ -39,6 +40,8 @@
|
|||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
#include "message_set.h"
|
#include "message_set.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@addtogroup DBG
|
*@addtogroup DBG
|
||||||
*@{
|
*@{
|
||||||
|
@ -19,19 +19,7 @@
|
|||||||
#define __CW_DTLS_H
|
#define __CW_DTLS_H
|
||||||
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include "dtls_common.h"
|
||||||
#include "conn.h"
|
|
||||||
|
|
||||||
|
|
||||||
struct dtls_ssl_cert
|
|
||||||
{
|
|
||||||
int size;
|
|
||||||
int type;
|
|
||||||
uint8_t * data;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern int dtls_bio_read(struct conn *conn, char *out, int maxlen);
|
|
||||||
extern int dtls_bio_write(struct conn * conn, const char *data, int len);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
13
src/cw/dtls_common.h
Normal file
13
src/cw/dtls_common.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
#include "conn.h"
|
||||||
|
struct dtls_ssl_cert
|
||||||
|
{
|
||||||
|
int size;
|
||||||
|
int type;
|
||||||
|
uint8_t * data;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern int dtls_bio_read(struct conn *conn, char *out, int maxlen);
|
||||||
|
extern int dtls_bio_write(struct conn * conn, const char *data, int len);
|
||||||
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
|||||||
#include <gnutls/gnutls.h>
|
#include <gnutls/gnutls.h>
|
||||||
#include <gnutls/dtls.h>
|
#include <gnutls/dtls.h>
|
||||||
|
|
||||||
|
#include "dtls_common.h"
|
||||||
#include "dtls_gnutls.h"
|
#include "dtls_gnutls.h"
|
||||||
|
|
||||||
#include "conn.h"
|
#include "conn.h"
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "sock.h"
|
#include "sock.h"
|
||||||
#include "capwap.h"
|
#include "capwap.h"
|
||||||
|
#include "dtls_common.h"
|
||||||
#include "dtls_gnutls.h"
|
#include "dtls_gnutls.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
|
#include "dtls_common.h"
|
||||||
#include "dtls_gnutls.h"
|
#include "dtls_gnutls.h"
|
||||||
|
|
||||||
const char *dtls_gnutls_get_cipher(struct conn *conn)
|
const char *dtls_gnutls_get_cipher(struct conn *conn)
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "capwap.h"
|
#include "capwap.h"
|
||||||
#include "sock.h"
|
#include "sock.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
int hdr_print(char *str, uint8_t *packet, int len)
|
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;
|
return s-str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
@ -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"}
|
|
||||||
|
|
||||||
};
|
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
#include "lwapp.h"
|
#include "lwapp.h"
|
||||||
|
|
||||||
|
/*
|
||||||
int lw_put_80211_wtp_wlan_radio_configuration(uint8_t*dst,struct radioinfo *ri)
|
int lw_put_80211_wtp_wlan_radio_configuration(uint8_t*dst,struct radioinfo *ri)
|
||||||
{
|
{
|
||||||
lw_put_byte(dst,ri->rid);
|
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_byte(dst+4,ri->cfp_period);
|
||||||
lw_put_word(dst+5,ri->cfp_max_duration);
|
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_word(dst+13,ri->beacon_period);
|
||||||
lw_put_byte(dst+15,ri->dtim_period);
|
lw_put_byte(dst+15,ri->dtim_period);
|
||||||
lw_put_data(dst+16,ri->country_str,4);
|
lw_put_data(dst+16,ri->country_str,4);
|
||||||
lw_put_byte(dst+20,ri->max_bssid);
|
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);
|
lw_put_data(dst+21,(uint8_t*)"DEAU990",7);
|
||||||
|
|
||||||
return 21+7;
|
return 21+7;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "lwapp.h"
|
|
||||||
|
|
||||||
int lw_readelem_80211_wtp_wlan_radio_configuration(int elem_id,uint8_t *elem, int len,struct radioinfo *ri)
|
|
||||||
{
|
|
||||||
if (elem_id != LW_ELEM_80211_WLAN_RADIO_CONFIGURATION)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (len<21){
|
|
||||||
cw_dbg(DBG_ERR,"LWAPP Radio Cfg element too short, %d < 21",len);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ri->rid = lw_get_byte(elem);
|
|
||||||
ri->occupancy_limit = lw_get_word(elem+2);
|
|
||||||
|
|
||||||
bstr_replace(ri->bssid,bstr_create(elem+7,6);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
/**
|
|
||||||
* @file
|
|
||||||
* @brief Implementation of lw_readelem_wtp_board_data
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
|
|
||||||
#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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include "cw_util.h"
|
#include "cw_util.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include "dbg.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the LWAPP message element WTP Name
|
* 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){
|
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;
|
len=254;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
//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 *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;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void *mavl_replace(struct mavl *t,void *data){
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline void mavl_destroy(struct mavl *t)
|
void mavl_destroy(struct mavl *t);
|
||||||
{
|
|
||||||
mavl_del_all(t);
|
|
||||||
free (t);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -169,41 +150,12 @@ typedef struct mavliter mavliter_t;
|
|||||||
|
|
||||||
void * mavliter_next(mavliter_t *i);
|
void * mavliter_next(mavliter_t *i);
|
||||||
|
|
||||||
static inline void * mavliter_seek_set(struct mavliter *i)
|
void * mavliter_seek_set(struct mavliter *i);
|
||||||
{
|
|
||||||
i->stack_ptr=0;
|
|
||||||
i->cur=i->root;
|
|
||||||
return mavliter_next(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
void mavliter_init(mavliter_t *i, mavl_t t);
|
||||||
* 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_get(mavliter_t *i);
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
extern void * mavliter_seek(mavliter_t *i,void *d);
|
extern void * mavliter_seek(mavliter_t *i,void *d);
|
||||||
|
|
||||||
|
9
src/cw/mavl_destroy.c
Normal file
9
src/cw/mavl_destroy.c
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#include "mavl.h"
|
||||||
|
|
||||||
|
void mavl_destroy(struct mavl *t)
|
||||||
|
{
|
||||||
|
mavl_del_all(t);
|
||||||
|
free (t);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
12
src/cw/mavl_replace.c
Normal file
12
src/cw/mavl_replace.c
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
12
src/cw/mavl_replace_data.c
Normal file
12
src/cw/mavl_replace_data.c
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
14
src/cw/mavliter_get.c
Normal file
14
src/cw/mavliter_get.c
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
19
src/cw/mavliter_init.c
Normal file
19
src/cw/mavliter_init.c
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
10
src/cw/mavliter_seek_set.c
Normal file
10
src/cw/mavliter_seek_set.c
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
158
src/cw/mbag.c
158
src/cw/mbag.c
@ -237,3 +237,161 @@ struct mbag_item *strmbag_item_create(mbag_t s, char *name)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int mbag_set(mbag_t t,mbag_item_t *is)
|
||||||
|
{
|
||||||
|
mavl_del(t,is);
|
||||||
|
mavl_add(t,is);
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
struct mbag_item *i = mavl_get(s, is);
|
||||||
|
if (i) {
|
||||||
|
mbag_del_data(i);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
mavl_add(t,is);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
int mbag_set_byte(mbag_t s, const char *id, uint8_t byte)
|
||||||
|
{
|
||||||
|
struct mbag_item *i = mbag_item_create(s, id);
|
||||||
|
if (!i)
|
||||||
|
return 0;
|
||||||
|
i->byte = byte;
|
||||||
|
i->type = &mbag_type_byte;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct mbag_item * mbag_set_word(mbag_t s, const char *id, uint16_t word)
|
||||||
|
{
|
||||||
|
struct mbag_item *i = mbag_item_create(s, id);
|
||||||
|
if (!i)
|
||||||
|
return 0;
|
||||||
|
i->word = word;
|
||||||
|
i->type = &mbag_type_word;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct mbag_item * mbag_set_dword(mbag_t s, const char *id, uint32_t dword)
|
||||||
|
{
|
||||||
|
struct mbag_item *i = mbag_item_create(s, id);
|
||||||
|
if (!i)
|
||||||
|
return NULL;
|
||||||
|
i->dword = dword;
|
||||||
|
i->type = &mtype_dword;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int mbag_i_set_mbag(mbag_t s, uint32_t id, mbag_t mbag)
|
||||||
|
{
|
||||||
|
struct mbag_item *i = mbag_i_item_create(s, id);
|
||||||
|
if (!i)
|
||||||
|
return 0;
|
||||||
|
i->data = mbag;
|
||||||
|
i->type = &mbag_type_mbag;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mbag_set_mbag(mbag_t s, const char *id, mbag_t mbag)
|
||||||
|
{
|
||||||
|
struct mbag_item *i = mbag_item_create(s, id);
|
||||||
|
if (!i)
|
||||||
|
return 0;
|
||||||
|
i->data = mbag;
|
||||||
|
i->type = &mbag_type_mbag;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mbag_set_data(mbag_t s, const char *id, const struct mbag_typedef *type, void *data)
|
||||||
|
{
|
||||||
|
struct mbag_item *i = mbag_item_create(s, id);
|
||||||
|
if (!i)
|
||||||
|
return 0;
|
||||||
|
i->data = data;
|
||||||
|
i->type = type;
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bstrv_t mbag_set_bstrv(mbag_t s, const char *id, uint32_t vendor_id,
|
||||||
|
uint8_t * version, int len)
|
||||||
|
{
|
||||||
|
mbag_item_t *i = mbag_item_create(s, id);
|
||||||
|
if (!i)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
i->type = MBAG_VENDORSTR;
|
||||||
|
i->data = bstrv_create(vendor_id,version,len);
|
||||||
|
return i->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
mbag_item_t *mbag_get(mbag_t s, const char *id)
|
||||||
|
{
|
||||||
|
mbag_item_t i;
|
||||||
|
i.id = id;
|
||||||
|
i.type=0;
|
||||||
|
return mavl_get(s, &i);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mbag_item_t *mbag_i_get(mbag_t s, uint32_t id)
|
||||||
|
{
|
||||||
|
mbag_item_t i;
|
||||||
|
i.iid = id;
|
||||||
|
i.type=0;
|
||||||
|
return mavl_get(s, &i);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void mbag_del(mbag_t s,const char *id)
|
||||||
|
{
|
||||||
|
mbag_item_t i;
|
||||||
|
i.id = id;
|
||||||
|
i.type=0;
|
||||||
|
mavl_del(s, &i);
|
||||||
|
}
|
||||||
|
|
||||||
|
void * mbag_get_data(mbag_t s, const char *id, const struct mbag_typedef * type, void * def)
|
||||||
|
{
|
||||||
|
struct mbag_item *i = mbag_get(s, id);
|
||||||
|
if (!i)
|
||||||
|
return def;
|
||||||
|
if (i->type != type)
|
||||||
|
return def;
|
||||||
|
return i->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
144
src/cw/mbag.h
144
src/cw/mbag.h
@ -176,100 +176,15 @@ struct mbag_item *mbag_item_create(mbag_t s, const char *id);
|
|||||||
struct mbag_item *mbag_i_item_create(mbag_t s, uint32_t id);
|
struct mbag_item *mbag_i_item_create(mbag_t s, uint32_t id);
|
||||||
|
|
||||||
|
|
||||||
static inline int mbag_set(mbag_t t,mbag_item_t *is)
|
bstrv_t mbag_set_bstrv(mbag_t s, const char *id, uint32_t vendor_id,
|
||||||
{
|
uint8_t * version, int len);
|
||||||
mavl_del(t,is);
|
int mbag_set_data(mbag_t s, const char *id, const struct mbag_typedef *type, void *data);
|
||||||
mavl_add(t,is);
|
int mbag_set_mbag(mbag_t s, const char *id, mbag_t mbag);
|
||||||
return 1;
|
int mbag_i_set_mbag(mbag_t s, uint32_t id, mbag_t mbag);
|
||||||
|
struct mbag_item * mbag_set_dword(mbag_t s, const char *id, uint32_t dword);
|
||||||
/*
|
struct mbag_item * mbag_set_word(mbag_t s, const char *id, uint16_t word);
|
||||||
struct mbag_item *i = mavl_get(s, is);
|
int mbag_set_byte(mbag_t s, const char *id, uint8_t byte);
|
||||||
if (i) {
|
int mbag_set(mbag_t t,mbag_item_t *is);
|
||||||
mbag_del_data(i);
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
mavl_add(t,is);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int mbag_set_byte(mbag_t s, const char *id, uint8_t byte)
|
|
||||||
{
|
|
||||||
struct mbag_item *i = mbag_item_create(s, id);
|
|
||||||
if (!i)
|
|
||||||
return 0;
|
|
||||||
i->byte = byte;
|
|
||||||
i->type = &mbag_type_byte;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline struct mbag_item * mbag_set_word(mbag_t s, const char *id, uint16_t word)
|
|
||||||
{
|
|
||||||
struct mbag_item *i = mbag_item_create(s, id);
|
|
||||||
if (!i)
|
|
||||||
return 0;
|
|
||||||
i->word = word;
|
|
||||||
i->type = &mbag_type_word;
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static inline struct mbag_item * mbag_set_dword(mbag_t s, const char *id, uint32_t dword)
|
|
||||||
{
|
|
||||||
struct mbag_item *i = mbag_item_create(s, id);
|
|
||||||
if (!i)
|
|
||||||
return NULL;
|
|
||||||
i->dword = dword;
|
|
||||||
i->type = &mtype_dword;
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline int mbag_i_set_mbag(mbag_t s, uint32_t id, mbag_t mbag)
|
|
||||||
{
|
|
||||||
struct mbag_item *i = mbag_i_item_create(s, id);
|
|
||||||
if (!i)
|
|
||||||
return 0;
|
|
||||||
i->data = mbag;
|
|
||||||
i->type = &mbag_type_mbag;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int mbag_set_mbag(mbag_t s, const char *id, mbag_t mbag)
|
|
||||||
{
|
|
||||||
struct mbag_item *i = mbag_item_create(s, id);
|
|
||||||
if (!i)
|
|
||||||
return 0;
|
|
||||||
i->data = mbag;
|
|
||||||
i->type = &mbag_type_mbag;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int mbag_set_data(mbag_t s, const char *id, const struct mbag_typedef *type, void *data)
|
|
||||||
{
|
|
||||||
struct mbag_item *i = mbag_item_create(s, id);
|
|
||||||
if (!i)
|
|
||||||
return 0;
|
|
||||||
i->data = data;
|
|
||||||
i->type = type;
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline bstrv_t mbag_set_bstrv(mbag_t s, const char *id, uint32_t vendor_id,
|
|
||||||
uint8_t * version, int len)
|
|
||||||
{
|
|
||||||
mbag_item_t *i = mbag_item_create(s, id);
|
|
||||||
if (!i)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
i->type = MBAG_VENDORSTR;
|
|
||||||
i->data = bstrv_create(vendor_id,version,len);
|
|
||||||
return i->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
mbag_item_t *mbag_item_new(mbagtype_t type);
|
mbag_item_t *mbag_item_new(mbagtype_t type);
|
||||||
@ -281,42 +196,19 @@ mbag_item_t *mbag_item_new(mbagtype_t type);
|
|||||||
#define mbag_set_bstr16(m,i,d) mbag_set_data(m,i,MBAG_BSTR16,d)
|
#define mbag_set_bstr16(m,i,d) mbag_set_data(m,i,MBAG_BSTR16,d)
|
||||||
|
|
||||||
|
|
||||||
static inline mbag_item_t *mbag_get(mbag_t s, const char *id)
|
|
||||||
{
|
|
||||||
mbag_item_t i;
|
|
||||||
i.id = id;
|
|
||||||
i.type=0;
|
|
||||||
return mavl_get(s, &i);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline mbag_item_t *mbag_i_get(mbag_t s, uint32_t id)
|
|
||||||
{
|
|
||||||
mbag_item_t i;
|
|
||||||
i.iid = id;
|
|
||||||
i.type=0;
|
|
||||||
return mavl_get(s, &i);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static inline void mbag_del(mbag_t s,const char *id)
|
void * mbag_get_data(mbag_t s, const char *id, const struct mbag_typedef * type, void * def);
|
||||||
{
|
void mbag_del(mbag_t s,const char *id);
|
||||||
mbag_item_t i;
|
mbag_item_t *mbag_i_get(mbag_t s, uint32_t id);
|
||||||
i.id = id;
|
mbag_item_t *mbag_get(mbag_t s, const char *id);
|
||||||
i.type=0;
|
|
||||||
mavl_del(s, &i);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static inline void * mbag_get_data(mbag_t s, const char *id, const struct mbag_typedef * type, void * def)
|
|
||||||
{
|
|
||||||
struct mbag_item *i = mbag_get(s, id);
|
|
||||||
if (!i)
|
|
||||||
return def;
|
|
||||||
if (i->type != type)
|
|
||||||
return def;
|
|
||||||
return i->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define mbag_get_bstr(m,i,d) mbag_get_data(m,i,MBAG_BSTR,d)
|
#define mbag_get_bstr(m,i,d) mbag_get_data(m,i,MBAG_BSTR,d)
|
||||||
#define mbag_get_bstr16(m,i,d) mbag_get_data(m,i,MBAG_BSTR16,d)
|
#define mbag_get_bstr16(m,i,d) mbag_get_data(m,i,MBAG_BSTR16,d)
|
||||||
|
@ -1,118 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "capwap80211_types.h"
|
|
||||||
#include "dot11.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int to_str(void *item,char *dst)
|
|
||||||
{
|
|
||||||
mbag_item_t *it= item;
|
|
||||||
|
|
||||||
uint8_t *data = (uint8_t*)it->data;
|
|
||||||
int n=*data;
|
|
||||||
data++;
|
|
||||||
|
|
||||||
char *d=dst;
|
|
||||||
char *space="";
|
|
||||||
int i;
|
|
||||||
for (i=0; i<n; i++){
|
|
||||||
int val = data[i];
|
|
||||||
|
|
||||||
|
|
||||||
d+=sprintf(d,"%s",space);
|
|
||||||
if (val & 0x80){
|
|
||||||
d+=sprintf(d,"*");
|
|
||||||
}
|
|
||||||
|
|
||||||
d+=sprintf(d,"%0.1f",dot11_rate2float(val & 0x7f));
|
|
||||||
|
|
||||||
space=" ";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return d-dst;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static struct mbag_item * from_str(const char *src)
|
|
||||||
{
|
|
||||||
mbag_item_t * item = mbag_item_new(CAPWAP80211_TYPE_RATESET);
|
|
||||||
if (!item)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (strlen(src)==0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
uint8_t rates[64];
|
|
||||||
int nrates =0;
|
|
||||||
|
|
||||||
const char *s = src;
|
|
||||||
|
|
||||||
while (*s!=0){
|
|
||||||
while (*s==' ')
|
|
||||||
s++;
|
|
||||||
int m=0;
|
|
||||||
if(*s=='*'){
|
|
||||||
m=0x80;
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
m=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
float val;
|
|
||||||
int n=sscanf(s,"%f",&val);
|
|
||||||
if (n!=1)
|
|
||||||
break;
|
|
||||||
|
|
||||||
int r = dot11_float2rate(val) | m;
|
|
||||||
|
|
||||||
rates[nrates++]=r;
|
|
||||||
|
|
||||||
|
|
||||||
while (*s!=0 && *s!=' ')
|
|
||||||
s++;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t *data = malloc(nrates+1);
|
|
||||||
*data=nrates;
|
|
||||||
memcpy(data+1,rates,nrates);
|
|
||||||
|
|
||||||
item->data=data;
|
|
||||||
|
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct mbag_item * get(const uint8_t *src,int len)
|
|
||||||
{
|
|
||||||
|
|
||||||
mbag_item_t * item = mbag_item_new(MBAG_BIN);
|
|
||||||
if (!item)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
uint8_t *data = malloc(len+1);
|
|
||||||
if (!data){
|
|
||||||
free (item);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
*data=len;
|
|
||||||
memcpy(data+1,src,len);
|
|
||||||
item->data=data;
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const struct mbag_typedef capwap80211_type_rateset = {
|
|
||||||
.name = "Biary",
|
|
||||||
.del = free,
|
|
||||||
.from_str = from_str,
|
|
||||||
.to_str = to_str,
|
|
||||||
.get = get
|
|
||||||
|
|
||||||
};
|
|
@ -1,5 +0,0 @@
|
|||||||
const struct mbag_typedef mbag_type_bstr = {
|
|
||||||
"bstr",free
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
@ -53,4 +53,3 @@ char * sock_get_primary_if(int family)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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));
|
memcpy (sa, ifa->ifa_addr, sock_addrlen(ifa->ifa_addr));
|
||||||
rc=1;
|
rc=1;
|
||||||
break;
|
break;
|
||||||
case IFF_BROADCAST:
|
// 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));
|
||||||
memcpy (sa, ifa->ifa_broadaddr, sock_addrlen(ifa->ifa_addr));
|
// rc=1;
|
||||||
rc=1;
|
// break;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#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;
|
|
||||||
}
|
|
||||||
|
|
@ -1,73 +0,0 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
#include "wtpinfo.h"
|
|
||||||
|
|
||||||
#include "capwap.h"
|
|
||||||
|
|
||||||
#include "cw_util.h"
|
|
||||||
#include "cw_log.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void wtpinfo_readsubelems_wtp_board_data(struct wtpinfo * wtpinfo,uint8_t * msgelem,int len)
|
|
||||||
{
|
|
||||||
int i=0;
|
|
||||||
uint32_t val;
|
|
||||||
do {
|
|
||||||
val = ntohl(*((uint32_t*)(msgelem+i)));
|
|
||||||
int subtype= (val>>16)&0xffff;
|
|
||||||
int sublen = val&0xffff;
|
|
||||||
i+=4;
|
|
||||||
if (sublen+i>len){
|
|
||||||
cw_dbg(DBG_ELEM,"WTP Board data sub-element too long, type=%d,len=%d",subtype,sublen);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
cw_dbg(DBG_ELEM,"Reading WTP board data sub-element, type=%d, len=%d",subtype,sublen);
|
|
||||||
|
|
||||||
switch(subtype){
|
|
||||||
case CWBOARDDATA_MODELNO:
|
|
||||||
bstr_replace(&wtpinfo->model_no,bstr_create(msgelem+i,sublen));
|
|
||||||
break;
|
|
||||||
case CWBOARDDATA_SERIALNO:
|
|
||||||
bstr_replace(&wtpinfo->serial_no,bstr_create(msgelem+i,sublen));
|
|
||||||
break;
|
|
||||||
case CWBOARDDATA_MACADDRESS:
|
|
||||||
wtpinfo->macaddress=realloc(wtpinfo->macaddress,sublen);
|
|
||||||
memcpy(wtpinfo->macaddress,msgelem+i,sublen);
|
|
||||||
wtpinfo->macaddress_len=sublen;
|
|
||||||
break;
|
|
||||||
case CWBOARDDATA_BOARDID:
|
|
||||||
bstr_replace(&wtpinfo->board_id,bstr_create(msgelem+i,sublen));
|
|
||||||
break;
|
|
||||||
case CWBOARDDATA_REVISION:
|
|
||||||
bstr_replace(&wtpinfo->board_revision,bstr_create(msgelem+i,sublen));
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i+=sublen;
|
|
||||||
|
|
||||||
}while(i<len);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int wtpinfo_readelem_wtp_board_data(struct wtpinfo *wtpinfo, int type, uint8_t *msgelem, int len)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (type!=CAPWAP_ELEM_WTP_BOARD_DATA)
|
|
||||||
return 0;
|
|
||||||
if (len<4){
|
|
||||||
cw_dbg(DBG_ELEM,"Discarding WTP_BOARD_DATA msgelem, wrong size, type=%d, len=%d\n",type,len);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
wtpinfo->vendor_id = ntohl(*((uint32_t*)msgelem));
|
|
||||||
wtpinfo_readsubelems_wtp_board_data(wtpinfo,msgelem+4,len-4);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user