2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "capwap.h"
|
2015-02-01 16:55:45 +01:00
|
|
|
#include "bstr.h"
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
|
2015-03-14 21:41:50 +01:00
|
|
|
static int add_board_data_subelem(uint8_t *msg,int type, bstr_t data)
|
|
|
|
{
|
|
|
|
if (!data)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
int l = bstr_len(data);
|
|
|
|
*((uint32_t *) (msg)) = htonl(type << 16 | l);
|
|
|
|
memcpy(msg + 4, bstr_data(data), l);
|
|
|
|
return l+4;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-01 16:55:45 +01:00
|
|
|
void cwmsg_addelem_wtp_board_data(struct cwmsg *cwmsg, struct wtpinfo *wtpinfo)
|
2014-07-11 22:12:11 +02:00
|
|
|
{
|
2015-03-14 21:41:50 +01:00
|
|
|
uint8_t msg[1024];
|
2015-03-12 23:21:57 +01:00
|
|
|
|
|
|
|
/* vendor identifier */
|
2015-02-01 16:55:45 +01:00
|
|
|
*((uint32_t *) msg) = htonl(wtpinfo->vendor_id);
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2015-02-01 16:55:45 +01:00
|
|
|
int len = 4;
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2015-03-12 23:21:57 +01:00
|
|
|
/* mandatory sub-elements */
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2015-03-14 21:41:50 +01:00
|
|
|
|
|
|
|
len += add_board_data_subelem(msg+len,CWBOARDDATA_MODELNO,wtpinfo->model_no);
|
|
|
|
|
|
|
|
len += add_board_data_subelem(msg+len,CWBOARDDATA_SERIALNO,wtpinfo->serial_no);
|
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2015-03-12 23:21:57 +01:00
|
|
|
/* other sub-elements */
|
2015-03-14 21:41:50 +01:00
|
|
|
|
|
|
|
len += add_board_data_subelem(msg+len,CWBOARDDATA_BOARDID,wtpinfo->board_id);
|
|
|
|
|
|
|
|
len += add_board_data_subelem(msg+len,CWBOARDDATA_REVISION,wtpinfo->board_revision);
|
|
|
|
|
|
|
|
|
2015-03-28 08:29:59 +01:00
|
|
|
|
2015-02-01 16:55:45 +01:00
|
|
|
if (wtpinfo->macaddress) {
|
|
|
|
*((uint32_t *) (msg + len)) =
|
|
|
|
htonl(CWBOARDDATA_MACADDRESS << 16 | wtpinfo->macaddress_len);
|
|
|
|
memcpy(msg + len + 4, wtpinfo->macaddress, wtpinfo->macaddress_len);
|
|
|
|
len += wtpinfo->macaddress_len + 4;
|
2014-07-11 22:12:11 +02:00
|
|
|
}
|
|
|
|
|
2015-03-30 07:56:42 +02:00
|
|
|
cwmsg_addelem(cwmsg, CW_ELEM_WTP_BOARD_DATA, msg, len);
|
2014-07-11 22:12:11 +02:00
|
|
|
}
|