actube/src/mod/capwap/capwap_out_wtp_board_data.c

71 lines
1.7 KiB
C
Raw Normal View History

#include "cw/conn.h"
#include "cw/log.h"
2022-07-31 17:15:32 +02:00
#include "cw/val.h"
#include "cw/msgset.h"
#include "cw/keys.h"
#include "cw/cw.h"
2022-08-13 09:47:12 +02:00
#include "cw/dbg.h"
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){
2022-08-15 16:31:26 +02:00
char key[CW_CFG_MAX_KEY_LEN];
int len;
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);
2022-08-15 16:31:26 +02:00
if (len==-1) {
cw_log(LOG_ERR,
"Creating WTP Board Data sub-element %d. Key not '%s' found",type,key);
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;
}
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;
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);
2022-08-15 16:31:26 +02:00
if (rc==-1) {
cw_log(LOG_ERR,
"Creating WTP Board Data element. Key '%s' not found.", key);
return 0;
}
2022-08-15 16:31:26 +02:00
d += rc;
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);
l = d - dst-4;
return l + cw_put_elem_hdr(dst, CAPWAP_ELEM_WTP_BOARD_DATA, l );
}