Reads Cisco 1048 elements
FossilOrigin-Name: 862bfe7c8db943b9aada1de60f3c537ffe7fd0fc0f943d952c6a912ff9f53cdd
This commit is contained in:
parent
28b0488a10
commit
17aeec3516
@ -4,8 +4,8 @@
|
||||
<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="Yes"/>
|
||||
<Project Name="mod_cisco" Path="mod_cisco.project" Active="Yes"/>
|
||||
<Project Name="libcw" Path="libcw.project" Active="No"/>
|
||||
<Project Name="mod_capwap80211" Path="mod_capwap80211.project" Active="No"/>
|
||||
<Project Name="mod_fortinet" Path="mod_fortinet.project" Active="No"/>
|
||||
<BuildMatrix>
|
||||
|
@ -266,6 +266,7 @@
|
||||
<File Name="src/cw/cw_in_generic_struct.c"/>
|
||||
<File Name="src/cw/cw_out_radio_generic.c"/>
|
||||
<File Name="src/cw/cw_read_radio_generic.c"/>
|
||||
<File Name="src/cw/cw_read_from.c"/>
|
||||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
<Description/>
|
||||
|
@ -106,7 +106,8 @@ CWSRC=\
|
||||
cw_type_ipaddress.c\
|
||||
cw_type_word.c\
|
||||
cw_util.c\
|
||||
cw_write_descriptor_subelem.c
|
||||
cw_write_descriptor_subelem.c\
|
||||
cw_read_from.c
|
||||
|
||||
|
||||
LWSRC=\
|
||||
|
@ -561,7 +561,7 @@ extern struct cw_StrListElem capwap_strings_vendor[];
|
||||
extern struct cw_StrListElem capwap_strings_elem[];
|
||||
extern struct cw_StrListElem capwap_strings_result[];
|
||||
extern struct cw_StrListElem capwap_strings_board[];
|
||||
extern struct cw_StrListElem mbag_item_strings[];
|
||||
/*extern struct cw_StrListElem mbag_item_strings[];*/
|
||||
|
||||
|
||||
|
||||
@ -574,7 +574,7 @@ extern struct cw_StrListElem mbag_item_strings[];
|
||||
|
||||
#define cw_strboardelem(id) cw_strlist_get_str(capwap_strings_board,id)
|
||||
|
||||
#define cw_stritem(id) cw_strlist_get_str(mbag_item_strings,(id))
|
||||
/*#define cw_stritem(id) cw_strlist_get_str(mbag_item_strings,(id))*/
|
||||
|
||||
/*
|
||||
#define cw_strrc(rc) \
|
||||
|
@ -309,7 +309,7 @@ extern int conn_recvfrom_packet(struct conn *conn, uint8_t * buf, int len,
|
||||
struct sockaddr_storage *from);
|
||||
|
||||
int conn_send_msg(struct conn * conn, uint8_t *rawmsg);
|
||||
int cw_read_from(struct conn * conn);
|
||||
int cw_read_from(struct conn * conn, struct sockaddr_storage * from);
|
||||
|
||||
int conn_send_msg(struct conn *conn, uint8_t * rawmsg);
|
||||
|
||||
|
@ -722,29 +722,3 @@ int cw_read_messages(struct conn *conn)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int cw_read_from(struct conn *conn)
|
||||
{
|
||||
int n;
|
||||
struct sockaddr_storage from;
|
||||
uint8_t buf[2024];
|
||||
int len = 2024;
|
||||
|
||||
if (!conn->readfrom) {
|
||||
cw_log(LOG_ERR, "Fatal error, no readfrom method available.");
|
||||
errno = EPROTO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
n = conn->readfrom(conn, buf, len, &from);
|
||||
if (n < 0)
|
||||
return n;
|
||||
|
||||
if (n > 0) {
|
||||
return conn->process_packet(conn, buf, n, (struct sockaddr *) &from);
|
||||
}
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
}
|
||||
|
@ -51,11 +51,9 @@ int cw_out_radio_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerP
|
||||
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+1;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;
|
||||
}
|
||||
|
29
src/cw/cw_read_from.c
Normal file
29
src/cw/cw_read_from.c
Normal file
@ -0,0 +1,29 @@
|
||||
#include "cw.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
int cw_read_from(struct conn *conn, struct sockaddr_storage * from)
|
||||
{
|
||||
int n;
|
||||
uint8_t buf[2024];
|
||||
int len = 2024;
|
||||
|
||||
if (!conn->readfrom) {
|
||||
cw_log(LOG_ERR, "Fatal error, no readfrom method available.");
|
||||
errno = EPROTO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
n = conn->readfrom(conn, buf, len, from);
|
||||
if (n < 0)
|
||||
return n;
|
||||
|
||||
if (n > 0) {
|
||||
return conn->process_packet(conn, buf, n, (struct sockaddr *) from);
|
||||
}
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
}
|
@ -259,8 +259,17 @@ static inline void *mavl_replace(struct mavl *t,void *data){
|
||||
|
||||
|
||||
void mavl_freeptr(void *ptr);
|
||||
|
||||
/**
|
||||
* Create a mavl_t object which stores pointers.
|
||||
* @param cmp a pointer to the compare function
|
||||
* @param del a pointer to a delete function
|
||||
* @return The mavl_t object or NULL if an error has occured.
|
||||
*/
|
||||
#define mavl_create_ptr(cmp,del)\
|
||||
mavl_create(cmp,del,sizeof(void*))
|
||||
|
||||
|
||||
int mavl_cmpstr(const void *p1, const void *p2);
|
||||
#define mavl_create_str() mavl_create_ptr(mavl_cmpstr,mavl_freeptr)
|
||||
#define mavl_create_conststr() mavl_create_ptr(mavl_cmpstr,NULL)
|
||||
@ -271,6 +280,7 @@ void * mavl_add_ptr ( mavl_t tree, const void *ptr );
|
||||
#define mavl_add_str(tree,str) mavl_add_ptr(tree,str)
|
||||
#define mavl_get_str(tree,search) ((char *)(mavl_get_ptr(tree,search)))
|
||||
#define mavliter_get_str(iter) ((char*)(mavliter_get_ptr(iter)))
|
||||
#define mavliter_get_conststr(iter) ((const char*)(mavliter_get_ptr(iter)))
|
||||
|
||||
/**
|
||||
* @} MAVL
|
||||
|
@ -17,7 +17,7 @@ static struct cw_ElemHandler handlers[] = {
|
||||
CAPWAP80211_ELEM_WTP_RADIO_INFORMATION, /* Element ID */
|
||||
0, 0, /* Vendor / Proto */
|
||||
0, 0, /* min/max length */
|
||||
CW_TYPE_DWORD, /* type */
|
||||
CW_TYPE_DWORD, /* type */
|
||||
"wtp-radio-information", /* Key */
|
||||
cw_in_radio_generic, /* get */
|
||||
cw_out_radio_generic /* put */
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
|
||||
#include "cw/capwap.h"
|
||||
#include "cw/capwap80211.h"
|
||||
#include "cw/msgset.h"
|
||||
#include "cw/ktv.h"
|
||||
#include "cw/keys.h"
|
||||
@ -61,7 +62,7 @@ static struct cw_ElemHandler handlers[] = {
|
||||
}
|
||||
,
|
||||
{
|
||||
"AC Descriptor (Cisco)", /* name */
|
||||
"AC Descriptor (Cisco LWAPP)", /* name */
|
||||
CAPWAP_ELEM_AC_DESCRIPTOR, /* Element ID */
|
||||
0,0, /* Vendor / Proto */
|
||||
4,128, /* min/max length */
|
||||
@ -134,8 +135,9 @@ static struct cw_ElemDef discovery_request_elements[] ={
|
||||
|
||||
static int discovery_response_states[] = {CAPWAP_STATE_DISCOVERY,0};
|
||||
static struct cw_ElemDef discovery_response_elements[] ={
|
||||
{0,CW_VENDOR_ID_CISCO, CISCO_ELEM_AP_TIMESYNC, 1, 0},
|
||||
{0,CW_VENDOR_ID_CISCO, CISCO_ELEM_MWAR_TYPE, 0, 0},
|
||||
{0,CW_VENDOR_ID_CISCO, CISCO_ELEM_AP_TIMESYNC, 1, 0},
|
||||
{0,CW_VENDOR_ID_CISCO, CISCO_ELEM_MWAR_TYPE, 0, 0},
|
||||
{0,0, CAPWAP80211_ELEM_WTP_RADIO_INFORMATION, 0, 0},
|
||||
{0,0,0,00}
|
||||
|
||||
};
|
||||
@ -143,15 +145,15 @@ static struct cw_ElemDef discovery_response_elements[] ={
|
||||
|
||||
static struct cw_MsgDef messages[] = {
|
||||
{
|
||||
"Discovery Request",
|
||||
CAPWAP_MSG_DISCOVERY_REQUEST,
|
||||
CW_RECEIVER_AC,
|
||||
NULL, /* name */
|
||||
CAPWAP_MSG_DISCOVERY_REQUEST, /* type */
|
||||
CW_RECEIVER_AC,
|
||||
discovery_request_states,
|
||||
discovery_request_elements
|
||||
},
|
||||
{
|
||||
"Discovery Response",
|
||||
CAPWAP_MSG_DISCOVERY_RESPONSE,
|
||||
NULL, /* name */
|
||||
CAPWAP_MSG_DISCOVERY_RESPONSE, /* type */
|
||||
CW_RECEIVER_WTP,
|
||||
discovery_response_states,
|
||||
discovery_response_elements
|
||||
|
@ -12,4 +12,6 @@ int cisco_in_ac_descriptor(struct cw_ElemHandler *eh,
|
||||
struct cw_ElemHandlerParams *params,
|
||||
uint8_t * data, int len);
|
||||
|
||||
struct cw_MsgSet * cisco_register_msg_set(struct cw_MsgSet * set, int mode);
|
||||
|
||||
#endif
|
||||
|
@ -8,20 +8,23 @@
|
||||
|
||||
|
||||
/*#include "mod_cisco.h"*/
|
||||
#include "../modload.h"
|
||||
/*#include "../modload.h"*/
|
||||
|
||||
#include "cw/vendors.h"
|
||||
|
||||
#include "mod_cisco.h"
|
||||
|
||||
|
||||
|
||||
/*
|
||||
extern int cisco_register_actions80211_ac(struct cw_actiondef *def);
|
||||
extern int cisco_register_actions_ac(struct cw_actiondef *def);
|
||||
*/
|
||||
|
||||
/*mbag_t cisco_config = NULL;*/
|
||||
|
||||
static struct cw_Mod * capwap_mod = NULL;
|
||||
|
||||
static struct cw_Mod * capwap80211_mod = NULL;
|
||||
|
||||
|
||||
static struct cw_MsgSet * register_messages(struct cw_MsgSet *set, int mode)
|
||||
{
|
||||
@ -30,30 +33,25 @@ static struct cw_MsgSet * register_messages(struct cw_MsgSet *set, int mode)
|
||||
case CW_MOD_MODE_CAPWAP:
|
||||
{
|
||||
capwap_mod->register_messages(set, CW_MOD_MODE_CAPWAP);
|
||||
capwap80211_mod->register_messages(set, CW_MOD_MODE_BINDINGS);
|
||||
cisco_register_msg_set(set,CW_MOD_MODE_CAPWAP);
|
||||
|
||||
|
||||
/* cw_dbg(DBG_MOD,"Cisco: loading cisco message set");*/
|
||||
cisco_register_msg_set(set,CW_MOD_MODE_CAPWAP);
|
||||
|
||||
/* cw_dbg(DBG_INFO, "Initialized mod_cisco with %d messages", 7);*/
|
||||
break;
|
||||
}
|
||||
/* case CW_MOD_MODE_BINDINGS:
|
||||
case CW_MOD_MODE_BINDINGS:
|
||||
{
|
||||
return 0;
|
||||
struct cw_Mod *cmod = cw_mod_load("capwap80211"); //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_messages(set, CW_MOD_MODE_BINDINGS);
|
||||
int rc = cisco_register_actions80211_ac(set);
|
||||
cw_dbg(DBG_INFO, "Initialized mod_cisco 80211 with %d actions", 12);
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
cw_dbg(DBG_INFO,"CISCO: Done register messages");
|
||||
return 0;
|
||||
|
||||
@ -90,6 +88,11 @@ static int init(struct cw_Mod *mod, mavl_t global_cfg, int role)
|
||||
if (capwap_mod == NULL){
|
||||
cw_log(LOG_ERR, "CISCO: failed to load base module 'capwap");
|
||||
}
|
||||
|
||||
capwap80211_mod = cw_mod_load("capwap80211", global_cfg,role);
|
||||
if (capwap_mod == NULL){
|
||||
cw_log(LOG_ERR, "CISCO: failed to load base module 'capwap80211");
|
||||
}
|
||||
|
||||
/*cisco_config = mbag_create();*/
|
||||
|
||||
@ -128,7 +131,7 @@ static int init(struct cw_Mod *mod, mavl_t global_cfg, int role)
|
||||
free(str);
|
||||
}
|
||||
*/
|
||||
errX:
|
||||
/*errX:*/
|
||||
if (hardware_version)
|
||||
free (hardware_version);
|
||||
if (software_version)
|
||||
|
@ -26,6 +26,6 @@ wtp-descriptor/bootloader/vendor:Dword:906090
|
||||
wtp-descriptor/bootloader/version:Bstr16:.x171312
|
||||
wtp-descriptor/max-radios:Byte:2
|
||||
|
||||
radio/1/wtp-radio-information:Dword:012
|
||||
radio/2/wtp-radio-information:Dword:013
|
||||
radio/1/wtp-radio-information:Dword:04
|
||||
radio/2/wtp-radio-information:Dword:03
|
||||
|
||||
|
@ -21,7 +21,9 @@ static int run_discovery(struct conn *conn)
|
||||
/*// conn->incomming = mbag_create();*/
|
||||
time_t timer;
|
||||
uint8_t dtype=0;
|
||||
|
||||
mlist_t discovery_results;
|
||||
struct sockaddr_storage from;
|
||||
|
||||
conn->capwap_state = CAPWAP_STATE_DISCOVERY;
|
||||
|
||||
|
||||
@ -35,14 +37,15 @@ static int run_discovery(struct conn *conn)
|
||||
|
||||
timer = cw_timer_start(0);
|
||||
|
||||
|
||||
|
||||
discovery_results = mlist_create(NULL,NULL,sizeof(void*));
|
||||
while (!cw_timer_timeout(timer)
|
||||
&& conn->capwap_state == CAPWAP_STATE_DISCOVERY) {
|
||||
int rc;
|
||||
char addr_str[SOCK_ADDR_BUFSIZE];
|
||||
/*mavl_del_all(conn->incomming);*/
|
||||
|
||||
rc = cw_read_from(conn);
|
||||
|
||||
rc = cw_read_from(conn, &from);
|
||||
if (rc<0) {
|
||||
if (errno==EAGAIN)
|
||||
continue;
|
||||
@ -50,9 +53,12 @@ static int run_discovery(struct conn *conn)
|
||||
cw_log(LOG_ERROR,"Error reading messages: %s",strerror(errno));
|
||||
break;
|
||||
}
|
||||
cw_dbg(DBG_INFO,"Received Discovery Response from %s", sock_addr2str(&from,addr_str));
|
||||
mlist_append_ptr(discovery_results,conn->remote_cfg);
|
||||
conn->remote_cfg=cw_ktv_create();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
mbag_t discs;
|
||||
discs = mbag_get_mavl(conn->remote, CW_ITEM_DISCOVERIES);
|
||||
|
Loading…
Reference in New Issue
Block a user