From 2e2cfbdb715bd59502b97baf927a407c650996d3 Mon Sep 17 00:00:00 2001 From: "7u83@mail.ru" <7u83@mail.ru@noemail.net> Date: Tue, 27 Mar 2018 05:07:14 +0000 Subject: [PATCH] work on 802.11 FossilOrigin-Name: dfa8ffdff341f91001290ed71359f052ee095855a480e148e4d27f94207ebe3b --- actube.workspace | 4 +- libcw.project | 1 + mod_capwap80211.project | 2 - src/cw/Makefile | 6 +- src/cw/cw.h | 3 + src/cw/cw_out_generic.c | 19 +++---- src/cw/cw_out_radio_generic.c | 64 ++++++++++++++++++++++ src/mod/capwap80211/capwap80211_messages.c | 24 ++++---- src/wtp/wtp_main.c | 33 +++++++---- 9 files changed, 117 insertions(+), 39 deletions(-) create mode 100644 src/cw/cw_out_radio_generic.c diff --git a/actube.workspace b/actube.workspace index b21adfd1..e0162c79 100644 --- a/actube.workspace +++ b/actube.workspace @@ -1,11 +1,11 @@ - + - + diff --git a/libcw.project b/libcw.project index 7622096c..ac976a7e 100644 --- a/libcw.project +++ b/libcw.project @@ -264,6 +264,7 @@ + diff --git a/mod_capwap80211.project b/mod_capwap80211.project index ccd54962..36b44a2b 100644 --- a/mod_capwap80211.project +++ b/mod_capwap80211.project @@ -4,9 +4,7 @@ - - diff --git a/src/cw/Makefile b/src/cw/Makefile index 2c501c1b..76684cc7 100644 --- a/src/cw/Makefile +++ b/src/cw/Makefile @@ -235,8 +235,12 @@ MISCSRC=\ DTLSSRC+=\ dtls_bio.c\ + +RADIOSRC=\ + cw_out_radio_generic.c + #SRC=$(wildcard *.c) -SRC = $(CWSRC) $(LWSRC) $(MAVLSRC) $(MLISTSRC) $(SOCKSRC) $(LOGSRC) $(DTLSSRC) $(MISCSRC) +SRC = $(CWSRC) $(LWSRC) $(MAVLSRC) $(MLISTSRC) $(SOCKSRC) $(LOGSRC) $(DTLSSRC) $(RADIOSRC) $(MISCSRC) OBJS=$(patsubst %.c,%.o,$(SRC)) OBJS:=$(patsubst %.o,$(OBJDIR)/%.o,$(OBJS)) diff --git a/src/cw/cw.h b/src/cw/cw.h index 126374ef..5f6b4d3e 100644 --- a/src/cw/cw.h +++ b/src/cw/cw.h @@ -387,6 +387,9 @@ int cw_in_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerP int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params , uint8_t * dst); +int cw_out_radio_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params + , uint8_t * dst); + extern int cw_in_wtp_reboot_statistics(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len, struct sockaddr *from); diff --git a/src/cw/cw_out_generic.c b/src/cw/cw_out_generic.c index 88ee313e..4c9a56e0 100644 --- a/src/cw/cw_out_generic.c +++ b/src/cw/cw_out_generic.c @@ -19,9 +19,6 @@ int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams search.key=(char*)handler->key; elem = mavl_get(params->conn->local_cfg, &search); - /* Size for msg elem header depends on - vendor specific payload */ - start = handler->vendor ? 10 : 4; if (elem == NULL) { const char *vendor=""; @@ -44,23 +41,21 @@ int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams } return 0; } + + /* Size for msg elem header depends on + vendor specific payload */ + start = handler->vendor ? 10 : 4; len = ((const cw_Type_t*)(handler->type))->put(elem,dst+start); - - - ((const cw_Type_t*)(handler->type))->to_str(elem,detail,120); + +/* ((const cw_Type_t*)(handler->type))->to_str(elem,detail,120); sprintf(params->debug_details, " Value = %s", detail); - - params->elem = elem; + params->elem = elem;*/ if (handler->vendor) return len + cw_put_elem_vendor_hdr(dst, handler->vendor, handler->id, len); - - l = len + cw_put_elem_hdr(dst, handler->id, len); - cw_dbg_elem(DBG_ELEM_OUT,params->conn,params->msgdata->type,handler,dst,l); - return l; } diff --git a/src/cw/cw_out_radio_generic.c b/src/cw/cw_out_radio_generic.c new file mode 100644 index 00000000..b196c2db --- /dev/null +++ b/src/cw/cw_out_radio_generic.c @@ -0,0 +1,64 @@ + +#include "cw.h" +#include "dbg.h" + + +static int cw_put_radio_generic(struct cw_ElemHandler * handler, int idx, struct cw_ElemHandlerParams * params + , uint8_t * dst) +{ + char key[CW_KTV_MAX_KEY_LEN]; + cw_KTV_t *elem, search; + int len; + uint8_t * d; + + len =0; + + sprintf(key,"radio/%d/%s",idx,handler->key); + + printf("Looking for key: %s\n",key); + + search.key=key; + elem = mavl_get(params->conn->local_cfg, &search); + + if (elem==NULL){ + return 0; + } + + /* Size for msg elem header depends on + vendor specific payload */ + d = handler->vendor ? dst+10 : dst+4; + + /* put radio id */ + len += cw_put_byte(d+len,idx); + + len += ((const cw_Type_t*)(handler->type))->put(elem,d+len); +/* l = len + cw_put_elem_hdr(dst, handler->id, len);*/ + +/* if (handler->vendor) + return len + cw_put_elem_vendor_hdr(dst, handler->vendor, handler->id, len); +*/ + return len + cw_put_elem_hdr(dst, handler->id, len); +} + + +int cw_out_radio_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params + , uint8_t * dst) +{ +/* char key[CW_KTV_MAX_KEY_LEN];*/ +/* cw_KTV_t *elem, search;*/ + int len,i,l; + int radios; + len =0; + + radios = cw_ktv_get_byte(params->conn->local_cfg,"wtp-descriptor/max-radios",0); + printf("Must put radios: %d\n",radios); + + for(i=1;iconn,params->msgdata->type,handler,dst,l); + len+=l; + } + + return len; +} diff --git a/src/mod/capwap80211/capwap80211_messages.c b/src/mod/capwap80211/capwap80211_messages.c index 745077b2..d17fda6f 100644 --- a/src/mod/capwap80211/capwap80211_messages.c +++ b/src/mod/capwap80211/capwap80211_messages.c @@ -13,15 +13,16 @@ static struct cw_ElemHandler handlers[] = { { - "80211 WTP Radio Information", /* name */ - CAPWAP80211_ELEM_WTP_RADIO_INFORMATION, /* Element ID */ - 0, 0, /* Vendor / Proto */ - 0, 0, /* min/max length */ - NULL, /* type */ - "wtp-radio_information", /* Key */ - NULL, /* get */ - NULL /* put */ - }, + "80211 WTP Radio Information", /* name */ + CAPWAP80211_ELEM_WTP_RADIO_INFORMATION, /* Element ID */ + 0, 0, /* Vendor / Proto */ + 0, 0, /* min/max length */ + CW_TYPE_DWORD, /* type */ + "wtp-radio-information", /* Key */ + NULL, /* get */ + cw_out_radio_generic /* put */ + } + , {NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL} @@ -41,7 +42,9 @@ static struct cw_MsgDef messages[] = { CAPWAP_MSG_DISCOVERY_REQUEST, CW_RECEIVER_AC, discovery_request_states, - discovery_request_elements}, + discovery_request_elements + } + , {0, 0, 0, 0, 0} }; @@ -53,7 +56,6 @@ int mode; return NULL; cw_dbg(DBG_INFO, "CAPWAP80211: Register messages"); - cw_msgset_add(set, messages, handlers); cw_dbg(DBG_INFO, "CAPWAP0211: Done register messages"); diff --git a/src/wtp/wtp_main.c b/src/wtp/wtp_main.c index 4a72a92d..de87d52a 100644 --- a/src/wtp/wtp_main.c +++ b/src/wtp/wtp_main.c @@ -14,7 +14,8 @@ #include "wtp.h" struct bootcfg{ - const char * modname; + const char * modnames[32]; + int nmods; const char * modpath; const char * cfgfilename; }; @@ -25,7 +26,6 @@ static int parse_args (int argc, char *argv[], struct bootcfg * bootcfg) int c; opterr = 1; - bootcfg->modname = "capwap"; bootcfg->cfgfilename = "config.ktv"; while ( (c = getopt (argc, argv, "p:d:vc:m:h")) != -1) { @@ -43,7 +43,7 @@ static int parse_args (int argc, char *argv[], struct bootcfg * bootcfg) break; } case 'm': - bootcfg->modname = optarg; + bootcfg->modnames[bootcfg->nmods++] = optarg; break; case 'p': cw_mod_set_path(optarg); @@ -74,9 +74,18 @@ int main (int argc, char **argv) FILE * file; mavl_t global_cfg, types_tree; const cw_Type_t ** ti; + int i; + + bootcfg.nmods=0; /* read command line args, results are in bootcfg */ parse_args(argc,argv, &bootcfg); + + if (bootcfg.nmods==0){ + bootcfg.modnames[0]="capwap"; + bootcfg.modnames[1]="capwap80211"; + bootcfg.nmods=2; + } /* create an empty message set */ @@ -113,15 +122,16 @@ int main (int argc, char **argv) cw_dbg_ktv_dump(global_cfg,DBG_CFG_DMP,"----- global cfg start -----","","----- global cfg end -----"); - - mod = cw_mod_load(bootcfg.modname, global_cfg, CW_ROLE_WTP); - if (mod == NULL){ - exit (EXIT_FAILURE); + for (i=0;iregister_messages(msgset, CW_MOD_MODE_CAPWAP); + mod->register_messages(msgset, CW_MOD_MODE_BINDINGS); } - - /* Build a message set from our loaded modules */ - mod->register_messages(msgset, CW_MOD_MODE_CAPWAP); - mod->register_messages(msgset, CW_MOD_MODE_BINDINGS); + /* create a connection object */ conn = conn_create_noq(-1, NULL); @@ -138,6 +148,7 @@ int main (int argc, char **argv) conn->local_cfg = global_cfg; conn->remote_cfg = cw_ktv_create(); conn->receiver = CW_RECEIVER_WTP; + conn->wbid=1; cw_run_discovery(conn, "255.255.255.255",NULL);