work on 802.11

FossilOrigin-Name: dfa8ffdff341f91001290ed71359f052ee095855a480e148e4d27f94207ebe3b
This commit is contained in:
7u83@mail.ru 2018-03-27 05:07:14 +00:00
parent 848a319d45
commit 2e2cfbdb71
9 changed files with 117 additions and 39 deletions

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<CodeLite_Workspace Name="actube" Database="">
<Project Name="ac" Path="ac.project" Active="Yes"/>
<Project Name="ac" Path="ac.project" Active="No"/>
<Project Name="wtp" Path="wtp.project" Active="No"/>
<Project Name="mod_cipwap" Path="mod_cipwap.project" Active="No"/>
<Project Name="mod_capwap" Path="mod_capwap.project" Active="No"/>
<Project Name="mod_cisco" Path="mod_cisco.project" Active="No"/>
<Project Name="libcw" Path="libcw.project" Active="No"/>
<Project Name="libcw" Path="libcw.project" Active="Yes"/>
<Project Name="mod_capwap80211" Path="mod_capwap80211.project" Active="No"/>
<Project Name="mod_fortinet" Path="mod_fortinet.project" Active="No"/>
<BuildMatrix>

View File

@ -264,6 +264,7 @@
<File Name="src/cw/cw_ktv_read_struct.c"/>
<File Name="src/cw/algos.h"/>
<File Name="src/cw/cw_in_generic_struct.c"/>
<File Name="src/cw/cw_out_radio_generic.c"/>
</VirtualDirectory>
</VirtualDirectory>
<Description/>

View File

@ -4,9 +4,7 @@
<VirtualDirectory Name="mod">
<VirtualDirectory Name="capwap80211">
<File Name="src/mod/capwap80211/mod_capwap80211.h"/>
<File Name="src/mod/capwap80211/capwap80211_actions_wtp.c"/>
<File Name="src/mod/capwap80211/capwap80211_out_wtp_radio_cfg.c"/>
<File Name="src/mod/capwap80211/capwap80211_actions_ac.c"/>
<File Name="src/mod/capwap80211/mod_capwap80211.c"/>
<File Name="src/mod/capwap80211/capwap80211_messages.c"/>
</VirtualDirectory>

View File

@ -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))

View File

@ -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);

View File

@ -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;
}

View File

@ -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;i<radios;i++){
l = cw_put_radio_generic(handler,i,params,dst+len);
printf("put radio %i, returns %d\n",i,l);
cw_dbg_elem(DBG_ELEM_OUT,params->conn,params->msgdata->type,handler,dst,l);
len+=l;
}
return len;
}

View File

@ -17,11 +17,12 @@ static struct cw_ElemHandler handlers[] = {
CAPWAP80211_ELEM_WTP_RADIO_INFORMATION, /* Element ID */
0, 0, /* Vendor / Proto */
0, 0, /* min/max length */
NULL, /* type */
"wtp-radio_information", /* Key */
CW_TYPE_DWORD, /* type */
"wtp-radio-information", /* Key */
NULL, /* get */
NULL /* put */
},
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");

View File

@ -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,10 +74,19 @@ 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 */
msgset = cw_msgset_create();
@ -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);
for (i=0;i<bootcfg.nmods; i++){
mod = cw_mod_load(bootcfg.modnames[i], global_cfg, CW_ROLE_WTP);
if (mod == NULL){
exit (EXIT_FAILURE);
}
/* 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);