diff --git a/src/ac/ac_main.c b/src/ac/ac_main.c index 5d75b45a..2b4ff51f 100644 --- a/src/ac/ac_main.c +++ b/src/ac/ac_main.c @@ -86,11 +86,12 @@ extern struct mod_ac * cw_get_mod_ac(const char *name); int main(int argc, char *argv[]) { int rc = 0; +/* +struct mod_ac *m = cw_get_mod_ac("cipwap"); +printf("Ptr: %p\n",m); -//struct mod_ac *m = cw_get_mod_ac("capwap"); -//m->init(); -//exit(0); - +m->init(); +*/ /* parse arguments */ parse_args(argc, argv); diff --git a/src/ac/conf.c b/src/ac/conf.c index f4d7ef9f..b43e6aab 100644 --- a/src/ac/conf.c +++ b/src/ac/conf.c @@ -134,6 +134,20 @@ static int init_acname() return 1; } +#include "capwap/mod.h" + + +struct mod_ac * conf_mods[10]; + +static int init_mods() +{ + + conf_mods[0]=cw_get_mod_ac("cipwap"); + conf_mods[1]=NULL; + + return 0; +} + static int init_acid() { @@ -811,6 +825,8 @@ int read_config(const char *filename) if (!conf_image_dir) conf_image_dir = CONF_DEFAULT_IMAGE_DIR; + init_mods(); + conf_init_capwap_mode(); diff --git a/src/ac/conf.h b/src/ac/conf.h index b98917b4..197d2086 100644 --- a/src/ac/conf.h +++ b/src/ac/conf.h @@ -29,6 +29,10 @@ #include "capwap/capwap.h" #include "capwap/lwapp.h" #include "capwap/bstr.h" +#include "capwap/mod.h" + + +extern struct mod_ac * conf_mods[10]; #ifndef CONF_DEFAULT_ACNAME #define CONF_DEFAULT_ACNAME "AC" diff --git a/src/ac/socklist.c b/src/ac/socklist.c index ae6e4069..5043a3e0 100644 --- a/src/ac/socklist.c +++ b/src/ac/socklist.c @@ -77,7 +77,6 @@ void socklist_destroy() free(socklist); socklist = 0; pthread_mutex_destroy(&socklist_mutex); - } /** diff --git a/src/ac/wtpman.c b/src/ac/wtpman.c index 44230eff..dbd65cf8 100644 --- a/src/ac/wtpman.c +++ b/src/ac/wtpman.c @@ -510,8 +510,6 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr) replyfd = socklist[socklistindex].sockfd; } - - int sockfd = replyfd; //socklist[socklistindex].reply_sockfd; @@ -519,7 +517,7 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr) socklen_t dbgaddrl=sizeof(dbgaddr); getsockname(sockfd,&dbgaddr,&dbgaddrl); - cw_dbg(DBG_INFO,"Creating wtpman with socket %d, %s:%d",sockfd,sock_addr2str(&dbgaddr),sock_getport(&dbgaddr)); + cw_dbg(DBG_INFO,"Creating wtpman on socket %d, %s:%d",sockfd,sock_addr2str(&dbgaddr),sock_getport(&dbgaddr)); wtpman->conn = conn_create(sockfd, srcaddr, 100); if (!wtpman->conn) { diff --git a/src/capwap/Makefile b/src/capwap/Makefile index 095931bc..3b8e7abe 100644 --- a/src/capwap/Makefile +++ b/src/capwap/Makefile @@ -47,7 +47,7 @@ LOGOBJS=log.o \ log_file.o \ dbg_strings.o\ dbg.o \ - cw_get_mods.o + cw_get_mod_ac.o WTPINFOOBJS =\ @@ -290,6 +290,7 @@ CFLAGS += $(GNUTLS_CFLAGS) \ #SRCS = $(OBJS:.o=.c) +MODOBJS=$(wildcard ./mod/cipwap/$(ARCH)/*.o) $(ARCH)/%.o:%.c @mkdir -p $(ARCH) @@ -297,7 +298,7 @@ $(ARCH)/%.o:%.c @$(CC) -c $(CFLAGS) $< -o $@ # @$(CC) -MM $(CFLAGS) $< > $*.d -$(ARCH)/$(NAME) : $(OBJS) +$(ARCH)/$(NAME) : $(OBJS) $(MODOBJS) @echo " AR $(ARCH)/$(NAME)" @$(AR) rcs $(ARCH)/$(NAME) $(OBJS) $(MODOBJS) @@ -305,17 +306,23 @@ $(ARCH)/$(NAME) : $(OBJS) SRCS = $(OBJS:.o=.c) DEPS := $(OBJS:.o=.d) -mod_cipwap: - $(MAKE) -C mod/cipwap - .PHONY: deps clean clean_libs libs + # top-level rule, to compile everything. -all: $(ARCH)/$(NAME) +all: $(MAKE) mod_cipwap + $(MAKE) capwap +capwap: $(ARCH)/$(NAME) + + + + +mod_cipwap: + $(MAKE) -C mod/cipwap diff --git a/src/capwap/conn.h b/src/capwap/conn.h index 22e32e71..688d6115 100644 --- a/src/capwap/conn.h +++ b/src/capwap/conn.h @@ -40,6 +40,7 @@ #include "intavltree.h" #include "mbag.h" +#include "mod.h" /** * Connection Object @@ -181,8 +182,10 @@ struct conn { int (*process_packet)(struct conn *conn, uint8_t * packet, int len,struct sockaddr *from); int (*process_message)(struct conn *conn, uint8_t * rawmsg, int rawlen, struct sockaddr *from); + + void * mods; }; diff --git a/src/capwap/cw_get_mods.c b/src/capwap/cw_get_mod_ac.c similarity index 93% rename from src/capwap/cw_get_mods.c rename to src/capwap/cw_get_mod_ac.c index a3485fb9..e1ed47d2 100644 --- a/src/capwap/cw_get_mods.c +++ b/src/capwap/cw_get_mod_ac.c @@ -1,8 +1,11 @@ #include + #include "mod.h" +#include + struct mod_ac *(*mods_ac[])() = MODS_AC; @@ -11,11 +14,10 @@ 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/capwap/mod.h b/src/capwap/mod.h index 3aeeeab0..3589a320 100644 --- a/src/capwap/mod.h +++ b/src/capwap/mod.h @@ -3,12 +3,20 @@ #include +#include "sock.h" +#include "conn.h" + struct mod_ac { + /** Name of the mod */ const char *name; + /** Initializion method */ int (*init)(); - int (*detect_by_raw)(const char *msg, int len); - int (*detect_by_discovery)(const char*); + /** Detect capwap + This function ifter receiving and disassembling a complete + CAPWAP message. Either on Discovery Request or Join Request + **/ + int (*detect)(struct conn *conn,const char *rawmsg, int rawlen,struct sockaddr *from); }; @@ -18,5 +26,6 @@ struct mod_ac #define MODS_AC { mod_cipwap_ac,NULL } +extern struct mod_ac * cw_get_mod_ac(const char *name); #endif diff --git a/src/capwap/mod/cipwap/mod_cipwap_ac.c b/src/capwap/mod/cipwap/mod_cipwap_ac.c index b1843c83..cc6e36b2 100644 --- a/src/capwap/mod/cipwap/mod_cipwap_ac.c +++ b/src/capwap/mod/cipwap/mod_cipwap_ac.c @@ -11,8 +11,8 @@ int cipwap_init() static struct mod_ac cipwap_ac = { -// .init = cipwap_init() - + .init = cipwap_init, + .name ="cipwap" }; struct mod_ac * mod_cipwap_ac(){ diff --git a/src/contrib/install_libuci.sh b/src/contrib/install_libuci.sh index b2d0184c..3c9f9362 100755 --- a/src/contrib/install_libuci.sh +++ b/src/contrib/install_libuci.sh @@ -12,6 +12,7 @@ cp libubox.so /usr/local/lib ldconfig cd ../.. + git clone git://nbd.name/uci.git uci cd uci mkdir build diff --git a/src/wtp/cfg.json b/src/wtp/cfg.json index 7ec28f82..659944e8 100644 --- a/src/wtp/cfg.json +++ b/src/wtp/cfg.json @@ -22,33 +22,8 @@ "radios":{ "0":{ "admin_state":"1", - "aironet_ie":"0", - "allow_aaa_override":"1", "bssid":".x123456789abc", - "dot11e_data":".x0042435e0062322f000000000000000000000000000000000000000000000000", - "dot11e_len":"0", - "dtim_period":"241", - "enc_capab":"1073", - "enc_policy":"5", - "key":".x210127bab42d5c063ae05a292ea01709d00a6347407e52d5f14d5a6ab82dae3a", - "key_index":"1", - "key_shared":"0", - "max_clients":"17", - "qos":"0", - "radio_id":"0", - "radio_type":"1", - "reserved":".x000000000000000000000000000000000cdd0a00c0b9010000000801010000000000000000000000000000000000000000", - "reserved2":".x00000000000000000000000000000000000000000000000000000000000000000000000000000000", - "rsn_data":".x0000000000000000000000000000001630140100000fac020100000fac040100000fac0229000000000000000000000000000000000000000000000000000000", - "rsn_len":"0", - "ssid":"Hotler", - "ssid_broadcast":"1", - "wlan_id":"1", - "wlan_name":".x53757065726e6574776f726b3230313521212100000000000000000000000000", - "wme_data":".x0000000000000000000000000000001add180050f2020101800003a4000027a4", - "wme_len":"0", - "wpa_data":".xdd1c0050f20101000050f20202000050f2020050f20401000050f20200000000", - "wpa_len":"30" + "radio_type":"1" }, "1":{ "admin_state":"1", diff --git a/src/wtp/nlt.h b/src/wtp/nlt.h index 8f101d68..bdf4f4f0 100644 --- a/src/wtp/nlt.h +++ b/src/wtp/nlt.h @@ -2,6 +2,7 @@ #define __NLT_H #include "nl80211.h" +#include extern const char * nlt_attrnames[]; extern const char * nlt_cmdnames[];