Some work on WTP.

FossilOrigin-Name: 6ec1370311c5b83dc78adbfb75f8241e0916b171a9c0f939d24ec28ebdf908c8
This commit is contained in:
7u83@mail.ru 2015-04-19 14:44:20 +00:00
parent 5a71654ebd
commit fdc6b0e4a0
36 changed files with 496 additions and 61 deletions

View File

@ -43,7 +43,7 @@ AP = RAD = WTP
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Radio ID | CFG Type | Occupancy Limit | | Radio ID | CFG Type | Occupancy Limit |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| CFP Per | CFP Maximum Duration | BSS ID | | CFP Period | CFP Maximum Duration | BSS ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| BSS ID | | BSS ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

View File

@ -103,10 +103,28 @@ int readelem_cisco_rad_name(struct conn *conn,struct cw_action * a,uint8_t *data
#include "capwap/capwap_crypto.h" #include "capwap/capwap_crypto.h"
#include "capwap/mbag.h"
int main (int argc, const char * argv[]) int main (int argc, const char * argv[])
{ {
mbag_t data = mbag_create();
mbag_set_byte(data,1,25);
mbag_set_byte(data,7,125);
int b = mbag_get_byte(data,1,255);
printf("Result: %d\n",b);
mbag_del(data,1);
b = mbag_get_byte(data,1,255);
printf("Result: %d\n",b);
//return 0;
/* /*
intavltree_t t = intavltree_create(); intavltree_t t = intavltree_create();

View File

@ -437,7 +437,7 @@ static void wtpman_run(void *arg)
if (conn->capwap_state == CW_STATE_IMAGE_DATA) { if (conn->capwap_state == CW_STATE_IMAGE_DATA) {
/* Image upload */ /* Image upload */
const char *filename = const char *filename =
cw_itemstore_get_str(conn->outgoing, CW_ITEM_IMAGE_FILENAME); cw_itemstore_get_str(conn->outgoing, CW_ITEM_IMAGE_FILENAME,NULL);
if (!filename) { if (!filename) {
cw_log(LOG_ERR, cw_log(LOG_ERR,
"Can't send image to %s. No Image Filename Item found.", "Can't send image to %s. No Image Filename Item found.",
@ -455,7 +455,7 @@ static void wtpman_run(void *arg)
DEFINE_CLOCK(clk); CLOCK_DEFINE(clk);
cw_clock_start(&clk); cw_clock_start(&clk);
cw_item_t *eof = cw_itemstore_set_const_ptr(conn->outgoing, CW_ITEM_IMAGE_FILEHANDLE, cw_item_t *eof = cw_itemstore_set_const_ptr(conn->outgoing, CW_ITEM_IMAGE_FILEHANDLE,

View File

@ -76,6 +76,10 @@ MAVLOBJS= \
mavl_del.o \ mavl_del.o \
mavl_add.o \ mavl_add.o \
mavl_create.o\ mavl_create.o\
mavl_get.o\
mavl_del_all.o\
mavliter_seek.o \
mavliter_next.o \
utf8.o utf8.o
# cw_foreach_msgelem.o \ # cw_foreach_msgelem.o \
@ -316,7 +320,12 @@ CWACTION=action.o \
capwap_strings_result.o\ capwap_strings_result.o\
cw_put_msg.o \ cw_put_msg.o \
capwap_action_helpers.o \ capwap_action_helpers.o \
cw_put_image_data.o cw_put_image_data.o \
cisco.o \
item_strings.o \
mbag.o\
radio.o \
cw_out_radio_info.o
# cw_process_msg.o \ # cw_process_msg.o \

View File

@ -132,14 +132,14 @@ struct capwap_ctrlhdr
//extern int capwap_parse_ctrlhdr(struct capwap_ctrlhdr * ch,uint8_t * msg, int len); //extern int capwap_parse_ctrlhdr(struct capwap_ctrlhdr * ch,uint8_t * msg, int len);
/** /**
*@defgroup CAPWAPMessages CAPWAP Messages *@addtogroup CAPWAPConstants
*@{ *@{
*/ */
/** /**
* CAPWAP message types as defined in RFC 5416 * CAPWAP message types as defined in RFC 5416
*/ */
typedef enum { enum cw_message_types{
/**Discovery Request */ /**Discovery Request */
CW_MSG_DISCOVERY_REQUEST = 1, CW_MSG_DISCOVERY_REQUEST = 1,
@ -183,7 +183,9 @@ CW_STATION_CONFIGURATION_RESPONSE = 26,
CW_MSG_MAXMSG = 26 CW_MSG_MAXMSG = 26
}cw_msg_t; };
//cw_msg_t;
/**@}*/ /**@}*/
@ -590,6 +592,7 @@ extern int cw_readmsg_configuration_update_request(uint8_t * elems, int elems_le
#define cw_put_dword lw_put_dword #define cw_put_dword lw_put_dword
#define cw_put_data lw_put_data #define cw_put_data lw_put_data
#define cw_put_bstr lw_put_bstr #define cw_put_bstr lw_put_bstr
#define cw_put_bstr16 lw_put_bstr16
#define cw_set_dword lw_set_dword #define cw_set_dword lw_set_dword
@ -929,6 +932,9 @@ extern struct cw_str capwap_strings_state[];
extern struct cw_str capwap_strings_vendor[]; extern struct cw_str capwap_strings_vendor[];
extern struct cw_str capwap_strings_elem[]; extern struct cw_str capwap_strings_elem[];
extern struct cw_str capwap_strings_result[]; extern struct cw_str capwap_strings_result[];
extern struct cw_str cw_item_strings[];
#define cw_strmsg(id) cw_strlist_get_str(capwap_strings_msg,id) #define cw_strmsg(id) cw_strlist_get_str(capwap_strings_msg,id)
@ -937,6 +943,8 @@ extern struct cw_str capwap_strings_result[];
#define cw_strvendor(id) cw_strlist_get_str(capwap_strings_vendor,id) #define cw_strvendor(id) cw_strlist_get_str(capwap_strings_vendor,id)
#define cw_strresult(id) cw_strlist_get_str(capwap_strings_result,(id)) #define cw_strresult(id) cw_strlist_get_str(capwap_strings_result,(id))
#define cw_stritem(id) cw_strlist_get_str(cw_item_strings,(id))
/* /*
#define cw_strrc(rc) \ #define cw_strrc(rc) \
((rc)<0 ? ((rc)!=EAGAIN ? strerror(errno):"Timed out"): cw_strresult(rc)) ((rc)<0 ? ((rc)!=EAGAIN ? strerror(errno):"Timed out"): cw_strresult(rc))

View File

@ -13,10 +13,12 @@
#define CWMSG_80211_WLAN_CONFIGURATION_REQUEST 3398913 #define CWMSG_80211_WLAN_CONFIGURATION_REQUEST 3398913
#define CWMSG_80211_WLAN_CONFIGURATION_REPONSE 3398914 #define CWMSG_80211_WLAN_CONFIGURATION_REPONSE 3398914
/** 802.11 Message Elements */
enum radioelems {
#define CW_ELEM80211_ADD_WLAN 1024 /** Add WLAN Message element */
#define CW_ELEM80211_ANTENNA 1025 CW_ELEM80211_ADD_WLAN =1024,
/** Antenna Message element */
CW_ELEM80211_ANTENNA =1025,
/* /*
IEEE 802.11 Assigned WTP BSSID 1026 IEEE 802.11 Assigned WTP BSSID 1026
IEEE 802.11 Delete WLAN 1027 IEEE 802.11 Delete WLAN 1027
@ -26,8 +28,10 @@
IEEE 802.11 MIC Countermeasures 1031 IEEE 802.11 MIC Countermeasures 1031
IEEE 802.11 Multi-Domain Capability 1032 IEEE 802.11 Multi-Domain Capability 1032
IEEE 802.11 OFDM Control 1033 IEEE 802.11 OFDM Control 1033
IEEE 802.11 Rate Set 1034 */
IEEE 802.11 RSNA Error Report From Station 1035 /** Supported WLAN Rates */
CW_ELEM80211_RATE_SET=1034,
/* IEEE 802.11 RSNA Error Report From Station 1035
IEEE 802.11 Station 1036 IEEE 802.11 Station 1036
IEEE 802.11 Station QoS Profile 1037 IEEE 802.11 Station QoS Profile 1037
IEEE 802.11 Station Session Key 1038 IEEE 802.11 Station Session Key 1038
@ -42,7 +46,9 @@
IEEE 802.11 WTP Radio Fail Alarm Indication 1047 IEEE 802.11 WTP Radio Fail Alarm Indication 1047
*/ */
#define CW_ELEM80211_WTP_RADIO_INFORMATION 1048 /** Radio Information Message Element */
CW_ELEM80211_WTP_RADIO_INFORMATION=1048
};
@ -80,6 +86,7 @@ struct cw_wlan {
int cw_out_radio_infos(struct conn *conn, struct cw_action_out *a, uint8_t * dst);
extern int cw_register_actions_capwap_80211_wtp(struct cw_actiondef *def); extern int cw_register_actions_capwap_80211_wtp(struct cw_actiondef *def);

View File

@ -2,6 +2,7 @@
#include "action.h" #include "action.h"
#include "capwap_80211_actions.h" #include "capwap_80211_actions.h"
#include "capwap_80211.h"
#include "capwap.h" #include "capwap.h"
@ -21,11 +22,20 @@ cw_action_in_t capwap_80211_actions_wtp_in[] = {
}; };
cw_action_out_t capwap_80211_actions_wtp_out[]={
/* Session ID */
{CW_MSG_JOIN_REQUEST, CW_ELEM80211_WTP_RADIO_INFORMATION, 0,
CW_ELEM80211_WTP_RADIO_INFORMATION, NULL,cw_out_radio_infos, NULL,1}
};
int cw_register_actions_capwap_80211_wtp(struct cw_actiondef *def) int cw_register_actions_capwap_80211_wtp(struct cw_actiondef *def)
{ {
cw_actionlist_in_register_actions(def->in, capwap_80211_actions_wtp_in); cw_actionlist_in_register_actions(def->in, capwap_80211_actions_wtp_in);
// cw_actionlist_out_register_actions(def->out, capwap_actions_wtp_out); cw_actionlist_out_register_actions(def->out, capwap_80211_actions_wtp_out);
int rc; int rc;
rc = cw_strheap_register_strings(def->strelem, capwap_strings_elem80211); rc = cw_strheap_register_strings(def->strelem, capwap_strings_elem80211);

View File

@ -41,7 +41,7 @@ struct cw_item * cw_out_get_session_id(struct conn *conn,struct cw_action_out *
int slen; int slen;
if ( conn->capwap_mode == CW_MODE_CISCO){ if ( conn->capwap_mode == CW_MODE_CISCO){
slen=4; slen=2;
} }
else else
slen=16; slen=16;

View File

@ -91,6 +91,50 @@ cw_action_in_t capwap_actions_wtp_in[] = {
/* ------------------------------------------------------------------------------- */
/* Message Config Status Response IN */
{0, 0, CW_STATE_CONFIGURE, CW_MSG_CONFIGURATION_STATUS_RESPONSE, 0,
0,0 }
,
{0, 0, CW_STATE_CONFIGURE, CW_MSG_CONFIGURATION_STATUS_RESPONSE,
CW_ACTION_IN_VENDOR_SPECIFIC_PAYLOAD, 0}
,
/* ------------------------------------------------------------------------------- */
/* Message Change State Response IN */
{0, 0, CW_STATE_CONFIGURE, CW_MSG_CHANGE_STATE_EVENT_RESPONSE, 0,
0,0 }
,
/* Message Change State Response IN */
{0, 0, CW_STATE_RUN, CW_MSG_CONFIGURATION_UPDATE_REQUEST,
0, 0,0 }
,
/* Element: Vendor Specific */
{0, 0, CW_STATE_RUN, CW_MSG_CONFIGURATION_UPDATE_REQUEST,
CW_ACTION_IN_VENDOR_SPECIFIC_PAYLOAD, 0}
,
/* Echo Response Response IN */
{0, 0, CW_STATE_RUN, CW_MSG_ECHO_RESPONSE, 0,
0,0 }
,
/* Element: Vendor Specific */
{0, 0, CW_STATE_RUN, CW_MSG_ECHO_RESPONSE,
CW_ACTION_IN_VENDOR_SPECIFIC_PAYLOAD, 0}
,
{0, 0, 0} {0, 0, 0}
}; };
@ -202,11 +246,33 @@ cw_action_out_t capwap_actions_wtp_out[] = {
*/ */
{CW_MSG_CONFIGURATION_STATUS_REQUEST, CW_ITEM_NONE} {CW_MSG_CONFIGURATION_STATUS_REQUEST, CW_ITEM_NONE}
, ,
/* AC Name */
{CW_MSG_CONFIGURATION_STATUS_REQUEST, CW_ITEM_AC_NAME, 0,
CW_ELEM_AC_NAME, NULL, cw_out_generic, cw_out_get_local,1}
,
/* -------------------------------------------------------------------------------
* Configuration Status Request OUT
*/
{CW_MSG_CHANGE_STATE_EVENT_REQUEST, CW_ITEM_NONE}
,
/* -------------------------------------------------------------------------------
* Echo Request Request OUT
*/
{CW_MSG_ECHO_REQUEST, CW_ITEM_NONE}
,
/* -------------------------------------------------------------------------------
* Echo Request Request OUT
*/
{CW_MSG_CONFIGURATION_UPDATE_RESPONSE, CW_ITEM_NONE}
,
{0, 0} {0, 0}
}; };

View File

@ -63,6 +63,7 @@
#define CW_CISCO_AP_STATIC_IP_ADDR 83 #define CW_CISCO_AP_STATIC_IP_ADDR 83
#define CW_CISCO_AC_NAME_WITH_INDEX 91 #define CW_CISCO_AC_NAME_WITH_INDEX 91
#define CW_CISCO_SPAM_DOMAIN_SECRET 96
#define CW_CISCO_SPAM_VENDOR_SPECIFIC 104 #define CW_CISCO_SPAM_VENDOR_SPECIFIC 104
@ -203,6 +204,8 @@ int cw_in_check_cipwap_join_req(struct conn *conn, struct cw_action_in *a, uint8
int cw_out_cisco_wtp_radio_cfg(struct conn *conn, struct cw_action_out *a, uint8_t * dst);
/* /*
#define cw_addelem_cisco_rad(dst,acinfo)\ #define cw_addelem_cisco_rad(dst,acinfo)\
@ -213,6 +216,8 @@ int cw_in_check_cipwap_join_req(struct conn *conn, struct cw_action_in *a, uint8
/* cwmsg methods */ /* cwmsg methods */
/*
#define cwmsg_addelem_cisco_ap_timesync(cwmsg,time,type)\ #define cwmsg_addelem_cisco_ap_timesync(cwmsg,time,type)\
(cwmsg)->pos+=cw_addelem_cisco_ap_timesync(((cwmsg)->msgelems+(cwmsg)->pos),time,type) (cwmsg)->pos+=cw_addelem_cisco_ap_timesync(((cwmsg)->msgelems+(cwmsg)->pos),time,type)
@ -234,5 +239,7 @@ int cw_in_check_cipwap_join_req(struct conn *conn, struct cw_action_in *a, uint8
#define cwmsg_addelem_cisco_wtp_radio_cfg(cwmsg,radioinfo)\ #define cwmsg_addelem_cisco_wtp_radio_cfg(cwmsg,radioinfo)\
(cwmsg)->pos+=cw_addelem_cisco_wtp_radio_cfg(((cwmsg)->msgelems+(cwmsg)->pos),radioinfo) (cwmsg)->pos+=cw_addelem_cisco_wtp_radio_cfg(((cwmsg)->msgelems+(cwmsg)->pos),radioinfo)
*/
#endif #endif

View File

@ -56,7 +56,11 @@ enum capwap_items {
CW_ITEM_IMAGE_FILENAME, /* Full path of image filename */ CW_ITEM_IMAGE_FILENAME, /* Full path of image filename */
CW_ITEM_DISCOVERIES, CW_ITEM_DISCOVERIES,
CW_ITEM_AC_PRIO_LIST, /* AC Name with Priority list */ CW_ITEM_AC_PRIO_LIST, /* AC Name with Priority list */
CW_ITEM_IMAGE_FILEHANDLE /* FILE handle for uploading and downloading images */
/** FILE handle for uploading and downloading images */
CW_ITEM_IMAGE_FILEHANDLE,
CW_ITEM_RADIO_CFG
}; };

View File

@ -21,7 +21,7 @@ struct cw_str capwap_strings_elem[] = {
{CW_ELEM_DATA_TRANSFER_DATA, "Data Transfer Data"}, {CW_ELEM_DATA_TRANSFER_DATA, "Data Transfer Data"},
{CW_ELEM_DATA_TRANSFER_MODE, "Data Transfer Mode"}, {CW_ELEM_DATA_TRANSFER_MODE, "Data Transfer Mode"},
{CW_ELEM_DECRYPTION_ERROR_REPORT, "Encryption Error Report"}, {CW_ELEM_DECRYPTION_ERROR_REPORT, "Encryption Error Report"},
{CW_ELEM_DECRYPTION_ERROR_REPORT_PERIOD, "Encryption Error Report Period"}, {CW_ELEM_DECRYPTION_ERROR_REPORT_PERIOD, "Decryption Error Report Period"},
{CW_ELEM_DELETE_MAC_ACL_ENTRY, "Delete MAC ACL Entry"}, {CW_ELEM_DELETE_MAC_ACL_ENTRY, "Delete MAC ACL Entry"},
{CW_ELEM_DELETE_STATION, "Delete Station"}, {CW_ELEM_DELETE_STATION, "Delete Station"},
{CW_ELEM_RESERVED_19, "Reserved 19"}, {CW_ELEM_RESERVED_19, "Reserved 19"},

View File

@ -3,9 +3,10 @@
struct cw_str capwap_strings_elem80211[] = { struct cw_str capwap_strings_elem80211[] = {
{CW_ELEM80211_WTP_RADIO_INFORMATION, "802.11 WTP Radio Information"}, {CW_ELEM80211_ADD_WLAN, "802.11 Add WLAN"},
{CW_STR_STOP,"Unknown"} {CW_ELEM80211_ANTENNA, "802.11 Antenna"},
{CW_ELEM80211_RATE_SET, " 802.11 Rate Set"},
{CW_ELEM80211_WTP_RADIO_INFORMATION, " 802.11 WTP Radio Information"},
{CW_STR_STOP, " Unknown "}
}; };

View File

@ -30,7 +30,7 @@
cw_in_generic, 0, /* start/end callback */ \ cw_in_generic, 0, /* start/end callback */ \
CW_ITEMTYPE_BSTR, /* Type of element */ \ CW_ITEMTYPE_BSTR, /* Type of element */ \
CW_ITEM_SESSION_ID, /* ID to use store */ \ CW_ITEM_SESSION_ID, /* ID to use store */ \
4, 16 /* min/max length */ 2, 16 /* min/max length */
#define CW_ACTION_IN_CIPWAP_AC_NAME \ #define CW_ACTION_IN_CIPWAP_AC_NAME \
CW_ELEM_AC_NAME, /* Element ID*/ \ CW_ELEM_AC_NAME, /* Element ID*/ \

View File

@ -1,12 +1,16 @@
#include "capwap.h" #include "capwap.h"
#include "cipwap.h" #include "cipwap.h"
#include "capwap_cisco.h"
struct cw_str cipwap_strings_elem[] = { struct cw_str cipwap_strings_elem[] = {
{CW_ELEM_WTP_IPV4_IP_ADDRESS, "WTP IPv4 IP Address"}, {CW_ELEM_WTP_IPV4_IP_ADDRESS, "WTP IPv4 IP Address"},
{CW_ELEM_WTP_IPV6_IP_ADDRESS, "WTP IPv6 IP Address"}, {CW_ELEM_WTP_IPV6_IP_ADDRESS, "WTP IPv6 IP Address"},
{CW_CISCO_AP_GROUP_NAME, "WTP Group Name" },
{0,"Unknown Element"} {0,"Unknown Element"}
}; };

View File

@ -40,6 +40,8 @@
#include "itemstore.h" #include "itemstore.h"
#include "intavltree.h" #include "intavltree.h"
#include "mbag.h"
/** /**
* Connection Object * Connection Object
*/ */
@ -53,6 +55,8 @@ struct conn {
cw_itemstore_t remote; cw_itemstore_t remote;
cw_itemstore_t local; cw_itemstore_t local;
mbag_t radios;
/** base_mac */ /** base_mac */
bstr_t base_rmac; bstr_t base_rmac;

View File

@ -444,9 +444,12 @@ int conn_process_packet(struct conn *conn, uint8_t * packet, int len,struct sock
/* fragmented, add the packet to fragman */ /* fragmented, add the packet to fragman */
uint8_t *f; uint8_t *f;
f = fragman_add(conn->fragman, packet, offs, payloadlen); f = fragman_add(conn->fragman, packet, offs, payloadlen);
if (f == NULL) if (f == NULL){
return 0; errno=EAGAIN;
return -1;
}
cw_dbg_pkt(DBG_PKT_IN, conn, f+4, *(uint32_t*)f,from);
cw_dbg_msg(DBG_MSG_IN, conn, f+4, *(uint32_t*)f,from); cw_dbg_msg(DBG_MSG_IN, conn, f+4, *(uint32_t*)f,from);
int rc = process_message(conn, f + 4, *(uint32_t *) f, from); int rc = process_message(conn, f + 4, *(uint32_t *) f, from);

View File

@ -105,6 +105,8 @@ const char * cw_cisco_id_to_str(int elem_id)
return "Antenna Payload"; return "Antenna Payload";
case CW_CISCO_SUPPORTED_RATES: case CW_CISCO_SUPPORTED_RATES:
return "Supported Rates"; return "Supported Rates";
case CW_CISCO_SPAM_DOMAIN_SECRET:
return "SPAM Domain Secret";
default: default:

View File

@ -25,9 +25,7 @@ int cw_in_check_img_data_req_ac(struct conn *conn, struct cw_action_in *a, uint8
uint32_t vendor_id = vendorstr_get_vendor_id(i->data); uint32_t vendor_id = vendorstr_get_vendor_id(i->data);
const char * image_dir; const char * image_dir;
image_dir = cw_itemstore_get_str(conn->local,CW_ITEM_AC_IMAGE_DIR); image_dir = cw_itemstore_get_str(conn->local,CW_ITEM_AC_IMAGE_DIR,"./img");
if ( !image_dir )
image_dir="./img/"; //XXX
char * image_filename = malloc(6+vendorstr_len(i->data)+1+strlen(image_dir)); char * image_filename = malloc(6+vendorstr_len(i->data)+1+strlen(image_dir));
if (!image_filename) if (!image_filename)

View File

@ -36,9 +36,7 @@ int cw_in_check_img_data_req_wtp(struct conn *conn, struct cw_action_in *a, uint
uint32_t vendor_id = vendorstr_get_vendor_id(i->data); uint32_t vendor_id = vendorstr_get_vendor_id(i->data);
const char * image_dir; const char * image_dir;
image_dir = cw_itemstore_get_str(conn->local,CW_ITEM_AC_IMAGE_DIR); image_dir = cw_itemstore_get_str(conn->local,CW_ITEM_AC_IMAGE_DIR,"./img");
if ( !image_dir )
image_dir="./img/"; //XXX
char * image_filename = malloc(6+vendorstr_len(i->data)+1+strlen(image_dir)); char * image_filename = malloc(6+vendorstr_len(i->data)+1+strlen(image_dir));
if (!image_filename) if (!image_filename)

View File

@ -21,6 +21,8 @@ int cw_put_item(uint8_t * dst, struct cw_item *item)
return cw_put_dword(dst, item->dword); return cw_put_dword(dst, item->dword);
case CW_ITEMTYPE_BSTR: case CW_ITEMTYPE_BSTR:
return cw_put_bstr(dst, item->data); return cw_put_bstr(dst, item->data);
case CW_ITEMTYPE_BSTR16:
return cw_put_bstr16(dst,item->data);
case CW_ITEMTYPE_VENDORSTR: case CW_ITEMTYPE_VENDORSTR:
{ {
int l=0; int l=0;
@ -54,15 +56,21 @@ int cw_out_generic(struct conn *conn, struct cw_action_out *a, uint8_t * dst) //
int len; int len;
if (!item) { if (!item) {
const char *vendor="";
if ( a->vendor_id ) {
vendor=cw_strvendor(a->vendor_id);
}
if (a->mand) { if (a->mand) {
cw_log(LOG_ERR, cw_log(LOG_ERR,
"Can't put mandatory element %d - (%s) into %s. No value found.", "Can't put mandatory element %s%d - (%s) into %s. No value found.",
vendor,
a->elem_id, cw_strelemp(conn->actions, a->elem_id) a->elem_id, cw_strelemp(conn->actions, a->elem_id)
, cw_strmsg(a->msg_id) , cw_strmsg(a->msg_id)
); );
} }
else{ else{
cw_dbg(DBG_WARN,"No output for element %d -(%s) in %s. Item %d not found.", cw_dbg(DBG_WARN,"No output for element %s%d -(%s) in %s. Item %d not found.",
vendor,
a->elem_id, cw_strelemp(conn->actions, a->elem_id) a->elem_id, cw_strelemp(conn->actions, a->elem_id)
, cw_strmsg(a->msg_id),a->item_id); , cw_strmsg(a->msg_id),a->item_id);

View File

@ -32,16 +32,24 @@ int cw_out_wtp_descriptor(struct conn *conn, struct cw_action_out *a, uint8_t *
uint8_t *d = dst+4; uint8_t *d = dst+4;
d+=cw_put_byte(d,2); //max radios d+=cw_put_byte(d,2); //max radios
d+=cw_put_byte(d,0); //radios in use d+=cw_put_byte(d,2); //radios in use
d+=cw_put_encryption_subelems(d); d+=cw_put_encryption_subelems(d);
cw_item_t * i; cw_item_t * i;
i = cw_itemstore_get(conn->outgoing,CW_ITEM_WTP_HARDWARE_VERSION); i = cw_itemstore_get(conn->local,CW_ITEM_WTP_HARDWARE_VERSION);
if ( i ) { if ( i ) {
d += cw_put_version(d,CW_SUBELEM_WTP_HARDWARE_VERSION,i->data); d += cw_put_version(d,CW_SUBELEM_WTP_HARDWARE_VERSION,i->data);
} }
else { else {
cw_log(LOG_ERR, "Can't send hard version in WTP descriptor, not set."); cw_log(LOG_ERR, "Can't send Hardware Version in WTP Descriptor, not set.");
}
i = cw_itemstore_get(conn->local,CW_ITEM_WTP_SOFTWARE_VERSION);
if ( i ) {
d += cw_put_version(d,CW_SUBELEM_WTP_SOFTWARE_VERSION,i->data);
}
else {
cw_log(LOG_ERR, "Can't send Software Version in WTP descriptor, not set.");
} }

View File

@ -495,5 +495,45 @@ void cw_dbg_colored(int level, const char *file, int line, const char *format, .
} }
int cw_is_utf8(unsigned char *str, size_t len);
int cw_format_item(char *dst,cw_item_t * item)
{
*dst=0;
switch (item->type) {
case CW_ITEMTYPE_BSTR16:
strncpy(dst,bstr16_data(item->data),bstr16_len(item->data));
*(dst+bstr16_len(item->data))=0;
return bstr16_len(item->data);
}
}
void dbg_istore_dmp(cw_itemstore_t s)
{
DEFINE_AVLITER(it,s);
avliter_foreach(&it) {
cw_item_t *i = avliter_get(&it);
char buffer[1000];
struct cw_str * strings = cw_item_strings;
const char * in = cw_strlist_get_str(strings,i->id);
cw_format_item(buffer,i);
printf("Item ID %d-%s: %s\n",i->id,in,buffer);
}
}
/**@}*/ /**@}*/

View File

@ -88,15 +88,17 @@ int cw_itemstore_set_bstr16n(cw_itemstore_t s, uint32_t id, uint8_t * data, int
extern int cw_itemstore_set_data(cw_itemstore_t s, uint32_t id, const uint8_t * data, extern int cw_itemstore_set_data(cw_itemstore_t s, uint32_t id, const uint8_t * data,
int len); int len);
static inline char *cw_itemstore_get_str(cw_itemstore_t s, uint32_t id) static inline char *cw_itemstore_get_str(cw_itemstore_t s, uint32_t id, char *def)
{ {
struct cw_item *i = cw_itemstore_get(s, id); struct cw_item *i = cw_itemstore_get(s, id);
if (!i) if (!i)
return NULL; return def;
return i->data; return i->data;
}; };
static inline struct avltree *cw_itemstore_get_avltree(cw_itemstore_t s, uint32_t id) static inline struct avltree *cw_itemstore_get_avltree(cw_itemstore_t s, uint32_t id)
{ {
struct cw_item *i = cw_itemstore_get(s, id); struct cw_item *i = cw_itemstore_get(s, id);
@ -139,5 +141,34 @@ int cw_itemstore_set(cw_itemstore_t itemstore, uint32_t item_id, int item_type,
struct cw_item *cw_item_create(cw_itemstore_t s, uint32_t id); struct cw_item *cw_item_create(cw_itemstore_t s, uint32_t id);
static inline void * cw_istore_get_data(cw_itemstore_t s,int id,void *def)
{
struct cw_item *i = cw_itemstore_get(s, id);
if (!i)
return def;
return i->data;
}
static inline uint8_t cw_istore_get_byte(cw_itemstore_t s, uint32_t id, uint8_t def)
{
struct cw_item *i = cw_itemstore_get(s, id);
if (!i)
return def;
return i->byte;
}
static inline uint16_t cw_istore_get_word(cw_itemstore_t s, uint32_t id, uint8_t def)
{
struct cw_item *i = cw_itemstore_get(s, id);
if (!i)
return def;
return i->word;
}
#define cw_istore_get_bstr(s,id,def) cw_istore_get_data(s,id,def)
#endif #endif

View File

@ -226,6 +226,13 @@ static inline int lw_put_bstr(uint8_t * dst, const bstr_t b){
return bstr_len(b); return bstr_len(b);
} }
static inline int lw_put_bstr16(uint8_t * dst, const bstr16_t b){
lw_put_data(dst,bstr16_data(b),bstr16_len(b));
return bstr16_len(b);
}
static inline int lw_put_str(uint8_t*dst,const uint8_t *str) { static inline int lw_put_str(uint8_t*dst,const uint8_t *str) {
return lw_put_data(dst,str,strlen((char*)str)); return lw_put_data(dst,str,strlen((char*)str));
} }

View File

@ -21,8 +21,15 @@
* @brief Yet another avl tree implementation! * @brief Yet another avl tree implementation!
*/ */
#ifndef __AVLTREE_H
#define __AVLTREE_H /**
* @defgroup MavlFunctions MAVL Functions
* @{
*/
#ifndef __MAVL_H
#define __MAVL_H
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -34,7 +41,7 @@
The number of nodes is calculated by 2^depth. The number of nodes is calculated by 2^depth.
So a value of 32 should be enough for around 4 So a value of 32 should be enough for around 4
billion nodes. */ billion nodes. */
#define AVLTREE_MAX_DEPTH 32 #define MAVL_MAX_DEPTH 32
/** /**
* Defines the structure of an AVL Node. * Defines the structure of an AVL Node.
@ -50,12 +57,19 @@ struct mavlnode {
* AVL Tree * AVL Tree
*/ */
struct mavl { struct mavl {
/** Pointer to root node */
struct mavlnode *root; struct mavlnode *root;
/** Compare function */
int (*cmp) (const void *, const void *); int (*cmp) (const void *, const void *);
/** Delete element function */
void (*del) (void *); void (*del) (void *);
/** Number of elements currently stored in the tree */
int count; int count;
}; };
/**
* MAVL AVL Tree type
*/
typedef struct mavl * mavl_t; typedef struct mavl * mavl_t;
@ -64,6 +78,7 @@ typedef struct mavl * mavl_t;
struct mavl *mavl_create(int (*cmp) (const void *, const void *), struct mavl *mavl_create(int (*cmp) (const void *, const void *),
void (*del) (void *)); void (*del) (void *));
//void mavl_destroy(struct mavl *t); //void mavl_destroy(struct mavl *t);
void mavlnode_destroy(struct mavl *t, struct mavlnode *n);
void mavl_del_all(struct mavl *t); void mavl_del_all(struct mavl *t);
void *mavl_del(struct mavl *t, void *data); void *mavl_del(struct mavl *t, void *data);
@ -120,7 +135,7 @@ static inline void mavl_destroy(struct mavl *t)
struct mavliter{ struct mavliter{
struct mavlnode *stack[AVLTREE_MAX_DEPTH*2]; struct mavlnode *stack[MAVL_MAX_DEPTH*2];
struct mavlnode *cur; struct mavlnode *cur;
int stack_ptr; int stack_ptr;
@ -171,11 +186,17 @@ static inline void * mavliter_get(mavliter_t *i){
extern void * mavliter_seek(mavliter_t *i,void *d); extern void * mavliter_seek(mavliter_t *i,void *d);
/**
#define DEFINE_MAVLITER(i,t)\ * Define a AVL Iterator Varialble and acciciate it with
* an AVL Tree.
* @param i Name of Variable to define
* @param t #mavl_t Tree to associate.
*/
#define MAVLITER_DEFINE(i,t)\
mavliter_t i; mavliter_init(&i,t) mavliter_t i; mavliter_init(&i,t)
#define mavliter_foreach(i)\ #define mavliter_foreach(i)\
for (mavliter_seek_set(i); NULL != mavliter_get(i); mavliter_next(i)) for (mavliter_seek_set(i); NULL != mavliter_get(i); mavliter_next(i))
@ -186,6 +207,7 @@ extern void * mavliter_seek(mavliter_t *i,void *d);
while(NULL != (val = mavliter_next(iter))) while(NULL != (val = mavliter_next(iter)))
/** @} */
#endif #endif

View File

@ -1,6 +1,6 @@
#include "mavl.h" #include "mavl.h"
static void mavlnode_destroy(struct mavl *t, struct mavlnode *n) void mavlnode_destroy(struct mavl *t, struct mavlnode *n)
{ {
if (t->del) { if (t->del) {
t->del(n->data); t->del(n->data);

View File

@ -31,7 +31,7 @@
*/ */
void * mavl_get(struct mavl *t ,void *data) void * mavl_get(struct mavl *t ,void *data)
{ {
struct avlnode *n = t->root; struct mavlnode *n = t->root;
while(n){ while(n){
int rc=t->cmp(data,n->data); int rc=t->cmp(data,n->data);
if (rc==0) if (rc==0)

View File

@ -28,6 +28,12 @@
* @{ * @{
*/ */
/**
* CAPWAP timer type, used in #cw_timer_start and #cw_timer_timeout.
*/
typedef time_t cw_timer_t;
/** /**
* Start a timer. * Start a timer.
* @param t number of seconds until the timer expires * @param t number of seconds until the timer expires
@ -55,7 +61,7 @@
* *
* @param c name of the variable * @param c name of the variable
*/ */
#define DEFINE_CLOCK(c)\ #define CLOCK_DEFINE(c)\
struct timeval c; struct timeval c;
/** /**

View File

@ -95,6 +95,7 @@ OBJS += join.o
OBJS += run.o OBJS += run.o
OBJS += sulking.o OBJS += sulking.o
OBJS += configure.o OBJS += configure.o
OBJS += changestate.o
OBJS += $(CONFOBJS) OBJS += $(CONFOBJS)

View File

@ -9,6 +9,7 @@
#include "jsmn.h" #include "jsmn.h"
#include "wtp.h" #include "wtp.h"
#include "capwap/bstr.h" #include "capwap/bstr.h"
#include "capwap/radio.h"
struct cw_itemdef { struct cw_itemdef {
int item_id; int item_id;
@ -95,6 +96,41 @@ printf("GET BYTE\n");
} }
int vendorstr_local(struct cw_itemdef *idef,char *js, jsmntok_t *t)
{
int item_id = idef->item_id;
struct conn * conn = get_conn();
*(js+t->end)=0;
char *str = js+t->start;
if (t->type != JSMN_ARRAY || t->type!=2){
printf("Error: No ARRAY or to short: %s\n",str);
exit(1);
}
// *(js+t->end)=0;
char * val = js+(t+1)->start;
*(js+(t+1)->end)=0;
printf("Val: %s\n",val);
uint32_t vendor_id = atoi(val);
str = (uint8_t*)js+(t+2)->start;
*((t+2)->end+js)=0;
bstr16_t v = bstr16cfgstr(str);
printf("Vendor: %d %s\n",vendor_id,str);
cw_itemstore_set_vendorstr(conn->local,item_id,vendor_id,bstr16_data(v),bstr16_len(v));
free(v);
return 0;
}
@ -116,6 +152,31 @@ int bstr16_local(struct cw_itemdef *idef,char *js, jsmntok_t *t)
return 0; return 0;
} }
int bstr_local(struct cw_itemdef *idef,char *js, jsmntok_t *t)
{
int item_id = idef->item_id;
struct conn * conn = get_conn();
*(js+t->end)=0;
char *str = js+t->start;
if (t->type != JSMN_STRING){
printf("Error: No Str: %s\n",str);
return 1;
}
// *(js+t->end)=0;
printf("Set str: %d %s\n", item_id,str);
bstr16_t v = bstr16cfgstr(str);
cw_itemstore_set_bstrn(conn->local,item_id,bstr16_data(v),bstr16_len(v)); //(uint8_t*)js+t->start,t->end-t->start);
free (v);
return 0;
}
int wtp_board_data_local(struct cw_itemdef *idef,char *js, jsmntok_t *t); int wtp_board_data_local(struct cw_itemdef *idef,char *js, jsmntok_t *t);
@ -123,13 +184,17 @@ int wtp_board_data_local(struct cw_itemdef *idef,char *js, jsmntok_t *t);
struct cw_itemdef general_cfg[] = { struct cw_itemdef general_cfg[] = {
{CW_ITEM_WTP_HARDWARE_VERSION, "hardware_version",bstr16_local}, {CW_ITEM_AC_NAME, "ac_name",bstr16_local},
{CW_ITEM_WTP_SOFTWARE_VERSION, "software_version",bstr16_local}, {CW_ITEM_WTP_NAME, "wtp_name",bstr16_local},
{CW_ITEM_WTP_HARDWARE_VERSION, "hardware_version",vendorstr_local},
{CW_ITEM_WTP_SOFTWARE_VERSION, "software_version",vendorstr_local},
{CW_ITEM_WTP_BOARD_MODELNO, "modelno",bstr16_local}, {CW_ITEM_WTP_BOARD_MODELNO, "modelno",bstr16_local},
{CW_ITEM_WTP_BOARD_DATA,"wtp_board_data",wtp_board_data_local}, {CW_ITEM_WTP_BOARD_DATA,"wtp_board_data",wtp_board_data_local},
{CW_ITEM_WTP_FRAME_TUNNEL_MODE,"frame_tunnel_mode",byte_local}, {CW_ITEM_WTP_FRAME_TUNNEL_MODE,"frame_tunnel_mode",byte_local},
{CW_ITEM_WTP_MAC_TYPE,"mac_type",byte_local}, {CW_ITEM_WTP_MAC_TYPE,"mac_type",byte_local},
{CW_ITEM_LOCATION_DATA,"location_data",bstr16_local}, {CW_ITEM_LOCATION_DATA,"location_data",bstr16_local},
{CW_ITEM_WTP_GROUP_NAME,"group_name",bstr16_local},
{CW_RADIO_BSSID,"bssid",bstr_local},
{0, 0, 0} {0, 0, 0}
}; };
@ -289,8 +354,9 @@ int setup_conf(struct conn *conn)
void dbg_istore_dmp(cw_itemstore_t s);
dbg_istore_dmp(conn->local);

View File

@ -2,22 +2,27 @@
"dbg":[o1,o2,o3], "dbg":[o1,o2,o3],
"Tube" : "tabbe",
"hardware_version": "12345", "hardware_version": ["4232704",".x01000000"],
"software_version": "98765", "software_version": ["4232704",".x08006E00"],
"comment": "** The following is debug info **", "comment": "** The following is debug info **",
"location_data": "Berlin", "location_data": "China",
"frame_tunnel_mode": "4", "frame_tunnel_mode": "4",
"mac_type": 2, "mac_type": 2,
"group_name" : "XGroup",
"wtp_name" : "TubeWTP",
"ac_name" : "LAC_AC",
"bssid": ".x003a9902fac0",
"wtp_board_data" : { "wtp_board_data" : {
"vendor_id": 4232704, "vendor_id": "4232704",
"model_no": "Moodle", "model_no": "AIR-LAP1131AG-E-K9",
"serial_no": "2045", "serial_no": "2045"
}, },
@ -36,6 +41,12 @@
} }
} }
"radios": {
"1": {
"domain"
}
}
} }

View File

@ -1,4 +1,3 @@
#include <stdlib.h> //Tube
#include "capwap/capwap.h" #include "capwap/capwap.h"
#include "capwap/conn.h" #include "capwap/conn.h"

View File

@ -64,7 +64,7 @@ cw_aciplist_t cw_select_ac(struct conn *conn, cw_itemstore_t dis)
avliter_foreach(&i){ avliter_foreach(&i){
cw_itemstore_t ac = ((cw_item_t *) (avliter_get(&i)))->data; cw_itemstore_t ac = ((cw_item_t *) (avliter_get(&i)))->data;
char *ac_name = cw_itemstore_get_str(ac, CW_ITEM_AC_NAME); char *ac_name = cw_itemstore_get_str(ac, CW_ITEM_AC_NAME,NULL);
int prio = 256; int prio = 256;
if (ac_name) { if (ac_name) {

View File

@ -14,6 +14,80 @@
#include "wtp_conf.h" #include "wtp_conf.h"
#include "capwap/timer.h"
#include "capwap/capwap.h"
#include "capwap/conn.h"
#include "wtp_interface.h"
int run()
{
struct conn *conn = get_conn();
conn->capwap_state = CW_STATE_RUN;
do {
time_t timer = cw_timer_start(25);
int rc;
while (!cw_timer_timeout(timer) && conn->capwap_state == CW_STATE_RUN) {
rc = cw_read_messages(conn);
if (rc < 0 && errno == EAGAIN) {
continue;
}
if ( !cw_rcok(rc))
break;
}
if (rc<0 && errno == EAGAIN){
rc = cw_send_request(conn,CW_MSG_ECHO_REQUEST);
if (!cw_rcok(rc)) {
cw_log(LOG_ERR,"Error in run state: %d %s",rc,cw_strrc(rc));
break;
}
continue;
}
if (!cw_rcok(rc)) {
cw_log(LOG_ERR,"Error in run state: %d %s",rc,cw_strrc(rc));
break;
}
} while (conn->capwap_state == CW_STATE_RUN);
// int rc = cw_send_request(conn,CW_MSG_CHANGE_STATE_EVENT_REQUEST);
// if ( !cw_rcok(rc) ) {
// cw_strresult(rc);
// }
}
/* /*
static int echo_interval_timer; static int echo_interval_timer;

View File

@ -10,6 +10,8 @@
#include "capwap/log.h" #include "capwap/log.h"
#include "capwap/dtls.h" #include "capwap/dtls.h"
#include "capwap/acpriolist.h" #include "capwap/acpriolist.h"
#include "capwap/capwap_80211.h"
#include "capwap/radio.h"
#include "wtp.h" #include "wtp.h"
#include "wtp_conf.h" #include "wtp_conf.h"
@ -63,8 +65,26 @@ int main()
the_conn = conn_create_noq(-1, NULL); the_conn = conn_create_noq(-1, NULL);
struct conn *conn = the_conn; struct conn *conn = the_conn;
conn->radios = mbag_create();
mbag_set_mbag(conn->radios,0,mbag_create());
mbag_set_mbag(conn->radios,1,mbag_create());
// mbag_set_mbag(conn->radios,0xff,mbag_create());
mbag_t r;
r = mbag_get_mbag(conn->radios,0,NULL);
mbag_set_dword(r,CW_RADIO_TYPE,1);
r = mbag_get_mbag(conn->radios,1,NULL);
mbag_set_dword(r,CW_RADIO_TYPE,2);
// r = mbag_get_mbag(conn->radios,1,NULL);
// mbag_set_dword(r,CW_RADIO_TYPE,1);
cw_register_actions_cipwap_wtp(&capwap_actions); cw_register_actions_cipwap_wtp(&capwap_actions);
cw_register_actions_capwap_80211_wtp(&capwap_actions);
////cw_register_actions_capwap_80211_wtp(&capwap_actions); ////cw_register_actions_capwap_80211_wtp(&capwap_actions);
conn->actions = &capwap_actions; conn->actions = &capwap_actions;
@ -101,7 +121,7 @@ int main()
cw_itemstore_set_avltree(conn->local,CW_ITEM_AC_PRIO_LIST,acprios); cw_itemstore_set_avltree(conn->local,CW_ITEM_AC_PRIO_LIST,acprios);
cw_itemstore_set_str(conn->local,CW_ITEM_LOCATION_DATA,"Berlin"); cw_itemstore_set_str(conn->local,CW_ITEM_LOCATION_DATA,"Berlin");
cw_itemstore_set_str(conn->local,CW_ITEM_WTP_NAME,"WTP Tube"); // cw_itemstore_set_str(conn->local,CW_ITEM_WTP_NAME,"WTP Tube");
cw_itemstore_set_byte(conn->local,CW_ITEM_WTP_MAC_TYPE,0); cw_itemstore_set_byte(conn->local,CW_ITEM_WTP_MAC_TYPE,0);
cw_itemstore_set_byte(conn->local,CW_ITEM_WTP_FRAME_TUNNEL_MODE,0); cw_itemstore_set_byte(conn->local,CW_ITEM_WTP_FRAME_TUNNEL_MODE,0);
@ -111,6 +131,9 @@ int main()
discovery(); discovery();
join(); join();
configure(); configure();
changestate();
run();
//image_update(); //image_update();