2018-03-17 12:32:40 +01:00
|
|
|
|
2022-07-28 01:36:16 +02:00
|
|
|
#include "cw/conn.h"
|
2018-03-17 12:32:40 +01:00
|
|
|
#include "cw/log.h"
|
2022-07-31 17:15:32 +02:00
|
|
|
#include "cw/val.h"
|
2018-03-17 12:32:40 +01:00
|
|
|
#include "cw/msgset.h"
|
|
|
|
#include "cw/keys.h"
|
|
|
|
#include "cw/cw.h"
|
2022-08-13 09:47:12 +02:00
|
|
|
#include "cw/dbg.h"
|
2018-03-17 12:32:40 +01:00
|
|
|
|
2022-08-15 16:31:26 +02:00
|
|
|
static int write_boarddata_subelem(uint8_t * dst, cw_Cfg_t ** cfg, const char * parent_key,
|
|
|
|
const char *skey, int type, void *param){
|
2018-03-17 12:32:40 +01:00
|
|
|
|
2022-08-15 16:31:26 +02:00
|
|
|
char key[CW_CFG_MAX_KEY_LEN];
|
|
|
|
int len;
|
2018-03-17 12:32:40 +01:00
|
|
|
|
|
|
|
sprintf(key,"%s/%s",parent_key,skey);
|
|
|
|
|
2022-08-15 16:31:26 +02:00
|
|
|
//val = cw_ktv_get(ktv,key,CW_TYPE_BSTR16);
|
|
|
|
len = cw_generic_write_l(cfg, CW_TYPE_BSTR16,key,
|
|
|
|
dst+4, param);
|
2018-03-17 12:32:40 +01:00
|
|
|
|
2022-08-15 16:31:26 +02:00
|
|
|
if (len==-1) {
|
2018-03-17 12:32:40 +01:00
|
|
|
cw_log(LOG_ERR,
|
2018-03-19 13:29:49 +01:00
|
|
|
"Creating WTP Board Data sub-element %d. Key not '%s' found",type,key);
|
2018-03-17 12:32:40 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-08-15 16:31:26 +02:00
|
|
|
cw_set_word(dst, (uint16_t)type);
|
|
|
|
cw_set_word(dst+2,(uint16_t)len);
|
|
|
|
return len+4;
|
2018-03-17 12:32:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int capwap_out_wtp_board_data(struct cw_ElemHandler * eh,
|
|
|
|
struct cw_ElemHandlerParams * params, uint8_t * dst)
|
|
|
|
{
|
2022-08-15 16:31:26 +02:00
|
|
|
int rc;
|
2018-03-17 12:32:40 +01:00
|
|
|
uint8_t * d;
|
|
|
|
char key[256];
|
|
|
|
int l;
|
|
|
|
|
|
|
|
d=dst+4;
|
|
|
|
|
|
|
|
sprintf(key,"%s/%s",eh->key,CW_SKEY_VENDOR);
|
2022-08-15 16:31:26 +02:00
|
|
|
rc = cw_generic_write_l(params->cfg_list, CW_TYPE_DWORD,key,
|
|
|
|
d, eh->param);
|
|
|
|
|
2018-03-17 12:32:40 +01:00
|
|
|
|
2022-08-15 16:31:26 +02:00
|
|
|
if (rc==-1) {
|
2018-03-17 12:32:40 +01:00
|
|
|
cw_log(LOG_ERR,
|
2018-03-19 13:29:49 +01:00
|
|
|
"Creating WTP Board Data element. Key '%s' not found.", key);
|
2018-03-17 12:32:40 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-08-15 16:31:26 +02:00
|
|
|
d += rc;
|
2018-03-17 12:32:40 +01:00
|
|
|
|
2022-08-15 16:31:26 +02:00
|
|
|
d+=write_boarddata_subelem(d,params->cfg_list,eh->key,"model-no",CW_BOARDDATA_MODELNO,eh->param);
|
|
|
|
d+=write_boarddata_subelem(d,params->cfg_list,eh->key,"serial-no",CW_BOARDDATA_SERIALNO,eh->param);
|
|
|
|
d+=write_boarddata_subelem(d,params->cfg_list,eh->key,"board-id",CW_BOARDDATA_BOARDID,eh->param);
|
|
|
|
d+=write_boarddata_subelem(d,params->cfg_list,eh->key,"revision",CW_BOARDDATA_REVISION,eh->param);
|
|
|
|
d+=write_boarddata_subelem(d,params->cfg_list,eh->key,"mac-address",CW_BOARDDATA_MACADDRESS,eh->param);
|
2018-03-17 12:32:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
l = d - dst-4;
|
|
|
|
return l + cw_put_elem_hdr(dst, CAPWAP_ELEM_WTP_BOARD_DATA, l );
|
|
|
|
|
|
|
|
}
|