Heavy changes ... mbag uses const char * as key
WTP is still not 100% working... FossilOrigin-Name: 9e80cb8f1b62f854b54393e3af75b789125870b1397ccccad6d3442e3395181c
This commit is contained in:
parent
cd484f61e9
commit
3ba95015a4
11
src/ac/db.c
11
src/ac/db.c
@ -150,8 +150,8 @@ errX:
|
||||
int db_get_tasks(const char * wtpid)
|
||||
{
|
||||
|
||||
sqlite3_reset(put_wtp_prop_stmt);
|
||||
sqlite3_clear_bindings(put_wtp_prop_stmt);
|
||||
sqlite3_reset(get_tasks_stmt);
|
||||
sqlite3_clear_bindings(get_tasks_stmt);
|
||||
|
||||
if(sqlite3_bind_text(get_tasks_stmt,1,wtpid,-1,SQLITE_STATIC))
|
||||
goto errX;
|
||||
@ -160,19 +160,20 @@ int db_get_tasks(const char * wtpid)
|
||||
|
||||
rc = sqlite3_step(get_tasks_stmt);
|
||||
if (rc == SQLITE_ROW) {
|
||||
DBGX("Have a rowi %s",sqlite3_column_text(get_tasks_stmt,0));
|
||||
/* DBGX("Have a rowi %s",sqlite3_column_text(get_tasks_stmt,0));
|
||||
DBGX("Have a rowi %s",sqlite3_column_text(get_tasks_stmt,1));
|
||||
DBGX("Have a rowi %s",sqlite3_column_text(get_tasks_stmt,2));
|
||||
DBGX("Have a rowi %s",sqlite3_column_text(get_tasks_stmt,3));
|
||||
DBGX("Have a rowi %s",sqlite3_column_text(get_tasks_stmt,4));
|
||||
*/
|
||||
}
|
||||
|
||||
DBGX("The SQL RC: %d\n",rc);
|
||||
// DBGX("The SQL RC: %d\n",rc);
|
||||
return 1;
|
||||
|
||||
errX:
|
||||
if (rc) {
|
||||
cw_log(LOG_ERR,"Can't update database with WTP props: %d - %s",
|
||||
cw_log(LOG_ERR,"Can't get tasks: %d - %s",
|
||||
rc,sqlite3_errmsg(handle));
|
||||
}
|
||||
|
||||
|
@ -338,16 +338,16 @@ void config_to_sql(struct conn *conn)
|
||||
mavliter_foreach(&it){
|
||||
mbag_item_t * i = mavliter_get(&it);
|
||||
|
||||
struct cw_item * cwi = cw_item_get_by_id(i->id,capwap_itemdefs);
|
||||
struct cw_item * cwi = cw_item_get_by_name(i->id,capwap_itemdefs);
|
||||
if (cwi){
|
||||
// DBGX("ID %d,%s",i->id,cwi->cfgname);
|
||||
DBGX("ID %d,%s",i->id,cwi->id);
|
||||
|
||||
// printf("%s != %s ?\n",i->type->name,cwi->type->name);
|
||||
char str[256];
|
||||
if (i->type->to_str)
|
||||
i->type->to_str(i,str);
|
||||
|
||||
db_put_wtp_prop(wtp_id,-1,cwi->cfgname,str);
|
||||
db_put_wtp_prop(wtp_id,-1,cwi->id,str);
|
||||
|
||||
}
|
||||
else{
|
||||
@ -428,8 +428,10 @@ static void wtpman_run(void *arg)
|
||||
conn->capwap_state=CW_STATE_RUN;
|
||||
|
||||
// XXX testing ...
|
||||
DBGX("Cofig to sql","");
|
||||
config_to_sql(conn);
|
||||
|
||||
|
||||
|
||||
rc = 0;
|
||||
while (wtpman->conn->capwap_state == CW_STATE_RUN) {
|
||||
@ -477,10 +479,10 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr)
|
||||
|
||||
wtpman->conn->strict_capwap = conf_strict_capwap;
|
||||
wtpman->conn->strict_hdr = conf_strict_headers;
|
||||
wtpman->conn->radios=mbag_create();
|
||||
wtpman->conn->radios=mbag_i_create();
|
||||
wtpman->conn->local = ac_config;
|
||||
//wtpman->conn->capwap_mode=0; //CW_MODE_STD; //CISCO;
|
||||
//wtpman->conn->capwap_mode=CW_MODE_CISCO;
|
||||
wtpman->conn->capwap_mode=CW_MODE_CISCO;
|
||||
//wtpman->conn->strict_capwap_hdr=0;
|
||||
|
||||
return wtpman;
|
||||
|
@ -231,7 +231,6 @@ CWACTION=action.o \
|
||||
capwap_action_helpers.o \
|
||||
cw_put_image_data.o \
|
||||
cisco.o \
|
||||
item_strings.o \
|
||||
mbag.o\
|
||||
radio.o \
|
||||
cw_out_radio_info.o \
|
||||
@ -239,6 +238,7 @@ CWACTION=action.o \
|
||||
item.o
|
||||
|
||||
# cw_process_msg.o \
|
||||
# item_strings.o \
|
||||
|
||||
|
||||
|
||||
|
@ -46,7 +46,7 @@ struct cw_action_in{
|
||||
int (*start)(struct conn *conn,struct cw_action_in *a,uint8_t*data,int len,struct sockaddr *from);
|
||||
int (*end)(struct conn *conn,struct cw_action_in *a,uint8_t*elem,int len,struct sockaddr *from);
|
||||
const struct mbag_typedef * itemtype;
|
||||
uint16_t item_id;
|
||||
const char * item_id;
|
||||
uint16_t min_len;
|
||||
uint16_t max_len;
|
||||
uint8_t mand;
|
||||
@ -82,7 +82,7 @@ cw_action_fun_t cw_set_msg_end_callback(struct conn *conn,
|
||||
/* Definitions for outgoing messages */
|
||||
struct cw_action_out{
|
||||
uint32_t msg_id;
|
||||
uint32_t item_id;
|
||||
const char * item_id;
|
||||
uint32_t vendor_id;
|
||||
uint16_t elem_id;
|
||||
int (*init)(struct conn * conn, struct cw_action_out *a, uint8_t * dst);
|
||||
|
@ -35,12 +35,12 @@ cw_action_in_t capwap_80211_actions_ac_in[] = {
|
||||
|
||||
cw_action_out_t capwap_80211_actions_ac_out[]={
|
||||
/* Radio Infos */
|
||||
{CW_MSG_DISCOVERY_RESPONSE, CW_ELEM80211_WTP_RADIO_INFORMATION, 0,
|
||||
{CW_MSG_DISCOVERY_RESPONSE, NULL /*CW_ELEM80211_WTP_RADIO_INFORMATION*/, 0,
|
||||
CW_ELEM80211_WTP_RADIO_INFORMATION, NULL,cw_out_radio_infos, NULL,1}
|
||||
,
|
||||
|
||||
/* Radio Infos */
|
||||
{CW_MSG_JOIN_RESPONSE, CW_ELEM80211_WTP_RADIO_INFORMATION, 0,
|
||||
{CW_MSG_JOIN_RESPONSE, NULL /*CW_ELEM80211_WTP_RADIO_INFORMATION*/, 0,
|
||||
CW_ELEM80211_WTP_RADIO_INFORMATION, NULL,cw_out_radio_infos, NULL,1}
|
||||
,
|
||||
|
||||
|
@ -34,7 +34,7 @@ cw_action_out_t capwap_80211_actions_wtp_out[]={
|
||||
*/
|
||||
|
||||
/* 802.11 Radio Information */
|
||||
{CW_MSG_DISCOVERY_REQUEST, CW_ELEM80211_WTP_RADIO_INFORMATION, 0,
|
||||
{CW_MSG_DISCOVERY_REQUEST, NULL /*CW_ELEM80211_WTP_RADIO_INFORMATION*/, 0,
|
||||
CW_ELEM80211_WTP_RADIO_INFORMATION, NULL,cw_out_radio_infos, NULL,1}
|
||||
,
|
||||
|
||||
@ -43,7 +43,7 @@ cw_action_out_t capwap_80211_actions_wtp_out[]={
|
||||
*/
|
||||
|
||||
/* 802.11 Radio Information */
|
||||
{CW_MSG_JOIN_REQUEST, CW_ELEM80211_WTP_RADIO_INFORMATION, 0,
|
||||
{CW_MSG_JOIN_REQUEST, NULL /*CW_ELEM80211_WTP_RADIO_INFORMATION*/, 0,
|
||||
CW_ELEM80211_WTP_RADIO_INFORMATION, NULL,cw_out_radio_infos, NULL,1}
|
||||
|
||||
|
||||
|
@ -2,10 +2,101 @@
|
||||
|
||||
#include "capwap_items.h"
|
||||
|
||||
|
||||
const char CW_ITEM_NONE[]="";
|
||||
const char CW_ITEM_IDLE_TIMEOUT[]="idle_timeout";
|
||||
const char CW_ITEM_DISCOVERY_TYPE[]="discovery_type";
|
||||
const char CW_ITEM_WTP_NAME[]="wtp_name";
|
||||
|
||||
const char CW_ITEM_WTP_BOARD_VENDOR[]="vendor_id";
|
||||
const char CW_ITEM_WTP_BOARD_MODELNO[]="model_no";
|
||||
const char CW_ITEM_WTP_BOARD_MACADDRESS[]="wtp_board_macadddress";
|
||||
const char CW_ITEM_WTP_BOARD_ID[]="wtp_board_id";
|
||||
const char CW_ITEM_WTP_BOARD_REVISION[]="wtp_board_revision";
|
||||
const char CW_ITEM_WTP_BOARD_SERIALNO[]="serial_no";
|
||||
|
||||
|
||||
|
||||
const char CW_ITEM_WTP_MAC_TYPE[]="wtp_mac_type";
|
||||
const char CW_ITEM_WTP_FRAME_TUNNEL_MODE[]="wtp_frame_tunnel_mode";
|
||||
const char CW_ITEM_WTP_RADIOS_IN_USE[]="max_radios";
|
||||
const char CW_ITEM_WTP_MAX_RADIOS[]="radios_in_use";
|
||||
|
||||
/*
|
||||
const char CW_ITEM_WTP_HARDWARE_VENDOR=
|
||||
*/
|
||||
|
||||
const char CW_ITEM_WTP_HARDWARE_VERSION[]="wtp_hardware_version";
|
||||
|
||||
/*
|
||||
const char CW_ITEM_WTP_SOFTWARE_VENDOR,
|
||||
*/
|
||||
const char CW_ITEM_WTP_SOFTWARE_VERSION[]="wtp_software_version";
|
||||
|
||||
/*
|
||||
const char CW_ITEM_WTP_BOOTLOADER_VENDOR,
|
||||
*/
|
||||
const char CW_ITEM_WTP_BOOTLOADER_VERSION[]="wtp_bootloader_version";
|
||||
/*
|
||||
const char CW_ITEM_WTP_OTHERSOFTWARE_VENDOR,
|
||||
const char CW_ITEM_WTP_OTHERSOFTWARE_VERSION,
|
||||
*/
|
||||
const char CW_ITEM_WTP_BOARD_DATA[]="wtp_board_data";
|
||||
const char CW_ITEM_WTP_DESCRIPTOR[]="wtp_descriptor";
|
||||
const char CW_ITEM_CAPWAP_TIMERS[]="capwap_timers";
|
||||
const char CW_ITEM_RADIO_ADMINISTRATIVE_STATE[]="radio_admin_state";
|
||||
|
||||
const char CW_ITEM_AC_NAME[]="ac_name";
|
||||
const char CW_ITEM_AC_DESCRIPTOR[]="ac_descriptor";
|
||||
const char CW_ITEM_RESULT_CODE[]="result_code";
|
||||
const char CW_ITEM_AC_STATUS[]="ac_status";
|
||||
|
||||
const char CW_ITEM_AC_HARDWARE_VERSION[]="ac_hardware_version";
|
||||
const char CW_ITEM_AC_SOFTWARE_VERSION[]="ac_software_version";
|
||||
|
||||
const char CW_ITEM_AC_IP_LIST[]="ac_ip_list";
|
||||
const char CW_ITEM_CAPWAP_CONTROL_IP_ADDRESS_LIST[]="capwap_ctrl_ip_addr";
|
||||
const char CW_ITEM_CAPWAP_LOCAL_IP_ADDRESS[]="capwap_local_ip_addr";
|
||||
|
||||
const char CW_ITEM_LOCATION_DATA[]="location_data";
|
||||
const char CW_ITEM_SESSION_ID[]="session_id";
|
||||
|
||||
const char CW_ITEM_AC_TIMESTAMP[]="ac_timestamp";
|
||||
const char CW_ITEM_STATISTICS_TIMER[]="statistics_timer";
|
||||
const char CW_ITEM_WTP_REBOOT_STATISTICS[]="wtp_reboot_statistics";
|
||||
const char CW_ITEM_IMAGE_IDENTIFIER[]="image_identifier";
|
||||
const char CW_ITEM_AC_HASH_VALUE[]="ac_hash_value";
|
||||
|
||||
const char CW_ITEM_AC_NAME_WITH_PRIORITY[]="ac_name_with_priority";
|
||||
const char CW_ITEM_MAXIMUM_MESSAGE_LENGTH[]="maximum_message_length";
|
||||
|
||||
|
||||
/* CIPWAP and Cisco */
|
||||
const char CW_ITEM_WTP_GROUP_NAME[]="wtp_group_name";
|
||||
|
||||
|
||||
/* Other Items */
|
||||
const char CW_ITEM_AC_IMAGE_DIR[]="ac_img_dir"; /* Path where WTP images are stored */
|
||||
const char CW_ITEM_IMAGE_FILENAME[]="img_filename"; /* Full path of image filename */
|
||||
const char CW_ITEM_DISCOVERIES[]="discoveries";
|
||||
|
||||
/** FILE handle for uploading and downloading images */
|
||||
const char CW_ITEM_IMAGE_FILEHANDLE[]="image_file_handle";
|
||||
|
||||
const char CW_ITEM_RADIO_CFG[]="radio_cfg";
|
||||
const char CW_ITEM_AP_MODE_AND_TYPE[]="cisco_ap_mode_and_type";
|
||||
|
||||
const char CW_ITEM_CISCO_BOARD_DATA_OPTIONS[]="cisco_board_data_options";
|
||||
const char CW_ITEM_RADIOS[]="radios";
|
||||
const char CW_ITEM_RADIO_OPER_STATE[]="radio_oper_state";
|
||||
|
||||
|
||||
|
||||
|
||||
struct cw_item capwap_itemdefs[] = {
|
||||
|
||||
{CW_ITEM_WTP_NAME,"wtp_name",MBAG_BSTR16},
|
||||
{CW_ITEM_LOCATION_DATA,"location_data",MBAG_BSTR16},
|
||||
{CW_ITEM_WTP_NAME,MBAG_BSTR16},
|
||||
{CW_ITEM_LOCATION_DATA,MBAG_BSTR16},
|
||||
|
||||
|
||||
{CW_ITEM_NONE}
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "item.h"
|
||||
|
||||
enum capwap_items {
|
||||
/*
|
||||
CW_ITEM_NONE=0,
|
||||
CW_ITEM_IDLE_TIMEOUT,
|
||||
CW_ITEM_DISCOVERY_TYPE,
|
||||
@ -56,16 +56,13 @@ enum capwap_items {
|
||||
CW_ITEM_MAXIMUM_MESSAGE_LENGTH,
|
||||
|
||||
|
||||
/* CIPWAP and Cisco */
|
||||
CW_ITEM_WTP_GROUP_NAME,
|
||||
|
||||
|
||||
/* Other Items */
|
||||
CW_ITEM_AC_IMAGE_DIR, /* Path where WTP images are stored */
|
||||
CW_ITEM_IMAGE_FILENAME, /* Full path of image filename */
|
||||
CW_ITEM_AC_IMAGE_DIR,
|
||||
CW_ITEM_IMAGE_FILENAME,
|
||||
CW_ITEM_DISCOVERIES,
|
||||
|
||||
/** FILE handle for uploading and downloading images */
|
||||
CW_ITEM_IMAGE_FILEHANDLE,
|
||||
|
||||
CW_ITEM_RADIO_CFG,
|
||||
@ -76,7 +73,108 @@ enum capwap_items {
|
||||
CW_ITEM_RADIO_OPER_STATE,
|
||||
|
||||
|
||||
};
|
||||
*/
|
||||
|
||||
extern const char CW_ITEM_NONE[];
|
||||
extern const char CW_ITEM_IDLE_TIMEOUT[];
|
||||
extern const char CW_ITEM_DISCOVERY_TYPE[];
|
||||
extern const char CW_ITEM_WTP_NAME[];
|
||||
|
||||
/*
|
||||
extern const char CW_ITEM_WTP_BOARD_VENDOR,
|
||||
extern const char CW_ITEM_WTP_BOARD_MODELNO,
|
||||
extern const char CW_ITEM_WTP_BOARD_MACADDRESS,
|
||||
extern const char CW_ITEM_WTP_BOARD_ID,
|
||||
extern const char CW_ITEM_WTP_BOARD_REVISION,
|
||||
extern const char CW_ITEM_WTP_BOARD_SERIALNO,
|
||||
*/
|
||||
extern const char CW_ITEM_WTP_MAC_TYPE[];
|
||||
extern const char CW_ITEM_WTP_FRAME_TUNNEL_MODE[];
|
||||
/*
|
||||
extern const char CW_ITEM_WTP_RADIOS_IN_USE=
|
||||
extern const char CW_ITEM_WTP_MAX_RADIOS,
|
||||
*/
|
||||
/*
|
||||
extern const char CW_ITEM_WTP_HARDWARE_VENDOR=
|
||||
extern const char CW_ITEM_WTP_HARDWARE_VERSION="
|
||||
*/
|
||||
/*
|
||||
extern const char CW_ITEM_WTP_SOFTWARE_VENDOR,
|
||||
extern const char CW_ITEM_WTP_SOFTWARE_VERSION,
|
||||
extern const char CW_ITEM_WTP_BOOTLOADER_VENDOR,
|
||||
extern const char CW_ITEM_WTP_BOOTLOADER_VERSION,
|
||||
extern const char CW_ITEM_WTP_OTHERSOFTWARE_VENDOR,
|
||||
extern const char CW_ITEM_WTP_OTHERSOFTWARE_VERSION,
|
||||
*/
|
||||
extern const char CW_ITEM_WTP_BOARD_DATA[];
|
||||
extern const char CW_ITEM_WTP_DESCRIPTOR[];
|
||||
extern const char CW_ITEM_CAPWAP_TIMERS[];
|
||||
extern const char CW_ITEM_RADIO_ADMINISTRATIVE_STATE[];
|
||||
|
||||
extern const char CW_ITEM_AC_NAME[];
|
||||
extern const char CW_ITEM_AC_DESCRIPTOR[];
|
||||
extern const char CW_ITEM_RESULT_CODE[];
|
||||
extern const char CW_ITEM_AC_STATUS[];
|
||||
|
||||
extern const char CW_ITEM_AC_HARDWARE_VERSION[];
|
||||
extern const char CW_ITEM_AC_SOFTWARE_VERSION[];
|
||||
|
||||
extern const char CW_ITEM_AC_IP_LIST[];
|
||||
extern const char CW_ITEM_CAPWAP_CONTROL_IP_ADDRESS_LIST[];
|
||||
extern const char CW_ITEM_CAPWAP_LOCAL_IP_ADDRESS[];
|
||||
|
||||
extern const char CW_ITEM_LOCATION_DATA[];
|
||||
extern const char CW_ITEM_SESSION_ID[];
|
||||
|
||||
extern const char CW_ITEM_AC_TIMESTAMP[];
|
||||
extern const char CW_ITEM_STATISTICS_TIMER[];
|
||||
extern const char CW_ITEM_WTP_REBOOT_STATISTICS[];
|
||||
extern const char CW_ITEM_IMAGE_IDENTIFIER[];
|
||||
extern const char CW_ITEM_AC_HASH_VALUE[];
|
||||
|
||||
extern const char CW_ITEM_AC_NAME_WITH_PRIORITY[];
|
||||
extern const char CW_ITEM_MAXIMUM_MESSAGE_LENGTH[];
|
||||
|
||||
|
||||
/* CIPWAP and Cisco */
|
||||
extern const char CW_ITEM_WTP_GROUP_NAME[];
|
||||
|
||||
|
||||
/* Other Items */
|
||||
extern const char CW_ITEM_AC_IMAGE_DIR[]; /* Path where WTP images are stored */
|
||||
extern const char CW_ITEM_IMAGE_FILENAME[]; /* Full path of image filename */
|
||||
extern const char CW_ITEM_DISCOVERIES[];
|
||||
|
||||
/** FILE handle for uploading and downloading images */
|
||||
extern const char CW_ITEM_IMAGE_FILEHANDLE[];
|
||||
|
||||
extern const char CW_ITEM_RADIO_CFG[];
|
||||
extern const char CW_ITEM_AP_MODE_AND_TYPE[];
|
||||
|
||||
extern const char CW_ITEM_CISCO_BOARD_DATA_OPTIONS[];
|
||||
extern const char CW_ITEM_RADIOS[];
|
||||
extern const char CW_ITEM_RADIO_OPER_STATE[];
|
||||
|
||||
|
||||
extern const char CW_ITEM_WTP_BOARD_VENDOR[];
|
||||
extern const char CW_ITEM_WTP_BOARD_MODELNO[];
|
||||
extern const char CW_ITEM_WTP_BOARD_MACADDRESS[];
|
||||
extern const char CW_ITEM_WTP_BOARD_ID[];
|
||||
extern const char CW_ITEM_WTP_BOARD_REVISION[];
|
||||
extern const char CW_ITEM_WTP_BOARD_SERIALNO[];
|
||||
|
||||
extern const char CW_ITEM_WTP_SOFTWARE_VERSION[];
|
||||
extern const char CW_ITEM_WTP_HARDWARE_VERSION[];
|
||||
|
||||
extern const char CW_ITEM_WTP_BOOTLOADER_VERSION[];
|
||||
|
||||
extern const char CW_ITEM_WTP_RADIOS_IN_USE[];
|
||||
extern const char CW_ITEM_WTP_MAX_RADIOS[];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extern struct cw_item capwap_itemdefs[];
|
||||
|
||||
|
@ -95,8 +95,8 @@ int cw_out_cisco_wtp_radio_cfg(struct conn *conn, struct cw_action_out *a, uint8
|
||||
continue;
|
||||
}
|
||||
// l+=cw_put_elem_radio_info(dst+l,i->id,i->data);
|
||||
l+=cw_put_elem_cisco_radio_cfg(dst+l,i->id,i->data);
|
||||
l+=cw_put_elem_cisco_ap_regulatory_domain(dst+l,i->id,i->data);
|
||||
l+=cw_put_elem_cisco_radio_cfg(dst+l,i->iid,i->data);
|
||||
l+=cw_put_elem_cisco_ap_regulatory_domain(dst+l,i->iid,i->data);
|
||||
|
||||
}
|
||||
return l;
|
||||
@ -123,7 +123,7 @@ int cw_in_cisco_radio_cfg(struct conn *conn, struct cw_action_in *a, uint8_t * d
|
||||
{
|
||||
|
||||
int rid = cw_get_byte(data);
|
||||
mbag_t radio = mbag_get_mbag(conn->radios,rid,NULL);
|
||||
mbag_t radio = mbag_i_get_mbag(conn->radios,rid,NULL);
|
||||
if ( !radio){
|
||||
cw_dbg(DBG_ELEM_ERR,"Radio ID %d not defined",rid);
|
||||
return 0;
|
||||
@ -147,7 +147,7 @@ int cw_radio_cisco_set_state(struct conn * conn, uint8_t *data, int len, int cau
|
||||
MAVLITER_DEFINE(it,conn->radios);
|
||||
mavliter_foreach(&it){
|
||||
mbag_item_t *i = mavliter_get(&it);
|
||||
cw_radio_set_admin_state(conn->radios,i->id,state,cause);
|
||||
cw_radio_set_admin_state(conn->radios,i->iid,state,cause);
|
||||
|
||||
}
|
||||
return 1;
|
||||
|
@ -262,7 +262,7 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,struct
|
||||
if (af->mand && afrc) {
|
||||
/* add found mandatory message element
|
||||
to mand list */
|
||||
intavltree_add(conn->mand, af->item_id);
|
||||
intavltree_add(conn->mand, (int)af->item_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ int cw_check_missing_mand(cw_action_in_t ** out, struct conn * conn, cw_action_i
|
||||
if (!ai->mand)
|
||||
continue;
|
||||
|
||||
int i = ai->item_id;
|
||||
int i = (int)ai->item_id;
|
||||
void * rc = mavl_get(conn->mand,&i);
|
||||
if (!rc) {
|
||||
out[n++]=ai;
|
||||
@ -84,7 +84,6 @@ int cw_check_missing_mand(cw_action_in_t ** out, struct conn * conn, cw_action_i
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
struct args args;
|
||||
|
@ -13,7 +13,7 @@
|
||||
int cw_in_ac_name_with_priority(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
|
||||
struct sockaddr *from)
|
||||
{
|
||||
cw_acpriolist_t prios = mbag_get_mavl(conn->config,CW_ITEM_AC_NAME_WITH_PRIORITY,NULL);
|
||||
cw_acpriolist_t prios = mbag_get_mavl(conn->config,CW_ITEM_AC_NAME_WITH_PRIORITY);
|
||||
if (!prios)
|
||||
return 0;
|
||||
|
||||
|
@ -22,7 +22,7 @@ int cw_in_capwap_control_ipv4_address(struct conn *conn, struct cw_action_in *a,
|
||||
uint8_t * data, int len,struct sockaddr *from)
|
||||
{
|
||||
cw_aciplist_t list =
|
||||
mbag_get_avltree_c(conn->incomming,a->item_id,cw_aciplist_create);
|
||||
mbag_get_mavl_c(conn->incomming,a->item_id,cw_aciplist_create);
|
||||
|
||||
if (!list) {
|
||||
cw_log(LOG_ERR, "Error: Can't allocate CAWAP IP Adress List");
|
||||
|
@ -32,8 +32,8 @@ int cw_in_check_disc_resp(struct conn *conn, struct cw_action_in *a, uint8_t * d
|
||||
/* we have all AC information in the incomming buffer */
|
||||
mbag_t discs;
|
||||
|
||||
discs = mbag_get_avltree_c(conn->remote, CW_ITEM_DISCOVERIES,
|
||||
mbag_create);
|
||||
discs = mbag_get_mavl_c(conn->remote, CW_ITEM_DISCOVERIES,
|
||||
mbag_i_create);
|
||||
|
||||
//mavl_del_all(discs);
|
||||
//exit(0);
|
||||
@ -44,7 +44,8 @@ int cw_in_check_disc_resp(struct conn *conn, struct cw_action_in *a, uint8_t * d
|
||||
return -1;
|
||||
}
|
||||
|
||||
mbag_set_avltree(discs,discs->count,conn->incomming);
|
||||
mbag_i_set_mavl(discs,discs->count,conn->incomming);
|
||||
|
||||
conn->incomming = mbag_create();
|
||||
|
||||
|
||||
|
@ -104,7 +104,7 @@ int cw_in_radio_generic(struct conn *conn, struct cw_action_in *a, uint8_t * dat
|
||||
return 0;
|
||||
|
||||
int rid = cw_get_byte(data);
|
||||
mbag_t radio = mbag_get_mbag(conn->radios, rid, NULL);
|
||||
mbag_t radio = mbag_i_get_mbag(conn->radios, rid, NULL);
|
||||
if (!radio) {
|
||||
if (a->vendor_id != 0
|
||||
|| ( (a->vendor_id == 0) && (a->msg_id != CW_MSG_DISCOVERY_REQUEST
|
||||
@ -112,7 +112,7 @@ int cw_in_radio_generic(struct conn *conn, struct cw_action_in *a, uint8_t * dat
|
||||
cw_dbg(DBG_ELEM_ERR, "Radio not found %d", rid);
|
||||
return 0;
|
||||
}
|
||||
mbag_set_mbag(conn->radios,rid,mbag_create());
|
||||
mbag_i_set_mbag(conn->radios,rid,mbag_create());
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "sock.h"
|
||||
|
||||
|
||||
static int cw_read_wtp_descriptor_versions(mbag_t itemstore, uint8_t * data,
|
||||
static int cw_read_wtp_descriptor_versions(mbag_t mbag, uint8_t * data,
|
||||
int len, int silent)
|
||||
{
|
||||
int i = 0;
|
||||
@ -74,35 +74,49 @@ static int cw_read_wtp_descriptor_versions(mbag_t itemstore, uint8_t * data,
|
||||
|
||||
switch (subtype) {
|
||||
case CW_SUBELEM_WTP_HARDWARE_VERSION:
|
||||
mbag_set_dword(itemstore,
|
||||
/*
|
||||
mbag_set_dword(mbag,
|
||||
CW_ITEM_WTP_HARDWARE_VENDOR,
|
||||
vendor_id);
|
||||
mbag_set_bstrn(itemstore,
|
||||
mbag_set_bstrn(mbag,
|
||||
CW_ITEM_WTP_HARDWARE_VERSION,
|
||||
data + i, sublen);
|
||||
*/
|
||||
|
||||
mbag_set_vendorstr(mbag,
|
||||
CW_ITEM_WTP_HARDWARE_VERSION,
|
||||
vendor_id, data + i, sublen);
|
||||
|
||||
break;
|
||||
case CW_SUBELEM_WTP_SOFTWARE_VERSION:
|
||||
|
||||
mbag_set_vendorstr(itemstore,
|
||||
mbag_set_vendorstr(mbag,
|
||||
CW_ITEM_WTP_SOFTWARE_VERSION,
|
||||
vendor_id, data + i, sublen);
|
||||
/*
|
||||
mbag_set_dword(itemstore,
|
||||
mbag_set_dword(mbag,
|
||||
CW_ITEM_WTP_SOFTWARE_VENDOR,
|
||||
vendor_id);
|
||||
mbag_set_bstrn(itemstore,
|
||||
mbag_set_bstrn(mbag,
|
||||
CW_ITEM_WTP_SOFTWARE_VERSION,
|
||||
data + i, sublen);
|
||||
|
||||
*/
|
||||
break;
|
||||
case CW_SUBELEM_WTP_BOOTLOADER_VERSION:
|
||||
mbag_set_dword(itemstore,
|
||||
|
||||
mbag_set_vendorstr(mbag,
|
||||
CW_ITEM_WTP_BOOTLOADER_VERSION,
|
||||
vendor_id, data + i, sublen);
|
||||
|
||||
/*
|
||||
mbag_set_dword(mbag,
|
||||
CW_ITEM_WTP_BOOTLOADER_VENDOR,
|
||||
vendor_id);
|
||||
mbag_set_bstrn(itemstore,
|
||||
mbag_set_bstrn(mbag,
|
||||
CW_ITEM_WTP_BOOTLOADER_VERSION,
|
||||
data + i, sublen);
|
||||
*/
|
||||
break;
|
||||
default:
|
||||
if (!silent)
|
||||
@ -119,14 +133,14 @@ static int cw_read_wtp_descriptor_versions(mbag_t itemstore, uint8_t * data,
|
||||
|
||||
}
|
||||
|
||||
static int cw_read_wtp_descriptor(mbag_t itemstore, struct conn *conn,
|
||||
static int cw_read_wtp_descriptor(mbag_t mbag, struct conn *conn,
|
||||
struct cw_action_in *a, uint8_t * data, int len,
|
||||
int silent)
|
||||
{
|
||||
|
||||
|
||||
mbag_set_byte(itemstore, CW_ITEM_WTP_MAX_RADIOS, cw_get_byte(data));
|
||||
mbag_set_byte(itemstore, CW_ITEM_WTP_RADIOS_IN_USE,
|
||||
mbag_set_byte(mbag, CW_ITEM_WTP_MAX_RADIOS, cw_get_byte(data));
|
||||
mbag_set_byte(mbag, CW_ITEM_WTP_RADIOS_IN_USE,
|
||||
cw_get_byte(data + 1));
|
||||
|
||||
|
||||
@ -151,7 +165,7 @@ static int cw_read_wtp_descriptor(mbag_t itemstore, struct conn *conn,
|
||||
pos += 3;
|
||||
}
|
||||
|
||||
return cw_read_wtp_descriptor_versions(itemstore, data + pos, len - pos, silent);
|
||||
return cw_read_wtp_descriptor_versions(mbag, data + pos, len - pos, silent);
|
||||
|
||||
}
|
||||
|
||||
@ -161,13 +175,13 @@ static int cw_read_wtp_descriptor(mbag_t itemstore, struct conn *conn,
|
||||
* Read WTP Descriptor in Cisco-Style (Draft 7)
|
||||
*/
|
||||
|
||||
static int cw_read_cisco_wtp_descriptor(mbag_t itemstore, struct conn *conn,
|
||||
static int cw_read_cisco_wtp_descriptor(mbag_t mbag, struct conn *conn,
|
||||
struct cw_action_in *a, uint8_t * data, int len,
|
||||
int silent)
|
||||
{
|
||||
|
||||
mbag_set_byte(itemstore, CW_ITEM_WTP_MAX_RADIOS, cw_get_byte(data));
|
||||
mbag_set_byte(itemstore, CW_ITEM_WTP_RADIOS_IN_USE,
|
||||
mbag_set_byte(mbag, CW_ITEM_WTP_MAX_RADIOS, cw_get_byte(data));
|
||||
mbag_set_byte(mbag, CW_ITEM_WTP_RADIOS_IN_USE,
|
||||
cw_get_byte(data + 1));
|
||||
|
||||
|
||||
@ -177,7 +191,7 @@ static int cw_read_cisco_wtp_descriptor(mbag_t itemstore, struct conn *conn,
|
||||
cw_get_word(data + pos + 2);
|
||||
pos += 2;
|
||||
|
||||
return cw_read_wtp_descriptor_versions(itemstore, data + pos, len - pos, silent);
|
||||
return cw_read_wtp_descriptor_versions(mbag, data + pos, len - pos, silent);
|
||||
|
||||
}
|
||||
|
||||
@ -191,9 +205,9 @@ static int cw_read_cisco_wtp_descriptor(mbag_t itemstore, struct conn *conn,
|
||||
int cw_in_wtp_descriptor(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len, struct sockaddr *from)
|
||||
{
|
||||
mbag_t itemstore = conn->incomming;
|
||||
mbag_t mbag = conn->incomming;
|
||||
|
||||
return cw_read_wtp_descriptor(itemstore, conn, a, data, len, 0);
|
||||
return cw_read_wtp_descriptor(mbag, conn, a, data, len, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -201,38 +215,38 @@ int cw_in_wtp_descriptor(struct conn *conn, struct cw_action_in *a, uint8_t * da
|
||||
int cw_in_cipwap_wtp_descriptor(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len, struct sockaddr *from)
|
||||
{
|
||||
mbag_t itemstore = conn->incomming;
|
||||
mbag_t mbag = conn->incomming;
|
||||
|
||||
switch (conn->capwap_mode) {
|
||||
case CW_MODE_CISCO:
|
||||
return cw_read_cisco_wtp_descriptor(itemstore, conn, a, data, len,
|
||||
return cw_read_cisco_wtp_descriptor(mbag, conn, a, data, len,
|
||||
0);
|
||||
case CW_MODE_CIPWAP:
|
||||
{
|
||||
/* try to get the right WTP Descriptor */
|
||||
int rc;
|
||||
rc = cw_read_wtp_descriptor(itemstore, conn, a, data, len,
|
||||
rc = cw_read_wtp_descriptor(mbag, conn, a, data, len,
|
||||
1);
|
||||
|
||||
if (rc) {
|
||||
return cw_read_wtp_descriptor(itemstore, conn, a,
|
||||
return cw_read_wtp_descriptor(mbag, conn, a,
|
||||
data, len, 0);
|
||||
}
|
||||
|
||||
rc = cw_read_cisco_wtp_descriptor(itemstore, conn, a,
|
||||
rc = cw_read_cisco_wtp_descriptor(mbag, conn, a,
|
||||
data, len, 0);
|
||||
if (rc) {
|
||||
return cw_read_cisco_wtp_descriptor(itemstore,
|
||||
return cw_read_cisco_wtp_descriptor(mbag,
|
||||
conn, a, data,
|
||||
len, 0);
|
||||
}
|
||||
|
||||
return cw_read_wtp_descriptor(itemstore, conn, a, data,
|
||||
return cw_read_wtp_descriptor(mbag, conn, a, data,
|
||||
len, 0);
|
||||
|
||||
}
|
||||
default:
|
||||
return cw_read_wtp_descriptor(itemstore, conn, a, data, len, 0);
|
||||
return cw_read_wtp_descriptor(mbag, conn, a, data, len, 0);
|
||||
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ int cw_put_ac_name_with_priority(uint8_t *dst,cw_acprio_t * acprio)
|
||||
|
||||
int cw_out_ac_name_with_priority(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
|
||||
{
|
||||
cw_acpriolist_t prios = mbag_get_mavl(conn->config,CW_ITEM_AC_NAME_WITH_PRIORITY,NULL);
|
||||
cw_acpriolist_t prios = mbag_get_mavl(conn->config,CW_ITEM_AC_NAME_WITH_PRIORITY);
|
||||
if (!prios)
|
||||
return 0;
|
||||
|
||||
|
@ -36,7 +36,7 @@ int cw_out_radio_infos(struct conn *conn, struct cw_action_out *a, uint8_t * dst
|
||||
if ( i->type != MBAG_MBAG ) {
|
||||
continue;
|
||||
}
|
||||
l+=cw_put_elem_radio_info(dst+l,i->id,i->data);
|
||||
l+=cw_put_elem_radio_info(dst+l,i->iid,i->data);
|
||||
|
||||
}
|
||||
return l;
|
||||
@ -52,7 +52,7 @@ int cw_out_radio_administrative_states(struct conn *conn, struct cw_action_out *
|
||||
if ( i->type != MBAG_MBAG ) {
|
||||
continue;
|
||||
}
|
||||
l+=cw_put_elem_radio_administrative_state(dst+l,i->id,i->data);
|
||||
l+=cw_put_elem_radio_administrative_state(dst+l,i->iid,i->data);
|
||||
|
||||
}
|
||||
return l;
|
||||
|
@ -27,7 +27,7 @@ int cw_out_radio_operational_states(struct conn *conn, struct cw_action_out *a,
|
||||
}
|
||||
|
||||
/* Put the radio ID */
|
||||
cw_put_byte(d+4,radioitem->id);
|
||||
cw_put_byte(d+4,radioitem->iid);
|
||||
|
||||
/* Get the operational state and cause */
|
||||
uint16_t os = ositem->word;
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
static int cmp(const void *v1,const void*v2)
|
||||
{
|
||||
return *((int*)v1) - *((char*)v2);
|
||||
return *((int*)v1) - *((int*)v2);
|
||||
}
|
||||
|
||||
static void del(void* d)
|
||||
@ -16,14 +16,14 @@ static void del(void* d)
|
||||
return;
|
||||
}
|
||||
|
||||
struct avltree * intavltree_create()
|
||||
struct mavl * intavltree_create()
|
||||
{
|
||||
return avltree_create(cmp,del);
|
||||
return mavl_create(cmp,del);
|
||||
}
|
||||
|
||||
int * intavltree_add(struct avltree * t, int val)
|
||||
int * intavltree_add(struct mavl * t, int val)
|
||||
{
|
||||
int *v = avltree_get(t,&val);
|
||||
int *v = mavl_get(t,&val);
|
||||
if (v)
|
||||
return v;
|
||||
|
||||
@ -31,5 +31,5 @@ int * intavltree_add(struct avltree * t, int val)
|
||||
if (!v)
|
||||
return NULL;
|
||||
*v=val;
|
||||
return avltree_add(t,v);
|
||||
return mavl_add(t,v);
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
#ifndef __INTAVLTREE_H
|
||||
#define __INTAVLTREE_H
|
||||
|
||||
#include "avltree.h"
|
||||
#include "mavl.h"
|
||||
|
||||
extern struct avltree * intavltree_create();
|
||||
typedef struct avltree * intavltree_t;
|
||||
int * intavltree_add(struct avltree * t, int val);
|
||||
extern struct mavl * intavltree_create();
|
||||
typedef struct mavl * intavltree_t;
|
||||
int * intavltree_add(struct mavl * t, int val);
|
||||
|
||||
#define intavltree_destroy(t) avltree_destroy(t)
|
||||
#define intavltree_foreach_asc(t,f,p) avltree_foreach_asc(t,f,p)
|
||||
#define intavltree_foreach_desc(t,f,p) avltree_foreach_desc(t,f,p)
|
||||
#define intavltree_destroy(t) mavl_destroy(t)
|
||||
#define intavltree_foreach_asc(t,f,p) mavl_foreach_asc(t,f,p)
|
||||
#define intavltree_foreach_desc(t,f,p) mavl_foreach_desc(t,f,p)
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "item.h"
|
||||
#include "capwap_items.h"
|
||||
|
||||
/*
|
||||
struct cw_item * cw_item_get_by_id(int id,struct cw_item *table)
|
||||
{
|
||||
int i;
|
||||
@ -13,13 +14,13 @@ struct cw_item * cw_item_get_by_id(int id,struct cw_item *table)
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
struct cw_item * cw_item_get_by_name(const char *name,struct cw_item *table)
|
||||
struct cw_item * cw_item_get_by_name(const char *id,struct cw_item *table)
|
||||
{
|
||||
int i;
|
||||
while (table->id != CW_ITEM_NONE) {
|
||||
if (!strcmp(table->cfgname,name))
|
||||
if (!strcmp(table->id,id))
|
||||
return table;
|
||||
table++;
|
||||
|
||||
|
@ -7,9 +7,7 @@
|
||||
|
||||
struct cw_item {
|
||||
/** ID */
|
||||
uint32_t id;
|
||||
/** Name of the item in cfg files */
|
||||
const char * cfgname;
|
||||
const char *id;
|
||||
/** Type */
|
||||
mbagtype_t type;
|
||||
|
||||
|
@ -106,7 +106,7 @@ static void mbag_del_fun(void *e)
|
||||
}
|
||||
|
||||
|
||||
static void strmbag_del_fun(void *e)
|
||||
static void mbag_i_del_fun(void *e)
|
||||
{
|
||||
|
||||
mbag_del_data(e);
|
||||
@ -114,31 +114,31 @@ static void strmbag_del_fun(void *e)
|
||||
}
|
||||
|
||||
|
||||
static int strmbag_cmp_fun(const void *x1, const void *x2)
|
||||
{
|
||||
return strcmp(( (struct mbag_item *) x1)->name , ((struct mbag_item *) x2)->name );
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int mbag_cmp_fun(const void *x1, const void *x2)
|
||||
{
|
||||
return ((struct mbag_item *) x1)->id - ((struct mbag_item *) x2)->id;
|
||||
return strcmp(( (struct mbag_item *) x1)->id , ((struct mbag_item *) x2)->id );
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int mbag_i_cmp_fun(const void *x1, const void *x2)
|
||||
{
|
||||
return ((struct mbag_item *) x1)->iid - ((struct mbag_item *) x2)->iid;
|
||||
}
|
||||
|
||||
mbag_t mbag_i_create()
|
||||
{
|
||||
return mavl_create(mbag_i_cmp_fun, mbag_i_del_fun);
|
||||
}
|
||||
|
||||
|
||||
mbag_t mbag_create()
|
||||
{
|
||||
return mavl_create(mbag_cmp_fun, mbag_del_fun);
|
||||
}
|
||||
|
||||
|
||||
mbag_t strmbag_create()
|
||||
{
|
||||
return mavl_create(strmbag_cmp_fun, strmbag_del_fun);
|
||||
|
||||
}
|
||||
|
||||
struct mbag_item *mbag_item_create(mbag_t s, uint32_t id)
|
||||
struct mbag_item *mbag_item_create(mbag_t s, const char *id)
|
||||
{
|
||||
struct mbag_item is;
|
||||
is.id = id;
|
||||
@ -158,6 +158,30 @@ struct mbag_item *mbag_item_create(mbag_t s, uint32_t id)
|
||||
}
|
||||
|
||||
|
||||
struct mbag_item *mbag_i_item_create(mbag_t s, uint32_t id)
|
||||
{
|
||||
struct mbag_item is;
|
||||
is.iid = id;
|
||||
|
||||
|
||||
struct mbag_item *i = mavl_get(s, &is);
|
||||
if (i) {
|
||||
mbag_del_data(i);
|
||||
return i;
|
||||
}
|
||||
|
||||
i = malloc(sizeof(struct mbag_item));
|
||||
if (!i)
|
||||
return NULL;
|
||||
i->iid = id;
|
||||
return mavl_add(s, i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
struct mbag_item *strmbag_item_create(mbag_t s, char *name)
|
||||
{
|
||||
struct mbag_item is;
|
||||
@ -177,4 +201,5 @@ struct mbag_item *strmbag_item_create(mbag_t s, char *name)
|
||||
return mavl_add(s, i);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
@ -43,10 +43,11 @@ typedef const struct mbag_typedef * mbagtype_t;
|
||||
|
||||
|
||||
|
||||
|
||||
struct mbag_item{
|
||||
union {
|
||||
uint32_t id;
|
||||
const char *name;
|
||||
uint32_t iid;
|
||||
const char *id;
|
||||
};
|
||||
const struct mbag_typedef * type;
|
||||
union {
|
||||
@ -58,6 +59,7 @@ struct mbag_item{
|
||||
};
|
||||
|
||||
typedef mavl_t mbag_t;
|
||||
|
||||
typedef struct mbag_item mbag_item_t;
|
||||
|
||||
|
||||
@ -91,13 +93,14 @@ extern const struct mbag_typedef mbag_type_const_data;
|
||||
|
||||
|
||||
extern mbag_t mbag_create();
|
||||
extern mbag_t mbag_i_create();
|
||||
|
||||
extern struct mbag_item *mbag_item_create(mbag_t s, uint32_t id);
|
||||
extern struct mbag_item *strmbag_item_create(mbag_t s, char *name);
|
||||
struct mbag_item *mbag_item_create(mbag_t s, const char *id);
|
||||
struct mbag_item *mbag_i_item_create(mbag_t s, uint32_t id);
|
||||
|
||||
|
||||
|
||||
static inline int mbag_set_byte(mbag_t s, uint32_t id, uint8_t byte)
|
||||
static inline int mbag_set_byte(mbag_t s, const char *id, uint8_t byte)
|
||||
{
|
||||
struct mbag_item *i = mbag_item_create(s, id);
|
||||
if (!i)
|
||||
@ -107,7 +110,7 @@ static inline int mbag_set_byte(mbag_t s, uint32_t id, uint8_t byte)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline int mbag_set_word(mbag_t s, uint32_t id, uint16_t word)
|
||||
static inline int mbag_set_word(mbag_t s, const char *id, uint16_t word)
|
||||
{
|
||||
struct mbag_item *i = mbag_item_create(s, id);
|
||||
if (!i)
|
||||
@ -119,7 +122,7 @@ static inline int mbag_set_word(mbag_t s, uint32_t id, uint16_t word)
|
||||
|
||||
|
||||
|
||||
static inline int mbag_set_dword(mbag_t s, uint32_t id, uint32_t dword)
|
||||
static inline int mbag_set_dword(mbag_t s, const char *id, uint32_t dword)
|
||||
{
|
||||
struct mbag_item *i = mbag_item_create(s, id);
|
||||
if (!i)
|
||||
@ -130,8 +133,17 @@ static inline int mbag_set_dword(mbag_t s, uint32_t id, uint32_t dword)
|
||||
}
|
||||
|
||||
|
||||
static inline int mbag_i_set_mbag(mbag_t s, uint32_t id, mbag_t mbag)
|
||||
{
|
||||
struct mbag_item *i = mbag_i_item_create(s, id);
|
||||
if (!i)
|
||||
return 0;
|
||||
i->data = mbag;
|
||||
i->type = &mbag_type_mbag;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline int mbag_set_mbag(mbag_t s, uint32_t id, mbag_t mbag)
|
||||
static inline int mbag_set_mbag(mbag_t s, const char *id, mbag_t mbag)
|
||||
{
|
||||
struct mbag_item *i = mbag_item_create(s, id);
|
||||
if (!i)
|
||||
@ -141,7 +153,7 @@ static inline int mbag_set_mbag(mbag_t s, uint32_t id, mbag_t mbag)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline int mbag_set_data(mbag_t s, uint32_t id, const struct mbag_typedef *type, void *data)
|
||||
static inline int mbag_set_data(mbag_t s, const char *id, const struct mbag_typedef *type, void *data)
|
||||
{
|
||||
struct mbag_item *i = mbag_item_create(s, id);
|
||||
if (!i)
|
||||
@ -154,7 +166,7 @@ static inline int mbag_set_data(mbag_t s, uint32_t id, const struct mbag_typedef
|
||||
}
|
||||
|
||||
|
||||
static inline vendorstr_t mbag_set_vendorstr(mbag_t s, uint32_t id, uint32_t vendor_id,
|
||||
static inline vendorstr_t mbag_set_vendorstr(mbag_t s, const char *id, uint32_t vendor_id,
|
||||
uint8_t * vendorstr, int len)
|
||||
{
|
||||
mbag_item_t *i = mbag_item_create(s, id);
|
||||
@ -174,7 +186,7 @@ static inline vendorstr_t mbag_set_vendorstr(mbag_t s, uint32_t id, uint32_t ven
|
||||
#define mbag_set_bstr16(m,i,d) mbag_set_data(m,i,MBAG_BSTR16,d)
|
||||
|
||||
|
||||
static inline mbag_item_t *mbag_get(mbag_t s, uint32_t id)
|
||||
static inline mbag_item_t *mbag_get(mbag_t s, const char *id)
|
||||
{
|
||||
mbag_item_t i;
|
||||
i.id = id;
|
||||
@ -182,7 +194,18 @@ static inline mbag_item_t *mbag_get(mbag_t s, uint32_t id)
|
||||
return mavl_get(s, &i);
|
||||
}
|
||||
|
||||
static inline void mbag_del(mbag_t s,uint32_t id)
|
||||
|
||||
static inline mbag_item_t *mbag_i_get(mbag_t s, uint32_t id)
|
||||
{
|
||||
mbag_item_t i;
|
||||
i.iid = id;
|
||||
i.type=0;
|
||||
return mavl_get(s, &i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static inline void mbag_del(mbag_t s,const char *id)
|
||||
{
|
||||
mbag_item_t i;
|
||||
i.id = id;
|
||||
@ -190,7 +213,7 @@ static inline void mbag_del(mbag_t s,uint32_t id)
|
||||
mavl_del(s, &i);
|
||||
}
|
||||
|
||||
static inline void * mbag_get_data(mbag_t s, uint32_t id, const struct mbag_typedef * type, void * def)
|
||||
static inline void * mbag_get_data(mbag_t s, const char *id, const struct mbag_typedef * type, void * def)
|
||||
{
|
||||
struct mbag_item *i = mbag_get(s, id);
|
||||
if (!i)
|
||||
@ -203,7 +226,7 @@ static inline void * mbag_get_data(mbag_t s, uint32_t id, const struct mbag_type
|
||||
#define mbag_get_bstr(m,i,d) mbag_get_data(m,i,MBAG_BSTR,d)
|
||||
#define mbag_get_bstr16(m,i,d) mbag_get_data(m,i,MBAG_BSTR16,d)
|
||||
|
||||
static inline void * mbag_get_raw(mbag_t s, uint32_t id, void * def)
|
||||
static inline void * mbag_get_raw(mbag_t s, const char *id, void * def)
|
||||
{
|
||||
struct mbag_item *i = mbag_get(s, id);
|
||||
if (!i)
|
||||
@ -213,7 +236,7 @@ static inline void * mbag_get_raw(mbag_t s, uint32_t id, void * def)
|
||||
|
||||
|
||||
|
||||
static inline uint8_t mbag_get_byte(mbag_t s, uint32_t id, uint8_t def)
|
||||
static inline uint8_t mbag_get_byte(mbag_t s, const char *id, uint8_t def)
|
||||
{
|
||||
struct mbag_item *i = mbag_get(s, id);
|
||||
if (!i)
|
||||
@ -223,7 +246,7 @@ static inline uint8_t mbag_get_byte(mbag_t s, uint32_t id, uint8_t def)
|
||||
return i->byte;
|
||||
}
|
||||
|
||||
static inline uint16_t mbag_get_word(mbag_t s, uint32_t id, uint16_t def)
|
||||
static inline uint16_t mbag_get_word(mbag_t s, const char *id, uint16_t def)
|
||||
{
|
||||
struct mbag_item *i = mbag_get(s, id);
|
||||
if (!i)
|
||||
@ -235,7 +258,7 @@ static inline uint16_t mbag_get_word(mbag_t s, uint32_t id, uint16_t def)
|
||||
|
||||
|
||||
|
||||
static inline uint32_t mbag_get_dword(mbag_t s, uint32_t id, uint32_t def)
|
||||
static inline uint32_t mbag_get_dword(mbag_t s, const char *id, uint32_t def)
|
||||
{
|
||||
struct mbag_item *i = mbag_get(s, id);
|
||||
if (!i)
|
||||
@ -246,8 +269,18 @@ static inline uint32_t mbag_get_dword(mbag_t s, uint32_t id, uint32_t def)
|
||||
}
|
||||
|
||||
|
||||
static inline mbag_t mbag_i_get_mbag(mbag_t s, uint32_t id, mbag_t def)
|
||||
{
|
||||
struct mbag_item *i = mbag_i_get(s, id);
|
||||
if (!i)
|
||||
return def;
|
||||
if (i->type != MBAG_MBAG)
|
||||
return def;
|
||||
return i->data;
|
||||
}
|
||||
|
||||
static inline mbag_t mbag_get_mbag(mbag_t s, uint32_t id, mbag_t def)
|
||||
|
||||
static inline mbag_t mbag_get_mbag(mbag_t s, const char *id, mbag_t def)
|
||||
{
|
||||
struct mbag_item *i = mbag_get(s, id);
|
||||
if (!i)
|
||||
@ -257,7 +290,7 @@ static inline mbag_t mbag_get_mbag(mbag_t s, uint32_t id, mbag_t def)
|
||||
return i->data;
|
||||
}
|
||||
|
||||
static inline mbag_item_t * mbag_set_bstrn(mbag_t s, uint32_t id, uint8_t * data, int len)
|
||||
static inline mbag_item_t * mbag_set_bstrn(mbag_t s, const char *id, uint8_t * data, int len)
|
||||
{
|
||||
struct mbag_item *i = mbag_item_create(s, id);
|
||||
if (!i)
|
||||
@ -267,7 +300,7 @@ static inline mbag_item_t * mbag_set_bstrn(mbag_t s, uint32_t id, uint8_t * data
|
||||
return i;
|
||||
}
|
||||
|
||||
static inline struct avltree *mbag_get_avltree(mbag_t s, uint32_t id)
|
||||
static inline struct mavl *mbag_get_mavl(mbag_t s, const char *id)
|
||||
{
|
||||
struct mbag_item *i = mbag_get(s, id);
|
||||
if (!i)
|
||||
@ -277,7 +310,17 @@ static inline struct avltree *mbag_get_avltree(mbag_t s, uint32_t id)
|
||||
return i->data;
|
||||
}
|
||||
|
||||
static inline int mbag_set_avltree(mbag_t s, uint32_t id, struct avltree *t)
|
||||
static inline int mbag_i_set_mavl(mbag_t s, uint32_t id, mavl_t t)
|
||||
{
|
||||
struct mbag_item *i = mbag_i_item_create(s, id);
|
||||
if (!i)
|
||||
return 0;
|
||||
i->type = MBAG_AVLTREE;
|
||||
i->data = t;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline int mbag_set_mavl(mbag_t s, const char *id, mavl_t t)
|
||||
{
|
||||
struct mbag_item *i = mbag_item_create(s, id);
|
||||
if (!i)
|
||||
@ -287,21 +330,11 @@ static inline int mbag_set_avltree(mbag_t s, uint32_t id, struct avltree *t)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline int mbag_set_mavl(mbag_t s, uint32_t id, mavl_t t)
|
||||
/*
|
||||
static inline struct mavl *mbag_get_avltree_c(mbag_t s, const char *id,
|
||||
struct mavl *(creator) ())
|
||||
{
|
||||
struct mbag_item *i = mbag_item_create(s, id);
|
||||
if (!i)
|
||||
return 0;
|
||||
i->type = MBAG_AVLTREE;
|
||||
i->data = t;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static inline struct avltree *mbag_get_avltree_c(mbag_t s, uint32_t id,
|
||||
struct avltree *(creator) ())
|
||||
{
|
||||
struct avltree *avltree = mbag_get_avltree(s, id);
|
||||
struct mavl * avltree = mbag_get_mavl(s, id);
|
||||
if (avltree){
|
||||
return avltree;
|
||||
}
|
||||
@ -309,12 +342,12 @@ static inline struct avltree *mbag_get_avltree_c(mbag_t s, uint32_t id,
|
||||
avltree = creator();
|
||||
if (!avltree)
|
||||
return NULL;
|
||||
mbag_set_avltree(s, id, avltree);
|
||||
mbag_set_mavl(s, id, avltree);
|
||||
return avltree;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
static inline mavl_t mbag_get_mavl(mbag_t s, uint32_t id,
|
||||
static inline mavl_t mbag_get_mavl_c(mbag_t s, const char *id,
|
||||
mavl_t (creator) ())
|
||||
{
|
||||
struct mbag_item *i = mbag_get(s, id);
|
||||
@ -330,12 +363,28 @@ static inline mavl_t mbag_get_mavl(mbag_t s, uint32_t id,
|
||||
return avltree;
|
||||
}
|
||||
|
||||
static inline mavl_t mbag_i_get_mavl(mbag_t s, uint32_t id,
|
||||
mavl_t (creator) ())
|
||||
{
|
||||
struct mbag_item *i = mbag_i_get(s, id);
|
||||
if (i)
|
||||
return i->data;
|
||||
|
||||
if (!creator)
|
||||
return NULL;
|
||||
mavl_t avltree = creator();
|
||||
if (!avltree)
|
||||
return NULL;
|
||||
mbag_i_set_mavl(s, id, avltree);
|
||||
return avltree;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
static inline char *mbag_get_str(mbag_t s, uint32_t id, char *def)
|
||||
static inline char *mbag_get_str(mbag_t s, const char *id, char *def)
|
||||
{
|
||||
struct mbag_item *i = mbag_get(s, id);
|
||||
if (!i)
|
||||
@ -344,7 +393,7 @@ static inline char *mbag_get_str(mbag_t s, uint32_t id, char *def)
|
||||
|
||||
};
|
||||
|
||||
static inline int mbag_set_str(mbag_t s, uint32_t id, const char *str)
|
||||
static inline int mbag_set_str(mbag_t s, const char *id, const char *str)
|
||||
{
|
||||
struct mbag_item *i = mbag_item_create(s, id);
|
||||
if (!i)
|
||||
@ -393,7 +442,7 @@ static inline void mbag_item_release_data_ptr(struct mbag_item *item, void *data
|
||||
|
||||
}
|
||||
|
||||
static inline int mbag_set_strn(mbag_t s, uint32_t id, const char *str, int n)
|
||||
static inline int mbag_set_strn(mbag_t s, const char *id, const char *str, int n)
|
||||
{
|
||||
struct mbag_item *i = mbag_item_create(s, id);
|
||||
if (!i)
|
||||
@ -403,7 +452,7 @@ static inline int mbag_set_strn(mbag_t s, uint32_t id, const char *str, int n)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline int mbag_set_bstr16n(mbag_t s, uint32_t id, uint8_t * data, int len)
|
||||
static inline int mbag_set_bstr16n(mbag_t s, const char *id, uint8_t * data, int len)
|
||||
{
|
||||
struct mbag_item *i = mbag_item_create(s, id);
|
||||
if (!i)
|
||||
@ -415,7 +464,7 @@ static inline int mbag_set_bstr16n(mbag_t s, uint32_t id, uint8_t * data, int le
|
||||
|
||||
|
||||
|
||||
static inline mbag_item_t * mbag_set_const_ptr(mbag_t s, uint32_t id, void *ptr)
|
||||
static inline mbag_item_t * mbag_set_const_ptr(mbag_t s, const char *id, void *ptr)
|
||||
{
|
||||
struct mbag_item *i = mbag_item_create(s, id);
|
||||
if (!i)
|
||||
@ -426,7 +475,7 @@ static inline mbag_item_t * mbag_set_const_ptr(mbag_t s, uint32_t id, void *ptr)
|
||||
}
|
||||
|
||||
|
||||
static inline int mbag_set_ptr(mbag_t s, uint32_t id, void *ptr)
|
||||
static inline int mbag_set_ptr(mbag_t s, const char *id, void *ptr)
|
||||
{
|
||||
struct mbag_item *i = mbag_item_create(s, id);
|
||||
if (!i)
|
||||
@ -439,7 +488,7 @@ static inline int mbag_set_ptr(mbag_t s, uint32_t id, void *ptr)
|
||||
|
||||
|
||||
|
||||
static inline int mbag_set_fun(mbag_t s, uint32_t id,
|
||||
static inline int mbag_set_fun(mbag_t s, const char *id,
|
||||
void *(*funget) (void *arg),
|
||||
void (*funfree) (void *arg, void *data), void *arg)
|
||||
{
|
||||
|
@ -5,6 +5,26 @@
|
||||
#include "dbg.h"
|
||||
|
||||
|
||||
|
||||
const char CW_RADIO_ADMIN_STATE[]="admin_state";
|
||||
const char CW_RADIO_OPER_STATE[]="oper_state";
|
||||
const char CW_RADIO_TYPE[]="type";
|
||||
const char CW_RADIO_REG_DOMAIN[]="reg_domain";
|
||||
const char CW_RADIO_BSSID[]="bssid";
|
||||
const char CW_RADIO_SHORT_PREAMBLE[]="short_preamble";
|
||||
const char CW_RADIO_COUNTRY_STRING[]="country_string";
|
||||
|
||||
/* Cisco */
|
||||
|
||||
const char CW_RADIO_OCCUPANCY_LIMIT[]="occupancy_limit";
|
||||
const char CW_RADIO_CFP_PERIOD[]="cfp_period";
|
||||
const char CW_RADIO_CFP_MAX_DURATION[]="cfp_max_duration";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Update all radio operational states.
|
||||
* @param radios definitiion of radios
|
||||
@ -31,7 +51,7 @@ int cw_radio_update_oper_states(mbag_t radios,int cause)
|
||||
|
||||
int cw_radio_set_admin_state(mbag_t radios,int rid, int state, int cause)
|
||||
{
|
||||
mbag_t radio = mbag_get_mbag(radios,rid,NULL);
|
||||
mbag_t radio = mbag_i_get_mbag(radios,rid,NULL);
|
||||
if (!radio) {
|
||||
cw_dbg(DBG_ELEM_ERR,"Can't set radio administrative state for radio %d - radio does't exists",rid);
|
||||
return 0;
|
||||
|
@ -3,6 +3,25 @@
|
||||
|
||||
#include "mbag.h"
|
||||
|
||||
|
||||
|
||||
|
||||
extern const char CW_RADIO_ADMIN_STATE[];
|
||||
extern const char CW_RADIO_OPER_STATE[];
|
||||
extern const char CW_RADIO_TYPE[];
|
||||
extern const char CW_RADIO_REG_DOMAIN[];
|
||||
extern const char CW_RADIO_BSSID[];
|
||||
extern const char CW_RADIO_SHORT_PREAMBLE[];
|
||||
extern const char CW_RADIO_COUNTRY_STRING[];
|
||||
|
||||
/* Cisco */
|
||||
|
||||
extern const char CW_RADIO_OCCUPANCY_LIMIT[];
|
||||
extern const char CW_RADIO_CFP_PERIOD[];
|
||||
extern const char CW_RADIO_CFP_MAX_DURATION[];
|
||||
|
||||
|
||||
/*
|
||||
enum radiodata{
|
||||
CW_RADIO_ADMIN_STATE=10000,
|
||||
CW_RADIO_OPER_STATE,
|
||||
@ -12,7 +31,6 @@ enum radiodata{
|
||||
CW_RADIO_SHORT_PREAMBLE,
|
||||
CW_RADIO_COUNTRY_STRING,
|
||||
|
||||
/* Cisco */
|
||||
|
||||
CW_RADIO_OCCUPANCY_LIMIT,
|
||||
CW_RADIO_CFP_PERIOD,
|
||||
@ -20,7 +38,9 @@ enum radiodata{
|
||||
|
||||
|
||||
|
||||
};
|
||||
}[];
|
||||
*/
|
||||
|
||||
|
||||
|
||||
int cw_radio_update_oper_states(mbag_t radios,int cause);
|
||||
|
105
src/wtp/cfg.c
105
src/wtp/cfg.c
@ -1,5 +1,11 @@
|
||||
#include "capwap/mbag.h"
|
||||
#include "capwap/capwap_items.h"
|
||||
#include "capwap/radio.h"
|
||||
|
||||
|
||||
const char * uuuu = CW_ITEM_WTP_NAME;
|
||||
const char *uuu = CW_RADIO_ADMIN_STATE;
|
||||
|
||||
#include "capwap/conn.h"
|
||||
#include "capwap/bstr.h"
|
||||
|
||||
@ -9,7 +15,6 @@
|
||||
#include "jsmn.h"
|
||||
#include "wtp.h"
|
||||
#include "capwap/bstr.h"
|
||||
#include "capwap/radio.h"
|
||||
|
||||
#include "capwap/mavl.h"
|
||||
#include "capwap/format.h"
|
||||
@ -36,8 +41,8 @@ int cfg_json_put_bstr(char *dst, const char *name, mbag_item_t * i, int n);
|
||||
|
||||
|
||||
struct mbag_itemdef {
|
||||
int item_id;
|
||||
const char *cfgname;
|
||||
const char *item_id;
|
||||
// const char *cfgname;
|
||||
int (*setfun) (struct mbag_itemdef *, char *, jsmntok_t *, mbag_t mbag);
|
||||
int (*tojsonfun) (char *dst, const char *name, mbag_item_t * i, int n);
|
||||
|
||||
@ -188,7 +193,7 @@ int cfg_json_get_ac_ip_list(struct mbag_itemdef *idef, char *js, jsmntok_t * t,
|
||||
}
|
||||
|
||||
cw_aciplist_t aciplist =
|
||||
mbag_get_mavl(mbag, CW_ITEM_AC_IP_LIST, cw_aciplist_create);
|
||||
mbag_get_mavl_c(mbag, CW_ITEM_AC_IP_LIST, cw_aciplist_create);
|
||||
mavl_replace(aciplist, acip);
|
||||
|
||||
|
||||
@ -222,7 +227,7 @@ int byte_local(struct mbag_itemdef *idef, char *js, jsmntok_t * t)
|
||||
int cfg_json_get_vendorstr(struct mbag_itemdef *idef, char *js, jsmntok_t * t,
|
||||
mbag_t mbag)
|
||||
{
|
||||
int item_id = idef->item_id;
|
||||
const char * item_id = idef->item_id;
|
||||
|
||||
*(js + t->end) = 0;
|
||||
char *str = js + t->start;
|
||||
@ -251,7 +256,7 @@ int cfg_json_get_bstr(struct mbag_itemdef *idef, char *js, jsmntok_t * t, mbag_t
|
||||
|
||||
struct conn *conn = get_conn();
|
||||
|
||||
int item_id = idef->item_id;
|
||||
const char *item_id = idef->item_id;
|
||||
*(js + t->end) = 0;
|
||||
// char *str = js+t->start;
|
||||
if (t->type != JSMN_STRING) {
|
||||
@ -278,7 +283,7 @@ int cfg_json_get_bstr16(struct mbag_itemdef *idef, char *js, jsmntok_t * t, mbag
|
||||
|
||||
struct conn *conn = get_conn();
|
||||
|
||||
int item_id = idef->item_id;
|
||||
const char *item_id = idef->item_id;
|
||||
*(js + t->end) = 0;
|
||||
// char *str = js+t->start;
|
||||
if (t->type != JSMN_STRING) {
|
||||
@ -296,7 +301,7 @@ int cfg_json_get_dword(struct mbag_itemdef *idef, char *js, jsmntok_t * t, mbag_
|
||||
|
||||
struct conn *conn = get_conn();
|
||||
|
||||
int item_id = idef->item_id;
|
||||
const char *item_id = idef->item_id;
|
||||
*(js + t->end) = 0;
|
||||
// char *str = js+t->start;
|
||||
if (t->type != JSMN_STRING) {
|
||||
@ -313,7 +318,7 @@ int cfg_json_get_word(struct mbag_itemdef *idef, char *js, jsmntok_t * t, mbag_t
|
||||
|
||||
struct conn *conn = get_conn();
|
||||
|
||||
int item_id = idef->item_id;
|
||||
const char *item_id = idef->item_id;
|
||||
*(js + t->end) = 0;
|
||||
// char *str = js+t->start;
|
||||
if (t->type != JSMN_STRING) {
|
||||
@ -331,7 +336,7 @@ int cfg_json_get_byte(struct mbag_itemdef *idef, char *js, jsmntok_t * t, mbag_t
|
||||
|
||||
struct conn *conn = get_conn();
|
||||
|
||||
int item_id = idef->item_id;
|
||||
const char *item_id = idef->item_id;
|
||||
*(js + t->end) = 0;
|
||||
// char *str = js+t->start;
|
||||
if (t->type != JSMN_STRING) {
|
||||
@ -348,7 +353,7 @@ int cfg_json_get_byte(struct mbag_itemdef *idef, char *js, jsmntok_t * t, mbag_t
|
||||
|
||||
int bstr16_local(struct mbag_itemdef *idef, char *js, jsmntok_t * t)
|
||||
{
|
||||
int item_id = idef->item_id;
|
||||
const char *item_id = idef->item_id;
|
||||
struct conn *conn = get_conn();
|
||||
|
||||
*(js + t->end) = 0;
|
||||
@ -367,7 +372,7 @@ int bstr16_local(struct mbag_itemdef *idef, char *js, jsmntok_t * t)
|
||||
|
||||
int bstr_local(struct mbag_itemdef *idef, char *js, jsmntok_t * t)
|
||||
{
|
||||
int item_id = idef->item_id;
|
||||
const char *item_id = idef->item_id;
|
||||
struct conn *conn = get_conn();
|
||||
|
||||
*(js + t->end) = 0;
|
||||
@ -401,44 +406,44 @@ int cfg_json_get_radios(struct mbag_itemdef *idef, char *js, jsmntok_t * t, mbag
|
||||
|
||||
|
||||
struct mbag_itemdef general_cfg[] = {
|
||||
{CW_ITEM_WTP_NAME, "wtp_name", cfg_json_get_bstr16, cfg_json_put_bstr16},
|
||||
{CW_ITEM_WTP_GROUP_NAME, "wtp_group_name", cfg_json_get_bstr16,
|
||||
|
||||
{CW_ITEM_WTP_NAME, cfg_json_get_bstr16, cfg_json_put_bstr16},
|
||||
{CW_ITEM_WTP_GROUP_NAME, cfg_json_get_bstr16,
|
||||
cfg_json_put_bstr16},
|
||||
{CW_ITEM_LOCATION_DATA, "location_data", cfg_json_get_bstr16,
|
||||
{CW_ITEM_LOCATION_DATA, cfg_json_get_bstr16,
|
||||
cfg_json_put_bstr16},
|
||||
{CW_ITEM_WTP_HARDWARE_VERSION, "hardware_version", cfg_json_get_vendorstr,
|
||||
{CW_ITEM_WTP_HARDWARE_VERSION, cfg_json_get_vendorstr,
|
||||
cfg_json_put_vendorstr},
|
||||
{CW_ITEM_WTP_SOFTWARE_VERSION, "software_version", cfg_json_get_vendorstr,
|
||||
{CW_ITEM_WTP_SOFTWARE_VERSION, cfg_json_get_vendorstr,
|
||||
cfg_json_put_vendorstr},
|
||||
{CW_ITEM_WTP_BOARD_DATA, "wtp_board_data", wtp_board_data_local,
|
||||
{CW_ITEM_WTP_BOARD_DATA, wtp_board_data_local,
|
||||
cfg_json_put_obj},
|
||||
{CW_RADIO_BSSID, "bssid", cfg_json_get_bstr16, cfg_json_put_bstr16},
|
||||
{CW_ITEM_CAPWAP_TIMERS, "capwap_timers", cfg_json_get_word, cfg_json_put_word},
|
||||
{CW_ITEM_IDLE_TIMEOUT, "idle_timeout", cfg_json_get_dword, cfg_json_put_dword},
|
||||
{CW_ITEM_AC_IP_LIST, "ac_ip_list", cfg_json_get_ac_ip_list,
|
||||
{CW_RADIO_BSSID, cfg_json_get_bstr16, cfg_json_put_bstr16},
|
||||
{CW_ITEM_CAPWAP_TIMERS, cfg_json_get_word, cfg_json_put_word},
|
||||
{CW_ITEM_IDLE_TIMEOUT, cfg_json_get_dword, cfg_json_put_dword},
|
||||
{CW_ITEM_AC_IP_LIST, cfg_json_get_ac_ip_list,
|
||||
cfg_json_put_ac_ip_list},
|
||||
|
||||
{CW_ITEM_AP_MODE_AND_TYPE, "ap_mode_and_type", cfg_json_get_word,
|
||||
{CW_ITEM_AP_MODE_AND_TYPE, cfg_json_get_word,
|
||||
cfg_json_put_word},
|
||||
|
||||
{CW_ITEM_WTP_FRAME_TUNNEL_MODE, "wtp_frame_tunnel_mode", cfg_json_get_byte,
|
||||
{CW_ITEM_WTP_FRAME_TUNNEL_MODE, cfg_json_get_byte,
|
||||
cfg_json_put_byte},
|
||||
{CW_ITEM_WTP_MAC_TYPE, "wtp_mac_type", cfg_json_get_byte, cfg_json_put_byte},
|
||||
{CW_ITEM_WTP_MAC_TYPE, cfg_json_get_byte, cfg_json_put_byte},
|
||||
|
||||
{CW_ITEM_RADIOS, "radios", cfg_json_get_radios, cfg_json_put_radios},
|
||||
{CW_ITEM_RADIOS, cfg_json_get_radios, cfg_json_put_radios},
|
||||
|
||||
|
||||
{CW_ITEM_AC_NAME_WITH_PRIORITY, "ac_name_with_priority",
|
||||
{CW_ITEM_AC_NAME_WITH_PRIORITY,
|
||||
cfg_json_get_ac_name_with_priority, cfg_json_put_acobj},
|
||||
|
||||
{CW_ITEM_AC_HASH_VALUE, "ac_hash_value", cfg_json_get_bstr16,
|
||||
{CW_ITEM_AC_HASH_VALUE, cfg_json_get_bstr16,
|
||||
cfg_json_put_bstr16},
|
||||
|
||||
{CW_ITEM_CISCO_BOARD_DATA_OPTIONS, "wtp_board_data_options", cfg_json_get_bstr16,
|
||||
{CW_ITEM_CISCO_BOARD_DATA_OPTIONS, cfg_json_get_bstr16,
|
||||
cfg_json_put_bstr16},
|
||||
|
||||
|
||||
|
||||
/* {CW_ITEM_WTP_FRAME_TUNNEL_MODE,"frame_tunnel_mode",byte_local},
|
||||
{CW_ITEM_WTP_MAC_TYPE,"mac_type",byte_local},
|
||||
{CW_ITEM_WTP_GROUP_NAME,"group_name",bstr16_local},
|
||||
@ -450,31 +455,35 @@ struct mbag_itemdef general_cfg[] = {
|
||||
|
||||
|
||||
struct mbag_itemdef board_data_cfg[] = {
|
||||
{CW_ITEM_WTP_BOARD_MODELNO, "model_no", cfg_json_get_bstr16, cfg_json_put_bstr16},
|
||||
{CW_ITEM_WTP_BOARD_SERIALNO, "serial_no", cfg_json_get_bstr16,
|
||||
{CW_ITEM_WTP_BOARD_MODELNO, cfg_json_get_bstr16, cfg_json_put_bstr16},
|
||||
{CW_ITEM_WTP_BOARD_SERIALNO, cfg_json_get_bstr16,
|
||||
cfg_json_put_bstr16},
|
||||
{CW_ITEM_WTP_BOARD_VENDOR, "vendor_id", cfg_json_get_dword, cfg_json_put_dword},
|
||||
{CW_ITEM_WTP_BOARD_VENDOR, cfg_json_get_dword, cfg_json_put_dword},
|
||||
|
||||
{0, 0, 0}
|
||||
};
|
||||
|
||||
|
||||
struct mbag_itemdef radio_cfg[] = {
|
||||
{CW_RADIO_ADMIN_STATE, "admin_state", cfg_json_get_byte, cfg_json_put_byte},
|
||||
{CW_RADIO_TYPE, "radio_type", cfg_json_get_dword, cfg_json_put_dword},
|
||||
/* {CW_RADIO_OPER_STATE,"oper_state", cfg_json_get_word,cfg_json_put_word},*/
|
||||
{CW_RADIO_BSSID,"bssid", cfg_json_get_bstr,cfg_json_put_bstr},
|
||||
|
||||
typedef struct mbag_itemdef xxx;
|
||||
xxx radio_cfg[] = {
|
||||
|
||||
{CW_RADIO_ADMIN_STATE, cfg_json_get_byte, cfg_json_put_byte},
|
||||
|
||||
{CW_RADIO_TYPE, cfg_json_get_dword, cfg_json_put_dword},
|
||||
{CW_RADIO_BSSID, cfg_json_get_bstr,cfg_json_put_bstr},
|
||||
|
||||
{0,0,0}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct mbag_itemdef *get_idef_by_id(struct mbag_itemdef *cfg, uint32_t id)
|
||||
struct mbag_itemdef *get_idef_by_id(struct mbag_itemdef *cfg, const char * id)
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; cfg[i].item_id; i++) {
|
||||
if (cfg[i].item_id == id) {
|
||||
if (strcmp(cfg[i].item_id,id)==0) {
|
||||
return &cfg[i];
|
||||
}
|
||||
}
|
||||
@ -636,14 +645,14 @@ int cfg_json_put_radios(char *dst, const char *name, mbag_item_t * i, int n)
|
||||
const char * comma="";
|
||||
mavliter_foreach(&radios) {
|
||||
mbag_item_t *i = mavliter_get(&radios);
|
||||
int rid = i->id;
|
||||
int rid = i->iid;
|
||||
mbag_t radio = i->data;
|
||||
|
||||
d+=sprintf(d,"%s",comma);
|
||||
comma=",\n";
|
||||
memset(d, '\t', n+1);
|
||||
d += n+1;
|
||||
d += sprintf(d, "\"%d\":", i->id);
|
||||
d += sprintf(d, "\"%d\":", i->iid);
|
||||
|
||||
d += mbag_tojson(d, i->data, radio_cfg, n+1);
|
||||
|
||||
@ -735,7 +744,7 @@ int mbag_tojson(char *dst, mbag_t m, struct mbag_itemdef *defs, int n)
|
||||
|
||||
d += sprintf(d, "%s", delim);
|
||||
delim = ",\n";
|
||||
d += idef->tojsonfun(d, idef->cfgname, i, n + 1);
|
||||
d += idef->tojsonfun(d, idef->item_id, i, n + 1);
|
||||
|
||||
}
|
||||
d += sprintf(d, "\n");
|
||||
@ -766,7 +775,7 @@ struct mbag_itemdef *get_cfg(struct mbag_itemdef *cfg, const char *key)
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; cfg[i].item_id; i++) {
|
||||
if (!strcmp(key, cfg[i].cfgname)) {
|
||||
if (!strcmp(key, cfg[i].item_id)) {
|
||||
return &cfg[i];
|
||||
}
|
||||
}
|
||||
@ -872,7 +881,7 @@ int cfg_json_get_ac_name_with_priority(struct mbag_itemdef *idef, char *js, jsmn
|
||||
|
||||
struct conn *conn = get_conn();
|
||||
cw_acpriolist_t al =
|
||||
mbag_get_mavl(conn->config, CW_ITEM_AC_NAME_WITH_PRIORITY,
|
||||
mbag_get_mavl_c(conn->config, CW_ITEM_AC_NAME_WITH_PRIORITY,
|
||||
cw_acpriolist_create);
|
||||
if (!al)
|
||||
return skip(t + 1);
|
||||
@ -901,10 +910,10 @@ static int cfg_json_get_radios_cb(char *js, jsmntok_t * t,
|
||||
struct conn * conn = get_conn();
|
||||
|
||||
|
||||
mbag_t radio = mbag_get_mbag(conn->radios,atoi(key),NULL);
|
||||
mbag_t radio = mbag_i_get_mbag(conn->radios,atoi(key),NULL);
|
||||
if ( !radio ){
|
||||
radio=mbag_create();
|
||||
mbag_set_mbag(conn->radios,atoi(key),radio);
|
||||
mbag_i_set_mbag(conn->radios,atoi(key),radio);
|
||||
|
||||
//printf("Radio %d not found\n",atoi(key));
|
||||
//return skip(t+1);
|
||||
@ -929,7 +938,7 @@ int cfg_json_get_radios(struct mbag_itemdef *idef, char *js, jsmntok_t * t, mbag
|
||||
|
||||
struct conn *conn = get_conn();
|
||||
cw_acpriolist_t al =
|
||||
mbag_get_mavl(conn->config, CW_ITEM_AC_NAME_WITH_PRIORITY,
|
||||
mbag_get_mavl_c(conn->config, CW_ITEM_AC_NAME_WITH_PRIORITY,
|
||||
cw_acpriolist_create);
|
||||
if (!al)
|
||||
return skip(t + 1);
|
||||
|
@ -1,36 +1,39 @@
|
||||
{
|
||||
"idle_timeout":"300",
|
||||
"wtp_name":"Kaffe-Point",
|
||||
"wtp_mac_type":"1",
|
||||
"wtp_frame_tunnel_mode":"4",
|
||||
"hardware_version":["4232704",".x01000000"],
|
||||
"software_version":["4232704",".x08007300"],
|
||||
"wtp_board_data":{
|
||||
"vendor_id":"4232704",
|
||||
"model_no":"AIR-LAP1131AG-E-K9",
|
||||
"serial_no":"2045"
|
||||
},
|
||||
"capwap_timers":"2590",
|
||||
"ac_ip_list":[
|
||||
"192.168.0.1",
|
||||
"192.168.0.13",
|
||||
"192.168.0.15",
|
||||
"fe80::219:dbff:fee0:9327"
|
||||
],
|
||||
"location_data":"Germany",
|
||||
"ac_name_with_priority":{
|
||||
"":"2",
|
||||
"Master AC":"1"
|
||||
},
|
||||
"wtp_group_name":"tobias",
|
||||
"ap_mode_and_type":"512",
|
||||
"wtp_board_data_options":".x00010000",
|
||||
"bssid":"",
|
||||
"capwap_timers":"2590",
|
||||
"idle_timeout":"300",
|
||||
"location_data":"Germany",
|
||||
"radios":{
|
||||
"0":{
|
||||
"admin_state":"2",
|
||||
"radio_type":"1",
|
||||
"admin_state":"1",
|
||||
"bssid":".x123456789abc"
|
||||
},
|
||||
"1":{
|
||||
"admin_state":"1",
|
||||
"bssid":".xaabbccddeeff"
|
||||
},
|
||||
"2":{
|
||||
"admin_state":"1",
|
||||
"bssid":".xaabbccddeeff"
|
||||
}
|
||||
},
|
||||
"bssid":""
|
||||
"wtp_board_data":{
|
||||
"model_no":"AIR-LAP1131AG-E-K9",
|
||||
"serial_no":"2045",
|
||||
"vendor_id":"4232704"
|
||||
},
|
||||
"wtp_frame_tunnel_mode":"4",
|
||||
"wtp_group_name":"tobias",
|
||||
"wtp_mac_type":"1",
|
||||
"wtp_name":"Kaffe-Point"
|
||||
}
|
@ -55,7 +55,7 @@ cw_aciplist_t cw_select_ac(struct conn *conn, mbag_t dis)
|
||||
|
||||
/* get the AC Name with Priority list */
|
||||
cw_acpriolist_t priolist;
|
||||
priolist = mbag_get_avltree(conn->config, CW_ITEM_AC_NAME_WITH_PRIORITY);
|
||||
priolist = mbag_get_mavl(conn->config, CW_ITEM_AC_NAME_WITH_PRIORITY);
|
||||
|
||||
cw_aciplist_t resultlist=cw_aciplist_create();
|
||||
|
||||
@ -79,7 +79,7 @@ printf("nprio: %d\n",priolist->count);
|
||||
}
|
||||
|
||||
cw_aciplist_t acips =
|
||||
mbag_get_avltree(ac, CW_ITEM_CAPWAP_CONTROL_IP_ADDRESS_LIST);
|
||||
mbag_get_mavl(ac, CW_ITEM_CAPWAP_CONTROL_IP_ADDRESS_LIST);
|
||||
|
||||
DEFINE_AVLITER(i2, acips);
|
||||
avliter_foreach(&i2){
|
||||
@ -135,7 +135,7 @@ static int run_discovery(struct conn *conn)
|
||||
|
||||
|
||||
mbag_t discs;
|
||||
discs = mbag_get_avltree(conn->remote, CW_ITEM_DISCOVERIES);
|
||||
discs = mbag_get_mavl(conn->remote, CW_ITEM_DISCOVERIES);
|
||||
|
||||
|
||||
if (!discs) {
|
||||
@ -159,7 +159,7 @@ static int run_discovery(struct conn *conn)
|
||||
|
||||
mavl_del_all(conn->remote);
|
||||
|
||||
mbag_set_avltree(conn->local,CW_ITEM_CAPWAP_CONTROL_IP_ADDRESS_LIST,list);
|
||||
mbag_set_mavl(conn->local,CW_ITEM_CAPWAP_CONTROL_IP_ADDRESS_LIST,list);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ int join()
|
||||
{
|
||||
struct conn * conn = get_conn();
|
||||
|
||||
cw_aciplist_t iplist = mbag_get_avltree(conn->local,CW_ITEM_CAPWAP_CONTROL_IP_ADDRESS_LIST);
|
||||
cw_aciplist_t iplist = mbag_get_mavl(conn->local,CW_ITEM_CAPWAP_CONTROL_IP_ADDRESS_LIST);
|
||||
if (!iplist){
|
||||
cw_log(LOG_ERR,"No IPs to join controller.");
|
||||
return 0;
|
||||
|
@ -63,6 +63,7 @@ int handle_update_req(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
}
|
||||
|
||||
|
||||
const char *t = CW_ITEM_WTP_NAME;
|
||||
|
||||
|
||||
int main()
|
||||
@ -82,19 +83,20 @@ int main()
|
||||
|
||||
|
||||
|
||||
/*
|
||||
mbag_t b = mbag_create();
|
||||
|
||||
mbag_set_byte(b,1,99);
|
||||
mbag_set_avltree(b,2,mbag_create());
|
||||
mavl_destroy(b);
|
||||
|
||||
*/
|
||||
|
||||
dtls_init();
|
||||
|
||||
the_conn = conn_create_noq(-1, NULL);
|
||||
struct conn *conn = the_conn;
|
||||
|
||||
conn->radios = mbag_create();
|
||||
conn->radios = mbag_i_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());
|
||||
@ -152,7 +154,7 @@ conn->config=mbag_create();
|
||||
bstr_data(conf_serial_no), bstr_len(conf_serial_no));
|
||||
|
||||
|
||||
mbag_set_avltree(conn->outgoing, CW_ITEM_WTP_BOARD_DATA, board_data);
|
||||
mbag_set_mavl(conn->outgoing, CW_ITEM_WTP_BOARD_DATA, board_data);
|
||||
|
||||
cw_acpriolist_t acprios = cw_acpriolist_create();
|
||||
cw_acpriolist_set(acprios,"Master AC",strlen("Master AC"),1);
|
||||
|
Loading…
Reference in New Issue
Block a user