2015-04-10 17:52:01 +02:00
|
|
|
#include "log.h"
|
2015-04-07 07:46:55 +02:00
|
|
|
#include "conn.h"
|
|
|
|
|
2015-04-19 23:27:44 +02:00
|
|
|
#include "mbag.h"
|
2015-04-07 07:46:55 +02:00
|
|
|
#include "capwap_items.h"
|
|
|
|
#include "capwap.h"
|
|
|
|
|
|
|
|
|
2015-04-10 17:14:55 +02:00
|
|
|
int cw_out_wtp_board_data(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
|
2015-04-07 07:46:55 +02:00
|
|
|
{
|
2015-04-19 23:27:44 +02:00
|
|
|
mbag_t board_data =
|
2015-04-20 02:26:24 +02:00
|
|
|
mbag_get_mbag(conn->config, CW_ITEM_WTP_BOARD_DATA,NULL);
|
2016-03-03 19:24:28 +01:00
|
|
|
|
|
|
|
|
2015-04-10 17:14:55 +02:00
|
|
|
if (!board_data) {
|
2016-03-03 19:24:28 +01:00
|
|
|
cw_log(LOG_ERR, "Error: Can't send WTP Board Data element. \"%s\" is undefined.",CW_ITEM_WTP_BOARD_DATA);
|
2015-04-07 07:46:55 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-04-19 23:27:44 +02:00
|
|
|
struct mbag_item *i;
|
|
|
|
i = mbag_get(board_data, CW_ITEM_WTP_BOARD_VENDOR);
|
2015-04-10 17:14:55 +02:00
|
|
|
if (!i) {
|
|
|
|
cw_log(LOG_ERR,
|
|
|
|
"Error: Can't send WTP Board Data element - no vendor defined");
|
2015-04-07 07:46:55 +02:00
|
|
|
return 0;
|
2015-04-10 17:14:55 +02:00
|
|
|
}
|
2015-04-07 07:46:55 +02:00
|
|
|
|
2015-04-10 17:14:55 +02:00
|
|
|
uint8_t *d = dst + 4;
|
|
|
|
d += cw_put_dword(d, i->dword);
|
2015-04-07 07:46:55 +02:00
|
|
|
|
2015-04-19 23:27:44 +02:00
|
|
|
i = mbag_get(board_data, CW_ITEM_WTP_BOARD_MODELNO);
|
2015-04-10 17:14:55 +02:00
|
|
|
if (i) {
|
|
|
|
d += cw_put_word(d, CW_BOARDDATA_MODELNO);
|
|
|
|
d += cw_put_word(d, bstr16_len(i->data));
|
|
|
|
d += cw_put_data(d, bstr16_data(i->data), bstr16_len(i->data));
|
|
|
|
} else {
|
|
|
|
cw_log(LOG_ERR,
|
2015-04-18 11:20:24 +02:00
|
|
|
"Error: Can't set sub-element \"WTP Model Number\" in WTP Board Data.");
|
2015-04-07 07:46:55 +02:00
|
|
|
}
|
2015-04-10 17:14:55 +02:00
|
|
|
|
2015-04-19 23:27:44 +02:00
|
|
|
i = mbag_get(board_data, CW_ITEM_WTP_BOARD_SERIALNO);
|
2015-04-10 17:14:55 +02:00
|
|
|
if (i) {
|
|
|
|
d += cw_put_word(d, CW_BOARDDATA_SERIALNO);
|
|
|
|
d += cw_put_word(d, bstr16_len(i->data));
|
|
|
|
d += cw_put_data(d, bstr16_data(i->data), bstr16_len(i->data));
|
2015-04-18 11:20:24 +02:00
|
|
|
}else {
|
|
|
|
cw_log(LOG_ERR,
|
|
|
|
"Error: Can't set sub-element \"WTP Serial Number\" in WTP Board Data.");
|
2015-04-07 07:46:55 +02:00
|
|
|
}
|
|
|
|
|
2015-04-18 11:20:24 +02:00
|
|
|
|
2015-04-19 23:27:44 +02:00
|
|
|
i = mbag_get(board_data, CW_ITEM_WTP_BOARD_ID);
|
2015-04-10 17:14:55 +02:00
|
|
|
if (i) {
|
|
|
|
d += cw_put_word(d, CW_BOARDDATA_BOARDID);
|
|
|
|
d += cw_put_word(d, bstr16_len(i->data));
|
|
|
|
d += cw_put_data(d, bstr16_data(i->data), bstr16_len(i->data));
|
2015-04-07 07:46:55 +02:00
|
|
|
}
|
|
|
|
|
2015-04-19 23:27:44 +02:00
|
|
|
i = mbag_get(board_data, CW_ITEM_WTP_BOARD_REVISION);
|
2015-04-10 17:14:55 +02:00
|
|
|
if (i) {
|
|
|
|
d += cw_put_word(d, CW_BOARDDATA_REVISION);
|
|
|
|
d += cw_put_word(d, bstr16_len(i->data));
|
|
|
|
d += cw_put_data(d, bstr16_data(i->data), bstr16_len(i->data));
|
2015-04-07 07:46:55 +02:00
|
|
|
}
|
2015-04-10 17:14:55 +02:00
|
|
|
|
2015-04-19 23:27:44 +02:00
|
|
|
i = mbag_get(board_data, CW_ITEM_WTP_BOARD_MACADDRESS);
|
2015-04-10 17:14:55 +02:00
|
|
|
if (i) {
|
|
|
|
d += cw_put_word(d, CW_BOARDDATA_MACADDRESS);
|
|
|
|
d += cw_put_word(d, bstr_len(i->data));
|
|
|
|
d += cw_put_data(d, bstr_data(i->data), bstr_len(i->data));
|
2015-04-07 07:46:55 +02:00
|
|
|
}
|
|
|
|
|
2015-04-11 19:00:51 +02:00
|
|
|
int l = d - dst-4;
|
|
|
|
return l + cw_put_elem_hdr(dst, CW_ELEM_WTP_BOARD_DATA, l );
|
2015-04-07 07:46:55 +02:00
|
|
|
|
|
|
|
}
|