diff --git a/.gitignore b/.gitignore
index 50b47adf..efd43332 100644
--- a/.gitignore
+++ b/.gitignore
@@ -46,5 +46,10 @@ ssl/intermediate-ca/
*.tar.xz
# other stuff
+.depend
.codelite/
+lib/
+obj/
+bin/
+src/Config.local.mak
diff --git a/actube.workspace b/actube.workspace
index a1ba30eb..e0162c79 100644
--- a/actube.workspace
+++ b/actube.workspace
@@ -7,6 +7,7 @@
+
@@ -17,6 +18,7 @@
+
@@ -27,6 +29,7 @@
+
diff --git a/libcw.project b/libcw.project
index bb9d7294..a3cc5a86 100644
--- a/libcw.project
+++ b/libcw.project
@@ -305,6 +305,8 @@
+
+
diff --git a/mod_capwap80211.project b/mod_capwap80211.project
new file mode 100644
index 00000000..a41e8ac9
--- /dev/null
+++ b/mod_capwap80211.project
@@ -0,0 +1,107 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ make clean && make
+
+ make clean
+ make
+
+
+
+ None
+ $(WorkspacePath)/src/mod/capwap80211/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ make clean
+ make
+
+
+
+ None
+ $(WorkspacePath)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mod_cisco.project b/mod_cisco.project
index bfeabae9..d1c43e00 100644
--- a/mod_cisco.project
+++ b/mod_cisco.project
@@ -13,7 +13,6 @@
-
@@ -36,6 +35,7 @@
+
diff --git a/mod_fortinet.project b/mod_fortinet.project
new file mode 100644
index 00000000..b530d813
--- /dev/null
+++ b/mod_fortinet.project
@@ -0,0 +1,104 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ make clean && make
+ make clean
+ make
+
+
+
+ None
+ $(WorkspacePath)/src/mod/fortinet
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ make clean
+ make
+
+
+
+ None
+ $(WorkspacePath)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ACConfig.mak b/src/ACConfig.mak
index a010dc95..b8bd23b5 100644
--- a/src/ACConfig.mak
+++ b/src/ACConfig.mak
@@ -1,8 +1,7 @@
include ../Config.mak
-#Define SSL Library: OPENSSL or GNUTLS
-#SSL_LIBRARY=OPENSSL
-SSL_LIBRARY=GNUTLS
-
+# Define SSL Library: OPENSSL or GNUTLS
+# SSL_LIBRARY=OPENSSL
+SSL_LIBRARY=OPENSSL
diff --git a/src/CapwapConfig.mak b/src/CWConfig.mak
similarity index 100%
rename from src/CapwapConfig.mak
rename to src/CWConfig.mak
diff --git a/src/Config.mak b/src/Config.mak
index 1c0f0f40..2d0e2e69 100644
--- a/src/Config.mak
+++ b/src/Config.mak
@@ -1,25 +1,37 @@
-
#
# OpenSSL definitions
#
-#OPENSSL_VERSION=openssl-1.0.1l # doesn't work
-#OPENSSL_VERSION=openssl-1.0.2 # doesn't work
-OPENSSL_VERSION=openssl-1.0.1i
+# OPENSSL_VERSION=openssl-1.0.1i
USE_CONTRIB_OPENSSL=0
# GnuTLS definitions
-GNUTLS_VERSION=3.3.9
+# GNUTLS_VERSION=3.3.9
+
USE_CONTRIB_GNUTLS=0
# Compiler to use
-CC=clang
-#CC=gcc
-#CC=mips-openwrt-linux-uclibc-gcc
-#LD=mips-openwrt-linux-uclibc-ld
-#AR=mips-openwrt-linux-uclibc-ar
-
-
+# CC=clang
+# CC=mips-openwrt-linux-uclibc-gcc
+# LD=mips-openwrt-linux-uclibc-ld
+# AR=mips-openwrt-linux-uclibc-ar
+# CC=clang
COMPDEFS=-DWITH_CW_LOG
COMPDEFS+=-DWITH_CW_LOG_DEBUG
+
+# LIBCW settings
+
+# WITH_GNUTLS
+# compile in support for GnuTLS
+#
+WITH_GNUTLS=1
+
+# Compile in openssl support
+WITH_OPENSSL=1
+
+#
+#
+LIBDIR=lib
+
+
diff --git a/src/Macros.mak b/src/Macros.mak
index 1b0f1e6b..c99e06d1 100644
--- a/src/Macros.mak
+++ b/src/Macros.mak
@@ -9,21 +9,42 @@ endif
ifeq ($(USE_CONTRIB_GNUTLS),1)
GNUTLS_CFLAGS=-I../contrib/gnutls-${GNUTLS_VERSION}/lib/includes
-#GNUTLS_LIBS=-lnettle -lgmp ../contrib/gnutls-${GNUTLS_VERSION}/lib/.libs/libgnutls.a
GNUTLS_LIBS=-lgmp -lgnutls -lnettle
-
GNUTLS_LDFLAGS=-L../contrib/gnutls-${GNUTLS_VERSION}/lib/.libs/
else
GNUTLS_CFLAGS=
GNUTLS_LIBS=-lgnutls -lnettle -lgmp
GNUTLS_LDFLAGS=
-#-lgnutls -lnettle -lgmp
-
endif
ifndef ARCH
- ARCH = $(shell $(CC) -dumpmachine)
+ ARCH = $(shell uname -m)
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
+
+
+
+
diff --git a/src/ac/Makefile b/src/ac/Makefile
index 4d8300d8..91a622cc 100644
--- a/src/ac/Makefile
+++ b/src/ac/Makefile
@@ -1,30 +1,28 @@
-
+include ../Config.mak
include ../ACConfig.mak
+-include ../Config.local.mak
+-include ../ACConfig.local.mak
include ../Macros.mak
-ifndef CC
- CC=gcc
-endif
-#SYSARCH := $(shell uname -m)
-ifndef ARCH
- ARCH = $(shell $(CC) -dumpmachine)
-endif
-LDFLAGS+=-g -D_REENTRANT -L/usr/local/lib -L../lib/$(ARCH)
-CFLAGS += -Wall -g -O0 -D_REENTRANT -DIPV6 -I/usr/local/include -I../ -DSYS_ARCH=\"${ARCH}\"
+LIBARCHDIR=../../lib/$(ARCH)
+
+LDFLAGS+=-g -L/usr/local/lib -L$(LIBARCHDIR)
+CFLAGS += -W -g -O0 -D_REENTRANT -DIPV6 -I/usr/local/include -I../ -DSYS_ARCH=\"${ARCH}\"
-LIBS+=-lcapwap
-LIBS+=-lcapwap80211
-LIBS+=-lcipwap
-LIBS+=-lcisco
-LIBS+=-lfortinet
-LIBS+=-lzyxel
+#LIBS+=-lcapwap
+#LIBS+=-lcapwap80211
+#LIBS+=-lcipwap
+#LIBS+=-lcisco
+#LIBS+=-lfortinet
+#LIBS+=-lzyxel
LIBS+=-lcw
LIBS+=-lrt
LIBS+=-lpthread
LIBS+=-lconfuse
LIBS+=-lsqlite3
+LIBS+=-ldl
ifeq ($(SSL_LIBRARY),GNUTLS)
@@ -51,7 +49,7 @@ CFLAGS += -DWITH_IPV6
RM = /bin/rm -f
-AC_MODULES = mod_cipwap.o
+#AC_MODULES = mod_cipwap.o
# list of generated object files for AC.
@@ -77,12 +75,13 @@ AC_NAME = actube
all: $(AC_NAME)
%.o:%.c
- @echo " CC "$<
+ @echo " $(CC) "$<
@$(CC) -c $(CFLAGS) $< -o $@
$(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)
+ $(LD) $(AC_OBJS) -o $(AC_NAME) $(LDFLAGS) $(LIBS)
clean:
@@ -92,6 +91,6 @@ clean_deps:
$(AC_DEPS)
deps: $(AC_SRC)
- $(CC) -MD -E $(AC_SRCS) $(CFLAGS) >/dev/null
+ $(LD) -MD -E $(AC_SRCS) $(CFLAGS) >/dev/null
-include $(AC_DEPS)
diff --git a/src/ac/ac_main.c b/src/ac/ac_main.c
index 204c54e9..5151cc75 100644
--- a/src/ac/ac_main.c
+++ b/src/ac/ac_main.c
@@ -87,22 +87,17 @@ static int parse_args(int argc, char *argv[])
#include "cw/mod.h"
-extern struct mod_ac * cw_get_mod_ac(const char *name);
+extern struct cw_Mod * cw_get_mod_ac(const char *name);
#include "cw/mlist.h"
extern void test_sets();
+#include "cw/file.h"
int main(int argc, char *argv[])
{
-
-
-
-
-
-
int rc = 0;
/* parse arguments */
@@ -125,6 +120,14 @@ int main(int argc, char *argv[])
developers is turned on ;) */
DBGX("Attention! %s", "DBG X is ON!");
+// cw_mod_set_mod_path("../../lib/actube");
+// cw_mod_load("capwap");
+
+
+
+
+//test_sets();
+//exit(0);
/* Initialize the database */
if (!db_init())
diff --git a/src/ac/conf.c b/src/ac/conf.c
index f878678b..4bd14aca 100644
--- a/src/ac/conf.c
+++ b/src/ac/conf.c
@@ -38,7 +38,7 @@ uint8_t conf_macaddress_len = 0;
long conf_strict_capwap = 1;
long conf_strict_headers = 0;
-char *conf_capwap_mode_str = NULL;
+//char *conf_capwap_mode_str = NULL;
int conf_capwap_mode = CW_MODE_CAPWAP;
@@ -539,8 +539,8 @@ static int conf_read_dbg_level(cfg_t * cfg)
-struct mod_ac ** conf_mods; //[10];
-
+struct cw_Mod ** conf_mods; //[10];
+char *conf_mods_dir = NULL;
static int init_mods()
@@ -570,21 +570,22 @@ static int conf_read_mods(cfg_t *cfg){
int n, i;
n = cfg_size(cfg,CFG_ENTRY_MODS);
- conf_mods = malloc(sizeof(struct mod_ac *)*(n+1));
-
+ conf_mods = malloc(sizeof(struct cw_Mod *)*(n+1));
+
+ cw_dbg(DBG_INFO,"Mods directory: %s",conf_mods_dir);
+ cw_mod_set_mod_path(conf_mods_dir);
+
for (i=0; i < n; i++){
char *modname = cfg_getnstr(cfg, CFG_ENTRY_MODS, i);
- conf_mods[i] = modload_ac(modname);
- if (!conf_mods[i]){
- cw_log(LOG_ERR,"Can't load mod: %s",modname);
+ struct cw_Mod * mod = cw_mod_load(modname);
+ if (!mod)
return 0;
- }
+ cw_mod_add_to_list(mod);
}
- conf_mods[i]=NULL;
return 1;
}
-
+/*
void conf_init_capwap_mode()
{
if (conf_capwap_mode_str == NULL)
@@ -600,7 +601,7 @@ void conf_init_capwap_mode()
}
-
+*/
int conf_parse_listen_addr(const char *addrstr, char *saddr, char *port, int *proto)
@@ -700,6 +701,8 @@ int read_config(const char *filename)
cfg_opt_t opts[] = {
CFG_STR_LIST("mods", "{}", CFGF_NONE),
+ CFG_SIMPLE_STR("mods_dir", &conf_mods_dir),
+
CFG_STR_LIST("dbg", "{}", CFGF_NONE),
CFG_STR_LIST("listen", "{}", CFGF_NONE),
CFG_STR_LIST("mcast_groups", "{}", CFGF_NONE),
@@ -710,7 +713,7 @@ int read_config(const char *filename)
CFG_SIMPLE_BOOL("strict_capwap", &conf_strict_capwap),
CFG_SIMPLE_BOOL("strict_headers", &conf_strict_headers),
CFG_SIMPLE_BOOL("use_loopback", &conf_use_loopback),
- CFG_SIMPLE_STR("capwap_mode", &conf_capwap_mode_str),
+// CFG_SIMPLE_STR("capwap_mode", &conf_capwap_mode_str),
#ifdef WITH_LWAPP
@@ -815,16 +818,18 @@ int read_config(const char *filename)
if (!conf_image_dir)
conf_image_dir = CONF_DEFAULT_IMAGE_DIR;
- init_mods();
+//printf("INIT MODS\n");
+// init_mods();
+//printf("done init mods");
- conf_init_capwap_mode();
+// conf_init_capwap_mode();
init_listen_addrs();
init_mcast_groups();
init_bcast_addrs();
-
+//printf("Yea all mods inited\n");
return 1;
}
diff --git a/src/ac/conf.h b/src/ac/conf.h
index 54e4bd85..98b8e12e 100644
--- a/src/ac/conf.h
+++ b/src/ac/conf.h
@@ -33,7 +33,7 @@
#include "cw/vendors.h"
-extern struct mod_ac ** conf_mods;
+extern struct cw_Mod ** conf_mods;
#ifndef CONF_DEFAULT_ACNAME
#define CONF_DEFAULT_ACNAME "AC"
diff --git a/src/ac/db.c b/src/ac/db.c
index 1a403cda..9ab4f9bf 100644
--- a/src/ac/db.c
+++ b/src/ac/db.c
@@ -305,10 +305,10 @@ errX:
}
-
+// TODO XXXX
mavl_conststr_t db_get_update_tasks(struct conn * conn,const char * wtpid)
{
-
+/*
sqlite3_reset(get_tasks_stmt);
sqlite3_clear_bindings(get_tasks_stmt);
@@ -385,14 +385,14 @@ errX:
return NULL;
-
+*/
}
mavl_conststr_t db_get_radio_tasks(struct conn * conn,const char * wtpid)
{
-
+/*
//cw_dbg(DBG_X,"Get Radio Tasks for %s",wtpid);
sqlite3_reset(stmt_get_radio_tasks);
@@ -479,7 +479,7 @@ errX:
return NULL;
-
+*/
}
diff --git a/src/ac/wtpman.c b/src/ac/wtpman.c
index b4d49527..e0d6a04b 100644
--- a/src/ac/wtpman.c
+++ b/src/ac/wtpman.c
@@ -91,7 +91,7 @@ static void wtpman_run_discovery(void *arg)
extern cw_actionlist_in_t the_tree;
wtpman->conn->capwap_state = CAPWAP_STATE_DISCOVERY;
- wtpman->conn->actions = &capwap_actions;
+// wtpman->conn->actions = &capwap_actions;
wtpman->conn->outgoing = mbag_create();
wtpman->conn->incomming = mbag_create();
@@ -276,8 +276,12 @@ static void wtpman_image_data(struct wtpman *wtpman)
}
+
+// TODO XXXX
+
void props_to_sql(struct conn *conn, mbag_t mb, const char *mid)
{
+ /*
// XXX for the now we use just the IP adress as ID
char *wtp_id = sock_addr2str(&conn->addr);
@@ -327,6 +331,7 @@ void props_to_sql(struct conn *conn, mbag_t mb, const char *mid)
}
}
+ */
}
@@ -334,6 +339,8 @@ void props_to_sql(struct conn *conn, mbag_t mb, const char *mid)
void config_to_sql(struct conn *conn)
{
+
+/*
// XXX for the moment we use just the IP adress as ID
char *wtp_id = sock_addr2str(&conn->addr);
@@ -370,10 +377,13 @@ void config_to_sql(struct conn *conn)
}
}
+*/
}
void radio_to_sql(struct conn *conn, char *wtp_id, int rid, mbag_t radio)
{
+
+/*
MAVLITER_DEFINE(it, radio);
mavliter_foreach(&it) {
mbag_item_t *i = mavliter_get(&it);
@@ -408,7 +418,7 @@ void radio_to_sql(struct conn *conn, char *wtp_id, int rid, mbag_t radio)
// int rid = ((struct mbag_item*)mavliter_get(&it))->iid;
-
+*/
}
diff --git a/src/cw/Makefile b/src/cw/Makefile
index 03427153..fed02ce9 100644
--- a/src/cw/Makefile
+++ b/src/cw/Makefile
@@ -1,207 +1,16 @@
-include ../CapwapConfig.mak
+include ../CWConfig.mak
+-include ../Config.local.mak
include ../Macros.mak
-ifndef CC
- CC=gcc
-endif
-ifndef AR
- AR = ar
-endif
+LIBDIR := ../../lib
+LIBARCHDIR := $(LIBDIR)/$(ARCH)
+OBJDIR := ../../obj/cw/$(ARCH)
-#ifndef ARCH
-# ARCH = $(shell $(CC) -dumpmachine)
-#endif
+SNAME := $(LIBARCHDIR)/libcw.a
+DNAME := $(LIBARCHDIR)/libcw.so
-
-
-#OPENSSLINC=$(OPENSSLINC)
-#../contrib/openssl-1.0.1i/include
-
-NAME=libcw.a
-LIBDIR=../lib/$(ARCH)
-
-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 \
- 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=
ifeq ($(WITH_OPENSSL),1)
CFLAGS+=$(OPENSSL_CFLAGS)
@@ -211,6 +20,7 @@ DTLSOBJS += dtls_openssl.o \
dtls_openssl_connect.o \
dtls_openssl_get_cipher.o \
dtls_openssl_bio.o
+LIBS+=-lssl
endif
ifeq ($(WITH_GNUTLS),1)
@@ -222,145 +32,38 @@ DTLSOBJS+= dtls_gnutls.o \
dtls_gnutls_bio.o \
dtls_gnutls_get_cipher.o \
dtls_gnutls_get_peers_cert.o
+LIBS+=-lgnutls
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
+SRC=$(wildcard *.c)
+OBJS=$(patsubst %.c,%.o,$(SRC))
+OBJS:=$(patsubst %.o,$(OBJDIR)/%.o,$(OBJS))
-# 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 \
+all: $(SNAME) $(DNAME)
- #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)
-
-#include $(OBJS:.o=.d)
-
-O:=$(OBJS);
-
-OBJS:=$(patsubst %.o,$(ARCH)/%.o,$(OBJS))
-
-
-
-
-
-CFLAGS = -Wall -g -O0 -D_REENTRANT -DWITH_IPV6 -DWITH_RMAC_SUPPORT -I /usr/local/include -I../
-#CFLAGS = -Wall -Os -D_REENTRANT -DWITH_IPV6 -DWITH_RMAC_SUPPORT -I/usr/local/include
-
CFLAGS += $(GNUTLS_CFLAGS) \
-DWITH_CW_LOG \
-DWITH_CW_LOG_DEBUG \
- -DWITH_DTLS \
- $(XINCLUDE)\
- -I $(OPENSSLINC)\
- -Werror
+ -DWITH_DTLS
-
-
-#SRCS = $(OBJS:.o=.c)
-#MODOBJS=$(wildcard ./mod/cipwap/$(ARCH)/*.o)
-#MODOBJS+=$(wildcard ./mod/capwap/$(ARCH)/*.o)
-
-$(ARCH)/%.o:%.c
- @mkdir -p $(ARCH)
- @echo " CC "$<
+$(OBJDIR)/%.o:%.c
+ @mkdir -p $(OBJDIR)
+ @echo " $(CC) "$<
@$(CC) -c $(CFLAGS) $< -o $@
-# @$(CC) -MM $(CFLAGS) $< > $*.d
-$(LIBDIR)/$(NAME) : $(OBJS) $(MODOBJS)
- @mkdir -p $(LIBDIR)
- @echo " AR $(LIBDIR)/$(NAME)"
- @$(AR) rcs $(LIBDIR)/$(NAME) $(OBJS) $(MODOBJS)
+$(SNAME) : $(OBJS)
+ @mkdir -p $(LIBARCHDIR)
+ @echo " $(AR) $(SNAME)"
+ @$(AR) rcs $(SNAME) $(OBJS)
+
+$(DNAME) : $(OBJS)
+ @mkdir -p $(LIBARCHDIR)
+ @echo " $(LD) $(DNAME)"
+ @$(LD) $(LDFLAGS) -shared -o $(DNAME) $(OBJS) $(LIBS)
SRCS = $(OBJS:.o=.c)
@@ -370,19 +73,11 @@ DEPS := $(OBJS:.o=.d)
.PHONY: deps clean clean_libs libs
-# top-level rule, to compile everything.
-all: $(ARCH)/$(NAME)
-
-
-
-
clean:
- $(RM) $(ARCH)/*
- $(RM) $(LIBDIR)/$(NAME)
-# $(RM) $(OBJS)
-# $(RM) $(DEPS)
-# $(RM) $(ARCH)/$(NAME)
+ $(RM) $(OBJDIR)/*
+ $(RM) $(DNAME)
+ $(RM) $(SNAME)
clean_deps:
diff --git a/src/cw/acinfo_print.c b/src/cw/acinfo_print.c
deleted file mode 100644
index 5dbebf36..00000000
--- a/src/cw/acinfo_print.c
+++ /dev/null
@@ -1,78 +0,0 @@
-
-/**
- * @file
- * @breif defines acinfo_print function
- */
-
-#include
-#include
-
-#include "capwap.h"
-#include "sock.h"
-
-#include "acinfo.h"
-
-#include "cw_util.h"
-
-
-/**
- * Formats an acinfo object.
- *
- */
-int acinfo_print(char *str,const struct ac_info *acinfo)
-{
- char *s = str;
-
- s+=sprintf(s,"\tAC name: %s\n",acinfo->ac_name);
-
- s+=sprintf(s,"\tHardware version: ");
- s+=cw_format_version(s,acinfo->hardware_version,0,"-");
- s+=sprintf(s,"\n");
-
- s+=sprintf(s,"\tSoftware version: ");
- s+=cw_format_version(s,acinfo->software_version,0,"-");
- s+=sprintf(s,"\n");
-
- s+=sprintf(s,"\tStations: %i\n",acinfo->stations);
- s+=sprintf(s,"\tSation limit: %i\n",acinfo->limit);
- s+=sprintf(s,"\tActive WTPs: %i\n",acinfo->active_wtps);
- s+=sprintf(s,"\tMax WTPs: %i\n",acinfo->max_wtps);
- char help[64];
- sock_addrtostr((struct sockaddr*)&acinfo->local_ip,help,64);
- s+=sprintf(s,"\tLocal IP: %s\n",help);
- s+=sprintf(s,"\tECN support: %s\n",acinfo->ecn_support==0 ? "limited" : "full");
- s+=sprintf(s,"\tRMAC support: %s\n",acinfo->rmac==1 ? "supported" : "not supported");
-
-
- help[0]=0;
- if (acinfo->security & AC_SECURITY_S)
- strcpy(help,"psk");
- if (acinfo->security & AC_SECURITY_X){
- if (strlen(help))
- strcat(help,"/");
- strcat(help,"X.509");
- }
- if (!strlen(help))
- strcpy(help,"None");
- s+=sprintf(s,"\tSecurity: %s\n",help);
-
- help[0]=0;
-/* if (acinfo->dtls_policy & AC_DTLS_POLICY_D){
- strcpy(help,"dtls");
- }
- if (acinfo->dtls_policy & AC_DTLS_POLICY_C){
- if(strlen(help))
- strcat(help,"/");
- strcat(help,"clear");
- }
-*/ if (!strlen(help))
- strcpy(help,"Not set");
-
- s+=sprintf(s,"\tDTLS policy: %s\n",help);
-
-
- return s-str;
-}
-
-
-
diff --git a/src/cw/avliter_next.c b/src/cw/avliter_next.c
deleted file mode 100644
index 5e97f332..00000000
--- a/src/cw/avliter_next.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- This file is part of libcapwap.
-
- libcapwap is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- libcapwap is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Foobar. If not, see .
-
-*/
-
-/**
- *@file
- *@brief Implementation of avliter_next
- */
-
-#include "avltree.h"
-
-/**
- * Get the next element within an AVL Tree.
- * @param i pointer to AVL Iterator
- * @return the element or NULL if there is no next elemeent.
- */
-void * avliter_next(avliter_t *i)
-{
-
- while ( i->stack_ptr) {
- i->stack_ptr--;
- i->cur=i->stack[i->stack_ptr];
-
- if (!i->cur)
- continue;
-
- if ((i->stack_ptr)&1) {
- return i->cur->data;
- }
- break;
-
- }
-
-
- if (!i->cur){
- return NULL;
- }
-
- while(i->cur->left) {
- /* push right branch */
- i->stack[i->stack_ptr++]=i->cur->right;
-
- /* push node */
- i->stack[i->stack_ptr++]=i->cur;
-
- i->cur=i->cur->left;
-
- }
-
- i->stack[i->stack_ptr++]=i->cur->right;
-
- return i->cur->data;
-}
-
-
diff --git a/src/cw/avliter_seek.c b/src/cw/avliter_seek.c
deleted file mode 100644
index d84b600e..00000000
--- a/src/cw/avliter_seek.c
+++ /dev/null
@@ -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 .
-
-*/
-
-/**
- *@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;
-}
-
-
diff --git a/src/cw/avltree_foreach.c b/src/cw/avltree_foreach.c
deleted file mode 100644
index 795e7b77..00000000
--- a/src/cw/avltree_foreach.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- This file is part of libcapwap.
-
- libcapwap is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- libcapwap is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Foobar. If not, see .
-
-*/
-
-#include "avltree.h"
-
-int avltree_foreach_rl(struct avlnode *n, int (*callback)(void *,void *),void *cbpriv)
-{
- if (!n)
- return 1;
- if (!avltree_foreach_rl(n->right,callback,cbpriv))
- return 0;
- if (!callback(cbpriv,n->data))
- return 0;
- return avltree_foreach_rl(n->left,callback,cbpriv);
-}
-
-void avltree_foreach(struct avltree *t, int (*callback)(void *,void *),void * cbpriv,int dir)
-{
- if (dir)
- avltree_foreach_lr(t->root,callback,cbpriv);
- else
- avltree_foreach_rl(t->root,callback,cbpriv);
-}
-
diff --git a/src/cw/avltree_foreach_from_lr.c b/src/cw/avltree_foreach_from_lr.c
deleted file mode 100644
index f5d4cb22..00000000
--- a/src/cw/avltree_foreach_from_lr.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "avltree.h"
-
-
-// XXX Function is buggy
-
-int avltree_foreach_from_lr(struct avltree *t, struct avlnode *n, void *data,int (*callback)(void *,void *),void *cbpriv)
-{
- if (!n)
- return 1;
-
- int rc=t->cmp(data,n->data);
- if (rc<0){
- if(!avltree_foreach_from_lr(t,n->left,data,callback,cbpriv))
- return 0;
- if (!callback(cbpriv,n->data))
- return 0;
- return avltree_foreach_lr(n->right,callback,cbpriv);
- }
-
- if (rc>0) {
- avltree_foreach_from_lr(t,n->right,data,callback,cbpriv);
- return 0;
- }
-
- if (!callback(cbpriv,n->data))
- return 0;
-
- return avltree_foreach_lr(n->right,callback,cbpriv);
-}
-
-
diff --git a/src/cw/avltree_foreach_lr.c b/src/cw/avltree_foreach_lr.c
deleted file mode 100644
index 599d7bd0..00000000
--- a/src/cw/avltree_foreach_lr.c
+++ /dev/null
@@ -1,17 +0,0 @@
-#include "avltree.h"
-
-
-
-int avltree_foreach_lr(struct avlnode *n, int (*callback)(void *,void *),void *cbpriv)
-{
- if (!n)
- return 1;
- if (!avltree_foreach_lr(n->left,callback,cbpriv))
- return 0;
- if (!callback(cbpriv,n->data))
- return 0;
- return avltree_foreach_lr(n->right,callback,cbpriv);
-
-}
-
-
diff --git a/src/cw/avltree_foreach_node.c b/src/cw/avltree_foreach_node.c
deleted file mode 100644
index 5e0ada87..00000000
--- a/src/cw/avltree_foreach_node.c
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-int avltree_foreach_lr_node(struct avltree *t, struct avlnode *n, void *data,int (*callback)(void *,void *),void *cbpriv)
-{
- if (!n)
- return 1;
-
- int rc=t->cmp(data,n->data);
- if (rc<0){
- avltree_foreach_lr_node(t,n->left,data,callback,cbpriv);
- callback(cbpriv,n->data);
- avltree_foreach_lr(n->right,
- return 0;
- }
-
- if (rc>0) {
- avltree_foreach_lr_node(t,n->right,data,callback,cbpriv);
- return 0;
- }
-
- return callback(cbpriv,n->data);
-
-
-
-
-}
-
-
-int avltree_foreach_2(struct avltree *t,void *data,int (*callback)(void *,void *),void *cbpriv)
-{
-
-}
diff --git a/src/cw/avltree_foreach_rl.c b/src/cw/avltree_foreach_rl.c
deleted file mode 100644
index 7ee82a8f..00000000
--- a/src/cw/avltree_foreach_rl.c
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-#include "avltree.h"
-
-int avltree_foreach_rl(struct avlnode *n, int (*callback)(void *,void *),void *cbpriv)
-{
- if (!n)
- return 1;
- if (!avltree_foreach_rl(n->right,callback,cbpriv))
- return 0;
- if (!callback(cbpriv,n->data))
- return 0;
- return avltree_foreach_rl(n->left,callback,cbpriv);
-}
-
-
diff --git a/src/cw/avltree_get.c b/src/cw/avltree_get.c
deleted file mode 100644
index 62950050..00000000
--- a/src/cw/avltree_get.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- This file is part of libcapwap.
-
- libcapwap is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- libcapwap is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Foobar. If not, see .
-*/
-
-/**
- * @file
- * @brief Implementation of avltree_get
- */
-
-#include
-
-#include "avltree.h"
-
-/**
- * Get an AVL tree element.
- * @param data Element to get
- * @return pointer to element or NULL if not found.
- */
-void * avltree_get(struct avltree *t ,void *data)
-{
- struct avlnode *n = t->root;
- while(n){
- int rc=t->cmp(data,n->data);
- if (rc==0)
- return n->data;
- if (rc<0)
- n=n->left;
- else
- n=n->right;
- }
- return NULL;
-}
-
-
diff --git a/src/cw/avltree_get_node.c b/src/cw/avltree_get_node.c
deleted file mode 100644
index 8d3d3ff5..00000000
--- a/src/cw/avltree_get_node.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- This file is part of libcapwap.
-
- libcapwap is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- libcapwap is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Foobar. If not, see .
-
-*/
-
-
-#include
-
-#include "avltree.h"
-
-
-struct avlnode * avltree_get_node(struct avltree *t ,void *data)
-{
- struct avlnode *n = t->root;
- while(n){
- int rc=t->cmp(data,n->data);
- if (rc==0)
- return n;
- if (rc<0)
- n=n->left;
- else
- n=n->right;
- }
- return NULL;
-}
-
diff --git a/src/cw/bstr.h b/src/cw/bstr.h
index 779656b4..3351a3db 100644
--- a/src/cw/bstr.h
+++ b/src/cw/bstr.h
@@ -130,16 +130,7 @@ static inline int bstr16_ncpy(uint8_t *dst,uint8_t*src,uint16_t len)
*/
-static inline uint8_t * bstr16_create(const uint8_t *data, uint16_t len)
-{
- uint8_t * str = malloc(2+len*sizeof(uint8_t));
- if (!str)
- return 0;
- *((uint16_t*)str)=len;
- memcpy(str+2,data,len);
- return str;
-}
-
+extern uint8_t * bstr16_create(const uint8_t *data, uint16_t len);
uint8_t * bstr16_create_from_str(const char *s);
extern uint8_t * bstr16_create_from_cfgstr(const char * s);
@@ -182,25 +173,10 @@ typedef uint8_t * bstrv_t;
(1+6+(n)*sizeof(uint8_t))
-static inline uint8_t * bstrv_create(uint32_t vendor_id, uint8_t *data, uint8_t len)
-{
- uint8_t * str = malloc(bstrv_size(len));
- if (!str)
- return 0;
-
- bstrv_set_vendor_id(str,vendor_id);
- bstrv_set_len(str,len);
- memcpy(bstrv_data(str),data,len);
- *(bstrv_data(str)+bstrv_len(str))=0;
- return str;
-
-}
-
uint8_t * bstrv_create_from_str(uint32_t vendor_id,const char *s);
+uint8_t * bstrv_create(uint32_t vendor_id, uint8_t *data, uint8_t len);
-//uint8_t * bstr16cfgstr(const char * s);
-
#endif
diff --git a/src/cw/bstr16_create.c b/src/cw/bstr16_create.c
new file mode 100644
index 00000000..4738e1b1
--- /dev/null
+++ b/src/cw/bstr16_create.c
@@ -0,0 +1,13 @@
+#include "bstr.h"
+
+uint8_t * bstr16_create(const uint8_t *data, uint16_t len)
+{
+ uint8_t * str = malloc(2+len*sizeof(uint8_t));
+ if (!str)
+ return 0;
+ *((uint16_t*)str)=len;
+ memcpy(str+2,data,len);
+ return str;
+}
+
+
diff --git a/src/cw/bstrv_create.c b/src/cw/bstrv_create.c
new file mode 100644
index 00000000..17bdadc3
--- /dev/null
+++ b/src/cw/bstrv_create.c
@@ -0,0 +1,17 @@
+#include "bstr.h"
+
+uint8_t * bstrv_create(uint32_t vendor_id, uint8_t *data, uint8_t len)
+{
+ uint8_t * str = malloc(bstrv_size(len));
+ if (!str)
+ return 0;
+
+ bstrv_set_vendor_id(str,vendor_id);
+ bstrv_set_len(str,len);
+ memcpy(bstrv_data(str),data,len);
+ *(bstrv_data(str)+bstrv_len(str))=0;
+ return str;
+
+}
+
+
diff --git a/src/cw/capwap.h b/src/cw/capwap.h
index 07ba9e48..7fe05790 100644
--- a/src/cw/capwap.h
+++ b/src/cw/capwap.h
@@ -499,7 +499,7 @@ enum cw_reboot_failure_types {
17 Image Data Error (Image Already Present)
*/
-#define CW_RESULT_MSG_INVALID_IN_CURRENT_STATE 18
+#define CAPWAP_RESULT_MSG_INVALID_IN_CURRENT_STATE 18
#define CW_RESULT_MSG_UNRECOGNIZED 19
#define CW_RESULT_MISSING_MAND_ELEM 20
diff --git a/src/cw/capwap_80211_actions.h b/src/cw/capwap_80211_actions.h
deleted file mode 100644
index 09bbfa99..00000000
--- a/src/cw/capwap_80211_actions.h
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-#include "capwap80211.h"
-#include "capwap_items.h"
-
-#define CW_ACTION_IN_80211_WTP_RADIO_INFORMATION \
- CW_ELEM80211_WTP_RADIO_INFORMATION, /* Element ID*/ \
- cw_in_radio_generic, 0, /* start/end callback */ \
- MBAG_DWORD, /* Type of element */ \
- CW_ITEM_LOCATION_DATA, /* ID to use store */ \
- 5, 5 /* min/max length */
-
-
diff --git a/src/cw/capwap_80211_actions_ac.c b/src/cw/capwap_80211_actions_ac.c
deleted file mode 100644
index 5f66d457..00000000
--- a/src/cw/capwap_80211_actions_ac.c
+++ /dev/null
@@ -1,65 +0,0 @@
-
-
-#include "action.h"
-#include "capwap_80211_actions.h"
-#include "capwap80211.h"
-#include "capwap.h"
-
-
-
-
-
-
-cw_action_in_t capwap_80211_actions_ac_in[] = {
-
- /* --------------------------------------------------------
- * Discovery Resquest
- */
-
- {0, 0, CAPWAP_STATE_DISCOVERY, CAPWAP_MSG_DISCOVERY_REQUEST,
- CW_ACTION_IN_80211_WTP_RADIO_INFORMATION, 1}
- ,
- /* --------------------------------------------------------
- * Discovery Resquest
- */
-
- {0, 0, CW_STATE_JOIN, CAPWAP_MSG_JOIN_REQUEST,
- CW_ACTION_IN_80211_WTP_RADIO_INFORMATION, 1}
- ,
-
-
-
- {0, 0, 0}
-};
-
-
-cw_action_out_t capwap_80211_actions_ac_out[]={
- /* Radio Infos */
- {CAPWAP_MSG_DISCOVERY_RESPONSE, NULL /*CW_ELEM80211_WTP_RADIO_INFORMATION*/, 0,
- CW_ELEM80211_WTP_RADIO_INFORMATION, NULL,cw_out_radio_infos, NULL,1}
- ,
-
- /* Radio Infos */
- {CAPWAP_MSG_JOIN_RESPONSE, NULL /*CW_ELEM80211_WTP_RADIO_INFORMATION*/, 0,
- CW_ELEM80211_WTP_RADIO_INFORMATION, NULL,cw_out_radio_infos, NULL,1}
- ,
-
- {0,0,0}
-};
-
-
-int cw_register_actions_capwap_80211_ac(struct cw_actiondef *def)
-{
-
- int rc;
- rc=cw_actionlist_in_register_actions(def->in, capwap_80211_actions_ac_in);
- rc+=cw_actionlist_out_register_actions(def->out, capwap_80211_actions_ac_out);
-
- rc+= cw_strheap_register_strings(def->strelem, capwap_strings_elem80211);
- /*rc += cw_strheap_register_strings(def->strelem, capwap_strings_elem);
-*/
-
-
- return rc;
-}
-
diff --git a/src/cw/capwap_80211_actions_wtp.c b/src/cw/capwap_80211_actions_wtp.c
deleted file mode 100644
index fdc7147b..00000000
--- a/src/cw/capwap_80211_actions_wtp.c
+++ /dev/null
@@ -1,64 +0,0 @@
-
-
-#include "action.h"
-#include "capwap_80211_actions.h"
-#include "capwap80211.h"
-#include "capwap.h"
-
-
-
-
-
-
-cw_action_in_t capwap_80211_actions_wtp_in[] = {
-
- /* Discovery Response */
- {0, 0, CAPWAP_STATE_DISCOVERY, CAPWAP_MSG_DISCOVERY_RESPONSE,
- CW_ACTION_IN_80211_WTP_RADIO_INFORMATION, 1}
- ,
-
- /* Join Response */
- {0, 0, CW_STATE_JOIN, CAPWAP_MSG_JOIN_RESPONSE,
- CW_ACTION_IN_80211_WTP_RADIO_INFORMATION, 1}
- ,
-
-
- {0, 0, 0}
-};
-
-
-cw_action_out_t capwap_80211_actions_wtp_out[]={
-
- /* --------------------------------------------------------
- * Discovery Resquest
- */
-
- /* 802.11 Radio Information */
- {CAPWAP_MSG_DISCOVERY_REQUEST, CW_ITEM_RADIO_INFOS /*CW_ELEM80211_WTP_RADIO_INFORMATION*/, 0,
- CW_ELEM80211_WTP_RADIO_INFORMATION, NULL,cw_out_radio_infos, NULL,1}
- ,
-
- /* --------------------------------------------------------
- * Join Resquest
- */
-
- /* 802.11 Radio Information */
- {CAPWAP_MSG_JOIN_REQUEST, CW_ITEM_RADIO_INFOS, 0,
- CW_ELEM80211_WTP_RADIO_INFORMATION, NULL,cw_out_radio_infos, NULL,1},
-
-
- {0,0,0}
-
-
-};
-
-
-int cw_register_actions_capwap_80211_wtp(struct cw_actiondef *def)
-{
- int rc;
- rc=cw_actionlist_in_register_actions(def->in, capwap_80211_actions_wtp_in);
- rc+=cw_actionlist_out_register_actions(def->out, capwap_80211_actions_wtp_out);
- rc+=cw_strheap_register_strings(def->strelem, capwap_strings_elem80211);
- return rc;
-}
-
diff --git a/src/cw/capwap_strings_item.c b/src/cw/capwap_strings_item.c
deleted file mode 100644
index e70e2a39..00000000
--- a/src/cw/capwap_strings_item.c
+++ /dev/null
@@ -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"}
-
-}
diff --git a/src/cw/capwap_strings_result.c b/src/cw/capwap_strings_result.c
index fe143e19..8f9eeebd 100644
--- a/src/cw/capwap_strings_result.c
+++ b/src/cw/capwap_strings_result.c
@@ -9,7 +9,7 @@ struct cw_strlist_elem capwap_strings_result[] = {
{CW_RESULT_RESET_UNABLE_TO_RESET,"Reset Failure - Unable to Reset"}, /* 10 */
{CW_RESULT_IMAGE_DATA_INVALID_CHECKSUM,"Image Data Error (Invalid Checksum)"}, /* 14 */
{CW_RESULT_IMAGE_DATA_ERROR,"Image Data Error (Unspecified)"}, /* 16 */
- {CW_RESULT_MSG_INVALID_IN_CURRENT_STATE,"Message unexpected (Invalid in current state)"}, /* 18 */
+ {CAPWAP_RESULT_MSG_INVALID_IN_CURRENT_STATE,"Message unexpected (Invalid in current state)"}, /* 18 */
{CW_RESULT_MISSING_MAND_ELEM,"Missing Mandatory Message Element"}, /* 20 */
{CW_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT,"Unrecognized Message Element"}, /* 21 */
{CW_STR_STOP,"Unknown Result Code"}
diff --git a/src/cw/conn.h b/src/cw/conn.h
index 4a1c9fda..137aa4ca 100644
--- a/src/cw/conn.h
+++ b/src/cw/conn.h
@@ -96,7 +96,9 @@ struct conn {
/** Actionsdefs - this defines the possible actions for
this conn object, so in the end this is the specification
of the protocoll */
- struct cw_actiondef *actions;
+// struct cw_actiondef *actions;
+
+ struct cw_MsgSet * msgset;
/** Current CAPWAP state */
diff --git a/src/cw/conn_detect_capwap.c b/src/cw/conn_detect_capwap.c
deleted file mode 100644
index 99d122d1..00000000
--- a/src/cw/conn_detect_capwap.c
+++ /dev/null
@@ -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 .
-
-*/
-
-#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;
-
-}
diff --git a/src/cw/conn_get_message.c b/src/cw/conn_get_message.c
deleted file mode 100644
index ad3e25e6..00000000
--- a/src/cw/conn_get_message.c
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-#include
-#include
-#include
-
-#include "conn.h"
-#include "cwrmsg.h"
-#include "cw_log.h"
-#include "capwap.h"
-#include "sock.h"
-#include "cw_util.h"
-
-struct args {
- struct conn *conn;
- struct cwrmsg *cwrmsg;
-};
-
-static int message_cb(void *p, uint8_t *rawmsg, int len)
-{
- struct args *args = (struct args *) p;
- struct conn *conn = args->conn;
- memcpy(conn->cwrmsg_buffer, rawmsg, len);
-
-/*
-
- memcpy(&conn->cwrmsg, cwrmsg, sizeof(struct cwrmsg));
- conn->cwrmsg.msgelems = conn->cwrmsg_buffer;
-*/
- args->cwrmsg = &conn->cwrmsg;
- return 0;
-}
-
-
-int conn_msg_processor(struct conn *conn)
-{
- uint8_t buf[2024];
- int len = 2024;
-
- int n = conn->read(conn, buf, len);
- if (n<0 )
- return n;
-
- if (n > 0)
- conn_process_packet(conn, buf, n, cw_process_msg, conn);
-
-}
-
-
-
-
-uint8_t *conn_get_message(struct conn *conn)
-{
- struct args args;
- args.cwrmsg = 0;
- args.conn = conn;
- uint8_t buf[2024];
- int len = 2024;
-
- int n = conn->read(conn, buf, len);
- if (n > 0)
- conn_process_packet(conn, buf, n, message_cb, &args);
-
-
- if (args.cwrmsg) {
- cw_dbg(DBG_MSG,"Message recieved from %s",sock_addr2str(&conn->addr));
-/*
- cw_dbg(DBG_MSG,
- "Received message from %s, type=%d - %s, seq=%d",
- sock_addr2str(&conn->addr), args.cwrmsg->type,
- cw_msgtostr(args.cwrmsg->type),
- args.cwrmsg->seqnum);
-
-*/
- }
-
- return conn->cwrmsg_buffer;
-}
diff --git a/src/cw/conn_get_response.c b/src/cw/conn_get_response.c
deleted file mode 100644
index 388ebdd2..00000000
--- a/src/cw/conn_get_response.c
+++ /dev/null
@@ -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; imax_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;
-
-}
diff --git a/src/cw/conn_prepare_configuration_update_request.c b/src/cw/conn_prepare_configuration_update_request.c
deleted file mode 100644
index 768b646d..00000000
--- a/src/cw/conn_prepare_configuration_update_request.c
+++ /dev/null
@@ -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);
-}
diff --git a/src/cw/conn_prepare_image_data_request.c b/src/cw/conn_prepare_image_data_request.c
index 39fadd98..0b6d88de 100644
--- a/src/cw/conn_prepare_image_data_request.c
+++ b/src/cw/conn_prepare_image_data_request.c
@@ -19,7 +19,7 @@
#include "capwap.h"
#include "lwapp.h"
-
+/*
int conn_prepare_image_data_request(struct conn *conn, struct cwimage_data *data,
struct image_identifier *id)
@@ -33,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) {
uint8_t type = 3;
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,
&data->type, sizeof(data->type),
@@ -57,3 +57,5 @@ int conn_prepare_image_data_request(struct conn *conn, struct cwimage_data *data
return 0;
}
+
+*/
diff --git a/src/cw/conn_prepare_request.c b/src/cw/conn_prepare_request.c
deleted file mode 100644
index 165abeb0..00000000
--- a/src/cw/conn_prepare_request.c
+++ /dev/null
@@ -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;
-}
diff --git a/src/cw/conn_process_packet.c b/src/cw/conn_process_packet.c
index ffea24a8..1d039ca8 100644
--- a/src/cw/conn_process_packet.c
+++ b/src/cw/conn_process_packet.c
@@ -32,7 +32,7 @@
#include "stravltree.h"
#include "mod.h"
-
+#include "message_set.h"
int conn_send_msg(struct conn *conn, uint8_t * rawmsg);
@@ -151,7 +151,7 @@ static int check_len(struct conn *conn, struct cw_action_in *a, uint8_t * data,
if (!a->max_len)
return 1;
- if (len < a->min_len) {
+/* if (len < a->min_len) {
cw_dbg(DBG_ELEM_ERR,
"%d (%s) message element too short, len=%d, min len=%d",
a->elem_id, cw_strelemp(conn->actions, a->elem_id), len,
@@ -164,81 +164,35 @@ static int check_len(struct conn *conn, struct cw_action_in *a, uint8_t * data,
cw_strelemp(conn->actions, a->elem_id), len, a->max_len);
return 0;
}
-
+*/
return 1;
}
-static struct mod_ac *detect_mod(struct conn *conn, uint8_t * rawmsg, int len,
- int elems_len, struct sockaddr *from, int mode)
-{
- if (conn->mods) {
- struct mod_ac **mods = (struct mod_ac **) conn->mods;
- int i;
- for (i = 0; mods[i]; i++) {
- if (mods[i]->detect) {
- if (mods[i]->detect
- (conn, rawmsg, len, elems_len, from, mode)) {
- return mods[i];
- }
- }
- }
- }
-
- return MOD_NULL;
-}
-
-static struct cw_actiondef *load_mods(struct conn *conn, uint8_t * rawmsg, int len,
+static struct cw_MsgSet *load_msg_set(struct conn *conn, uint8_t * rawmsg, int len,
int elems_len, struct sockaddr *from)
{
- struct mod_ac *cmod =
- detect_mod(conn, rawmsg, len, elems_len, from, MOD_MODE_CAPWAP);
+ struct cw_Mod *cmod =
+ cw_mod_detect(conn, rawmsg, len, elems_len, from, CW_MOD_MODE_CAPWAP);
if (cmod == MOD_NULL) {
cw_dbg(DBG_MSG_ERR,
- "Can't find mod to handle connection from %s , discarding message",
+ "Can't find mod to handle connection from %s, discarding message",
sock_addr2str_p(from));
return NULL;
}
- struct mod_ac *bmod =
- detect_mod(conn, rawmsg, len, elems_len, from, MOD_MODE_BINDINGS);
+ struct cw_Mod *bmod =
+ cw_mod_detect(conn, rawmsg, len, elems_len, from, MOD_MODE_BINDINGS);
cw_dbg(DBG_INFO, "Mods deteced: %s,%s", cmod->name, bmod->name);
- struct cw_actiondef *ad = mod_cache_add(conn,cmod, bmod);
-
- return ad;
+// struct cw_actiondef *ad = mod_cache_add(conn,cmod, bmod);
+ struct cw_MsgSet * set = cw_mod_get_msg_set(conn,cmod,bmod);
-
-/*
- if (bindins_mod) {
- cw_dbg(DBG_INFO, "Using mod '%s' to handle CAWPAP for %s", mod->name,
- sock_addr2str_p(from));
- conn->detected=1;
- }
- else{
-// errno = EAGAIN;
-// return -1;
- }
-
-
- mod = detect_mod(conn, rawmsg, len, elems_len, from, MOD_DETECT_BINDINGS);
- if (mod) {
- cw_dbg(DBG_INFO, "Using bindings '%s' to handle %s", mod->name,
- sock_addr2str_p(from));
- conn->detected=1;
- }
- else{
- cw_dbg(DBG_MSG_ERR, "Can't detect bindings ... for %s",
- sock_addr2str_p(from));
- }
-
-
- return 0;
- */
+ return set;
}
int cw_in_check_generic(struct conn *conn, struct cw_action_in *a, uint8_t * data,
@@ -295,33 +249,47 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
}
}
-
+
if (!conn->detected) {
//struct mod_ac *mod;
- struct cw_actiondef *ad = load_mods(conn, rawmsg, len, elems_len, from);
- if (!ad) {
- cw_log(LOG_ERR, "Error");
+ struct cw_MsgSet *set = load_msg_set(conn, rawmsg, len, elems_len, from);
+
+
+ if (!set) {
+ //cw_log(LOG_ERR, "Error");
errno = EAGAIN;
return -1;
}
- conn->actions = ad;
+
+ conn->msgset= set;
+// conn->actions = ad;
conn->detected = 1;
+ }
+ cw_dbg_msg(DBG_MSG_IN, conn, rawmsg, len, from);
+
+ /* prepare struct for search operation */
+ struct cw_MsgData search;
+ search.type = cw_get_msg_id(msg_ptr);
+ struct cw_MsgData * message;
+ /* Search for message combination */
+ message = mavl_get(conn->msgset->messages,&search);
+
+ int result_code = 0;
+ if (!message){
+ /* Message is unknown */
+ cw_dbg(DBG_MSG_ERR, "Message type %d (%s) unknown.",
+ search.type, cw_strmsg(search.type),
+ cw_strstate(conn->capwap_state));
+ result_code = CW_RESULT_MSG_UNRECOGNIZED;
+ cw_send_error_response(conn, rawmsg, result_code);
+ errno = EAGAIN;
+ return -1;
}
-
- /* prepare struct for search operation */
- as.capwap_state = conn->capwap_state;
- as.msg_id = cw_get_msg_id(msg_ptr);
- as.vendor_id = 0;
- as.elem_id = 0;
- as.proto = 0;
-
-
- /* Search for state/message combination */
- afm = cw_actionlist_in_get(conn->actions->in, &as);
+// afm = cw_actionlist_in_get(conn->actions->in, &as);
if (!afm) {
/* Throw away unexpected response messages */
@@ -336,14 +304,16 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
/* Request message not found in current state, check if we know
anything else about this message type */
- const char *str = cw_strheap_get(conn->actions->strmsg, as.msg_id);
+ // TODO XXXX
+ //const char *str = cw_strheap_get(conn->actions->strmsg, as.msg_id);
+ const char *str = 0;
int result_code = 0;
if (str) {
/* Message found, but it was in wrong state */
cw_dbg(DBG_MSG_ERR,
"Message type %d (%s) not allowed in %s State.", as.msg_id,
cw_strmsg(as.msg_id), cw_strstate(as.capwap_state));
- result_code = CW_RESULT_MSG_INVALID_IN_CURRENT_STATE;
+ result_code = CAPWAP_RESULT_MSG_INVALID_IN_CURRENT_STATE;
} else {
/* Message is unknown */
cw_dbg(DBG_MSG_ERR, "Message type %d (%s) unknown.",
@@ -381,15 +351,18 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
as.elem_id = cw_get_elem_id(elem);
int elem_len = cw_get_elem_len(elem);
-
- af = cw_actionlist_in_get(conn->actions->in, &as);
+ // TODO XXX
+// af = cw_actionlist_in_get(conn->actions->in, &as);
+ af = 0;
if (!af) {
unrecognized++;
- cw_dbg(DBG_ELEM_ERR,
+ // TOOO XXXX
+/* cw_dbg(DBG_ELEM_ERR,
"Element %d (%s) not allowed in msg of type %d (%s), ignoring.",
as.elem_id, cw_strelemp(conn->actions, as.elem_id),
as.msg_id, cw_strmsg(as.msg_id));
+*/
continue;
}
@@ -415,7 +388,8 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
}
if(conn->elem_end){
- afrc = conn->elem_end(conn,af,afrc,cw_get_elem_data(elem), elem_len,from);
+ // TODO XXXX
+// afrc = conn->elem_end(conn,af,afrc,cw_get_elem_data(elem), elem_len,from);
}
}
@@ -423,7 +397,7 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
/* all message elements are processed, do now after processing
by calling the "end" function for the message */
- int result_code = 0;
+ //int result_code = 0;
@@ -496,7 +470,6 @@ int process_message(struct conn *conn, uint8_t * rawmsg, int rawlen,
{
-
uint8_t *msgptr = rawmsg + cw_get_hdr_msg_offset(rawmsg);
@@ -638,7 +611,7 @@ int conn_process_packet2(struct conn *conn, uint8_t * packet, int len,
cw_dbg_pkt(DBG_PKT_IN, conn, f + 4, *(uint32_t *) f, from);
- cw_dbg_msg(DBG_MSG_IN, conn, f + 4, *(uint32_t *) f, from);
+// cw_dbg_msg(DBG_MSG_IN, conn, f + 4, *(uint32_t *) f, from);
// XXX: Modify fragman to not throw away CAPWAP headers
@@ -649,7 +622,7 @@ int conn_process_packet2(struct conn *conn, uint8_t * packet, int len,
}
/* not fragmented, we have a complete message */
- cw_dbg_msg(DBG_MSG_IN, conn, packet, len, from);
+// cw_dbg_msg(DBG_MSG_IN, conn, packet, len, from);
return conn->process_message(conn, packet, len, from);
}
diff --git a/src/cw/conn_send_request.c b/src/cw/conn_send_request.c
index 48bc426b..634766a5 100644
--- a/src/cw/conn_send_request.c
+++ b/src/cw/conn_send_request.c
@@ -23,7 +23,7 @@
#include "capwap.h"
#include "cw_util.h"
-#include "cw_log.h"
+#include "log.h"
/**
* Send a request message and wait for its response
@@ -32,6 +32,9 @@
* The message has to be prepared and put to conn->req_msg
*
*/
+
+
+/*
struct cwrmsg * conn_send_request(struct conn * conn)
{
int i;
@@ -58,4 +61,4 @@ struct cwrmsg * conn_send_request(struct conn * conn)
cw_dbg(DBG_MSG_ERR,"Max retransmit's reached, message type=%d,seq=%d",cwmsg->type,cwmsg->seqnum);
return 0;
}
-
+*/
diff --git a/src/cw/conn_wait_for_message.c b/src/cw/conn_wait_for_message.c
deleted file mode 100644
index 7c00aa95..00000000
--- a/src/cw/conn_wait_for_message.c
+++ /dev/null
@@ -1,37 +0,0 @@
-
-#include "conn.h"
-#include "cw_util.h"
-
-
-struct cwrmsg * conn_wait_for_message(struct conn * conn, time_t timer)
-{
- struct cwrmsg * cwrmsg;
-
-
- while (!cw_timer_timeout(timer)){
- cwrmsg = conn_get_message(conn);
-
- if (!cwrmsg){
- if (!conn_is_error(conn))
- continue;
-
- return 0;
- }
-
- if (cwrmsg->type & 1){
- if (conn->request_handler){
- if (conn->request_handler(conn->request_handler_param))
- continue;
- }
-
-
- }
-
- return cwrmsg;
-
- }
-
- return 0;
-}
-
-
diff --git a/src/cw/conn_wait_for_request.c b/src/cw/conn_wait_for_request.c
deleted file mode 100644
index 8ab206f9..00000000
--- a/src/cw/conn_wait_for_request.c
+++ /dev/null
@@ -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;
-}
-
diff --git a/src/cw/connlist.h b/src/cw/connlist.h
index 9e05a423..f2ac2d6f 100644
--- a/src/cw/connlist.h
+++ b/src/cw/connlist.h
@@ -4,6 +4,7 @@
#include "conn.h"
#include "mavl.h"
+#include "pthread.h"
struct connlist {
/* struct conn ** connlist; */
diff --git a/src/cw/cw.h b/src/cw/cw.h
index fbb85509..1910f9d4 100644
--- a/src/cw/cw.h
+++ b/src/cw/cw.h
@@ -120,10 +120,12 @@ typedef struct {
}cw_elem_handler_t;
-typedef struct {
+struct cw_MsgSet {
mavl_t messages;
mavl_t all_elems;
-}cw_message_set_t;
+};
+
+typedef struct cw_MsgSet cw_MsgSet_t;
typedef struct{
cw_elem_handler_t * elem;
@@ -131,12 +133,13 @@ typedef struct{
int op;
}cw_msgelemprops_t;
-typedef struct {
+struct cw_MsgDef{
int type;
int * states;
cw_msgelemprops_t * elements;
const char * name;
-}cw_msgdef_t;
+};
+typedef struct cw_MsgDef cw_msgdef_t;
/**
* Get length wireless specific data
diff --git a/src/cw/cw_addelem_capwap_local_ip_addr.c b/src/cw/cw_addelem_capwap_local_ip_addr.c
index deeb0b1a..a871193b 100644
--- a/src/cw/cw_addelem_capwap_local_ip_addr.c
+++ b/src/cw/cw_addelem_capwap_local_ip_addr.c
@@ -27,6 +27,7 @@
#include "cwmsg.h"
#include "conn.h"
+/*
uint8_t * cw_addelem(uint8_t * buf,int type, uint8_t *elem, int len)
{
@@ -76,4 +77,4 @@ void cw_addelem_capwap_local_ip_addr(struct cwmsg *msg, int sock, int cw_mode)
}
-
+*/
diff --git a/src/cw/cw_addelem_vendor_specific_payload.c b/src/cw/cw_addelem_vendor_specific_payload.c
deleted file mode 100644
index a6ea93e8..00000000
--- a/src/cw/cw_addelem_vendor_specific_payload.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- This file is part of libcapwap.
-
- libcapwap is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- libcapwap is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Foobar. If not, see .
-
-*/
-
-
-/**
- *@file
- *@brief cw_addelem_vendor_specific_payload
- */
-
-#include "capwap.h"
-
-/**
- * Add a Vendor Specific Payload message element to a buffer
- * @param dst destination buffer
- * @param vendor_id the vendor id
- * @param type vendor specific message type
- * @data pointer to data the will be put
- * @len length of data
- */
-int cw_addelem_vendor_specific_payload(uint8_t * dst, uint32_t vendor_id,
- uint16_t type, uint8_t * data, uint16_t len)
-{
- uint8_t *d = dst + 4;
-
- d += cw_put_dword(d, vendor_id);
- d += cw_put_word(d, type);
- d += cw_put_data(d, data, len);
-
- int l = d - dst;
- cw_put_elem_hdr(dst, CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD, l - 4);
- return l;
-
-}
diff --git a/src/cw/cw_check_missing_mand.c b/src/cw/cw_check_missing_mand.c
index 0bb68e53..846357fa 100644
--- a/src/cw/cw_check_missing_mand.c
+++ b/src/cw/cw_check_missing_mand.c
@@ -13,7 +13,8 @@ int cw_check_missing_mand(cw_action_in_t ** out, struct conn * conn, cw_action_i
as.vendor_id = 0;
as.elem_id = 0;
as.proto=0;
-
+/// TODO XXXX
+/*
DEFINE_AVLITER(it,conn->actions->in);
int n=0;
avliter_foreach_from(&it,&as) {
@@ -30,7 +31,8 @@ int cw_check_missing_mand(cw_action_in_t ** out, struct conn * conn, cw_action_i
}
}
- return n;
+ return n;
+*/
}
diff --git a/src/cw/cw_filename.c b/src/cw/cw_filename.c
new file mode 100644
index 00000000..071a202c
--- /dev/null
+++ b/src/cw/cw_filename.c
@@ -0,0 +1,81 @@
+/*
+ This file is part of actube.
+
+ actube 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.
+
+ actube 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 actube. If not, see .
+*/
+/**
+ * @file
+ * @brief implents cw_filename
+ **/
+
+#include
+#include
+#include "file.h"
+
+/**
+ * @brief Build full pathname from path, filename and extension
+ * @param path Path
+ * @param name Filename
+ * @param ext Extension
+ * @return a pointer to the create filename which has to be
+ * released using free.
+ */
+char * cw_filename(const char * path, const char * name, const char * ext){
+
+ int size=0;
+
+ int path_len;
+ char c;
+
+ char * slash="";
+
+ path_len = strlen(path);
+ if (path_len>0){
+ c = path[path_len-1];
+ if (!strchr(CW_FILE_PATH_DELIMITERS,c)){
+ path_len++;
+ slash = "/";
+ }
+ }
+
+ int name_len = strlen (name);
+
+
+ int ext_len;
+
+ if (ext != NULL){
+ if (ext[0]=='.'){
+ ext++;
+ }
+ ext_len = strlen(ext);
+ }
+ else
+ ext_len=-1;
+
+ size = (path_len) + name_len + (ext_len+1) + 1;
+ char * result = malloc(size);
+ if (!result)
+ return NULL;
+
+ strncpy(result,path,path_len);
+ result[path_len]=0;
+ strcat(result,slash);
+ strcat(result,name);
+ if (ext){
+ strcat(result,".");
+ strcat(result,ext);
+ }
+
+ return result;
+}
diff --git a/src/cw/cw_get_mod_ac.c b/src/cw/cw_get_mod_ac.c
deleted file mode 100644
index e1ed47d2..00000000
--- a/src/cw/cw_get_mod_ac.c
+++ /dev/null
@@ -1,23 +0,0 @@
-
-#include
-
-
-#include "mod.h"
-
-#include
-
-
-struct mod_ac *(*mods_ac[])() = MODS_AC;
-
-
-struct mod_ac * cw_get_mod_ac(const char *name)
-{
- int i;
- for (i=0; mods_ac[i];i++){
-
- struct mod_ac * m = mods_ac[i]();
- if (strcmp(m->name,name)==0)
- return m;
- }
- return NULL;
-}
diff --git a/src/cw/cw_in_generic.c b/src/cw/cw_in_generic.c
index b1c2e1bb..18f0f541 100644
--- a/src/cw/cw_in_generic.c
+++ b/src/cw/cw_in_generic.c
@@ -5,10 +5,11 @@
#include "mbag.h"
#include "cw.h"
-
+/// TODO XXXX
int static check_len(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
struct sockaddr *from)
{
+ /*
if (len < a->min_len) {
cw_dbg(DBG_ELEM_ERR,
"%d (%s) message element too short, len=%d, min len=%d",
@@ -22,7 +23,7 @@ int static check_len(struct conn *conn, struct cw_action_in *a, uint8_t * data,
cw_strelemp(conn->actions, a->elem_id), len, a->max_len);
return 0;
}
-
+*/
return 1;
}
diff --git a/src/cw/cw_in_generic2.c b/src/cw/cw_in_generic2.c
index c118fcb0..0100d0f9 100644
--- a/src/cw/cw_in_generic2.c
+++ b/src/cw/cw_in_generic2.c
@@ -98,7 +98,10 @@ int static do_save(mbag_t itemstore, struct conn *conn, struct cw_action_in *a,
int cw_in_generic2(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
struct sockaddr *from)
{
- const cw_itemdef_t * idef = cw_itemdef_get(conn->actions->items,a->item_id,CW_ITEM_NONE);
+ /// TODO XXXX
+// const cw_itemdef_t * idef = cw_itemdef_get(conn->actions->items,a->item_id,CW_ITEM_NONE);
+
+const cw_itemdef_t * idef=0;
if (!idef) {
cw_log(LOG_ERR,"No itemdef found for %s",a->item_id);
diff --git a/src/cw/cw_in_radio_generic.c b/src/cw/cw_in_radio_generic.c
index dc9c27f3..d941b79a 100644
--- a/src/cw/cw_in_radio_generic.c
+++ b/src/cw/cw_in_radio_generic.c
@@ -14,8 +14,10 @@
int cw_in_radio_generic(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len, struct sockaddr *from)
{
-
- const cw_itemdef_t * idef = cw_itemdef_get(conn->actions->radioitems,a->item_id,CW_ITEM_NONE);
+ // TODO XXXX
+// const cw_itemdef_t * idef = cw_itemdef_get(conn->actions->radioitems,a->item_id,CW_ITEM_NONE);
+ const cw_itemdef_t * idef = 0;
+
if (!idef){
cw_log(LOG_ERR,"No definition found for %s",a->item_id);
return 0;
diff --git a/src/cw/cw_in_vendor_specific_payload.c b/src/cw/cw_in_vendor_specific_payload.c
index 2d6c5fbc..63cdbf23 100644
--- a/src/cw/cw_in_vendor_specific_payload.c
+++ b/src/cw/cw_in_vendor_specific_payload.c
@@ -22,9 +22,10 @@ int cw_in_vendor_specific_payload(struct conn *conn, struct cw_action_in *a,
as.vendor_id = cw_get_dword(data);
as.elem_id = cw_get_word(data + 4);
-
- af = cw_actionlist_in_get(conn->actions->in, &as);
-
+ // TODO XXXX
+// af = cw_actionlist_in_get(conn->actions->in, &as);
+ af = 0;
+
if (!af) {
cw_dbg(DBG_WARN,
"Can't handle Vendor Specific Payload %s/%d, in msg %d (%s) in %s state.",
@@ -44,4 +45,5 @@ int cw_in_vendor_specific_payload(struct conn *conn, struct cw_action_in *a,
}
return 1;
+
}
diff --git a/src/cw/cw_in_wtp_descriptor.c b/src/cw/cw_in_wtp_descriptor.c
deleted file mode 100644
index 11ad24b7..00000000
--- a/src/cw/cw_in_wtp_descriptor.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- This file is part of libcapwap.
-
- libcapwap is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- libcapwap is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Foobar. If not, see .
-
-*/
-
-
-#include "capwap.h"
-#include "capwap_items.h"
-
-
-#include "cw_util.h"
-#include "dbg.h"
-
-#include "sock.h"
-
-
-static int _cw_read_wtp_descriptor_versions(mbag_t mbag, uint8_t * data,
- int len, int silent)
-{
- int i = 0;
- while (i len) {
- if (!silent)
- cw_dbg(DBG_ELEM_ERR,
- "WTP descriptor subelement to long, length=%d>%d",
- i + 8, len);
- return 0;
- }
-
- uint32_t vendor_id = cw_get_dword(data + i);
- uint32_t val = cw_get_dword(data + i + 4);
-
- int subtype = (val >> 16) & 0xffff;
- int sublen = val & 0xffff;
- i += 8;
-
- if (sublen + i > len) {
- if (!silent)
- cw_dbg(DBG_ELEM_ERR,
- "WTP Descriptor sub-element too long, length = %d",
- sublen);
- return 0;
- }
-
- if (!silent) {
- char *dmp;
- char *dmpmem = NULL;
- if (cw_dbg_is_level(DBG_SUBELEM_DMP)) {
- dmpmem = cw_dbg_mkdmp(data + i, sublen);
- dmp = dmpmem;
- } else
- dmp = "";
- cw_dbg(DBG_SUBELEM, "WTP Descriptor subtype=%d,len=%d%s", subtype,
- sublen, dmp);
-
- if (dmpmem)
- free(dmpmem);
- }
-
- switch (subtype) {
- case CW_SUBELEM_WTP_HARDWARE_VERSION:
-/*
- mbag_set_dword(mbag,
- CW_ITEM_WTP_HARDWARE_VENDOR,
- vendor_id);
- mbag_set_bstrn(mbag,
- CW_ITEM_WTP_HARDWARE_VERSION,
- data + i, sublen);
-*/
-
- mbag_set_bstrv(mbag,
- CW_ITEM_WTP_HARDWARE_VERSION,
- vendor_id, data + i, sublen);
-
- break;
- case CW_SUBELEM_WTP_SOFTWARE_VERSION:
-
- mbag_set_bstrv(mbag,
- CW_ITEM_WTP_SOFTWARE_VERSION,
- vendor_id, data + i, sublen);
-/*
- mbag_set_dword(mbag,
- CW_ITEM_WTP_SOFTWARE_VENDOR,
- vendor_id);
- mbag_set_bstrn(mbag,
- CW_ITEM_WTP_SOFTWARE_VERSION,
- data + i, sublen);
-
-*/
- break;
- case CW_SUBELEM_WTP_BOOTLOADER_VERSION:
-
- mbag_set_bstrv(mbag,
- CW_ITEM_WTP_BOOTLOADER_VERSION,
- vendor_id, data + i, sublen);
-
-/*
- mbag_set_dword(mbag,
- CW_ITEM_WTP_BOOTLOADER_VENDOR,
- vendor_id);
- mbag_set_bstrn(mbag,
- CW_ITEM_WTP_BOOTLOADER_VERSION,
- data + i, sublen);
-*/
- break;
- default:
- if (!silent)
- cw_dbg(DBG_ELEM_ERR,
- "Unknown WTP descriptor subelement, type = %d",
- subtype);
- break;
- }
- i += sublen;
-
- } //while (i < len);
-
- return 1;
-
-}
-
-static int cw_read_wtp_descriptor(mbag_t mbag, struct conn *conn,
- struct cw_action_in *a, uint8_t * data, int len,
- int silent)
-{
-
-
- mbag_set_byte(mbag, CW_ITEM_WTP_MAX_RADIOS, cw_get_byte(data));
- mbag_set_byte(mbag, CW_ITEM_WTP_RADIOS_IN_USE,
- cw_get_byte(data + 1));
-
-
- /* Get number of encryption elements */
- int ncrypt = cw_get_byte(data + 2);
- if (ncrypt == 0) {
- if (conn->strict_capwap) {
- if (!silent)
- cw_dbg(DBG_ELEM_ERR,
- "Bad WTP Descriptor, number of encryption elements is 0.");
- return 0;
- }
- if (!silent)
- cw_dbg(DBG_RFC,
- "Non standard conform WTP Descriptor, number of encryptoin elements is 0.");
- }
-
- int pos = 3;
- int i;
- for (i = 0; i < ncrypt; i++) {
- // It's a dummy for now
- pos += 3;
- }
-
- return _cw_read_wtp_descriptor_versions(mbag, data + pos, len - pos, silent);
-
-}
-
-
-
-/**
- * Read WTP Descriptor in Cisco-Style (Draft 7)
- */
-
-static int cw_read_cisco_wtp_descriptor(mbag_t mbag, struct conn *conn,
- struct cw_action_in *a, uint8_t * data, int len,
- int silent)
-{
-
- mbag_set_byte(mbag, CW_ITEM_WTP_MAX_RADIOS, cw_get_byte(data));
- mbag_set_byte(mbag, CW_ITEM_WTP_RADIOS_IN_USE,
- cw_get_byte(data + 1));
-
-
- int pos = 2;
-
- /* Encryption element, for now dumy XXX */
- cw_get_word(data + pos + 2);
- pos += 2;
-
- return _cw_read_wtp_descriptor_versions(mbag, data + pos, len - pos, silent);
-
-}
-
-
-
-
-
-
-
-
-int cw_in_wtp_descriptor(struct conn *conn, struct cw_action_in *a, uint8_t * data,
- int len, struct sockaddr *from)
-{
- mbag_t mbag = conn->incomming;
-
- return cw_read_wtp_descriptor(mbag, conn, a, data, len, 0);
-}
-
-
-
-int cw_in_cipwap_wtp_descriptor(struct conn *conn, struct cw_action_in *a, uint8_t * data,
- int len, struct sockaddr *from)
-{
- mbag_t mbag = conn->incomming;
-
- switch (conn->capwap_mode) {
- case CW_MODE_CISCO:
- return cw_read_cisco_wtp_descriptor(mbag, conn, a, data, len,
- 0);
- case CW_MODE_CIPWAP:
- {
- /* try to get the right WTP Descriptor */
- int rc;
- rc = cw_read_wtp_descriptor(mbag, conn, a, data, len,
- 1);
-
- if (rc) {
- return cw_read_wtp_descriptor(mbag, conn, a,
- data, len, 0);
- }
-
- rc = cw_read_cisco_wtp_descriptor(mbag, conn, a,
- data, len, 0);
- if (rc) {
- return cw_read_cisco_wtp_descriptor(mbag,
- conn, a, data,
- len, 0);
- }
-
- return cw_read_wtp_descriptor(mbag, conn, a, data,
- len, 0);
-
- }
- default:
- return cw_read_wtp_descriptor(mbag, conn, a, data, len, 0);
-
-
- }
-
- return 0;
-}
diff --git a/src/cw/cw_msg_init.c b/src/cw/cw_msg_init.c
deleted file mode 100644
index af520a84..00000000
--- a/src/cw/cw_msg_init.c
+++ /dev/null
@@ -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);
-}
diff --git a/src/cw/cw_out_cisco_wtp_radio_cfg.c b/src/cw/cw_out_cisco_wtp_radio_cfg.c
deleted file mode 100644
index 66ae21f9..00000000
--- a/src/cw/cw_out_cisco_wtp_radio_cfg.c
+++ /dev/null
@@ -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);
-}
-
diff --git a/src/cw/cw_out_generic.c b/src/cw/cw_out_generic.c
index dea96586..e7b6aafa 100644
--- a/src/cw/cw_out_generic.c
+++ b/src/cw/cw_out_generic.c
@@ -29,20 +29,20 @@ int cw_out_generic(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
vendor=cw_strvendor(a->vendor_id);
}
if (a->mand) {
- cw_log(LOG_ERR,
+/* cw_log(LOG_ERR,
"Can't put mandatory element %s %d - (%s) into %s. No value for '%s' found.",
vendor,
a->elem_id, cw_strelemp(conn->actions, a->elem_id)
, cw_strmsg(a->msg_id)
, a->item_id
);
- }
+*/ }
else{
- cw_dbg(DBG_WARN,"No output for element %s%d -(%s) in %s. Item %s not found.",
+/* cw_dbg(DBG_WARN,"No output for element %s%d -(%s) in %s. Item %s not found.",
vendor,
a->elem_id, cw_strelemp(conn->actions, a->elem_id)
, cw_strmsg(a->msg_id),a->item_id);
-
+*/
}
return 0;
} else {
diff --git a/src/cw/cw_out_init_session_id.c b/src/cw/cw_out_init_session_id.c
deleted file mode 100644
index 974a6b8f..00000000
--- a/src/cw/cw_out_init_session_id.c
+++ /dev/null
@@ -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;
-
-}
-
diff --git a/src/cw/cw_prepare_configuration_status_request.c b/src/cw/cw_prepare_configuration_status_request.c
deleted file mode 100644
index d83eb581..00000000
--- a/src/cw/cw_prepare_configuration_status_request.c
+++ /dev/null
@@ -1,37 +0,0 @@
-
-#include "capwap.h"
-#include "lwapp_cisco.h"
-#include "capwap_cisco.h"
-
-
-#include "conn.h"
-#include "wtpinfo.h"
-
-void cw_prepare_configuration_status_request(struct conn * conn, struct radioinfo * radioinfo, struct wtpinfo *wtpinfo)
-{
- struct cwmsg * cwmsg = &conn->req_msg;
- uint8_t * buffer = conn->req_buffer;
-
- cwmsg_init(cwmsg,buffer,CAPWAP_MSG_CONFIGURATION_STATUS_REQUEST,conn_get_next_seqnum(conn),radioinfo);
- cwmsg->capwap_mode=conn->capwap_mode;
-
- cwmsg_addelem_ac_name(cwmsg,(uint8_t *)"AC-iMaxi");
-
-
- cwmsg_addelem_cisco_ap_regulatory_domain(cwmsg,&wtpinfo->radioinfo[0]);
- cwmsg_addelem_cisco_ap_regulatory_domain(cwmsg,&wtpinfo->radioinfo[1]);
-
- cwmsg_addelem_cisco_wtp_radio_cfg(cwmsg,&wtpinfo->radioinfo[0]);
- cwmsg_addelem_cisco_wtp_radio_cfg(cwmsg,&wtpinfo->radioinfo[1]);
-
-/*
- uint8_t mtu[2048];
- int l = lw_put_cisco_path_mtu(mtu,1485,1701);
-
- printf("Len = %d\n",l);
-
- cwmsg_addelem_vendor_specific_payload(cwmsg,LW_VENDOR_CISCO,
- LW_ELEM_VENDOR_SPECIFIC,mtu,l);
-
-*/
-}
diff --git a/src/cw/cw_put_msg.c b/src/cw/cw_put_msg.c
index 3dd2b8df..6ac76bae 100644
--- a/src/cw/cw_put_msg.c
+++ b/src/cw/cw_put_msg.c
@@ -53,7 +53,9 @@ int cw_put_msg(struct conn *conn, uint8_t * rawout)
uint8_t *dst = msgptr+8;
- mlist_t m = cw_actionlist_out_get(conn->actions->out,cw_get_msg_type(msgptr));
+/// TODO XXXX
+ //mlist_t m = cw_actionlist_out_get(conn->actions->out,cw_get_msg_type(msgptr));
+ mlist_t m =0;
if (!m){
cw_log(LOG_ERR,"Error: Can't create message of type %d (%s) - no definition found.",
@@ -152,8 +154,9 @@ int cw_put_custom_msg(struct conn *conn, uint8_t * rawout, mavl_conststr_t elems
uint8_t *dst = msgptr+8;
- DEFINE_AVLITER(i,conn->actions->out);
-
+/// TODO XXXX
+// DEFINE_AVLITER(i,conn->actions->out);
+DEFINE_AVLITER(i,0);
cw_action_out_t *am;
if (! (am=avliter_seek(&i,&as))){
diff --git a/src/cw/cw_read_image_data_request.c b/src/cw/cw_read_image_data_request.c
deleted file mode 100644
index c6cfd8c9..00000000
--- a/src/cw/cw_read_image_data_request.c
+++ /dev/null
@@ -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 .
-
-*/
-
-/**
- *@file
- *@brief Image Data handling
- */
-#include
-
-#include "capwap.h"
-
-#include "cw_log.h"
-#include "cw_util.h"
-
-#include
-
-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);
-}
-
-
-
diff --git a/src/cw/cw_readelem_80211_wtp_radio_info.c b/src/cw/cw_readelem_80211_wtp_radio_info.c
deleted file mode 100644
index b26984a9..00000000
--- a/src/cw/cw_readelem_80211_wtp_radio_info.c
+++ /dev/null
@@ -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 .
-
-*/
-
-#include
-
-#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;
-}
-
diff --git a/src/cw/cw_readelem_ac_descriptor.c b/src/cw/cw_readelem_ac_descriptor.c
deleted file mode 100644
index 362700f6..00000000
--- a/src/cw/cw_readelem_ac_descriptor.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- This file is part of libcapwap.
-
- libcapwap is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- libcapwap is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Foobar. If not, see .
-
-*/
-
-/**
- * @file
- * @brief cw_readelem_ac_descriptor is implemented here.
- */
-
-#include "capwap.h"
-#include "acinfo.h"
-#include "bstr.h"
-#include "cw_log.h"
-
-
-static int read_subelem_cisco(struct ac_info* acinfo,int subtype,uint8_t * elem, int len)
-{
- switch (subtype) {
- case 0:
- /* hardware version */
- bstr_replace(&acinfo->hardware_version,bstr_create(elem,len));
- break;
- case 1:
- /* software version */
- bstr_replace(&acinfo->software_version,bstr_create(elem,len));
- break;
-
- default:
- //printf("What? %d\n",subtype);
- break;
-
- }
-
- return 1;
-}
-
-
-static int read_subelem(struct ac_info* acinfo,int subtype,uint8_t *elem, int len)
-{
- switch (subtype){
- case 4:
- /* hardware version */
- bstr_replace(&acinfo->hardware_version,bstr_create(elem,len));
- break;
- case 5:
- /* software version */
- bstr_replace(&acinfo->software_version,bstr_create(elem,len));
- break;
- }
-
- return 1;
-}
-
-/**
- * Read CAPWAP message elment: AC Descriptor
- * @param acinfo pointer to acinfo where the result is stored
- * @param type message element type
- * @param msgelem pointer to message element
- * @param len length of message element
- * @return 1 AC descriptor sucessfull read \n
- * 0 not an ac descriptor message\n
- * -1 an error has occured
- */
-int cw_readelem_ac_descriptor(struct ac_info * acinfo,int type, uint8_t *msgelem, int len)
-{
- if (type != CAPWAP_ELEM_AC_DESCRIPTOR)
- return 0;
-
- if (len<12)
- return -1;
-
- uint32_t val;
-
- /* read stations and limit */
- val = ntohl(*((uint32_t*)msgelem));
- acinfo->stations = val>>16;
- acinfo->limit = val&0xffff;
-
-
- /* read active wtps and max wtps */
- val = ntohl(*((uint32_t*)(msgelem+4)));
- acinfo->active_wtps = val>>16;
- acinfo->max_wtps = val&0xffff;
-
- /* read active wtps and max wtps */
- val = ntohl(*((uint32_t*)(msgelem+8)));
- acinfo->security = val >>24;
- acinfo->rmac= (val >> 16)&0xff;
- acinfo->dtls_policy=val&0xf;
-
- int sub=12;
- int sublen;
-
-
- while (sub>16;
-
- cw_dbg(DBG_ELEM,"AC Descriptor sub-element vendor: %d, type:%d, len: %d",vendor,subtype,sublen);
- switch (vendor) {
- case 0:
- read_subelem(acinfo,subtype,msgelem+sub,sublen);
- break;
-
- case CW_VENDOR_ID_CISCO:
- read_subelem_cisco(acinfo,subtype,msgelem+sub,sublen);
- break;
-
- }
-
- if (sub+sublen>len)
- return -1;
-
- sub+=sublen;
- }
-
- return 1;
-}
-
-
diff --git a/src/cw/cw_readelem_cisco_wtp_radio_cfg.c b/src/cw/cw_readelem_cisco_wtp_radio_cfg.c
index 2e962f00..a4879fde 100644
--- a/src/cw/cw_readelem_cisco_wtp_radio_cfg.c
+++ b/src/cw/cw_readelem_cisco_wtp_radio_cfg.c
@@ -1,4 +1,4 @@
-
+/*
#include "capwap_cisco.h"
#include "cw_log.h"
@@ -19,4 +19,7 @@ int cw_readelem_cisco_wtp_radio_cfg(int elem_id,uint8_t *elem, int len,struct ra
ri->beacon_period = lw_get_word(elem+13);
return 1;
-}
+}
+
+
+*/
diff --git a/src/cw/cw_readelem_maximum_message_length.c b/src/cw/cw_readelem_maximum_message_length.c
deleted file mode 100644
index dcf6bb53..00000000
--- a/src/cw/cw_readelem_maximum_message_length.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- This file is part of libcapwap.
-
- libcapwap is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- libcapwap is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Foobar. If not, see .
-
-*/
-
-#include "capwap.h"
-#include "cw_util.h"
-#include "log.h"
-
-int cw_readelem_maximum_message_length(uint16_t *dst, int type,uint8_t *msgelem, int len)
-{
- if (type != CWMSGELEM_MAXIMUM_MESSAGE_LENGTH)
- return 0;
-
- if (len!=2){
- cw_dbg(DBG_CW_RFC,"Discarding MAXIMUM_MESSAGE_LENTGH msgelem, wrong size, type=%d,len=%d",type,len);
- return 0;
- }
-
- *dst = ntohs(* ((uint16_t*)msgelem));
- return 1;
-}
-
-
diff --git a/src/cw/cw_readelem_radio_operational_state.c b/src/cw/cw_readelem_radio_operational_state.c
deleted file mode 100644
index 6d5ba35b..00000000
--- a/src/cw/cw_readelem_radio_operational_state.c
+++ /dev/null
@@ -1,45 +0,0 @@
-
-/*
- This file is part of libcapwap.
-
- libcapwap is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- libcapwap is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Foobar. If not, see .
-
-*/
-
-#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;
-
-
-}
diff --git a/src/cw/cw_readelem_statistics_timer.c b/src/cw/cw_readelem_statistics_timer.c
index dc26c9c9..382e0d30 100644
--- a/src/cw/cw_readelem_statistics_timer.c
+++ b/src/cw/cw_readelem_statistics_timer.c
@@ -1,6 +1,6 @@
#include "capwap.h"
-#include "cw_log.h"
+#include "dbg.h"
int cw_readelem_statistics_timer(uint16_t *timer, int type, uint8_t * msgelem, int len)
{
@@ -8,7 +8,7 @@ int cw_readelem_statistics_timer(uint16_t *timer, int type, uint8_t * msgelem, i
return 0;
if (len!=2){
- cw_dbg(DBG_CW_RFC,"Statistics timer msgelem has wrong size, type=%d,len=%d",type,len);
+ cw_dbg(DBG_RFC,"Statistics timer msgelem has wrong size, type=%d,len=%d",type,len);
return 0;
}
*timer=*((uint16_t*)msgelem);
diff --git a/src/cw/cw_readmsg_configuration_status_request.c b/src/cw/cw_readmsg_configuration_status_request.c
deleted file mode 100644
index 41792941..00000000
--- a/src/cw/cw_readmsg_configuration_status_request.c
+++ /dev/null
@@ -1,22 +0,0 @@
-#include "capwap.h"
-#include "cw_log.h"
-
-int cw_readmsg_configuration_update_request(uint8_t *elems,int elems_len)
-{
- uint8_t * elem;
-
- cw_foreach_elem(elem,elems,elems_len){
-
- int type = cw_get_elem_type(elem);
- int len = cw_get_elem_len(elem);
- uint8_t *data = cw_get_elem_data(elem);
-
- cw_dbg_msgelem(CAPWAP_MSG_CONFIGURATION_STATUS_REQUEST, type, data, len);
-
-
-// cw_readelem_vendor_specific_payload(elem,CW_MSG_CONFIGURATION_STATUS_RESPONSE, type,data,len );
-
- }
-
-
-}
diff --git a/src/cw/cw_send_echo_response.c b/src/cw/cw_send_echo_response.c
index d5a18adc..f88645e6 100644
--- a/src/cw/cw_send_echo_response.c
+++ b/src/cw/cw_send_echo_response.c
@@ -33,8 +33,8 @@
int cw_send_echo_response(struct conn * conn,int seqnum,struct radioinfo * radioinfo)
{
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;
}
diff --git a/src/cw/cw_send_image_file.c b/src/cw/cw_send_image_file.c
deleted file mode 100644
index 3e45bbf6..00000000
--- a/src/cw/cw_send_image_file.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- This file is part of libcapwap.
-
- libcapwap is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- libcapwap is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Foobar. If not, see .
-
-*/
-
-
-/**
- * @file
- * @breif send image file
- */
-
-#include
-#include
-#include
-
-
-#include "capwap.h"
-#include "lwapp.h"
-
-#include "sock.h"
-#include "cw_log.h"
-
-
-/**
- * Send an image file to an AP
- *
- */
-void cw_send_image_file(struct conn *conn)
-{
-
-/*
- FILE *infile;
- infile = fopen(filename, "rb");
- if (!infile) {
- cw_log(LOG_ERR, "Can't open image file %s:%s", filename, strerror(errno));
- return;
- }
-
-
- cw_log(LOG_INFO, "Sending image file %s to %s", filename, sock_addr2str(&conn->addr));
-*/
-
-
-
-
-
-
- uint8_t buffer[1024]; /* buffer MUST be 1024 */
-
-
- struct cwimage_data data;
- memset(&data,0,sizeof(struct cwimage_data));
- data.data = buffer;
-
-
-/*
- conn->request_handler = cw_handle_echo_request;
- conn->request_handler_param = conn;
-*/
-
- int bl = 0;
-
- do {
-
- data.len = fread(buffer, 1, sizeof(buffer), infile);
-
- if (feof(infile))
- data.type = 2;
- else
- data.type = 1;
-
- cw_dbg(DBG_CW_IMG_DTL, "Sending img data request, block=%d, len=%d, ch=%d\n", bl,
- data.len, lw_checksum(data.data, data.len));
-
-
- bl++;
-
- // conn_prepare_image_data_request(conn, &data, 0);
- // cwrmsg = conn_send_request(conn);
-
- if (!cwrmsg) {
- cw_log(LOG_ERR,"Error sneding image file to %s",sock_addr2str(&conn->addr));
- break;
- }
-
-
- } while (!feof(infile));
-
-}
diff --git a/src/cw/cwmsg_addelem_80211_add_wlan.c b/src/cw/cwmsg_addelem_80211_add_wlan.c
deleted file mode 100644
index 9ecd022a..00000000
--- a/src/cw/cwmsg_addelem_80211_add_wlan.c
+++ /dev/null
@@ -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
-
- );
-
-}
-
diff --git a/src/cw/cwmsg_addelem_mtu_discovery_padding.c b/src/cw/cwmsg_addelem_mtu_discovery_padding.c
index d0e29ce9..560e7f52 100644
--- a/src/cw/cwmsg_addelem_mtu_discovery_padding.c
+++ b/src/cw/cwmsg_addelem_mtu_discovery_padding.c
@@ -33,7 +33,7 @@ printf("MTU discovery len %d %d and pos %d:\n",conn->mtu,len,msg->pos);
if (len < 0 )
return;
- uint32_t val = CWMSGELEM_MTU_DISCOVERY_PADDING<<16|len;
+ uint32_t val = CW_ELEM_MTU_DISCOVERY_PADDING<<16|len;
*((uint32_t*)(msg->msgelems+msg->pos))=htonl(val);
memset(msg->msgelems+4+msg->pos,0xff,len);
msg->pos+=4+len;
diff --git a/src/cw/cwmsg_addelem_vendor_cisco_mwar_addr.c b/src/cw/cwmsg_addelem_vendor_cisco_mwar_addr.c
deleted file mode 100644
index 6bacdc36..00000000
--- a/src/cw/cwmsg_addelem_vendor_cisco_mwar_addr.c
+++ /dev/null
@@ -1,58 +0,0 @@
-#include
-#include
-#include
-
-#include
-
-
-#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;
-*/
- }
-
-
-
-
-}
diff --git a/src/cw/dbg.c b/src/cw/dbg.c
index b675f48f..b50fd782 100644
--- a/src/cw/dbg.c
+++ b/src/cw/dbg.c
@@ -25,6 +25,7 @@
* @file Debugging Functions
* @brief Various debug functions.
*/
+#include
#include "capwap.h"
#include "dbg.h"
@@ -36,6 +37,10 @@
#include "capwap.h"
#include "capwap_cisco.h"
#include "lwapp_cisco.h"
+#include "cw.h"
+#include "message_set.h"
+
+
/**
*@addtogroup DBG
@@ -196,10 +201,12 @@ void cw_dbg_missing_mand(int level, struct conn *conn, cw_action_in_t ** ml, int
char *p = buffer;
int i;
char *delim = "";
+ // TODO XXXX
for (i = 0; i < n; i++) {
- p += sprintf(p, "%s", delim);
+/* p += sprintf(p, "%s", delim);
delim = ", ";
p += sprintf(p, "%s", cw_strelemp(conn->actions, ml[i]->elem_id));
+*/
}
cw_dbg(level, "Missing mandatory elements: [%s]", buffer);
}
@@ -483,7 +490,19 @@ void cw_dbg_msg(int level, struct conn *conn, uint8_t * packet, int len,
// int pplen = len - (msgptr-packet);
int msg_id = cw_get_msg_id(msgptr);
- s += sprintf(s, "%s Message (type=%d) ", cw_strmsg(msg_id), msg_id);
+
+ struct cw_MsgData search;
+ search.type = msg_id;
+ struct cw_MsgData * message;
+ message = mavl_get(conn->msgset->messages,&search);
+
+ char * msname;
+ if (!message)
+ msname="Unknown";
+ else
+ msname = message->name;
+
+ s += sprintf(s, "%s Message (type=%d) ", msname /*cw_strmsg(msg_id)*/, msg_id);
if (level == DBG_MSG_IN)
s += sprintf(s, "from %s ", sock_addr2str(from));
else
@@ -548,18 +567,21 @@ void cw_dbg_elem_colored(int level, struct conn *conn, int msg, int msgelem,
char vendorname[256];
char vendor_details[265];
*vendor_details = 0;
+/// TODO XXXX
if (msgelem == CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD) {
uint32_t vendor_id = ntohl(*((uint32_t *) msgbuf));
int type = ntohs(*((uint16_t *) (msgbuf + 4)));
cw_format_vendor(vendor_details, vendor_id, type, msgbuf);
- sprintf(vendorname, "%s/%s/%s",
+/* sprintf(vendorname, "%s/%s/%s",
cw_strelemp(conn->actions, msgelem),
(char *) cw_strvendor(vendor_id), vendor_details);
+*/
elemname = vendorname;
} else {
- elemname = cw_strelemp(conn->actions, msgelem);
+// elemname = cw_strelemp(conn->actions, msgelem);
+ elemname=0;
}
diff --git a/src/cw/dtls.h b/src/cw/dtls.h
index baaf5c8f..1177e057 100644
--- a/src/cw/dtls.h
+++ b/src/cw/dtls.h
@@ -19,19 +19,7 @@
#define __CW_DTLS_H
-#include
-#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);
+#include "dtls_common.h"
diff --git a/src/cw/dtls_common.h b/src/cw/dtls_common.h
new file mode 100644
index 00000000..ae268368
--- /dev/null
+++ b/src/cw/dtls_common.h
@@ -0,0 +1,13 @@
+#include
+#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);
+
+
diff --git a/src/cw/dtls_gnutls.c b/src/cw/dtls_gnutls.c
index 103276a1..723f04d7 100644
--- a/src/cw/dtls_gnutls.c
+++ b/src/cw/dtls_gnutls.c
@@ -22,6 +22,7 @@
#include
#include
+#include "dtls_common.h"
#include "dtls_gnutls.h"
#include "conn.h"
diff --git a/src/cw/dtls_gnutls_accept.c b/src/cw/dtls_gnutls_accept.c
index c4fb174a..33ac8a3d 100644
--- a/src/cw/dtls_gnutls_accept.c
+++ b/src/cw/dtls_gnutls_accept.c
@@ -29,6 +29,7 @@
#include "log.h"
#include "sock.h"
#include "capwap.h"
+#include "dtls_common.h"
#include "dtls_gnutls.h"
#include "timer.h"
diff --git a/src/cw/dtls_gnutls_get_cipher.c b/src/cw/dtls_gnutls_get_cipher.c
index 4a921d56..1b98e11a 100644
--- a/src/cw/dtls_gnutls_get_cipher.c
+++ b/src/cw/dtls_gnutls_get_cipher.c
@@ -1,5 +1,5 @@
-
+#include "dtls_common.h"
#include "dtls_gnutls.h"
const char *dtls_gnutls_get_cipher(struct conn *conn)
diff --git a/src/cw/file.h b/src/cw/file.h
index 2585a8c7..7eaac611 100644
--- a/src/cw/file.h
+++ b/src/cw/file.h
@@ -10,6 +10,9 @@
char *cw_load_file(const char *filename,size_t *size);
int cw_save_file(const char *filename, char *data,int len);
+char * cw_filename(const char * path, const char * name, const char * ext);
+
+#define CW_FILE_PATH_DELIMITERS "/"
/**@}*/
diff --git a/src/cw/fragman.h b/src/cw/fragman.h
index 4299f698..7106bbf0 100644
--- a/src/cw/fragman.h
+++ b/src/cw/fragman.h
@@ -31,6 +31,7 @@
#include
#include
+#include
#ifndef FRAG_MAXSIZE
/** maximaum size of a fragment */
diff --git a/src/cw/hdr_print.c b/src/cw/hdr_print.c
index d269cf69..cdb09a13 100644
--- a/src/cw/hdr_print.c
+++ b/src/cw/hdr_print.c
@@ -23,7 +23,7 @@
#include "capwap.h"
#include "sock.h"
-
+/*
int hdr_print(char *str, uint8_t *packet, int len)
{
@@ -119,3 +119,5 @@ int hdr_print(char *str, uint8_t *packet, int len)
return s-str;
}
+
+*/
diff --git a/src/cw/item_strings.c b/src/cw/item_strings.c
deleted file mode 100644
index b0b47ba5..00000000
--- a/src/cw/item_strings.c
+++ /dev/null
@@ -1,16 +0,0 @@
-
-#include "capwap_items.h"
-#include "strheap.h"
-
-struct cw_str cw_item_strings[] = {
- { CW_ITEM_WTP_HARDWARE_VERSION,"WTP Hardware Version"},
- { CW_ITEM_WTP_NAME, "WTP Name "},
- { CW_ITEM_AC_NAME, "AC Name "},
- { CW_ITEM_WTP_BOARD_VENDOR, "WTP Board Vendor"},
- { CW_ITEM_WTP_BOARD_MODELNO,"WTP Board Model No."},
- { CW_ITEM_WTP_BOARD_MACADDRESS, "WTP Board MAC Address"},
- { CW_ITEM_WTP_BOARD_ID,"WTP Board ID"},
- { CW_ITEM_WTP_GROUP_NAME,"WTP Group Name"},
- { CW_STR_STOP,"Unknown"}
-
-};
diff --git a/src/cw/log_syslog.c b/src/cw/log_syslog.c
index 9bb8a683..628add20 100644
--- a/src/cw/log_syslog.c
+++ b/src/cw/log_syslog.c
@@ -16,6 +16,7 @@
*/
+#include
#include "log.h"
diff --git a/src/cw/lw_in_vendor_specific.c b/src/cw/lw_in_vendor_specific.c
index ba772a43..383246c0 100644
--- a/src/cw/lw_in_vendor_specific.c
+++ b/src/cw/lw_in_vendor_specific.c
@@ -23,8 +23,10 @@ int lw_in_vendor_specific(struct conn *conn, struct cw_action_in *a,
as.elem_id = cw_get_word(data + 4);
as.proto = CW_ACTION_PROTO_LWAPP;
-
- af = cw_actionlist_in_get(conn->actions->in, &as);
+// TODO XXXX
+ //af = cw_actionlist_in_get(conn->actions->in, &as);
+
+ af = 0;
if (!af) {
cw_dbg(DBG_WARN,
diff --git a/src/cw/lw_put_80211_wtp_wlan_radio_configuration.c b/src/cw/lw_put_80211_wtp_wlan_radio_configuration.c
index 4e871379..04060f14 100644
--- a/src/cw/lw_put_80211_wtp_wlan_radio_configuration.c
+++ b/src/cw/lw_put_80211_wtp_wlan_radio_configuration.c
@@ -1,6 +1,7 @@
#include "lwapp.h"
+/*
int lw_put_80211_wtp_wlan_radio_configuration(uint8_t*dst,struct radioinfo *ri)
{
lw_put_byte(dst,ri->rid);
@@ -9,18 +10,18 @@ int lw_put_80211_wtp_wlan_radio_configuration(uint8_t*dst,struct radioinfo *ri)
lw_put_byte(dst+4,ri->cfp_period);
lw_put_word(dst+5,ri->cfp_max_duration);
- /* XXX catch rmac shorter or longer than 6*/
+ // XXX catch rmac shorter or longer than 6
- lw_put_bstr(dst+7,ri->rmac); /* length MUST be 6 */
+ lw_put_bstr(dst+7,ri->rmac); // length MUST be 6
lw_put_word(dst+13,ri->beacon_period);
lw_put_byte(dst+15,ri->dtim_period);
lw_put_data(dst+16,ri->country_str,4);
lw_put_byte(dst+20,ri->max_bssid);
- /* XXX not LWAP conform */
+ // XXX not LWAP conform
lw_put_data(dst+21,(uint8_t*)"DEAU990",7);
return 21+7;
}
-
+*/
diff --git a/src/cw/lw_readelem_80211_wtp_wlan_radio_configuration.c b/src/cw/lw_readelem_80211_wtp_wlan_radio_configuration.c
deleted file mode 100644
index 5569f473..00000000
--- a/src/cw/lw_readelem_80211_wtp_wlan_radio_configuration.c
+++ /dev/null
@@ -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);
-
-
-}
diff --git a/src/cw/lw_readelem_wtp_board_data.c b/src/cw/lw_readelem_wtp_board_data.c
deleted file mode 100644
index 1c0c0ab5..00000000
--- a/src/cw/lw_readelem_wtp_board_data.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * @file
- * @brief Implementation of lw_readelem_wtp_board_data
- */
-
-#include
-
-#include "log.h"
-#include "wtpinfo.h"
-
-#include "lwapp.h"
-
-
-/**
- * Read LWAPP board data element
- * @param wtpinfo results are stored here
- * @param type type of msg element (must be LWMSGELEM_WTP_BOARD_DATA)
- * @param msgelem msg element data
- * @param len length of msg element
- * @return 0 if msg is not wtp board data\n
- * 1 board data successful read
- */
-int lw_readelem_wtp_board_data(struct wtpinfo *wtpinfo, int type, uint8_t *msgelem, int len)
-{
- if (type != LW_ELEM_WTP_BOARD_DATA)
- return 0;
-
- if ( len != 46 ) {
- cw_dbg(DBG_MSG_ERR,"LWAPP msg size wrong. (WTP BOARD DATA) must be 46");
- return -1;
- }
-
-// uint16_t card_id = htonl( * ( (uint16_t*)(msgelem) ) );
-// uint16_t card_rev = htonl( * ( (uint16_t*)(msgelem +2 ) ) );
-
- return 1;
-}
-
-
diff --git a/src/cw/lw_readelem_wtp_name.c b/src/cw/lw_readelem_wtp_name.c
index e9d57f8b..a8a80bfe 100644
--- a/src/cw/lw_readelem_wtp_name.c
+++ b/src/cw/lw_readelem_wtp_name.c
@@ -26,6 +26,7 @@
#include "cw_util.h"
#include "log.h"
+#include "dbg.h"
/**
* Reads the LWAPP message element WTP Name
@@ -42,7 +43,7 @@ int lw_readelem_wtp_name(uint8_t ** dst, int type, uint8_t * msgelem, int len)
if (len>254){
- cw_dbg(DBG_MSG_ERR,"Truncating WTP_NAME msgelem to 254, wrong size, type=%d,len=%d",type,len);
+ cw_dbg(DBG_ELEM_ERR,"Truncating WTP_NAME msgelem to 254, wrong size, type=%d,len=%d",type,len);
len=254;
}
diff --git a/src/cw/mavl.h b/src/cw/mavl.h
index b0bd15b7..26590884 100644
--- a/src/cw/mavl.h
+++ b/src/cw/mavl.h
@@ -117,31 +117,12 @@ int mavl_foreach_from_lr(struct mavl *t, struct mavlnode *n, void *data,
//extern void mavl_foreach(struct mavl *t, int (*callback)(void *,void*),void *cbpriv,int dir);
-static inline void *mavl_replace_data(struct mavl *t, void *data, int len)
-{
- void *df = mavl_get(t, data);
- if (!df)
- return NULL;
- memcpy(df, data, len);
- return df;
-}
+void *mavl_replace_data(struct mavl *t, void *data, int len);
-static inline void *mavl_replace(struct mavl *t,void *data){
- struct mavlnode * node = mavl_get_node(t,data);
- if (node){
- t->del(node->data);
- return node->data=data;
- }
- return mavl_add(t,data);
-}
+void *mavl_replace(struct mavl *t,void *data);
-static inline void mavl_destroy(struct mavl *t)
-{
- mavl_del_all(t);
- free (t);
-}
-
+void mavl_destroy(struct mavl *t);
@@ -169,41 +150,12 @@ typedef struct mavliter mavliter_t;
void * mavliter_next(mavliter_t *i);
-static inline void * mavliter_seek_set(struct mavliter *i)
-{
- i->stack_ptr=0;
- i->cur=i->root;
- return mavliter_next(i);
-}
+void * mavliter_seek_set(struct mavliter *i);
-/**
- * Init an AVL Tree Iterator.
- *
- * After initialization #mavliter_next would return the first element.
- * The behavior of #mavliter_get would still be undefined.
- * @param i AVL Iterator to initialize
- * @param t correspondending AVL Tree
- *
- * @See mavliter_t,
- */
-static inline void mavliter_init(mavliter_t *i, mavl_t t){
- i->root = t->root;
- i->stack_ptr=0;
- i->cmp=t->cmp;
-}
+void mavliter_init(mavliter_t *i, mavl_t t);
-/**
- * Get the element, where AVL Iterator currently is positioned.
- * @param i AVL Iterator
- * @return element or NULL if not found.
- */
-static inline void * mavliter_get(mavliter_t *i){
- if(!i->cur)
- return NULL;
- return i->cur->data;
-}
-
+void * mavliter_get(mavliter_t *i);
extern void * mavliter_seek(mavliter_t *i,void *d);
diff --git a/src/cw/mavl_destroy.c b/src/cw/mavl_destroy.c
new file mode 100644
index 00000000..391fa649
--- /dev/null
+++ b/src/cw/mavl_destroy.c
@@ -0,0 +1,9 @@
+#include "mavl.h"
+
+void mavl_destroy(struct mavl *t)
+{
+ mavl_del_all(t);
+ free (t);
+}
+
+
diff --git a/src/cw/mavl_replace.c b/src/cw/mavl_replace.c
new file mode 100644
index 00000000..c6ea7037
--- /dev/null
+++ b/src/cw/mavl_replace.c
@@ -0,0 +1,12 @@
+#include "mavl.h"
+
+void *mavl_replace(struct mavl *t,void *data){
+ struct mavlnode * node = mavl_get_node(t,data);
+ if (node){
+ t->del(node->data);
+ return node->data=data;
+ }
+ return mavl_add(t,data);
+}
+
+
diff --git a/src/cw/mavl_replace_data.c b/src/cw/mavl_replace_data.c
new file mode 100644
index 00000000..4e8e8c7f
--- /dev/null
+++ b/src/cw/mavl_replace_data.c
@@ -0,0 +1,12 @@
+#include "mavl.h"
+
+void *mavl_replace_data(struct mavl *t, void *data, int len)
+{
+ void *df = mavl_get(t, data);
+ if (!df)
+ return NULL;
+ memcpy(df, data, len);
+ return df;
+}
+
+
diff --git a/src/cw/mavliter_get.c b/src/cw/mavliter_get.c
new file mode 100644
index 00000000..66818d97
--- /dev/null
+++ b/src/cw/mavliter_get.c
@@ -0,0 +1,14 @@
+#include "mavl.h"
+
+/**
+ * Get the element, where AVL Iterator currently is positioned.
+ * @param i AVL Iterator
+ * @return element or NULL if not found.
+ */
+void * mavliter_get(mavliter_t *i){
+ if(!i->cur)
+ return NULL;
+ return i->cur->data;
+}
+
+
diff --git a/src/cw/mavliter_init.c b/src/cw/mavliter_init.c
new file mode 100644
index 00000000..b9c83f51
--- /dev/null
+++ b/src/cw/mavliter_init.c
@@ -0,0 +1,19 @@
+#include "mavl.h"
+
+/**
+ * Init an AVL Tree Iterator.
+ *
+ * After initialization #mavliter_next would return the first element.
+ * The behavior of #mavliter_get would still be undefined.
+ * @param i AVL Iterator to initialize
+ * @param t correspondending AVL Tree
+ *
+ * @See mavliter_t,
+ */
+void mavliter_init(mavliter_t *i, mavl_t t){
+ i->root = t->root;
+ i->stack_ptr=0;
+ i->cmp=t->cmp;
+}
+
+
diff --git a/src/cw/mavliter_seek_set.c b/src/cw/mavliter_seek_set.c
new file mode 100644
index 00000000..ca634c72
--- /dev/null
+++ b/src/cw/mavliter_seek_set.c
@@ -0,0 +1,10 @@
+#include "mavl.h"
+
+void * mavliter_seek_set(struct mavliter *i)
+{
+ i->stack_ptr=0;
+ i->cur=i->root;
+ return mavliter_next(i);
+}
+
+
diff --git a/src/cw/mbag.c b/src/cw/mbag.c
index 0829e848..bb48b3b2 100644
--- a/src/cw/mbag.c
+++ b/src/cw/mbag.c
@@ -94,14 +94,15 @@ static void mbag_type_mbag_del(void *i)
mavl_destroy(x);
}
-const struct mbag_typedef mbag_type_mbag = {
+/*const struct mbag_typedef mbag_type_mbag = {
+# "mbag",mbag_type_mbag_del
+};
+*/
+
+/*const struct mbag_typedef mbag_type_mbag_dyn = {
"mbag",mbag_type_mbag_del
};
-
-const struct mbag_typedef mbag_type_mbag_dyn = {
- "mbag",mbag_type_mbag_del
-};
-
+*/
static void mbag_del_data(struct mbag_item *i)
{
@@ -236,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;
+}
+
+
diff --git a/src/cw/mbag.h b/src/cw/mbag.h
index 2a2d27b8..96d80761 100644
--- a/src/cw/mbag.h
+++ b/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);
-static inline 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);
-*/
-}
-
-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;
-}
+bstrv_t mbag_set_bstrv(mbag_t s, const char *id, uint32_t vendor_id,
+ uint8_t * version, int len);
+int mbag_set_data(mbag_t s, const char *id, const struct mbag_typedef *type, void *data);
+int mbag_set_mbag(mbag_t s, const char *id, mbag_t mbag);
+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);
+int mbag_set_byte(mbag_t s, const char *id, uint8_t byte);
+int mbag_set(mbag_t t,mbag_item_t *is);
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)
-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)
-{
- 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);
+void mbag_del(mbag_t s,const char *id);
+mbag_item_t *mbag_i_get(mbag_t s, uint32_t id);
+mbag_item_t *mbag_get(mbag_t s, const char *id);
+
+
+
+
+
-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_bstr16(m,i,d) mbag_get_data(m,i,MBAG_BSTR16,d)
diff --git a/src/cw/mbag_type_bin.c b/src/cw/mbag_type_bin.c
deleted file mode 100644
index aeaf7500..00000000
--- a/src/cw/mbag_type_bin.c
+++ /dev/null
@@ -1,118 +0,0 @@
-#include
-
-#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; idata=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
-
-};
diff --git a/src/cw/mbag_type_bstr.c b/src/cw/mbag_type_bstr.c
deleted file mode 100644
index 554b8dbe..00000000
--- a/src/cw/mbag_type_bstr.c
+++ /dev/null
@@ -1,5 +0,0 @@
-const struct mbag_typedef mbag_type_bstr = {
- "bstr",free
-};
-
-
diff --git a/src/cw/message_set.c b/src/cw/message_set.c
index 9c70c127..93da9ed7 100644
--- a/src/cw/message_set.c
+++ b/src/cw/message_set.c
@@ -5,6 +5,7 @@
#include "message_set.h"
+/*
typedef struct {
int type;
const char * name;
@@ -12,6 +13,7 @@ typedef struct {
mavl_t elements_tree;
mlist_t elements_list;
}message2_t;
+*/
static inline int cmp_cw_msgelemprops(const void *elem1, const void *elem2){
cw_elem_handler_t * e1 = ((cw_msgelemprops_t*)elem1)->elem;
@@ -39,7 +41,7 @@ static inline int msg_cmp(const void *elem1, const void *elem2)
}
-void cw_message_set_destroy(cw_message_set_t * set){
+void cw_message_set_destroy(cw_MsgSet_t * set){
if (set->messages){
mavl_destroy(set->messages);
}
@@ -49,14 +51,14 @@ void cw_message_set_destroy(cw_message_set_t * set){
free(set);
}
-cw_message_set_t * cw_message_set_create(){
+cw_MsgSet_t * cw_message_set_create(){
/* allocate memory for a message_set */
- cw_message_set_t * set = malloc(sizeof(cw_message_set_t));
+ cw_MsgSet_t * set = malloc(sizeof(cw_MsgSet_t));
if (set==NULL)
return NULL;
- memset(set,0,sizeof(cw_message_set_t));
+ memset(set,0,sizeof(cw_MsgSet_t));
/* create mavl for all_elems */
set->all_elems = mavl_create(cmp_cw_msgelemprops,NULL);
@@ -77,7 +79,7 @@ cw_message_set_t * cw_message_set_create(){
}
-static void update_message(message2_t * msg, cw_msgdef_t * src, cw_message_set_t * set){
+static void update_message(message2_t * msg, cw_msgdef_t * src, cw_MsgSet_t * set){
cw_msgelemprops_t *md;
@@ -95,16 +97,16 @@ static void update_message(message2_t * msg, cw_msgdef_t * src, cw_message_set_t
-void cw_message_set_add(cw_message_set_t * set,
+void cw_msgset_add(cw_MsgSet_t * set,
cw_msgdef_t messages[]){
- cw_msgdef_t * m;
- for (m=messages; m->type !=0; m++){
+ cw_msgdef_t * message;
+ for (message=messages; message->type !=0; message++){
message2_t search, *next;
- search.type = m->type;
+ search.type = message->type;
- cw_dbg(DBG_INFO,"Add message: Type:%d - %s",m->type,m->name);
+ cw_dbg(DBG_INFO,"Add message: Type:%d - %s",message->type,message->name);
next = mavl_find(set->messages,&search);
@@ -125,30 +127,28 @@ void cw_message_set_add(cw_message_set_t * set,
free(next);
return;
}
- next->type=m->type;
+ next->type=message->type;
mavl_add(set->messages,next);
}
/* massage is alreaddy in there */
- if (m->name)
- next->name=m->name;
- if (m->states)
- next->states=m->states;
+ if (message->name)
+ next->name=message->name;
+ if (message->states)
+ next->states=message->states;
- update_message(next,m, set);
-
+ update_message(next,message, set);
}
-
}
cw_elem_handler_t * cw_message_set_find_element(
- cw_message_set_t * set,
+ cw_MsgSet_t * set,
cw_elem_handler_t * element){
return mavl_find(set->all_elems,element);
}
-mlist_t cw_msgset_get_msg(cw_message_set_t * set, int type){
+mlist_t cw_msgset_get_msg(cw_MsgSet_t * set, int type){
message2_t search;
search.type = type;
message2_t * result = mavl_find(set->messages,&search);
diff --git a/src/cw/message_set.h b/src/cw/message_set.h
index 39ef9174..02aea9d0 100644
--- a/src/cw/message_set.h
+++ b/src/cw/message_set.h
@@ -3,9 +3,22 @@
#include "cw.h"
-extern void cw_message_set_destroy(cw_message_set_t * set);
-extern cw_message_set_t * cw_message_set_create();
-extern void cw_message_set_add(cw_message_set_t * set,
+extern void cw_message_set_destroy(cw_MsgSet_t * set);
+extern cw_MsgSet_t * cw_message_set_create();
+extern void cw_msgset_add(cw_MsgSet_t * set,
cw_msgdef_t messages[]);
-mlist_t cw_msgset_get_msg(cw_message_set_t * set, int type);
+mlist_t cw_msgset_get_msg(cw_MsgSet_t * set, int type);
+
+
+typedef struct cw_MsgData{
+ int type;
+ const char * name;
+ int * states;
+ mavl_t elements_tree;
+ mlist_t elements_list;
+};
+
+typedef struct cw_MsgData message2_t;
+
+
#endif
\ No newline at end of file
diff --git a/src/cw/mod.c b/src/cw/mod.c
index 4e4c610f..56551f58 100644
--- a/src/cw/mod.c
+++ b/src/cw/mod.c
@@ -18,28 +18,32 @@
/**
* @file
- * @brief Functions for mods
+ * @brief Functions for modules (mods) management.
*/
#include
#include
+#include
-#include "action.h"
+//#include "action.h"
#include "mavl.h"
#include "dbg.h"
#include "log.h"
+#include "file.h"
+#include "cw.h"
+#include "cw/message_set.h"
-
-static void (*actions_registered_cb) (struct mod_ac * capwap, struct mod_ac * bindings,
+static void (*actions_registered_cb) (struct cw_Mod * capwap, struct cw_Mod * bindings,
struct cw_actiondef * actions) = NULL;
-int mod_caching = 1;
+
void mod_set_actions_registered_cb(void (*fun)
- (struct mod_ac *, struct mod_ac *, struct cw_actiondef *))
+ (struct cw_Mod *, struct cw_Mod *,
+ struct cw_actiondef *))
{
actions_registered_cb = fun;
}
@@ -48,11 +52,9 @@ void mod_set_actions_registered_cb(void (*fun)
struct cache_item {
const char *capwap;
const char *bindings;
- struct cw_actiondef actions;
-
+ struct cw_MsgSet * msgset;
};
-
-static struct mavl *cache = NULL;
+static struct mavl *msgset_cache = NULL;
static int mod_null_register_actions(struct cw_actiondef *def, int mode)
{
@@ -62,9 +64,10 @@ static int mod_null_register_actions(struct cw_actiondef *def, int mode)
/**
* mod_null is a dummy mod
*/
-struct mod_ac mod_null = {
+struct cw_Mod mod_null = {
.name = "none",
- .register_actions = mod_null_register_actions
+ .register_actions = mod_null_register_actions,
+
};
@@ -89,49 +92,194 @@ struct cw_actiondef *mod_cache_get(const char *capwap, const char *bindings)
}
-struct cw_actiondef *mod_cache_add(struct conn *conn, struct mod_ac *c, struct mod_ac *b)
+struct cw_MsgSet *cw_mod_get_msg_set(struct conn *conn,
+ struct cw_Mod * capwap_mod, struct cw_Mod *bindings_mod)
{
- if (!cache) {
- cache = mavl_create(cmp, NULL);
- if (!cache) {
- cw_log(LOG_ERR, "Can't initialize mod cache: %s",
+ if (!msgset_cache) {
+ msgset_cache = mavl_create(cmp, NULL);
+ if (!msgset_cache) {
+ cw_log(LOG_ERR, "Can't initialize msgset cache: %s",
strerror(errno));
return NULL;
}
}
- struct cache_item s;
- s.capwap = c->name;
- s.bindings = b->name;
+ struct cache_item search;
+ search.capwap = capwap_mod->name;
+ search.bindings = bindings_mod->name;
- struct cache_item *i = mavl_get(cache, &s);
- if (i) {
- cw_dbg(DBG_INFO, "Using cached actions for %s,%s", c->name, b->name);
- return &(i->actions);
+ struct cache_item * cached_set = mavl_get(msgset_cache, &search);
+ if (cached_set) {
+ cw_dbg(DBG_INFO, "Using cached message set for %s,%s", capwap_mod->name, bindings_mod->name);
+ return cached_set->msgset;
}
- i = malloc(sizeof(struct cache_item));
- if (!i) {
+ cached_set = malloc(sizeof(struct cache_item));
+ if (!cached_set) {
cw_log(LOG_ERR, "Can't allocate memory for mod cache item %s",
strerror(errno));
return NULL;
}
-
- cw_dbg(DBG_INFO, "Loading actions for %s,%s", c->name, b->name);
- memset(i, 0, sizeof(struct cache_item));
- if (c) {
- i->capwap = c->name;
- c->register_actions(&(i->actions), MOD_MODE_CAPWAP);
+ memset(cached_set, 0, sizeof(struct cache_item));
+
+ struct cw_MsgSet * set = cw_message_set_create();
+ if (!set) {
+ free(cached_set);
+ cw_log(LOG_ERR, "Can't allocate memory for mod cache item %s",
+ strerror(errno));
+ return NULL;
}
- if (b) {
- i->bindings = b->name;
- b->register_actions(&(i->actions), MOD_MODE_BINDINGS);
+ cached_set->msgset=set;
+
+
+
+ cw_dbg(DBG_INFO, "Loading message set for %s,%s", capwap_mod->name, bindings_mod->name);
+
+
+ if (capwap_mod) {
+ cached_set->capwap = capwap_mod->name;
+ //c->register_actions(&(i->actions), CW_MOD_MODE_CAPWAP);
+ capwap_mod->register_messages(cached_set->msgset,CW_MOD_MODE_CAPWAP);
+ }
+ if (bindings_mod) {
+ cached_set->bindings = bindings_mod->name;
+ //b->register_actions(&(i->actions), MOD_MODE_BINDINGS);
}
- if (actions_registered_cb)
- actions_registered_cb(c,b,&(i->actions));
+// if (actions_registered_cb)
+// actions_registered_cb(capwap_mod, bindings_mod, &(cached_set->actions));
- mavl_add(cache, i);
- return &(i->actions);
+ mavl_add(msgset_cache, cached_set);
+ return cached_set->msgset;
+}
+
+
+
+/* static mavl to store modules */
+static struct mavl * mods_loaded = NULL;
+static int mod_cmp(const void *e1, const void *e2){
+ const struct cw_Mod * m1 = e1;
+ const struct cw_Mod * m2 = e2;
+ return strcmp(m1->name,m2->name);
+}
+
+static const char * mod_path="./";
+
+void cw_mod_set_mod_path(const char * path){
+ mod_path = path;
+}
+
+/**
+ * @brief Load a module
+ * @param mod_name Name of the module
+ * @return a pointer to the module interface
+ */
+struct cw_Mod * cw_mod_load(const char * mod_name){
+
+
+ /* if modlist is not initialized, initialize ... */
+ if (mods_loaded==NULL){
+ mods_loaded=mavl_create(mod_cmp,NULL);
+ if (mods_loaded==NULL){
+ cw_log(LOG_ERROR, "Can't init modlist, no memory");
+ return NULL;
+ }
+ }
+
+ /* Search for the module in mods_loaded, to see if it is
+ * already loaded or was statically linked */
+ struct cw_Mod search;
+ memset(&search,0,sizeof(search));
+ search.name=mod_name;
+ struct cw_Mod * mod;
+ mod = mavl_find(mods_loaded,&search);
+ if (mod){
+ return mod;
+ }
+
+ if (strlen(mod_name)>CW_MOD_MAX_MOD_NAME_LEN){
+ cw_log(LOG_ERROR,"Mod name too long: %s (max allowed = %d)",
+ mod_name,CW_MOD_MAX_MOD_NAME_LEN);
+ return NULL;
+ }
+
+ char mod_filename[CW_MOD_MAX_MOD_NAME_LEN+5];
+ sprintf(mod_filename,"mod_%s",mod_name);
+
+ /* we have to load the module dynamically */
+ char * filename;
+ filename = cw_filename(mod_path,mod_filename,".so");
+ if (filename==NULL)
+ return NULL;
+
+ /* Open the DLL */
+ void * handle;
+ handle = dlopen(filename,RTLD_NOW);
+
+ if (!handle){
+ cw_log(LOG_ERROR,"Failed to load module: %s",dlerror());
+ goto errX;
+ }
+
+ struct cw_Mod * (*mod_get_interface)();
+
+ mod_get_interface = dlsym(handle,mod_filename);
+
+ if (!mod_get_interface){
+ cw_log(LOG_ERROR,"Failed to load module: %s",dlerror());
+ goto errX;
+ }
+
+ mod = mod_get_interface();
+ mod->dll_handle=handle;
+
+ if (!mavl_add(mods_loaded,mod)){
+ dlclose(handle);
+ cw_log(LOG_ERR,"Can' add module %s",mod_name);
+ goto errX;
+ }
+
+ mod->init();
+errX:
+ free(filename);
+ return mod;
+}
+
+
+
+static struct mlist * mods_list = NULL;
+
+struct cw_Mod * cw_mod_add_to_list(struct cw_Mod * mod ){
+ if (!mods_list){
+ mods_list = mlist_create(mod_cmp);
+ if (!mods_list){
+ cw_log(LOG_ERROR,"Can't init mods_list");
+ return 0;
+ }
+ }
+ return mlist_append(mods_list,mod)->data;
+}
+
+struct cw_Mod * cw_mod_detect(struct conn *conn,
+ uint8_t * rawmsg, int len,
+ int elems_len, struct sockaddr *from,
+ int mode){
+ if (mods_list==NULL)
+ return MOD_NULL;
+
+ struct mlist_elem * e;
+ mlist_foreach(e,mods_list){
+ struct cw_Mod * mod = e->data;
+ cw_dbg(DBG_MOD,"Checking mod: %s",mod->name);
+
+ /* if there is no detect method, skip */
+ if (!mod->detect)
+ continue;
+
+ if ( mod->detect(conn,rawmsg,len,elems_len,from,mode) ){
+ return mod;
+ }
+ }
+ return MOD_NULL;
}
diff --git a/src/cw/mod.h b/src/cw/mod.h
index caedd4a0..fbfdc247 100644
--- a/src/cw/mod.h
+++ b/src/cw/mod.h
@@ -16,6 +16,11 @@
*/
+/**
+ * @file
+ * @brief module definitions
+ */
+
#ifndef __MOD_H
#define __MOD_H
@@ -28,15 +33,14 @@
struct cw_actiondef;
-#define MOD_MAXMODS 8
enum {
- MOD_MODE_CAPWAP,
+ CW_MOD_MODE_CAPWAP,
MOD_MODE_BINDINGS
};
-struct mod_ac {
- /** Name of the mod */
+struct cw_Mod {
+ /** Name of the module */
const char *name;
/** Initializion method */
int (*init) ();
@@ -45,8 +49,10 @@ struct mod_ac {
int (*init_config) (mbag_t config);
/** Detect capwap
- This function is called after receiving and disassembling a complete
- CAPWAP message. Either on Discovery Request or Join Request
+ * This function is called after receiving and disassembling a complete
+ * CAPWAP message. Either on Discovery Request or Join Request.
+ * @param conn current connection
+ * @return 0 if notdetected
**/
int (*detect) (struct conn * conn, const uint8_t * rawmsg, int rawlen,
int elems_len, struct sockaddr * from, int mode);
@@ -56,31 +62,45 @@ struct mod_ac {
/** Register actions */
int (*register_actions) (struct cw_actiondef * def,int mode);
+
+ struct cw_MsgSet * (*register_messages)(struct cw_MsgSet * set, int mode);
+
+ /**
+ * Handle returned by dlopen, if this module was loaded
+ * dynamically with dlopen. If this module was statically
+ * linked, dll_handle is NULL.
+ */
+ void * dll_handle;
};
-/**
- * We define here struct mod_wtp in case we need
- * different methods for WTP and AC later
- */
-#define mod_wtp mod_ac
-
-extern struct mod_ac mod_null;
+extern struct cw_Mod mod_null;
#define MOD_NULL (&mod_null)
-struct cw_actiondef * mod_cache_add(struct conn *conn,struct mod_ac *c, struct mod_ac *b);
+struct cw_actiondef * mod_cache_add(struct conn *conn,struct cw_Mod *c, struct cw_Mod *b);
#define mod_init_config(mod,cfg) (mod->init_config ? mod->init_config(cfg):1)
-void mod_set_actions_registered_cb(void (*fun) (struct mod_ac *, struct mod_ac *, struct cw_actiondef *));
+void mod_set_actions_registered_cb(void (*fun) (struct cw_Mod *, struct cw_Mod *, struct cw_actiondef *));
extern int mod_caching;
#define mod_set_caching(var) (mod_caching=var)
#define mod_get_caching() (mod_caching)
+struct cw_Mod * cw_mod_load(const char * mod_name);
+struct cw_Mod * cw_mod_add_to_list(struct cw_Mod * mod );
+struct cw_Mod * cw_mod_detect(struct conn *conn,
+ uint8_t * rawmsg, int len,
+ int elems_len, struct sockaddr *from,
+ int mode);
+struct cw_MsgSet *cw_mod_get_msg_set(struct conn *conn,
+ struct cw_Mod * capwap_mod, struct cw_Mod *bindings_mod);
+
+#define CW_MOD_MAX_MOD_NAME_LEN 128
+#define CW_MOD_INTERFACE_FUNCTION_NAME_SUFFIX "_get_interface"
#endif
diff --git a/src/cw/sock_get_primary_if.c b/src/cw/sock_get_primary_if.c
index 375e06f9..d46502f0 100644
--- a/src/cw/sock_get_primary_if.c
+++ b/src/cw/sock_get_primary_if.c
@@ -53,4 +53,3 @@ char * sock_get_primary_if(int family)
return r;
}
-
diff --git a/src/cw/sock_getifaddr.c b/src/cw/sock_getifaddr.c
index 5942dbe9..79ce5e2b 100644
--- a/src/cw/sock_getifaddr.c
+++ b/src/cw/sock_getifaddr.c
@@ -52,11 +52,10 @@ int sock_getifaddr(const char * ifname,int family, int type,struct sockaddr * sa
memcpy (sa, ifa->ifa_addr, sock_addrlen(ifa->ifa_addr));
rc=1;
break;
- case IFF_BROADCAST:
-// memcpy (sa, ifa->ifa_ifu.ifu_broadaddr, sock_addrlen(ifa->ifa_addr));
- memcpy (sa, ifa->ifa_broadaddr, sock_addrlen(ifa->ifa_addr));
- rc=1;
- break;
+// case IFF_BROADCAST:
+// memcpy (sa, ifa->ifa_broadaddr, sock_addrlen(ifa->ifa_addr));
+// rc=1;
+// break;
default:
break;
diff --git a/src/cw/wtpinfo_lwreadelem_wtp_descriptor.c b/src/cw/wtpinfo_lwreadelem_wtp_descriptor.c
deleted file mode 100644
index abadcafd..00000000
--- a/src/cw/wtpinfo_lwreadelem_wtp_descriptor.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- This file is part of libcapwap.
-
- libcapwap is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- libcapwap is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Foobar. If not, see .
-
-*/
-
-#include
-#include
-
-#include "capwap.h"
-#include "lwapp.h"
-
-#include "wtpinfo.h"
-
-#include "cw_util.h"
-
-int wtpinfo_lwreadelem_wtp_descriptor(struct wtpinfo * wtpinfo, int type, uint8_t *msgelem, int len)
-{
- if (type != LW_ELEM_WTP_DESCRIPTOR)
- return 0;
-
-/* if (len!=16)
- return -1;
-*/
-
- char str[64];
- uint32_t hwversion=ntohl(*((uint32_t*)(msgelem)));
- sprintf(str,"%08X",hwversion);
- cw_setstr(&wtpinfo->hardware_version,(uint8_t*)str,strlen(str));
-
- uint32_t swversion=ntohl(*((uint32_t*)(msgelem+4)));
- sprintf(str,"%08X",swversion);
- cw_setstr(&wtpinfo->software_version,(uint8_t*)str,strlen(str));
-
- uint32_t btversion=ntohl(*((uint32_t*)(msgelem+8)));
- sprintf(str,"%08X",btversion);
- cw_setstr(&wtpinfo->bootloader_version,(uint8_t*)str,strlen(str));
-
- uint32_t l=ntohl(*((uint32_t*)(msgelem+12)));
-
- wtpinfo->max_radios = l >> 24;
- wtpinfo->radios_in_use = (l>>16) & 0xff;
-
-
- return 1;
-}
-
diff --git a/src/cw/wtpinfo_readelem_wtp_board_data.c b/src/cw/wtpinfo_readelem_wtp_board_data.c
deleted file mode 100644
index 45c203b8..00000000
--- a/src/cw/wtpinfo_readelem_wtp_board_data.c
+++ /dev/null
@@ -1,73 +0,0 @@
-
-#include
-#include
-
-
-#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(ivendor_id = ntohl(*((uint32_t*)msgelem));
- wtpinfo_readsubelems_wtp_board_data(wtpinfo,msgelem+4,len-4);
- return 1;
-}
-
-
diff --git a/src/mod/Mod.mak b/src/mod/Mod.mak
index 51663598..8ad1d35a 100644
--- a/src/mod/Mod.mak
+++ b/src/mod/Mod.mak
@@ -1,31 +1,43 @@
include ../../Macros.mak
include ../../Config.mak
+include ../../Config.local.mak
+
+OBJS:=$(patsubst %.o,$(OBJDIR)/%.o,$(OBJS))
-OBJS:=$(patsubst %.o,$(ARCH)/%.o,$(OBJS))
+CFLAGS = -fPIC -Wall -g -O0 -D_REENTRANT -DWITH_IPV6 $(COMPDEFS) -DWITH_RMAC_SUPPORT -I ../../ -I../ -I../../include
-CFLAGS = -Wall -g -O0 -D_REENTRANT -DWITH_IPV6 $(COMPDEFS) -DWITH_RMAC_SUPPORT -I ../../ -I../ -I../../include
-
-LIBDIR=../../lib/$(ARCH)
-
SRCS = $(OBJS:.o=.c)
-$(ARCH)/%.o:%.c
- @mkdir -p $(ARCH)
- @echo " CC "$<
+all: $(SNAME) $(DNAME) $(MODNAME)
+
+$(OBJDIR)/%.o:%.c
+ @mkdir -p $(OBJDIR)
+ @echo " $(CC) "$<
@$(CC) -c $(CFLAGS) $< -o $@
-$(LIBDIR)/$(NAME) : $(OBJS) $(MODOBJS)
- @mkdir -p $(LIBDIR)
- @echo " AR $(LIBDIR)/$(NAME)"
- @$(AR) rcs $(LIBDIR)/$(NAME) $(OBJS) $(MODOBJS)
+$(SNAME) : $(OBJS) $(MODOBJS)
+ @mkdir -p $(LIBARCHDIR)
+ @echo " $(AR) $(SNAME)"
+ @$(AR) rcs $(SNAME) $(OBJS) $(MODOBJS)
+
+$(DNAME) : $(OBJS) $(MODOBJS)
+ @mkdir -p $(LIBARCHDIR)
+ @echo " $(CC) $(DNAME)"
+ @$(CC) -L$(LIBARCHDIR) $(LDFLAGS) -shared -o $(DNAME) $(OBJS) $(MODOBJS) $(SLIBS) $(LIBS)
+
+$(MODNAME) : $(DNAME)
+ cp $(DNAME) $(MODNAME)
+
+# $(CC) -L$(LIBARCHDIR) $(OBJS) $(MODOBJS) $(SLIBS) -v -shared -o ../../../lib/actube/capwap.so
-all: $(LIBDIR)/$(NAME)
clean:
- rm -rf $(ARCH)
- rm -f $(LIBDIR)/$(NAME)
+ rm -rf $(OBJDIR)
+ rm -f $(SNAME)
+ rm -f $(DNAME)
+ rm -f $(MODNAME)
diff --git a/src/mod/capwap/Makefile b/src/mod/capwap/Makefile
index b57c7671..08788054 100644
--- a/src/mod/capwap/Makefile
+++ b/src/mod/capwap/Makefile
@@ -1,3 +1,8 @@
+include ../../Macros.mak
+include ../../Config.mak
+include ../../Config.local.mak
+
+
OBJS=\
mod_capwap_ac.o \
@@ -12,10 +17,15 @@ OBJS=\
capwap_in_wtp_descriptor.o \
capwap_out_ac_ip_list.o \
capwap_in_session_id.o \
-# capwap_in
-NAME=libcapwap.a
+LIBDIR := ../../../lib
+LIBARCHDIR := $(LIBDIR)/$(ARCH)
+OBJDIR := ../../../obj/mod_capwap/$(ARCH)
+SNAME := $(LIBARCHDIR)/libmod_capwap.a
+DNAME := $(LIBARCHDIR)/mod_capwap.so
+MODNAME := $(LIBDIR)/mod_capwap.so
+SLIBS := -lcw
include ../Mod.mak
diff --git a/src/mod/capwap/capwap_actions_ac.c b/src/mod/capwap/capwap_actions_ac.c
index 03005c4c..4031c04c 100644
--- a/src/mod/capwap/capwap_actions_ac.c
+++ b/src/mod/capwap/capwap_actions_ac.c
@@ -101,7 +101,8 @@ static cw_msgdef_t messages[] = {
/* Discovery Request Message*/
{
.name = "Discovery Request",
- .type = CAPWAP_MSG_DISCOVERY_REQUEST,
+ // .type = CAPWAP_MSG_DISCOVERY_REQUEST,
+ .type = 7,
.states = (int[]){CAPWAP_STATE_DISCOVERY,0},
.elements = (cw_msgelemprops_t []){
{&_DISCOVERY_TYPE,1},
@@ -123,19 +124,31 @@ static cw_msgdef_t messages[] = {
{&_AC_DESCRIPTOR,1},
{0,0},
}
- }
+ },
+ {0,0,0,0}
+
+
+
};
+
+struct cw_MsgSet * capwap_register_msg_set(struct cw_MsgSet * set, int mode){
+ if (mode != CW_MOD_MODE_CAPWAP)
+ return NULL;
+ cw_msgset_add(set,messages);
+ return set;
+}
+
void test_sets(){
- cw_message_set_t * set = cw_message_set_create();
+ cw_MsgSet_t * set = cw_message_set_create();
if (set==NULL){
cw_log(LOG_ERR,"No mem");
return;
}
- cw_message_set_add(set,messages);
+ cw_msgset_add(set,messages);
cw_elem_handler_t el;
memset(&el,0,sizeof(el));
diff --git a/src/mod/capwap/mod_capwap.h b/src/mod/capwap/mod_capwap.h
index a118fc3f..0c90b3cb 100644
--- a/src/mod/capwap/mod_capwap.h
+++ b/src/mod/capwap/mod_capwap.h
@@ -1,8 +1,8 @@
#ifndef __MOD_CAPWAP_H
#define __MOD_CAPWAP_H
-struct mod_ac *mod_capwap_ac();
-struct mod_wtp *mod_capwap_wtp();
+struct cw_Mod *mod_capwap_ac();
+struct cw_Mod *mod_capwap_wtp();
extern int capwap_in_wtp_descriptor(struct conn *conn, struct cw_action_in *a,
@@ -28,5 +28,8 @@ extern struct mbag_item * capwap_out_get_capwap_timers(struct conn *conn,struct
extern int capwap_out_ac_ip_list(struct conn *conn, struct cw_action_out *a, uint8_t * dst);
+struct cw_MsgSet * capwap_register_msg_set(struct cw_MsgSet * set, int mode);
+
+
#endif
diff --git a/src/mod/capwap/mod_capwap_ac.c b/src/mod/capwap/mod_capwap_ac.c
index e5387fe6..f1ae89b7 100644
--- a/src/mod/capwap/mod_capwap_ac.c
+++ b/src/mod/capwap/mod_capwap_ac.c
@@ -18,8 +18,6 @@ extern int capwap_register_actions_ac(struct cw_actiondef *def);
static int init()
{
cw_dbg(DBG_MOD, "Initialiazing mod_capwap.");
-// int rc = capwap_register_actions_ac(&actions);
-// cw_dbg(DBG_INFO, "Initialized mod capwap with %d actions", rc);
return 0;
}
@@ -27,7 +25,7 @@ static int init()
static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int elems_len,
struct sockaddr *from, int mode)
{
- if (mode != MOD_MODE_CAPWAP)
+ if (mode != CW_MOD_MODE_CAPWAP)
return 0;
cw_dbg(DBG_MOD,"CAPWAP detected: yes");
return 1;
@@ -35,21 +33,27 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele
static int register_actions(struct cw_actiondef *def, int mode)
{
- if (mode != MOD_MODE_CAPWAP)
+ if (mode != CW_MOD_MODE_CAPWAP)
return 0;
return capwap_register_actions_ac(def);
}
-static struct mod_ac capwap_ac = {
+static struct cw_Mod capwap_ac = {
.name = "capwap",
.init = init,
.detect = detect,
- .register_actions = register_actions
+ .register_actions = register_actions,
+ .register_messages = capwap_register_msg_set
};
-struct mod_ac *mod_capwap_ac()
+struct cw_Mod *mod_capwap_ac()
{
return &capwap_ac;
};
+
+
+struct cw_Mod * mod_capwap(){
+ return &capwap_ac;
+}
\ No newline at end of file
diff --git a/src/mod/capwap/mod_capwap_wtp.c b/src/mod/capwap/mod_capwap_wtp.c
index 7c2f69d1..830d6a31 100644
--- a/src/mod/capwap/mod_capwap_wtp.c
+++ b/src/mod/capwap/mod_capwap_wtp.c
@@ -27,28 +27,28 @@ static int init()
static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int elems_len,
struct sockaddr *from, int mode)
{
- if (mode != MOD_MODE_CAPWAP)
+ if (mode != CW_MOD_MODE_CAPWAP)
return 0;
conn->detected = 1;
- conn->actions = &actions;
+ //conn->actions = &actions;
return 1;
}
static int register_actions(struct cw_actiondef *def, int mode)
{
- if (mode != MOD_MODE_CAPWAP)
+ if (mode != CW_MOD_MODE_CAPWAP)
return 0;
return capwap_register_actions_wtp(def);
}
-static struct mod_wtp capwap_wtp = {
+static struct cw_Mod capwap_wtp = {
.name = "capwap",
.init = init,
.detect = detect,
.register_actions=register_actions
};
-struct mod_wtp *mod_capwap_wtp()
+struct cw_Mod *mod_capwap_wtp()
{
return &capwap_wtp;
};
diff --git a/src/mod/capwap80211/mod_capwap80211.h b/src/mod/capwap80211/mod_capwap80211.h
index ebae79b2..4fbedea0 100644
--- a/src/mod/capwap80211/mod_capwap80211.h
+++ b/src/mod/capwap80211/mod_capwap80211.h
@@ -1,8 +1,8 @@
#ifndef __MOD_CAPWAP80211_H
#define __MOD_CAPWAP80211_H
-struct mod_ac *mod_capwap80211_ac();
-struct mod_wtp *mod_capwap80211_wtp();
+struct cw_Mod *mod_capwap80211_ac();
+struct cw_Mod *mod_capwap80211_wtp();
extern int capwap80211_register_actions_ac(struct cw_actiondef *def);
extern int capwap80211_register_actions_wtp(struct cw_actiondef *def);
diff --git a/src/mod/capwap80211/mod_capwap80211_ac.c b/src/mod/capwap80211/mod_capwap80211_ac.c
index 12884259..10e5cf64 100644
--- a/src/mod/capwap80211/mod_capwap80211_ac.c
+++ b/src/mod/capwap80211/mod_capwap80211_ac.c
@@ -47,14 +47,14 @@ static int register_actions(struct cw_actiondef *actions, int mode)
return capwap80211_register_actions_ac(actions);
}
-static struct mod_ac capwap80211_ac = {
+static struct cw_Mod capwap80211_ac = {
.name = "capwap80211",
.init = init,
.detect = detect,
.register_actions = register_actions
};
-struct mod_ac *mod_capwap80211_ac()
+struct cw_Mod *mod_capwap80211_ac()
{
return &capwap80211_ac;
};
diff --git a/src/mod/capwap80211/mod_capwap80211_wtp.c b/src/mod/capwap80211/mod_capwap80211_wtp.c
index 69f5675e..9dd9cdc3 100644
--- a/src/mod/capwap80211/mod_capwap80211_wtp.c
+++ b/src/mod/capwap80211/mod_capwap80211_wtp.c
@@ -40,14 +40,14 @@ static int register_actions(struct cw_actiondef *actions,int mode)
return capwap80211_register_actions_wtp(actions);
}
-static struct mod_ac capwap80211_wtp = {
+static struct cw_Mod capwap80211_wtp = {
.name = "capwap80211",
.init = init,
.detect = detect,
.register_actions = register_actions
};
-struct mod_ac *mod_capwap80211_wtp()
+struct cw_Mod *mod_capwap80211_wtp()
{
return &capwap80211_wtp;
};
diff --git a/src/mod/cipwap/Makefile b/src/mod/cipwap/Makefile
index a16c9a15..4e931050 100644
--- a/src/mod/cipwap/Makefile
+++ b/src/mod/cipwap/Makefile
@@ -1,13 +1,23 @@
+include ../../Macros.mak
+include ../../Config.mak
+include ../../Config.local.mak
OBJS=\
mod_cipwap_ac.o \
- mod_cipwap_wtp.o \
cipwap_actions_ac.o \
cipwap_actions_wtp.o \
cipwap_items.o \
+NAME := cipwap
+
+LIBDIR := ../../../lib
+LIBARCHDIR := $(LIBDIR)/$(ARCH)
+OBJDIR := ../../../obj/mod_$(NAME)/$(ARCH)
+SNAME := $(LIBARCHDIR)/libmod_$(NAME).a
+DNAME := $(LIBARCHDIR)/mod_$(NAME).so
+MODNAME := $(LIBDIR)/mod_$(NAME).so
+SLIBS := -lcw
-NAME=libcipwap.a
include ../Mod.mak
diff --git a/src/mod/cipwap/mod_cipwap.h b/src/mod/cipwap/mod_cipwap.h
index d6530c53..0c4bb045 100644
--- a/src/mod/cipwap/mod_cipwap.h
+++ b/src/mod/cipwap/mod_cipwap.h
@@ -1,8 +1,8 @@
#ifndef __MOD_CIPWAP_H
#define __MOD_CIPWAP_H
-struct mod_ac * mod_cipwap_ac();
-struct mod_wtp * mod_cipwap_wtp();
+struct cw_Mod * mod_cipwap_ac();
+struct cw_Mod * mod_cipwap_wtp();
extern int cipwap_register_actions_ac(struct cw_actiondef *def);
diff --git a/src/mod/cipwap/mod_cipwap_ac.c b/src/mod/cipwap/mod_cipwap_ac.c
index 72d54fb9..cf18fb8f 100644
--- a/src/mod/cipwap/mod_cipwap_ac.c
+++ b/src/mod/cipwap/mod_cipwap_ac.c
@@ -18,7 +18,7 @@ int cipwap_init()
static int detect(struct conn *conn,const uint8_t *rawmsg, int rawlen,int elems_len, struct sockaddr *from, int mode)
{
- if (mode == MOD_MODE_CAPWAP)
+ if (mode == CW_MOD_MODE_CAPWAP)
return 1;
return 0;
@@ -27,16 +27,16 @@ static int detect(struct conn *conn,const uint8_t *rawmsg, int rawlen,int elems_
static int register_actions(struct cw_actiondef *actions, int mode)
{
switch (mode) {
- case MOD_MODE_CAPWAP:
+ case CW_MOD_MODE_CAPWAP:
{
- struct mod_ac *cmod = modload_ac("capwap");
+ struct cw_Mod *cmod = modload_ac("capwap");
if (!cmod) {
cw_log(LOG_ERR,
"Can't initialize mod_cisco, failed to load base mod mod_capwap");
return 1;
}
- cmod->register_actions(actions, MOD_MODE_CAPWAP);
+ cmod->register_actions(actions, CW_MOD_MODE_CAPWAP);
int rc = cipwap_register_actions_ac(actions);
cw_dbg(DBG_INFO, "Initialized mod_cisco with %d actions", rc);
return rc;
@@ -69,7 +69,7 @@ static int register_actions(struct cw_actiondef *actions, int mode)
-static struct mod_ac cipwap_ac = {
+static struct cw_Mod cipwap_ac = {
.name ="cipwap",
.init = cipwap_init,
.detect = detect,
@@ -79,7 +79,7 @@ static struct mod_ac cipwap_ac = {
-struct mod_ac * mod_cipwap_ac(){
+struct cw_Mod * mod_cipwap_ac(){
return &cipwap_ac;
};
diff --git a/src/mod/cipwap/mod_cipwap_wtp.c b/src/mod/cipwap/mod_cipwap_wtp.c
index cac0e6b9..99f85620 100644
--- a/src/mod/cipwap/mod_cipwap_wtp.c
+++ b/src/mod/cipwap/mod_cipwap_wtp.c
@@ -18,7 +18,7 @@ int cipwap_init()
static int detect(struct conn *conn,const uint8_t *rawmsg, int rawlen,int elems_len, struct sockaddr *from, int mode)
{
- if (mode == MOD_MODE_CAPWAP)
+ if (mode == CW_MOD_MODE_CAPWAP)
return 1;
return 0;
@@ -27,16 +27,16 @@ static int detect(struct conn *conn,const uint8_t *rawmsg, int rawlen,int elems_
static int register_actions(struct cw_actiondef *actions, int mode)
{
switch (mode) {
- case MOD_MODE_CAPWAP:
+ case CW_MOD_MODE_CAPWAP:
{
- struct mod_ac *cmod = modload_wtp("capwap");
+ struct cw_Mod *cmod = modload_wtp("capwap");
if (!cmod) {
cw_log(LOG_ERR,
"Can't initialize mod_cisco, failed to load base mod mod_capwap");
return 1;
}
- cmod->register_actions(actions, MOD_MODE_CAPWAP);
+ cmod->register_actions(actions, CW_MOD_MODE_CAPWAP);
int rc = cipwap_register_actions_ac(actions);
cw_dbg(DBG_INFO, "Initialized mod_cisco with %d actions", rc);
return rc;
@@ -69,7 +69,7 @@ static int register_actions(struct cw_actiondef *actions, int mode)
-static struct mod_ac cipwap_wtp = {
+static struct cw_Mod cipwap_wtp = {
.name ="cipwap",
.init = cipwap_init,
.detect = detect,
@@ -79,7 +79,7 @@ static struct mod_ac cipwap_wtp = {
-struct mod_ac * mod_cipwap_wtp(){
+struct cw_Mod * mod_cipwap_wtp(){
return &cipwap_wtp;
};
diff --git a/src/mod/cisco/Makefile b/src/mod/cisco/Makefile
index c0732cd8..e1947683 100644
--- a/src/mod/cisco/Makefile
+++ b/src/mod/cisco/Makefile
@@ -1,7 +1,10 @@
+include ../../Macros.mak
+include ../../Config.mak
+include ../../Config.local.mak
+
OBJS=\
mod_cisco_ac.o \
- mod_cisco_wtp.o \
cisco_actions_ac.o \
cisco_actions_wtp.o \
cisco_out_ap_timesync.o \
@@ -31,8 +34,14 @@ OBJS=\
# cisco_out_radio_administrative_state.o \
+LIBDIR := ../../../lib
+LIBARCHDIR := $(LIBDIR)/$(ARCH)
+OBJDIR := ../../../obj/mod_cisco/$(ARCH)
+SNAME := $(LIBARCHDIR)/libmod_cisco.a
+DNAME := $(LIBARCHDIR)/mod_cisco.so
+MODNAME := $(LIBDIR)/mod_cisco.so
+SLIBS := -lcw -lmod_cipwap -lmod_capwap
-NAME=libcisco.a
include ../Mod.mak
diff --git a/src/mod/cisco/cisco.h b/src/mod/cisco/cisco.h
index 8b507e98..26dfefd5 100644
--- a/src/mod/cisco/cisco.h
+++ b/src/mod/cisco/cisco.h
@@ -51,5 +51,5 @@ int cisco_out_wtp_operational_state(struct conn *conn, struct cw_action_out *a,
int cisco_out_radio_operational_state(struct conn *conn, struct cw_action_out *a, uint8_t * dst);
int cisco_in_radio_operational_state(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len, struct sockaddr *from);
-
+struct cw_MsgSet * cisco_register_msg_set(struct cw_MsgSet * set, int mode);
#endif
diff --git a/src/mod/cisco/cisco_actions_ac.c b/src/mod/cisco/cisco_actions_ac.c
index 72125bbc..858d2f31 100644
--- a/src/mod/cisco/cisco_actions_ac.c
+++ b/src/mod/cisco/cisco_actions_ac.c
@@ -41,6 +41,62 @@
#include "include/cipwap_items.h"
+
+static cw_elem_handler_t _DISCOVERY_TYPE = {
+ .id = CAPWAP_ELEM_DISCOVERY_TYPE,
+ .name = "WTP Frame Tunnel Mode",
+// .start = cw_in_generic2,
+// .item_id = CW_ITEM_WTP_FRAME_TUNNEL_MODE,
+ .min_len = 1,
+ .max_len = 1
+};
+
+
+static cw_msgdef_t messages[] = {
+
+ /* Discovery Request Message*/
+ {
+ .name = "Discovery Request Cisco",
+ .type = CAPWAP_MSG_DISCOVERY_REQUEST,
+ .states = (int[]){CAPWAP_STATE_DISCOVERY,0},
+ .elements = (cw_msgelemprops_t []){
+ {&_DISCOVERY_TYPE,1},
+ {0,0},
+ }
+ },
+ /* Discovery Request Response */
+ {
+ .name = "Discovery Response",
+ .type = CAPWAP_MSG_DISCOVERY_RESPONSE,
+ .states = (int[]){CAPWAP_STATE_DISCOVERY,0},
+ .elements = (cw_msgelemprops_t[]){
+ {0,0},
+ }
+ },
+ {0,0,0,0}
+
+
+
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
static cw_action_in_t actions_in[] = {
@@ -493,6 +549,15 @@ static cw_action_out_t actions_out[]={
};
+
+struct cw_MsgSet * cisco_register_msg_set(struct cw_MsgSet * set, int mode){
+ if (mode != CW_MOD_MODE_CAPWAP)
+ return NULL;
+ cw_msgset_add(set,messages);
+ return set;
+}
+
+
static cw_action_in_t actions80211_in[] = {
/* --------------------------------------------------------
* Discovery Resquest
diff --git a/src/mod/cisco/cisco_out_wtp_descriptor.c b/src/mod/cisco/cisco_out_wtp_descriptor.c
index 46fad8a1..b861d7b7 100644
--- a/src/mod/cisco/cisco_out_wtp_descriptor.c
+++ b/src/mod/cisco/cisco_out_wtp_descriptor.c
@@ -6,12 +6,13 @@
#include "cisco.h"
-extern mbag_t cisco_config_wtp;
+//#extern mbag_t cisco_config_wtp;
int cisco_out_wtp_descriptor(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
{
- mbag_t mbag = cisco_config_wtp;
+// mbag_t mbag = cisco_config_wtp;
+mbag_t mbag = NULL;
// XXX Dummy WTP Descriptor Header
uint8_t *d = dst+4;
diff --git a/src/mod/cisco/mod_cisco.h b/src/mod/cisco/mod_cisco.h
index e0e4b9b2..c1f8ee36 100644
--- a/src/mod/cisco/mod_cisco.h
+++ b/src/mod/cisco/mod_cisco.h
@@ -1,8 +1,9 @@
#ifndef __MOD_CISCO_H
#define __MOD_CISCO_H
-struct mod_ac * mod_cisco_ac();
-struct mod_ac * mod_cisco_wtp();
+struct cw_Mod * mod_cisco_ac();
+struct cw_Mod * mod_cisco_wtp();
+struct cw_MsgSet * cisco_register_msg_set(struct cw_MsgSet * set, int mode);
#endif
diff --git a/src/mod/cisco/mod_cisco_ac.c b/src/mod/cisco/mod_cisco_ac.c
index 54608193..3eab725a 100644
--- a/src/mod/cisco/mod_cisco_ac.c
+++ b/src/mod/cisco/mod_cisco_ac.c
@@ -21,34 +21,34 @@ extern int cisco_register_actions_ac(struct cw_actiondef *def);
mbag_t cisco_config = NULL;
-static int register_actions(struct cw_actiondef *actions, int mode)
+static struct cw_MsgSet * register_messages(struct cw_MsgSet *set, int mode)
{
switch (mode) {
- case MOD_MODE_CAPWAP:
+ case CW_MOD_MODE_CAPWAP:
{
- struct mod_ac *cmod = modload_ac("cipwap");
+ struct cw_Mod *cmod = cw_mod_load("capwap");// NULL; //modload_ac("cipwap");
if (!cmod) {
cw_log(LOG_ERR,
- "Can't initialize mod_cisco, failed to load base mod mod_cipwap");
+ "Can't initialize mod_cisco, failed to load base module mod_cipwap");
return 1;
}
- cmod->register_actions(actions, MOD_MODE_CAPWAP);
- int rc = cisco_register_actions_ac(actions);
- cw_dbg(DBG_INFO, "Initialized mod_cisco with %d actions", rc);
+ cmod->register_messages(set, CW_MOD_MODE_CAPWAP);
+ cisco_register_msg_set(set,CW_MOD_MODE_CAPWAP);
+ cw_dbg(DBG_INFO, "Initialized mod_cisco with %d messafe", 7);
return 0;
}
case MOD_MODE_BINDINGS:
{
- struct mod_ac *cmod = modload_ac("capwap80211");
+ struct cw_Mod *cmod = NULL; //modload_ac("capwap80211");
if (!cmod) {
cw_log(LOG_ERR,
"Can't initialize mod_cisco, failed to load base mod mod_capwap80211");
return 1;
}
- cmod->register_actions(actions, MOD_MODE_BINDINGS);
- int rc = cisco_register_actions80211_ac(actions);
- cw_dbg(DBG_INFO, "Initialized mod_cisco 80211 with %d actions", rc);
+ cmod->register_messages(set, MOD_MODE_BINDINGS);
+ int rc = cisco_register_actions80211_ac(set);
+ cw_dbg(DBG_INFO, "Initialized mod_cisco 80211 with %d actions", 12);
return 0;
}
@@ -144,7 +144,7 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele
uint32_t vendor_id = cw_get_dword(cw_get_elem_data(elem));
if (vendor_id == CW_VENDOR_ID_CISCO) {
// conn->actions = &actions;
- if (mode == MOD_MODE_CAPWAP) {
+ if (mode == CW_MOD_MODE_CAPWAP) {
cw_dbg(DBG_MOD, "CISCO capwap detected: yes");
} else {
cw_dbg(DBG_MOD, "CISCO bindings detected: yes");
@@ -158,7 +158,7 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele
}
- if (mode == MOD_MODE_CAPWAP) {
+ if (mode == CW_MOD_MODE_CAPWAP) {
cw_dbg(DBG_MOD, "CISCO capwap detected: no");
} else {
cw_dbg(DBG_MOD, "CISCO bindings detected: no");
@@ -167,16 +167,21 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele
return 0;
}
-static struct mod_ac capwap_ac = {
+static struct cw_Mod capwap_ac = {
.name = "cisco",
.init = init,
.detect = detect,
- .register_actions = register_actions,
+// .register_actions = register_actions,
+ .register_messages = register_messages
};
-struct mod_ac *mod_cisco_ac()
+struct cw_Mod *mod_cisco_ac()
{
return &capwap_ac;
};
+struct cw_Mod *mod_cisco()
+{
+ return &capwap_ac;
+};
diff --git a/src/mod/cisco/mod_cisco_wtp.c b/src/mod/cisco/mod_cisco_wtp.c
index aded4bf1..d66b687c 100644
--- a/src/mod/cisco/mod_cisco_wtp.c
+++ b/src/mod/cisco/mod_cisco_wtp.c
@@ -19,18 +19,19 @@ extern int cisco_register_actions_wtp(struct cw_actiondef *def);
static int register_actions(struct cw_actiondef *actions, int mode)
{
+
switch (mode) {
- case MOD_MODE_CAPWAP:
+ case CW_MOD_MODE_CAPWAP:
{
- struct mod_wtp *cmod = modload_wtp("cipwap");
+ struct cw_Mod *cmod = modload_wtp("cipwap");
if (!cmod) {
cw_log(LOG_ERR,
"Can't initzialize mod_cisco, failed to load base mod mod_cipwap");
return 1;
}
- cmod->register_actions(actions, MOD_MODE_CAPWAP);
+ cmod->register_actions(actions, CW_MOD_MODE_CAPWAP);
int rc = cisco_register_actions_wtp(actions);
@@ -40,7 +41,7 @@ static int register_actions(struct cw_actiondef *actions, int mode)
}
case MOD_MODE_BINDINGS:
{
- struct mod_ac *cmod = modload_wtp("capwap80211");
+ struct cw_Mod *cmod = modload_wtp("capwap80211");
if (!cmod) {
cw_log(LOG_ERR,
"Can't initzialize mod_cisco, failed to load base mod mod_capwap80211");
@@ -131,7 +132,7 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele
uint32_t vendor_id = cw_get_dword(cw_get_elem_data(elem));
if (vendor_id == CW_VENDOR_ID_CISCO) {
// conn->actions = &actions;
- if (mode == MOD_MODE_CAPWAP) {
+ if (mode == CW_MOD_MODE_CAPWAP) {
cw_dbg(DBG_MOD, "CISCO capwap detected: yes");
} else {
cw_dbg(DBG_MOD, "CISCO bindings detected: yes");
@@ -145,7 +146,7 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele
}
- if (mode == MOD_MODE_CAPWAP) {
+ if (mode == CW_MOD_MODE_CAPWAP) {
cw_dbg(DBG_MOD, "CISCO capwap detected: no");
} else {
cw_dbg(DBG_MOD, "CISCO bindings detected: no");
@@ -154,7 +155,7 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele
return 0;
}
-static struct mod_ac cisco_wtp = {
+static struct cw_Mod cisco_wtp = {
.name = "cisco",
.init = init,
.init_config = init_config,
@@ -162,7 +163,7 @@ static struct mod_ac cisco_wtp = {
.register_actions = register_actions
};
-struct mod_ac *mod_cisco_wtp()
+struct cw_Mod *mod_cisco_wtp()
{
return &cisco_wtp;
};
diff --git a/src/mod/fortinet/mod_fortinet.h b/src/mod/fortinet/mod_fortinet.h
index 0cdc9338..9b3d477b 100644
--- a/src/mod/fortinet/mod_fortinet.h
+++ b/src/mod/fortinet/mod_fortinet.h
@@ -1,8 +1,8 @@
#ifndef __MOD_FORTINET_H
#define __MOD_FORTINET_H
-struct mod_ac * mod_fortinet_ac();
-struct mod_ac * mod_fortinet_wtp();
+struct cw_Mod * mod_fortinet_ac();
+struct cw_Mod * mod_fortinet_wtp();
#endif
diff --git a/src/mod/fortinet/mod_fortinet_ac.c b/src/mod/fortinet/mod_fortinet_ac.c
index 0d96ed1b..a1eda779 100644
--- a/src/mod/fortinet/mod_fortinet_ac.c
+++ b/src/mod/fortinet/mod_fortinet_ac.c
@@ -18,23 +18,23 @@ extern int fortinet_register_actions_ac(struct cw_actiondef *def);
static int register_actions(struct cw_actiondef *actions, int mode)
{
switch (mode) {
- case MOD_MODE_CAPWAP:
+ case CW_MOD_MODE_CAPWAP:
{
- struct mod_ac *cmod = modload_ac("capwap");
+ struct cw_Mod *cmod = modload_ac("capwap");
if (!cmod) {
cw_log(LOG_ERR,
"Can't initialize mod_fortinet, failed to load base mod mod_capwap");
return 1;
}
- cmod->register_actions(actions, MOD_MODE_CAPWAP);
+ cmod->register_actions(actions, CW_MOD_MODE_CAPWAP);
int rc = fortinet_register_actions_ac(actions);
cw_dbg(DBG_INFO, "Initialized mod fortinet with %d actions", rc);
return 0;
}
case MOD_MODE_BINDINGS:
{
- struct mod_ac *cmod = modload_ac("capwap80211");
+ struct cw_Mod *cmod = modload_ac("capwap80211");
if (!cmod) {
cw_log(LOG_ERR,
"Can't initialize mod_fortinet, failed to load base mod mod_capwap80211");
@@ -60,7 +60,7 @@ static int register_actions(struct cw_actiondef *actions, int mode)
static int init()
{
cw_dbg(DBG_INFO, "Initialiazing mod_fortineto ...");
-// struct mod_ac *cmod = modload_ac("capwap");
+// struct cw_Mod *cmod = modload_ac("capwap");
return 1;
}
@@ -85,7 +85,7 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele
uint32_t vendor_id = cw_get_dword(cw_get_elem_data(elem));
if (vendor_id == CW_VENDOR_ID_FORTINET) {
// conn->actions = &actions;
- if (mode == MOD_MODE_CAPWAP) {
+ if (mode == CW_MOD_MODE_CAPWAP) {
cw_dbg(DBG_MOD, "Fortinet capwap detected: yes");
} else {
cw_dbg(DBG_MOD, "Fortinet bindings detected: yes");
@@ -99,7 +99,7 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele
}
- if (mode == MOD_MODE_CAPWAP) {
+ if (mode == CW_MOD_MODE_CAPWAP) {
cw_dbg(DBG_MOD, "Fortinet capwap detected: no");
} else {
cw_dbg(DBG_MOD, "Fortinet bindings detected: no");
@@ -108,14 +108,14 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele
return 0;
}
-static struct mod_ac capwap_ac = {
+static struct cw_Mod capwap_ac = {
.name = "fortinet",
.init = init,
.detect = detect,
.register_actions = register_actions
};
-struct mod_ac *mod_fortinet_ac()
+struct cw_Mod *mod_fortinet_ac()
{
return &capwap_ac;
};
diff --git a/src/mod/fortinet/mod_fortinet_wtp.c b/src/mod/fortinet/mod_fortinet_wtp.c
index a5316b09..5ae3c011 100644
--- a/src/mod/fortinet/mod_fortinet_wtp.c
+++ b/src/mod/fortinet/mod_fortinet_wtp.c
@@ -18,17 +18,17 @@ extern int cisco_register_actions_wtp(struct cw_actiondef *def);
static int register_actions(struct cw_actiondef *actions, int mode)
{
switch (mode) {
- case MOD_MODE_CAPWAP:
+ case CW_MOD_MODE_CAPWAP:
{
- struct mod_wtp *cmod = modload_wtp("capwap");
+ struct cw_Mod *cmod = modload_wtp("capwap");
if (!cmod) {
cw_log(LOG_ERR,
"Can't initialize mod_fortinet, failed to load base mod mod_capwap");
return 1;
}
- cmod->register_actions(actions, MOD_MODE_CAPWAP);
+ cmod->register_actions(actions, CW_MOD_MODE_CAPWAP);
int rc = cisco_register_actions_wtp(actions);
@@ -38,7 +38,7 @@ static int register_actions(struct cw_actiondef *actions, int mode)
}
case MOD_MODE_BINDINGS:
{
- struct mod_ac *cmod = modload_wtp("capwap80211");
+ struct cw_Mod *cmod = modload_wtp("capwap80211");
if (!cmod) {
cw_log(LOG_ERR,
"Can't initialize mod_fortinet, failed to load base mod mod_capwap80211");
@@ -82,7 +82,7 @@ static int init()
mbag_set_bstr16(cisco_config_wtp,CW_ITEM_WTP_BOOTLOADER_VERSION,v);
#endif
-// struct mod_ac *cmod = modload_ac("capwap");
+// struct cw_Mod *cmod = modload_ac("capwap");
return 1;
}
@@ -130,7 +130,7 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele
uint32_t vendor_id = cw_get_dword(cw_get_elem_data(elem));
if (vendor_id == CW_VENDOR_ID_FORTINET) {
// conn->actions = &actions;
- if (mode == MOD_MODE_CAPWAP) {
+ if (mode == CW_MOD_MODE_CAPWAP) {
cw_dbg(DBG_MOD, "Fortinet capwap detected: yes");
} else {
cw_dbg(DBG_MOD, "Fortinet bindings detected: yes");
@@ -144,7 +144,7 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele
}
- if (mode == MOD_MODE_CAPWAP) {
+ if (mode == CW_MOD_MODE_CAPWAP) {
cw_dbg(DBG_MOD, "Fortinet capwap detected: no");
} else {
cw_dbg(DBG_MOD, "Fortinet bindings detected: no");
@@ -153,7 +153,7 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele
return 0;
}
-static struct mod_ac fortinet_wtp = {
+static struct cw_Mod fortinet_wtp = {
.name = "fortinet",
.init = init,
.init_config = init_config,
@@ -161,7 +161,7 @@ static struct mod_ac fortinet_wtp = {
.register_actions = register_actions
};
-struct mod_ac *mod_fortinet_wtp()
+struct cw_Mod *mod_fortinet_wtp()
{
return &fortinet_wtp;
};
diff --git a/src/mod/modload.h b/src/mod/modload.h
index 65965d2f..ee8e0a1c 100644
--- a/src/mod/modload.h
+++ b/src/mod/modload.h
@@ -1,8 +1,8 @@
#include "cw/mod.h"
-struct mod_ac * modload_ac(const char *name);
-struct mod_wtp * modload_wtp(const char *name);
+struct cw_Mod * modload_ac(const char *name);
+struct cw_Mod * modload_wtp(const char *name);
diff --git a/src/mod/modload_ac.c b/src/mod/modload_ac.c
index 128b8a49..ff803c99 100644
--- a/src/mod/modload_ac.c
+++ b/src/mod/modload_ac.c
@@ -14,14 +14,14 @@
*/
-struct mod_ac *(*mods_ac[])() = MODS_AC;
+struct cw_Mod *(*mods_ac[])() = MODS_AC;
-struct mod_ac * modload_ac(const char *name)
+struct cw_Mod * modload_ac(const char *name)
{
int i;
for (i=0; mods_ac[i];i++){
- struct mod_ac * m = mods_ac[i]();
+ struct cw_Mod * m = mods_ac[i]();
if (strcmp(m->name,name)==0)
return m;
}
diff --git a/src/mod/modload_wtp.c b/src/mod/modload_wtp.c
index a3ca162e..74dabde6 100644
--- a/src/mod/modload_wtp.c
+++ b/src/mod/modload_wtp.c
@@ -12,14 +12,14 @@
#include "modload.h"
-struct mod_wtp *(*mods_wtp[])() = MODS_WTP;
+struct cw_Mod *(*mods_wtp[])() = MODS_WTP;
-struct mod_wtp * modload_wtp(const char *name)
+struct cw_Mod * modload_wtp(const char *name)
{
int i;
for (i=0; mods_wtp[i];i++){
- struct mod_wtp * m = mods_wtp[i]();
+ struct cw_Mod * m = mods_wtp[i]();
if (strcmp(m->name,name)==0)
return m;
}
diff --git a/src/mod/zyxel/mod_zyxel.h b/src/mod/zyxel/mod_zyxel.h
index 2f7078da..ae91e352 100644
--- a/src/mod/zyxel/mod_zyxel.h
+++ b/src/mod/zyxel/mod_zyxel.h
@@ -1,7 +1,7 @@
#ifndef __MOD_ZYXEL_H
#define __MOD_ZYXEL_H
-struct mod_ac * mod_zyxel_ac();
+struct cw_Mod * mod_zyxel_ac();
#endif
diff --git a/src/wtp/wtp_main.c b/src/wtp/wtp_main.c
index 30aea18a..8230dfe8 100644
--- a/src/wtp/wtp_main.c
+++ b/src/wtp/wtp_main.c
@@ -123,14 +123,14 @@ int main()
//#define CWBIND "capwap80211"
- struct mod_wtp *mod = modload_wtp(CWMOD);
+ struct cw_Mod *mod = modload_wtp(CWMOD);
if (!mod) {
printf("Can't load mod capwap\n");
exit(0);
}
mod->init();
- mod->register_actions(&capwap_actions,MOD_MODE_CAPWAP);
+ mod->register_actions(&capwap_actions,CW_MOD_MODE_CAPWAP);
mod = modload_wtp(CWBIND);
if (!mod) {
printf("Can't load mod capwap80211\n");