From a704463acf116df21121fcb3f719897a7946ae8f Mon Sep 17 00:00:00 2001 From: "7u83@mail.ru" <7u83@mail.ru@noemail.net> Date: Sat, 27 Feb 2016 04:35:25 +0000 Subject: [PATCH] Work on mods. FossilOrigin-Name: 2933314d1c705fae5022e022409b5f77a878656baead522ceb629b7f648c8307 --- src/ac/Makefile | 1 + src/ac/conf.c | 3 ++- src/capwap/Makefile | 2 +- src/capwap/action.h | 3 +-- src/capwap/conn_process_packet.c | 26 +++++++++++++---------- src/capwap/mod.h | 6 ++++++ src/mod/capwap/Makefile | 25 +--------------------- src/mod/capwap/capwap_in_wtp_descriptor.c | 4 +++- src/mod/capwap/mod_capwap_ac.c | 5 +++-- src/mod/cipwap/Makefile | 26 +---------------------- src/mod/cipwap/mod_cipwap_ac.c | 2 +- 11 files changed, 35 insertions(+), 68 deletions(-) diff --git a/src/ac/Makefile b/src/ac/Makefile index ed8c732d..d51bfa0c 100644 --- a/src/ac/Makefile +++ b/src/ac/Makefile @@ -15,6 +15,7 @@ CFLAGS += -Werror -g -O0 -D_REENTRANT -DIPV6 -I/usr/local/include -I../ -DSYS_AR LIBS+=-lcapwap +LIBS+=-lcisco LIBS+=-lcipwap LIBS+=-lcw LIBS+=-lrt diff --git a/src/ac/conf.c b/src/ac/conf.c index 15afa9ba..c4395410 100644 --- a/src/ac/conf.c +++ b/src/ac/conf.c @@ -144,7 +144,8 @@ static int init_mods() conf_mods[0]=modload_ac("cipwap"); conf_mods[1]=modload_ac("capwap"); - conf_mods[2]=NULL; + conf_mods[2]=modload_ac("cisco"); + conf_mods[3]=NULL; diff --git a/src/capwap/Makefile b/src/capwap/Makefile index 43c84baf..2e0ac6d2 100644 --- a/src/capwap/Makefile +++ b/src/capwap/Makefile @@ -62,7 +62,7 @@ UTILOBJS= \ stravltree.o \ intavltree.o \ cw_util.o \ - send.o + send.o \ MAVLOBJS= \ mavl_del.o \ diff --git a/src/capwap/action.h b/src/capwap/action.h index 4fc93caa..99535569 100644 --- a/src/capwap/action.h +++ b/src/capwap/action.h @@ -34,8 +34,7 @@ #include "intavltree.h" #include "item.h" - - +struct conn; /* Generic functions and structs */ void * cw_actionlist_add(struct avltree *t, void *a, size_t s); diff --git a/src/capwap/conn_process_packet.c b/src/capwap/conn_process_packet.c index 84cdeec6..69639b64 100644 --- a/src/capwap/conn_process_packet.c +++ b/src/capwap/conn_process_packet.c @@ -170,13 +170,16 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len, if (!conn->detected) { - if (conn->mods){ - struct mod_ac ** mods = (struct mod_ac **)conn->mods; + 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,from)){ - cw_dbg(DBG_INFO,"Using mod '%s' to handle connection from %s",mods[i]->name,sock_addr2str(from)); + for (i = 0; mods[i]; i++) { + if (mods[i]->detect) { + if (mods[i]->detect(conn, rawmsg, len, from)) { + cw_dbg(DBG_INFO, + "Using mod '%s' to handle connection from %s", + mods[i]->name, + sock_addr2str(from)); break; } } @@ -184,11 +187,12 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len, } } - if (!conn->detected){ - cw_dbg(DBG_INFO,"Cant't detect capwap, discarding message from %s",sock_addr2str(from)); - errno=EAGAIN; + if (!conn->detected) { + cw_dbg(DBG_INFO, "Cant't detect capwap, discarding message from %s", + sock_addr2str(from)); + errno = EAGAIN; return -1; - + } @@ -328,7 +332,7 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len, int process_message(struct conn *conn, uint8_t * rawmsg, int rawlen, - struct sockaddr *from) + struct sockaddr *from) { uint8_t *msgptr = rawmsg + cw_get_hdr_msg_offset(rawmsg); diff --git a/src/capwap/mod.h b/src/capwap/mod.h index 0af58b11..1681c8f4 100644 --- a/src/capwap/mod.h +++ b/src/capwap/mod.h @@ -6,6 +6,9 @@ #include "capwap/sock.h" #include "capwap/conn.h" +#include "action.h" + +struct cw_actiondef; struct mod_ac { @@ -21,6 +24,9 @@ struct mod_ac /** used for private data */ void *data; + + int (*register_actions)(struct cw_actiondef *def); + }; diff --git a/src/mod/capwap/Makefile b/src/mod/capwap/Makefile index f0911a40..5c7a897c 100644 --- a/src/mod/capwap/Makefile +++ b/src/mod/capwap/Makefile @@ -1,5 +1,3 @@ -include ../../Macros.mak -include ../../Config.mak OBJS=\ mod_capwap_ac.o \ @@ -7,30 +5,9 @@ OBJS=\ capwap_in_wtp_descriptor.o \ capwap_in_wtp_board_data.o -OBJS:=$(patsubst %.o,$(ARCH)/%.o,$(OBJS)) - - -CFLAGS = -Wall -g -O0 -D_REENTRANT -DWITH_IPV6 -DWITH_RMAC_SUPPORT -I ../../ -I../ NAME=libcapwap.a -LIBDIR=../../lib/$(ARCH) -SRCS = $(OBJS:.o=.c) - -$(ARCH)/%.o:%.c - @mkdir -p $(ARCH) - @echo " CC "$< - @$(CC) -c $(CFLAGS) $< -o $@ +include ../Mod.mak -$(LIBDIR)/$(NAME) : $(OBJS) $(MODOBJS) - @mkdir -p $(LIBDIR) - @echo " AR $(LIBDIR)/$(NAME)" - @$(AR) rcs $(LIBDIR)/$(NAME) $(OBJS) $(MODOBJS) - - -all: $(LIBDIR)/$(NAME) - -clean: - rm -rf $(ARCH) - rm -f $(LIBDIR)/$(NAME) diff --git a/src/mod/capwap/capwap_in_wtp_descriptor.c b/src/mod/capwap/capwap_in_wtp_descriptor.c index 46092660..85f7baab 100644 --- a/src/mod/capwap/capwap_in_wtp_descriptor.c +++ b/src/mod/capwap/capwap_in_wtp_descriptor.c @@ -156,9 +156,11 @@ static int cw_read_wtp_descriptor(mbag_t mbag, struct conn *conn, int capwap_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 rc =cw_read_wtp_descriptor(mbag, conn, a, data, len, 0); + return rc; } diff --git a/src/mod/capwap/mod_capwap_ac.c b/src/mod/capwap/mod_capwap_ac.c index 0a99d841..14545a4f 100644 --- a/src/mod/capwap/mod_capwap_ac.c +++ b/src/mod/capwap/mod_capwap_ac.c @@ -1,5 +1,5 @@ -#include "mod.h" +#include "capwap/mod.h" #include "capwap/log.h" #include "capwap/dbg.h" @@ -35,7 +35,8 @@ static int detect(struct conn *conn,const uint8_t *rawmsg, int rawlen,struct soc static struct mod_ac capwap_ac = { .name ="capwap", .init = init, - .detect = detect + .detect = detect, + .register_actions = capwap_register_actions_ac }; diff --git a/src/mod/cipwap/Makefile b/src/mod/cipwap/Makefile index 099c6736..75499ede 100644 --- a/src/mod/cipwap/Makefile +++ b/src/mod/cipwap/Makefile @@ -1,32 +1,8 @@ -include ../../Macros.mak -include ../../Config.mak OBJS=\ mod_cipwap_ac.o -OBJS:=$(patsubst %.o,$(ARCH)/%.o,$(OBJS)) - - -CFLAGS = -Wall -g -O0 -D_REENTRANT -DWITH_IPV6 -DWITH_RMAC_SUPPORT -I ../../ -I../ - - NAME=libcipwap.a -LIBDIR=../../lib/$(ARCH) -SRCS = $(OBJS:.o=.c) +include ../Mod.mak -$(ARCH)/%.o:%.c - @mkdir -p $(ARCH) - @echo " CC "$< - @$(CC) -c $(CFLAGS) $< -o $@ - -$(LIBDIR)/$(NAME) : $(OBJS) $(MODOBJS) - @mkdir -p $(LIBDIR) - @echo " AR $(LIBDIR)/$(NAME)" - @$(AR) rcs $(LIBDIR)/$(NAME) $(OBJS) $(MODOBJS) - - -all: $(LIBDIR)/$(NAME) - -clean: - rm -rf $(ARCH) diff --git a/src/mod/cipwap/mod_cipwap_ac.c b/src/mod/cipwap/mod_cipwap_ac.c index e2514dd3..4c943f4e 100644 --- a/src/mod/cipwap/mod_cipwap_ac.c +++ b/src/mod/cipwap/mod_cipwap_ac.c @@ -1,5 +1,5 @@ -#include "mod.h" +#include "capwap/mod.h" #include "capwap/log.h" #include "mod_cipwap.h"