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="wtp" Path="wtp.project" Active="No"/>
|
||||||
<Project Name="mod_cipwap" Path="mod_cipwap.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_capwap" Path="mod_capwap.project" Active="No"/>
|
||||||
<Project Name="mod_cisco" Path="mod_cisco.project" Active="No"/>
|
<Project Name="mod_cisco" Path="mod_cisco.project" Active="Yes"/>
|
||||||
<Project Name="libcw" Path="libcw.project" Active="Yes"/>
|
<Project Name="libcw" Path="libcw.project" Active="No"/>
|
||||||
<Project Name="mod_capwap80211" Path="mod_capwap80211.project" Active="No"/>
|
<Project Name="mod_capwap80211" Path="mod_capwap80211.project" Active="No"/>
|
||||||
<Project Name="mod_fortinet" Path="mod_fortinet.project" Active="No"/>
|
<Project Name="mod_fortinet" Path="mod_fortinet.project" Active="No"/>
|
||||||
<BuildMatrix>
|
<BuildMatrix>
|
||||||
|
@ -266,6 +266,7 @@
|
|||||||
<File Name="src/cw/cw_in_generic_struct.c"/>
|
<File Name="src/cw/cw_in_generic_struct.c"/>
|
||||||
<File Name="src/cw/cw_out_radio_generic.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_radio_generic.c"/>
|
||||||
|
<File Name="src/cw/cw_read_from.c"/>
|
||||||
</VirtualDirectory>
|
</VirtualDirectory>
|
||||||
</VirtualDirectory>
|
</VirtualDirectory>
|
||||||
<Description/>
|
<Description/>
|
||||||
|
@ -106,7 +106,8 @@ CWSRC=\
|
|||||||
cw_type_ipaddress.c\
|
cw_type_ipaddress.c\
|
||||||
cw_type_word.c\
|
cw_type_word.c\
|
||||||
cw_util.c\
|
cw_util.c\
|
||||||
cw_write_descriptor_subelem.c
|
cw_write_descriptor_subelem.c\
|
||||||
|
cw_read_from.c
|
||||||
|
|
||||||
|
|
||||||
LWSRC=\
|
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_elem[];
|
||||||
extern struct cw_StrListElem capwap_strings_result[];
|
extern struct cw_StrListElem capwap_strings_result[];
|
||||||
extern struct cw_StrListElem capwap_strings_board[];
|
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_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) \
|
#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);
|
struct sockaddr_storage *from);
|
||||||
|
|
||||||
int conn_send_msg(struct conn * conn, uint8_t *rawmsg);
|
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);
|
int conn_send_msg(struct conn *conn, uint8_t * rawmsg);
|
||||||
|
|
||||||
|
@ -722,29 +722,3 @@ int cw_read_messages(struct conn *conn)
|
|||||||
return -1;
|
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;
|
len =0;
|
||||||
|
|
||||||
radios = cw_ktv_get_byte(params->conn->local_cfg,"wtp-descriptor/max-radios",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++){
|
for(i=1;i<radios+1;i++){
|
||||||
l = cw_put_radio_generic(handler,i,params,dst+len);
|
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);
|
cw_dbg_elem(DBG_ELEM_OUT,params->conn,params->msgdata->type,handler,dst,l);
|
||||||
len+=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);
|
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)\
|
#define mavl_create_ptr(cmp,del)\
|
||||||
mavl_create(cmp,del,sizeof(void*))
|
mavl_create(cmp,del,sizeof(void*))
|
||||||
|
|
||||||
|
|
||||||
int mavl_cmpstr(const void *p1, const void *p2);
|
int mavl_cmpstr(const void *p1, const void *p2);
|
||||||
#define mavl_create_str() mavl_create_ptr(mavl_cmpstr,mavl_freeptr)
|
#define mavl_create_str() mavl_create_ptr(mavl_cmpstr,mavl_freeptr)
|
||||||
#define mavl_create_conststr() mavl_create_ptr(mavl_cmpstr,NULL)
|
#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_add_str(tree,str) mavl_add_ptr(tree,str)
|
||||||
#define mavl_get_str(tree,search) ((char *)(mavl_get_ptr(tree,search)))
|
#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_str(iter) ((char*)(mavliter_get_ptr(iter)))
|
||||||
|
#define mavliter_get_conststr(iter) ((const char*)(mavliter_get_ptr(iter)))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @} MAVL
|
* @} MAVL
|
||||||
|
@ -17,7 +17,7 @@ static struct cw_ElemHandler handlers[] = {
|
|||||||
CAPWAP80211_ELEM_WTP_RADIO_INFORMATION, /* Element ID */
|
CAPWAP80211_ELEM_WTP_RADIO_INFORMATION, /* Element ID */
|
||||||
0, 0, /* Vendor / Proto */
|
0, 0, /* Vendor / Proto */
|
||||||
0, 0, /* min/max length */
|
0, 0, /* min/max length */
|
||||||
CW_TYPE_DWORD, /* type */
|
CW_TYPE_DWORD, /* type */
|
||||||
"wtp-radio-information", /* Key */
|
"wtp-radio-information", /* Key */
|
||||||
cw_in_radio_generic, /* get */
|
cw_in_radio_generic, /* get */
|
||||||
cw_out_radio_generic /* put */
|
cw_out_radio_generic /* put */
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "cw/capwap.h"
|
#include "cw/capwap.h"
|
||||||
|
#include "cw/capwap80211.h"
|
||||||
#include "cw/msgset.h"
|
#include "cw/msgset.h"
|
||||||
#include "cw/ktv.h"
|
#include "cw/ktv.h"
|
||||||
#include "cw/keys.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 */
|
CAPWAP_ELEM_AC_DESCRIPTOR, /* Element ID */
|
||||||
0,0, /* Vendor / Proto */
|
0,0, /* Vendor / Proto */
|
||||||
4,128, /* min/max length */
|
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 int discovery_response_states[] = {CAPWAP_STATE_DISCOVERY,0};
|
||||||
static struct cw_ElemDef discovery_response_elements[] ={
|
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_AP_TIMESYNC, 1, 0},
|
||||||
{0,CW_VENDOR_ID_CISCO, CISCO_ELEM_MWAR_TYPE, 0, 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}
|
{0,0,0,00}
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -143,15 +145,15 @@ static struct cw_ElemDef discovery_response_elements[] ={
|
|||||||
|
|
||||||
static struct cw_MsgDef messages[] = {
|
static struct cw_MsgDef messages[] = {
|
||||||
{
|
{
|
||||||
"Discovery Request",
|
NULL, /* name */
|
||||||
CAPWAP_MSG_DISCOVERY_REQUEST,
|
CAPWAP_MSG_DISCOVERY_REQUEST, /* type */
|
||||||
CW_RECEIVER_AC,
|
CW_RECEIVER_AC,
|
||||||
discovery_request_states,
|
discovery_request_states,
|
||||||
discovery_request_elements
|
discovery_request_elements
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Discovery Response",
|
NULL, /* name */
|
||||||
CAPWAP_MSG_DISCOVERY_RESPONSE,
|
CAPWAP_MSG_DISCOVERY_RESPONSE, /* type */
|
||||||
CW_RECEIVER_WTP,
|
CW_RECEIVER_WTP,
|
||||||
discovery_response_states,
|
discovery_response_states,
|
||||||
discovery_response_elements
|
discovery_response_elements
|
||||||
|
@ -12,4 +12,6 @@ int cisco_in_ac_descriptor(struct cw_ElemHandler *eh,
|
|||||||
struct cw_ElemHandlerParams *params,
|
struct cw_ElemHandlerParams *params,
|
||||||
uint8_t * data, int len);
|
uint8_t * data, int len);
|
||||||
|
|
||||||
|
struct cw_MsgSet * cisco_register_msg_set(struct cw_MsgSet * set, int mode);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -8,20 +8,23 @@
|
|||||||
|
|
||||||
|
|
||||||
/*#include "mod_cisco.h"*/
|
/*#include "mod_cisco.h"*/
|
||||||
#include "../modload.h"
|
/*#include "../modload.h"*/
|
||||||
|
|
||||||
#include "cw/vendors.h"
|
#include "cw/vendors.h"
|
||||||
|
|
||||||
|
#include "mod_cisco.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
extern int cisco_register_actions80211_ac(struct cw_actiondef *def);
|
extern int cisco_register_actions80211_ac(struct cw_actiondef *def);
|
||||||
extern int cisco_register_actions_ac(struct cw_actiondef *def);
|
extern int cisco_register_actions_ac(struct cw_actiondef *def);
|
||||||
|
*/
|
||||||
|
|
||||||
/*mbag_t cisco_config = NULL;*/
|
/*mbag_t cisco_config = NULL;*/
|
||||||
|
|
||||||
static struct cw_Mod * capwap_mod = 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)
|
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:
|
case CW_MOD_MODE_CAPWAP:
|
||||||
{
|
{
|
||||||
capwap_mod->register_messages(set, 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");*/
|
/* 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);*/
|
/* cw_dbg(DBG_INFO, "Initialized mod_cisco with %d messages", 7);*/
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* case CW_MOD_MODE_BINDINGS:
|
case CW_MOD_MODE_BINDINGS:
|
||||||
{
|
{
|
||||||
return 0;
|
break;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cw_dbg(DBG_INFO,"CISCO: Done register messages");
|
cw_dbg(DBG_INFO,"CISCO: Done register messages");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -90,6 +88,11 @@ static int init(struct cw_Mod *mod, mavl_t global_cfg, int role)
|
|||||||
if (capwap_mod == NULL){
|
if (capwap_mod == NULL){
|
||||||
cw_log(LOG_ERR, "CISCO: failed to load base module 'capwap");
|
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();*/
|
/*cisco_config = mbag_create();*/
|
||||||
|
|
||||||
@ -128,7 +131,7 @@ static int init(struct cw_Mod *mod, mavl_t global_cfg, int role)
|
|||||||
free(str);
|
free(str);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
errX:
|
/*errX:*/
|
||||||
if (hardware_version)
|
if (hardware_version)
|
||||||
free (hardware_version);
|
free (hardware_version);
|
||||||
if (software_version)
|
if (software_version)
|
||||||
|
@ -26,6 +26,6 @@ wtp-descriptor/bootloader/vendor:Dword:906090
|
|||||||
wtp-descriptor/bootloader/version:Bstr16:.x171312
|
wtp-descriptor/bootloader/version:Bstr16:.x171312
|
||||||
wtp-descriptor/max-radios:Byte:2
|
wtp-descriptor/max-radios:Byte:2
|
||||||
|
|
||||||
radio/1/wtp-radio-information:Dword:012
|
radio/1/wtp-radio-information:Dword:04
|
||||||
radio/2/wtp-radio-information:Dword:013
|
radio/2/wtp-radio-information:Dword:03
|
||||||
|
|
||||||
|
@ -21,7 +21,9 @@ static int run_discovery(struct conn *conn)
|
|||||||
/*// conn->incomming = mbag_create();*/
|
/*// conn->incomming = mbag_create();*/
|
||||||
time_t timer;
|
time_t timer;
|
||||||
uint8_t dtype=0;
|
uint8_t dtype=0;
|
||||||
|
mlist_t discovery_results;
|
||||||
|
struct sockaddr_storage from;
|
||||||
|
|
||||||
conn->capwap_state = CAPWAP_STATE_DISCOVERY;
|
conn->capwap_state = CAPWAP_STATE_DISCOVERY;
|
||||||
|
|
||||||
|
|
||||||
@ -35,14 +37,15 @@ static int run_discovery(struct conn *conn)
|
|||||||
|
|
||||||
timer = cw_timer_start(0);
|
timer = cw_timer_start(0);
|
||||||
|
|
||||||
|
|
||||||
|
discovery_results = mlist_create(NULL,NULL,sizeof(void*));
|
||||||
while (!cw_timer_timeout(timer)
|
while (!cw_timer_timeout(timer)
|
||||||
&& conn->capwap_state == CAPWAP_STATE_DISCOVERY) {
|
&& conn->capwap_state == CAPWAP_STATE_DISCOVERY) {
|
||||||
int rc;
|
int rc;
|
||||||
|
char addr_str[SOCK_ADDR_BUFSIZE];
|
||||||
/*mavl_del_all(conn->incomming);*/
|
/*mavl_del_all(conn->incomming);*/
|
||||||
|
|
||||||
rc = cw_read_from(conn);
|
rc = cw_read_from(conn, &from);
|
||||||
|
|
||||||
if (rc<0) {
|
if (rc<0) {
|
||||||
if (errno==EAGAIN)
|
if (errno==EAGAIN)
|
||||||
continue;
|
continue;
|
||||||
@ -50,9 +53,12 @@ static int run_discovery(struct conn *conn)
|
|||||||
cw_log(LOG_ERROR,"Error reading messages: %s",strerror(errno));
|
cw_log(LOG_ERROR,"Error reading messages: %s",strerror(errno));
|
||||||
break;
|
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;
|
mbag_t discs;
|
||||||
discs = mbag_get_mavl(conn->remote, CW_ITEM_DISCOVERIES);
|
discs = mbag_get_mavl(conn->remote, CW_ITEM_DISCOVERIES);
|
||||||
|
Loading…
Reference in New Issue
Block a user