Byte - in has now valguard
FossilOrigin-Name: 7926e93ff40c6f5f6b34190ed6591339025f1a23c93469370c1fa160176571e5
This commit is contained in:
parent
98c682e7e6
commit
1f68439fa7
@ -1,10 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CodeLite_Workspace Name="actube" Database="">
|
||||
<Project Name="ac" Path="ac.project" Active="No"/>
|
||||
<Project Name="wtp" Path="wtp.project" Active="Yes"/>
|
||||
<Project Name="wtp" Path="wtp.project" Active="No"/>
|
||||
<Project Name="mod_cipwap" Path="mod_cipwap.project" Active="No"/>
|
||||
<Project Name="mod_capwap" Path="mod_capwap.project" Active="No"/>
|
||||
<Project Name="mod_cisco" Path="mod_cisco.project" Active="No"/>
|
||||
<Project Name="mod_cisco" Path="mod_cisco.project" Active="Yes"/>
|
||||
<Project Name="libcw" Path="libcw.project" Active="No"/>
|
||||
<Project Name="mod_capwap80211" Path="mod_capwap80211.project" Active="No"/>
|
||||
<Project Name="mod_fortinet" Path="mod_fortinet.project" Active="No"/>
|
||||
|
@ -15,7 +15,7 @@ int cw_in_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams *
|
||||
}
|
||||
|
||||
result = cw_ktv_add(params->conn->remote_cfg, handler->key,
|
||||
handler->type, elem_data,elem_len);
|
||||
handler->type,NULL, elem_data,elem_len);
|
||||
|
||||
params->elem=result;
|
||||
|
||||
|
@ -9,6 +9,6 @@ int cw_in_generic_with_index(struct cw_ElemHandler *eh,
|
||||
|
||||
idx = cw_get_byte(data);
|
||||
sprintf(key,"%s.%d",eh->key,idx);
|
||||
cw_ktv_add(params->conn->remote_cfg,key,eh->type,data+1,len-1);
|
||||
cw_ktv_add(params->conn->remote_cfg,key,eh->type,NULL,data+1,len-1);
|
||||
return 1;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ int cw_in_idx_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerPara
|
||||
sprintf(key,handler->key,idx);
|
||||
|
||||
result = cw_ktv_add(params->conn->remote_cfg, key,
|
||||
handler->type, elem_data+1,elem_len-1);
|
||||
handler->type, NULL, elem_data+1,elem_len-1);
|
||||
|
||||
params->elem=result;
|
||||
|
||||
|
@ -4,19 +4,23 @@
|
||||
#include "log.h"
|
||||
#include "dbg.h"
|
||||
|
||||
cw_KTV_t * cw_ktv_add(mavl_t kvtstore, const char *key, const struct cw_Type *type,
|
||||
cw_KTV_t * cw_ktv_add(mavl_t kvtstore, const char *key, const struct cw_Type *type,
|
||||
const void * valguard,
|
||||
const uint8_t * data, int len)
|
||||
{
|
||||
cw_KTV_t mdata, *mresult;
|
||||
int exists;
|
||||
|
||||
mdata.key=cw_strdup(key);
|
||||
mdata.valguard=valguard;
|
||||
|
||||
if (!mdata.key){
|
||||
cw_log(LOG_ERR, "Can't allocate memory for KTV key %s: %s",
|
||||
key,strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
mresult = type->get(&mdata,data,len);
|
||||
if (!mresult){
|
||||
cw_log(LOG_ERR, "Can't create kvstore element for key %s of type %s: %s",
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
const char * cw_ktv_add_from_str(mavl_t kvtstore, const char *key,
|
||||
const struct cw_Type *type,
|
||||
const void * valguard,
|
||||
const char * str)
|
||||
{
|
||||
cw_KTV_t mdata, *mresult;
|
||||
@ -15,6 +16,7 @@ const char * cw_ktv_add_from_str(mavl_t kvtstore, const char *key,
|
||||
type->name, key );
|
||||
*/
|
||||
mdata.key=cw_strdup(key);
|
||||
mdata.valguard=valguard;
|
||||
if (!mdata.key){
|
||||
cw_log(LOG_ERR, "Can't allocate memory for key %s: %s",
|
||||
key,strerror(errno));
|
||||
|
@ -31,7 +31,7 @@ int cw_ktv_read_file(FILE * file, mavl_t ktv, mavl_t types)
|
||||
continue;
|
||||
}
|
||||
|
||||
cw_ktv_add_from_str(ktv,key,cwtype,val);
|
||||
cw_ktv_add_from_str(ktv,key,cwtype,NULL,val);
|
||||
|
||||
|
||||
}while(rc==0);
|
||||
|
@ -37,7 +37,7 @@ int cw_ktv_read_struct(mavl_t ktv,const cw_KTVStruct_t * stru, const char *pkey,
|
||||
|
||||
}
|
||||
|
||||
result = cw_ktv_add(ktv,key,stru[i].type,data+pos,l);
|
||||
result = cw_ktv_add(ktv,key,stru[i].type,stru[i].valguard,data+pos,l);
|
||||
|
||||
stru[i].type->to_str(result,dbstr,100);
|
||||
cw_dbg(DBG_ELEM_DETAIL, "Read (%d): %s: %s",pos,key,dbstr);
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "dbg.h"
|
||||
|
||||
cw_KTV_t * cw_ktv_replace(mavl_t kvtstore, const char *key, const struct cw_Type *type,
|
||||
const void * valguard,
|
||||
const uint8_t * data, int len)
|
||||
{
|
||||
cw_KTV_t mdata, *mresult;
|
||||
|
@ -2,5 +2,5 @@
|
||||
|
||||
cw_KTV_t * cw_ktv_set_byte(mavl_t ktv,const char * key, uint8_t byte)
|
||||
{
|
||||
return cw_ktv_replace(ktv,key,CW_TYPE_BYTE,&byte,1);
|
||||
return cw_ktv_replace(ktv,key,CW_TYPE_BYTE,NULL,&byte,1);
|
||||
}
|
||||
|
@ -2,5 +2,5 @@
|
||||
|
||||
cw_KTV_t * cw_ktv_set_dword(mavl_t ktv,const char * key, uint32_t dword)
|
||||
{
|
||||
return cw_ktv_replace(ktv,key,CW_TYPE_DWORD,(void*)&dword,4);
|
||||
return cw_ktv_replace(ktv,key,CW_TYPE_DWORD,NULL,(void*)&dword,4);
|
||||
}
|
||||
|
@ -2,5 +2,5 @@
|
||||
|
||||
cw_KTV_t * cw_ktv_set_word(mavl_t ktv,const char * key, uint16_t word)
|
||||
{
|
||||
return cw_ktv_replace(ktv,key,CW_TYPE_WORD,(void*)&word,2);
|
||||
return cw_ktv_replace(ktv,key,CW_TYPE_WORD,NULL,(void*)&word,2);
|
||||
}
|
||||
|
@ -70,11 +70,11 @@ int cw_read_descriptor_subelems(mavl_t cfg, const char * parent_key,
|
||||
|
||||
/* vendor */
|
||||
sprintf(key,"%s/%s/%s",parent_key,elems[i].key,CW_SKEY_VENDOR);
|
||||
cw_ktv_add(cfg,key,CW_TYPE_DWORD,data + sub,4);
|
||||
cw_ktv_add(cfg,key,CW_TYPE_DWORD,NULL,data + sub,4);
|
||||
|
||||
/* version */
|
||||
sprintf(key,"%s/%s/%s",parent_key,elems[i].key,CW_SKEY_VERSION);
|
||||
cw_ktv_add(cfg,key,CW_TYPE_BSTR16,data+sub+8,l);
|
||||
cw_ktv_add(cfg,key,CW_TYPE_BSTR16,NULL,data+sub+8,l);
|
||||
|
||||
sprintf(dbgstr, "%s", key);
|
||||
cw_dbg_version_subelem(DBG_SUBELEM, dbgstr, subtype, vendor_id, data+sub+8,l);
|
||||
|
@ -22,7 +22,7 @@ int cw_in_radio_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerPa
|
||||
sprintf(key,"radio.%d/%s",radio,handler->key);
|
||||
|
||||
result = cw_ktv_add(params->conn->remote_cfg, key,
|
||||
handler->type, elem_data+1,elem_len-1);
|
||||
handler->type, NULL, elem_data+1,elem_len-1);
|
||||
|
||||
params->elem=result;
|
||||
|
||||
|
@ -39,10 +39,10 @@ int cw_read_wtp_descriptor(mavl_t cfg, struct conn *conn,
|
||||
}
|
||||
|
||||
sprintf(key,"%s/%s",eh->key, CW_SKEY_MAX_RADIOS);
|
||||
cw_ktv_add(cfg,key,CW_TYPE_BYTE,data,1);
|
||||
cw_ktv_add(cfg,key,CW_TYPE_BYTE,NULL,data,1);
|
||||
|
||||
sprintf(key,"%s/%s",eh->key, CW_SKEY_RADIOS_IN_USE);
|
||||
cw_ktv_add(cfg,key,CW_TYPE_BYTE,data+1,1);
|
||||
cw_ktv_add(cfg,key,CW_TYPE_BYTE,NULL,data+1,1);
|
||||
|
||||
|
||||
|
||||
|
@ -30,10 +30,10 @@ int cw_read_wtp_descriptor_7(mavl_t cfg, struct conn *conn,
|
||||
char key[64];
|
||||
|
||||
sprintf(key,"%s/%s",eh->key, CW_SKEY_MAX_RADIOS);
|
||||
cw_ktv_add(cfg,key,CW_TYPE_BYTE,data,1);
|
||||
cw_ktv_add(cfg,key,CW_TYPE_BYTE,NULL,data,1);
|
||||
|
||||
sprintf(key,"%s/%s",eh->key, CW_SKEY_RADIOS_IN_USE);
|
||||
cw_ktv_add(cfg,key,CW_TYPE_BYTE,data+1,1);
|
||||
cw_ktv_add(cfg,key,CW_TYPE_BYTE,NULL,data+1,1);
|
||||
|
||||
|
||||
pos = 2;
|
||||
|
@ -79,6 +79,11 @@ static void * data( cw_KTV_t * data)
|
||||
return & data->val.boolean;
|
||||
}
|
||||
|
||||
static const char * get_type_name(cw_KTV_t *data)
|
||||
{
|
||||
return CW_TYPE_BOOL->name;
|
||||
}
|
||||
|
||||
const struct cw_Type cw_type_bool = {
|
||||
"Bool", /* name */
|
||||
NULL, /* del */
|
||||
@ -87,5 +92,6 @@ const struct cw_Type cw_type_bool = {
|
||||
to_str, /* to_str */
|
||||
from_str, /* from_str */
|
||||
len, /* len */
|
||||
data /* data */
|
||||
data, /* data */
|
||||
get_type_name /* get_type_name */
|
||||
};
|
||||
|
@ -86,6 +86,11 @@ static void * data(cw_KTV_t * data)
|
||||
return bstr16_data(data->val.ptr);
|
||||
}
|
||||
|
||||
static const char * get_type_name(cw_KTV_t *data)
|
||||
{
|
||||
return CW_TYPE_BSTR16->name;
|
||||
}
|
||||
|
||||
const struct cw_Type cw_type_bstr16 = {
|
||||
"Bstr16", /* name */
|
||||
del, /* del */
|
||||
@ -94,5 +99,6 @@ const struct cw_Type cw_type_bstr16 = {
|
||||
to_str, /* to_str */
|
||||
from_str, /* from_str */
|
||||
len, /* len */
|
||||
data /* data */
|
||||
data, /* data */
|
||||
get_type_name /* get_type_name */
|
||||
};
|
||||
|
@ -33,12 +33,32 @@ static int put(const cw_KTV_t *data, uint8_t * dst)
|
||||
return cw_put_byte(dst, data->val.byte);
|
||||
}
|
||||
|
||||
static const char * get_guardstr(int val, const cw_KTVValRange_t * valrange)
|
||||
{
|
||||
while(valrange->name!=NULL){
|
||||
if(val>=valrange->min && val<=valrange->max)
|
||||
return valrange->name;
|
||||
valrange++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static int to_str(const cw_KTV_t *data, char *dst, int max_len)
|
||||
{
|
||||
/*if (max_len<3){
|
||||
return 0;
|
||||
}*/
|
||||
if (data->valguard!=NULL){
|
||||
const char * name;
|
||||
name = get_guardstr(data->val.byte,data->valguard);
|
||||
if (name != NULL){
|
||||
return sprintf(dst,"%s",name);
|
||||
}
|
||||
}
|
||||
|
||||
/*if (max_len<3){
|
||||
return 0;
|
||||
}*/
|
||||
return sprintf(dst, "%d", data->val.byte);
|
||||
|
||||
}
|
||||
|
||||
static cw_KTV_t *from_str(cw_KTV_t * data, const char *src)
|
||||
@ -50,7 +70,20 @@ static cw_KTV_t *from_str(cw_KTV_t * data, const char *src)
|
||||
|
||||
static int len (cw_KTV_t * data)
|
||||
{
|
||||
return sizeof(uint8_t);
|
||||
return sizeof(data->val.byte);
|
||||
}
|
||||
|
||||
static void * data(cw_KTV_t * data)
|
||||
{
|
||||
return &data->val.byte;
|
||||
}
|
||||
|
||||
static const char * get_type_name(cw_KTV_t *data)
|
||||
{
|
||||
if (data->valguard != NULL){
|
||||
return CW_TYPE_STR->name;
|
||||
}
|
||||
return CW_TYPE_BYTE->name;
|
||||
}
|
||||
|
||||
const struct cw_Type cw_type_byte = {
|
||||
@ -60,5 +93,7 @@ const struct cw_Type cw_type_byte = {
|
||||
get, /* get */
|
||||
to_str, /* to_str */
|
||||
from_str, /* from_str */
|
||||
len /* len */
|
||||
len, /* len */
|
||||
data, /* data */
|
||||
get_type_name /* get_type_name */
|
||||
};
|
||||
|
@ -45,12 +45,20 @@ static struct cw_KTV *from_str(struct cw_KTV * data, const char *src)
|
||||
return data;
|
||||
}
|
||||
|
||||
static const char * get_type_name(cw_KTV_t *data)
|
||||
{
|
||||
return CW_TYPE_DWORD->name;
|
||||
}
|
||||
|
||||
const struct cw_Type cw_type_dword = {
|
||||
"Dword", /* name */
|
||||
NULL, /* del */
|
||||
put, /* put */
|
||||
get, /* get */
|
||||
to_str, /* to_str */
|
||||
from_str /* from_str */
|
||||
from_str, /* from_str */
|
||||
NULL, /* len */
|
||||
NULL, /* data */
|
||||
get_type_name /* get_type_name */
|
||||
};
|
||||
|
||||
|
@ -106,6 +106,10 @@ static void * data(cw_KTV_t * data)
|
||||
{
|
||||
return bstr_data(data->val.ptr);
|
||||
}
|
||||
static const char * get_type_name(cw_KTV_t *data)
|
||||
{
|
||||
return CW_TYPE_IPADDRESS->name;
|
||||
}
|
||||
|
||||
const struct cw_Type cw_type_ipaddress = {
|
||||
"IPAddress", /* name */
|
||||
@ -115,7 +119,8 @@ const struct cw_Type cw_type_ipaddress = {
|
||||
to_str, /* to_str */
|
||||
from_str, /* from_str */
|
||||
len, /* len */
|
||||
data /* data */
|
||||
data, /* data */
|
||||
get_type_name
|
||||
};
|
||||
|
||||
|
||||
|
@ -85,6 +85,13 @@ static int len ( struct cw_KTV * data ){
|
||||
return strlen (data->val.str);
|
||||
}
|
||||
|
||||
static const char * get_type_name(cw_KTV_t *data)
|
||||
{
|
||||
return CW_TYPE_STR->name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const struct cw_Type cw_type_str = {
|
||||
"Str", /* name */
|
||||
del, /* del */
|
||||
@ -92,5 +99,7 @@ const struct cw_Type cw_type_str = {
|
||||
get, /* get */
|
||||
to_str, /* to_str */
|
||||
from_str, /* from_str */
|
||||
len /* len */
|
||||
len, /* len */
|
||||
NULL, /* data */
|
||||
get_type_name /* get_type_name */
|
||||
};
|
||||
|
@ -64,6 +64,11 @@ static int len ( struct cw_KTV * data ){
|
||||
return sizeof(void*);
|
||||
}
|
||||
|
||||
static const char * get_type_name(cw_KTV_t *data)
|
||||
{
|
||||
return CW_TYPE_SYSPTR->name;
|
||||
}
|
||||
|
||||
const struct cw_Type cw_type_sysptr = {
|
||||
"Sysptr", /* name */
|
||||
del, /* del */
|
||||
@ -71,5 +76,7 @@ const struct cw_Type cw_type_sysptr = {
|
||||
get, /* get */
|
||||
to_str, /* to_str */
|
||||
from_str, /* from_str */
|
||||
len /* len */
|
||||
len, /* len */
|
||||
NULL, /* data */
|
||||
get_type_name /* get_type_name */
|
||||
};
|
||||
|
@ -46,12 +46,21 @@ static cw_KTV_t *from_str(cw_KTV_t * data, const char *src)
|
||||
return data;
|
||||
}
|
||||
|
||||
static const char * get_type_name(cw_KTV_t *data)
|
||||
{
|
||||
return CW_TYPE_WORD->name;
|
||||
}
|
||||
|
||||
const struct cw_Type cw_type_word = {
|
||||
"Word", /* name */
|
||||
NULL, /* del */
|
||||
put, /* put */
|
||||
get, /* get */
|
||||
to_str, /* to_str */
|
||||
from_str /* from_str */
|
||||
from_str, /* from_str */
|
||||
NULL,
|
||||
NULL,
|
||||
get_type_name
|
||||
|
||||
};
|
||||
|
||||
|
@ -521,7 +521,7 @@ void cw_dbg_ktv_dump(mavl_t ktv, uint32_t dbglevel,
|
||||
type = data->type;
|
||||
type->to_str(data,value,0);
|
||||
|
||||
cw_dbg(dbglevel,"%s%s :%s: %s",prefix,data->key,type->name, value);
|
||||
cw_dbg(dbglevel,"%s%s :%s: %s",prefix,data->key,type->get_type_name(data), value);
|
||||
}
|
||||
|
||||
if (footer != NULL)
|
||||
|
49
src/cw/ktv.h
49
src/cw/ktv.h
@ -41,6 +41,7 @@ struct cw_KTV {
|
||||
int boolean;
|
||||
float float_val;
|
||||
} val;
|
||||
const void * valguard;
|
||||
};
|
||||
typedef struct cw_KTV cw_KTV_t;
|
||||
|
||||
@ -84,45 +85,36 @@ struct cw_Type {
|
||||
int (*len)(cw_KTV_t *);
|
||||
|
||||
void *(*data)(cw_KTV_t *);
|
||||
const char * (*get_type_name)(cw_KTV_t*);
|
||||
|
||||
int (*cast)(cw_KTV_t *);
|
||||
|
||||
};
|
||||
typedef struct cw_Type cw_Type_t;
|
||||
|
||||
|
||||
struct cw_KTVStruct {
|
||||
const struct cw_Type * type;
|
||||
const char * key;
|
||||
int len;
|
||||
int position;
|
||||
};
|
||||
|
||||
|
||||
enum cw_Types {
|
||||
CW_BYTE,
|
||||
CW_WORD,
|
||||
CW_DWORD,
|
||||
CW_STR
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct cw_KTVValRange {
|
||||
int min,max;
|
||||
const char * name;
|
||||
};
|
||||
typedef struct cw_KTVValRange cw_KTVValRange_t;
|
||||
|
||||
struct cw_KTVData {
|
||||
int position;
|
||||
uint8_t type;
|
||||
const char *key;
|
||||
int len;
|
||||
struct cw_KTVValRange *ranges;
|
||||
};
|
||||
typedef struct cw_KTVData cw_KTVData_t;
|
||||
|
||||
struct cw_KTVStruct {
|
||||
const struct cw_Type * type;
|
||||
const char * key;
|
||||
int len;
|
||||
int position;
|
||||
const void * valguard;
|
||||
};
|
||||
typedef struct cw_KTVStruct cw_KTVStruct_t;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define CW_KTVSTRUCT_L16 -2
|
||||
#define CW_KTVSTRUCT_L8 -3
|
||||
|
||||
@ -169,15 +161,18 @@ extern const struct cw_Type cw_type_bool;
|
||||
/*
|
||||
void cw_kvstore_mavl_delete(const void *data);
|
||||
*/
|
||||
cw_KTV_t *cw_ktv_add(mavl_t kvstore, const char *key, const struct cw_Type *type,
|
||||
cw_KTV_t *cw_ktv_add(mavl_t kvstore, const char *key, const struct cw_Type *type,
|
||||
const void * valguard,
|
||||
const uint8_t * data, int len);
|
||||
|
||||
void cw_ktv_del_sub(mavl_t ktvstore, const char *basekey);
|
||||
|
||||
cw_KTV_t * cw_ktv_replace(mavl_t kvtstore, const char *key, const struct cw_Type *type,
|
||||
const void * valguard,
|
||||
const uint8_t * data, int len);
|
||||
|
||||
const char * cw_ktv_add_from_str(mavl_t kvtstore, const char *key, const struct cw_Type *type,
|
||||
const char * cw_ktv_add_from_str(mavl_t kvtstore, const char *key, const struct cw_Type *type,
|
||||
const void * valguard,
|
||||
const char * str);
|
||||
|
||||
int cw_ktv_mavlcmp(const void *v1, const void *v2);
|
||||
|
@ -37,10 +37,10 @@ int capwap_in_capwap_control_ip_address(struct cw_ElemHandler *eh,
|
||||
/* printf("SKEY is %s , idx: %d\n",key,idx);*/
|
||||
|
||||
sprintf(key,"%s/address.%d",eh->key,idx+1);
|
||||
cw_ktv_add(params->conn->remote_cfg,key,CW_TYPE_IPADDRESS,data,len-2);
|
||||
cw_ktv_add(params->conn->remote_cfg,key,CW_TYPE_IPADDRESS,NULL,data,len-2);
|
||||
|
||||
sprintf(key,"%s/wtps.%d",eh->key,idx+1);
|
||||
cw_ktv_add(params->conn->remote_cfg,key,CW_TYPE_WORD,data+len-2,2);
|
||||
cw_ktv_add(params->conn->remote_cfg,key,CW_TYPE_WORD,NULL,data+len-2,2);
|
||||
|
||||
/* if (handler-id == CW_ELEM_CAPWAP_CONTROL_IPV4_ADDRESS) {
|
||||
struct sockaddr_in addr;
|
||||
|
@ -102,7 +102,7 @@ static void readsubelems_wtp_board_data(mavl_t cfg, uint8_t * msgelem,
|
||||
if (key != NULL){
|
||||
char add_key[256];
|
||||
sprintf(add_key,"wtp-board-data/%s",key);
|
||||
cw_ktv_add(cfg,add_key,CW_TYPE_BSTR16,msgelem+i,sublen);
|
||||
cw_ktv_add(cfg,add_key,CW_TYPE_BSTR16,NULL,msgelem+i,sublen);
|
||||
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ int capwap_in_wtp_board_data(struct cw_ElemHandler *eh, struct cw_ElemHandlerPar
|
||||
|
||||
sprintf(vendor_key,"%s/%s",eh->key,CW_SKEY_VENDOR);
|
||||
|
||||
cw_ktv_add(cfg,vendor_key,CW_TYPE_DWORD,data,len);
|
||||
cw_ktv_add(cfg,vendor_key,CW_TYPE_DWORD,NULL,data,len);
|
||||
|
||||
/*
|
||||
mbag_t itemstore = conn->incomming;
|
||||
|
@ -17,14 +17,14 @@ static int init(struct cw_Mod * mod, mavl_t global_cfg, int role)
|
||||
cw_dbg(DBG_MOD, "CAPWAP: Initialiazing mod_capwap in AC mode");
|
||||
cw_ktv_add_from_str(global_cfg,
|
||||
"capwap/ac-descriptor/hardware/version",
|
||||
CW_TYPE_BSTR16,"0.0.0.1");
|
||||
CW_TYPE_BSTR16,NULL,"0.0.0.1");
|
||||
cw_ktv_add_from_str(global_cfg,
|
||||
"capwap/ac-descriptor/hardware/vendor",CW_TYPE_DWORD,"0");
|
||||
"capwap/ac-descriptor/hardware/vendor",CW_TYPE_DWORD,NULL,"0");
|
||||
cw_ktv_add_from_str(global_cfg,
|
||||
"capwap/ac-descriptor/software/version",
|
||||
CW_TYPE_BSTR16,"0.0.0.1");
|
||||
CW_TYPE_BSTR16, NULL, "0.0.0.1");
|
||||
cw_ktv_add_from_str(global_cfg,
|
||||
"capwap/ac-descriptor/software/vendor",CW_TYPE_DWORD,"0");
|
||||
"capwap/ac-descriptor/software/vendor",CW_TYPE_DWORD, NULL, "0");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -473,6 +473,27 @@ static cw_KTVStruct_t cisco_add_lwwlan[]={
|
||||
{NULL,NULL,0,0}
|
||||
};
|
||||
|
||||
static cw_KTVValRange_t oper_val_state[]={
|
||||
{1,1,"disabled"},
|
||||
{2,2,"enabled"},
|
||||
{0,0,NULL}
|
||||
};
|
||||
|
||||
static cw_KTVValRange_t oper_val_cause[]={
|
||||
{0,0,"Normal"},
|
||||
{1,1,"Radio Failure"},
|
||||
{2,2,"Software Failure"},
|
||||
{3,3,"Administratively Set"},
|
||||
{0,0,NULL}
|
||||
};
|
||||
|
||||
static cw_KTVStruct_t cisco_radio_oper_state[]={
|
||||
{CW_TYPE_BYTE, "state", 1, -1, oper_val_state},
|
||||
{CW_TYPE_BYTE, "cause", 1, -1,oper_val_cause},
|
||||
{NULL,NULL,0,0}
|
||||
};
|
||||
|
||||
|
||||
static int cisoc_add_lwwlan_mkkey(const char *pkey, uint8_t*data, int len, char *dst)
|
||||
{
|
||||
int wlan_id,radio_id;
|
||||
@ -515,40 +536,10 @@ static cw_KTVValRange_t range_cause[] = {
|
||||
|
||||
};
|
||||
|
||||
static cw_KTVData_t radio_operational_state[] = {
|
||||
{0, CW_BYTE, "state", 1, range_operstate},
|
||||
{0, CW_BYTE, "cause", 1, range_cause},
|
||||
|
||||
{0,0,NULL,0}
|
||||
};
|
||||
|
||||
static cw_KTVData_t radio_admin_state[] = {
|
||||
{0, CW_BYTE, "state", 1, range_operstate},
|
||||
{0, CW_BYTE, "cause", 1, range_cause},
|
||||
|
||||
{0,0,NULL,0}
|
||||
};
|
||||
|
||||
|
||||
static const char * get_name(cw_KTVValRange_t *range,int x)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
static int read_struct(cw_KTVData_t *stru, const char *parentkey)
|
||||
{
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
int pos;
|
||||
|
||||
pos = 0;
|
||||
while (stru->key != NULL){
|
||||
if (stru->position!=-1)
|
||||
pos = stru->position;
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
|
||||
static int cisco_data(struct cw_ElemHandler *eh,
|
||||
struct cw_ElemHandlerParams *params,
|
||||
@ -566,7 +557,7 @@ static int cisco_data(struct cw_ElemHandler *eh,
|
||||
cw_dbg(DBG_INFO,"Del WLAN rid=%d, id=%d",wlan_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
static struct cw_ElemHandler handlers73[] = {
|
||||
|
||||
@ -1221,22 +1212,21 @@ static struct cw_ElemHandler handlers73[] = {
|
||||
CAPWAP_ELEM_RADIO_OPERATIONAL_STATE, /* Element ID */
|
||||
0,0, /* Vendor / Proto */
|
||||
3,3, /* min/max length */
|
||||
radio_operational_state, /* type */
|
||||
"radio_operational_state", /* Key */
|
||||
cisco_data, /* get */
|
||||
cisco_radio_oper_state, /* type */
|
||||
"operational-state", /* Key */
|
||||
cw_in_radio_generic_struct, /* get */
|
||||
NULL, /* put */
|
||||
NULL
|
||||
NULL /* mkkey */
|
||||
}
|
||||
,
|
||||
|
||||
{
|
||||
"Radio Administrative State Cisco", /* name */
|
||||
CAPWAP_ELEM_RADIO_ADMINISTRATIVE_STATE, /* Element ID */
|
||||
0,0, /* Vendor / Proto */
|
||||
2,2, /* min/max length */
|
||||
radio_admin_state, /* type */
|
||||
"radio_admin_state", /* Key */
|
||||
cisco_data, /* get */
|
||||
NULL, /* type */
|
||||
"radio-admin-state", /* Key */
|
||||
NULL, /* get */
|
||||
NULL, /* put */
|
||||
NULL
|
||||
}
|
||||
@ -1570,7 +1560,7 @@ static void set_ac_version(struct conn * conn)
|
||||
cw_dbg(DBG_INFO, "Cisco - Setting AC software version to: %s", verstr);
|
||||
|
||||
mavl_del(conn->local_cfg,&wtpver);
|
||||
cw_ktv_add(conn->local_cfg,"ac-descriptor/software/version",CW_TYPE_BSTR16,
|
||||
cw_ktv_add(conn->local_cfg,"ac-descriptor/software/version",CW_TYPE_BSTR16, NULL,
|
||||
wtpver->type->data(wtpver),wtpver->type->len(wtpver));
|
||||
|
||||
if(wtpver->type->len(wtpver)==4){
|
||||
@ -1605,7 +1595,7 @@ static int preprocess_join_request(struct conn *conn)
|
||||
|
||||
if (use_ac_version){
|
||||
ver = cw_ktv_get(conn->remote_cfg,"ac-descriptor/software/version", CW_TYPE_BSTR16);
|
||||
cw_ktv_replace(conn->local_cfg,"wtp-descriptor/software/version",CW_TYPE_BSTR16,
|
||||
cw_ktv_replace(conn->local_cfg,"wtp-descriptor/software/version",CW_TYPE_BSTR16, NULL,
|
||||
ver->type->data(ver),ver->type->len(ver));
|
||||
|
||||
cw_format_version(verstr,ver->type->data(ver),ver->type->len(ver));
|
||||
|
@ -72,9 +72,9 @@ int cw_select_ac(mavl_t local_cfg, struct cw_DiscoveryResult * dis)
|
||||
|
||||
sprintf(key, "%04d%05d%04d", prio, val->val.word, en);
|
||||
|
||||
cw_ktv_add(dis->prio_ip, key, CW_TYPE_SYSPTR, (uint8_t *) (&ipval),
|
||||
cw_ktv_add(dis->prio_ip, key, CW_TYPE_SYSPTR, NULL, (uint8_t *) (&ipval),
|
||||
sizeof(ipval));
|
||||
cw_ktv_add(dis->prio_ac, key, CW_TYPE_SYSPTR, (uint8_t *)(&remote_cfg),
|
||||
cw_ktv_add(dis->prio_ac, key, CW_TYPE_SYSPTR, NULL, (uint8_t *)(&remote_cfg),
|
||||
sizeof(remote_cfg));
|
||||
i++;
|
||||
en++;
|
||||
|
@ -192,8 +192,8 @@ exit(0);
|
||||
|
||||
|
||||
cw_discovery_init_results(&dis);
|
||||
cw_run_discovery(conn, "255.255.255.255","192.168.56.1", &dis);
|
||||
/* cw_run_discovery(conn, "255.255.255.255",NULL, &dis);*/
|
||||
/*cw_run_discovery(conn, "255.255.255.255","192.168.56.1", &dis);*/
|
||||
cw_run_discovery(conn, "255.255.255.255",NULL, &dis);
|
||||
cw_dbg_ktv_dump(dis.prio_ip, DBG_INFO, "=== IP list ===", "IP", "=== END IP List ===");
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user