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-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
|
|
|
{
|
|
|
|
uint8_t msg[1030];
|
2015-02-01 16:55:45 +01:00
|
|
|
*((uint32_t *) msg) = htonl(wtpinfo->vendor_id);
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
int l;
|
2015-02-01 16:55:45 +01:00
|
|
|
int len = 4;
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2015-02-01 16:55:45 +01:00
|
|
|
if (wtpinfo->model_no) {
|
|
|
|
l = bstr_len(wtpinfo->model_no);
|
|
|
|
*((uint32_t *) (msg + len)) = htonl(CWBOARDDATA_MODELNO << 16 | l);
|
|
|
|
memcpy(msg + len + 4, bstr_data(wtpinfo->model_no), l);
|
|
|
|
len += l + 4;
|
2014-07-11 22:12:11 +02:00
|
|
|
}
|
|
|
|
|
2015-02-01 16:55:45 +01:00
|
|
|
if (wtpinfo->serial_no) {
|
|
|
|
l = strlen((char *) wtpinfo->serial_no);
|
|
|
|
*((uint32_t *) (msg + len)) = htonl(CWBOARDDATA_SERIALNO << 16 | l);
|
|
|
|
memcpy(msg + len + 4, wtpinfo->serial_no, l);
|
|
|
|
len += l + 4;
|
2014-07-11 22:12:11 +02: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-02-01 16:55:45 +01:00
|
|
|
cwmsg_addelem(cwmsg, CWMSGELEM_WTP_BOARD_DATA, msg, len);
|
2014-07-11 22:12:11 +02:00
|
|
|
}
|