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"
|
2016-03-11 22:23:00 +01:00
|
|
|
#include "cw.h"
|
2015-04-07 07:46:55 +02:00
|
|
|
|
|
|
|
|
2016-03-13 18:50:24 +01:00
|
|
|
int cw_get_out_item(struct conn * conn, struct cw_action_out *a, void *dst, mbagtype_t type)
|
|
|
|
{
|
|
|
|
if (!a->get)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Get the item */
|
|
|
|
struct mbag_item *item = a->get(conn, a);
|
|
|
|
if (!item)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (item->type != type){
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cw_put_mbag_item(dst,item);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2016-03-11 22:23:00 +01:00
|
|
|
|
2016-03-13 18:50:24 +01:00
|
|
|
mbag_t board_data;
|
|
|
|
|
|
|
|
// mbag_get_mbag(conn->config, CW_ITEM_WTP_BOARD_DATA,NULL);
|
2016-03-03 19:24:28 +01:00
|
|
|
|
2016-03-13 18:50:24 +01:00
|
|
|
if (!cw_get_out_item(conn,a,&board_data,MBAG_MBAG)){
|
|
|
|
cw_log(LOG_ERROR,"Can't get item '%s' for msg %d, elem %d",a->item_id,a->msg_id,a->elem_id);
|
|
|
|
return 0;
|
|
|
|
}
|
2016-03-03 19:24:28 +01:00
|
|
|
|
2016-03-13 18:50:24 +01: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;
|
|
|
|
}
|
2016-03-13 18:50:24 +01:00
|
|
|
*/
|
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
|
|
|
|
2016-03-13 18:50:24 +01:00
|
|
|
char buf[90];
|
|
|
|
|
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) {
|
2016-03-13 18:50:24 +01:00
|
|
|
|
|
|
|
printf("We have got an i %p\n",i);
|
|
|
|
printf("len: %d\n",bstr16_len(i->data));
|
|
|
|
memcpy(buf,bstr16_data(i->data),bstr16_len(i->data));
|
|
|
|
buf[bstr16_len(i->data)]=0;
|
|
|
|
printf("Val: %s\n",buf);
|
|
|
|
|
2015-04-10 17:14:55 +02:00
|
|
|
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;
|
2018-02-23 20:14:10 +01:00
|
|
|
return l + cw_put_elem_hdr(dst, CAPWAP_ELEM_WTP_BOARD_DATA, l );
|
2015-04-07 07:46:55 +02:00
|
|
|
|
|
|
|
}
|