2016-02-26 18:55:40 +01:00
|
|
|
/*
|
|
|
|
This file is part of libcapwap.
|
|
|
|
|
|
|
|
libcapwap is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
libcapwap is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2022-07-28 01:36:16 +02:00
|
|
|
#include "cw/conn.h"
|
2018-03-06 03:08:14 +01:00
|
|
|
#include "mod_capwap.h"
|
2016-02-26 18:55:40 +01:00
|
|
|
|
2016-03-03 20:46:20 +01:00
|
|
|
#include "cw/dbg.h"
|
2018-03-06 03:08:14 +01:00
|
|
|
#include "cw/cw.h"
|
2016-02-26 18:55:40 +01:00
|
|
|
|
2022-07-31 17:15:32 +02:00
|
|
|
#include "cw/val.h"
|
2018-03-11 00:56:41 +01:00
|
|
|
|
2018-03-09 07:44:17 +01:00
|
|
|
#include "cw/keys.h"
|
2016-02-26 18:55:40 +01:00
|
|
|
|
2018-03-09 07:44:17 +01:00
|
|
|
|
2022-08-22 01:59:23 +02:00
|
|
|
static void readsubelems_wtp_board_data(cw_Cfg_t * cfg, uint8_t * msgelem,
|
2016-02-26 18:55:40 +01:00
|
|
|
int len)
|
|
|
|
{
|
2018-03-09 07:44:17 +01:00
|
|
|
int i = 0;
|
|
|
|
uint32_t val;
|
|
|
|
const char * key;
|
|
|
|
|
2016-02-26 18:55:40 +01:00
|
|
|
if (len<4)
|
|
|
|
return;
|
|
|
|
|
2018-03-09 07:44:17 +01:00
|
|
|
|
2016-02-26 18:55:40 +01:00
|
|
|
do {
|
2018-03-17 12:32:40 +01:00
|
|
|
int subtype;
|
|
|
|
int sublen;
|
|
|
|
|
2016-02-26 18:55:40 +01:00
|
|
|
val = ntohl(*((uint32_t *) (msgelem + i)));
|
2018-03-17 12:32:40 +01:00
|
|
|
subtype = (val >> 16) & 0xffff;
|
|
|
|
sublen = val & 0xffff;
|
2016-02-26 18:55:40 +01:00
|
|
|
i += 4;
|
|
|
|
if (sublen + i > len) {
|
|
|
|
cw_dbg(DBG_ELEM_ERR,
|
|
|
|
"WTP Board data sub-element too long, type=%d,len=%d",
|
|
|
|
subtype, sublen);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-08-13 09:47:12 +02:00
|
|
|
/* cw_dbg(DBG_SUBELEM, "WTP board data sub-element, type=%d, len=%d",
|
|
|
|
subtype, sublen);*/
|
2016-02-26 18:55:40 +01:00
|
|
|
|
|
|
|
switch (subtype) {
|
2018-03-09 07:44:17 +01:00
|
|
|
|
|
|
|
|
2016-02-26 18:55:40 +01:00
|
|
|
case CW_BOARDDATA_MODELNO:
|
2020-03-13 23:54:50 +01:00
|
|
|
key = "model-no";
|
2016-02-26 18:55:40 +01:00
|
|
|
break;
|
|
|
|
case CW_BOARDDATA_SERIALNO:
|
2020-03-13 23:54:50 +01:00
|
|
|
key = "serial-no";
|
2016-02-26 18:55:40 +01:00
|
|
|
break;
|
|
|
|
case CW_BOARDDATA_MACADDRESS:
|
2020-03-13 23:54:50 +01:00
|
|
|
key = "mac-address";
|
2016-02-26 18:55:40 +01:00
|
|
|
break;
|
|
|
|
case CW_BOARDDATA_BOARDID:
|
2020-03-13 23:54:50 +01:00
|
|
|
key = "board-id";
|
2016-02-26 18:55:40 +01:00
|
|
|
break;
|
|
|
|
case CW_BOARDDATA_REVISION:
|
2018-03-09 07:44:17 +01:00
|
|
|
key = "revision";
|
2020-03-13 23:54:50 +01:00
|
|
|
break;
|
2016-02-26 18:55:40 +01:00
|
|
|
default:
|
2018-03-09 07:44:17 +01:00
|
|
|
key = NULL;
|
2016-02-26 18:55:40 +01:00
|
|
|
break;
|
|
|
|
}
|
2018-03-17 12:32:40 +01:00
|
|
|
if (key != NULL){
|
2022-08-13 09:47:12 +02:00
|
|
|
char add_key[CW_CFG_MAX_KEY_LEN];
|
2018-04-07 19:28:22 +02:00
|
|
|
sprintf(add_key,"wtp-board-data/%s",key);
|
2022-08-13 09:47:12 +02:00
|
|
|
cw_cfg_set_val(cfg,add_key,CW_TYPE_BSTR16,NULL,msgelem+i,sublen);
|
2018-03-09 07:44:17 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-26 18:55:40 +01:00
|
|
|
i += sublen;
|
|
|
|
|
|
|
|
} while (i < len);
|
|
|
|
}
|
|
|
|
|
2018-03-09 07:44:17 +01:00
|
|
|
|
2016-02-26 18:55:40 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse a WTP Board Data messag element and put results to itemstore.
|
|
|
|
*/
|
2018-03-09 07:44:17 +01:00
|
|
|
int capwap_in_wtp_board_data(struct cw_ElemHandler *eh, struct cw_ElemHandlerParams *params,
|
|
|
|
uint8_t * data, int len)
|
2016-02-26 18:55:40 +01:00
|
|
|
{
|
2022-08-13 09:47:12 +02:00
|
|
|
char vendor_key[CW_CFG_MAX_KEY_LEN];
|
2016-02-26 18:55:40 +01:00
|
|
|
|
2022-08-13 09:47:12 +02:00
|
|
|
sprintf(vendor_key,"%s/%s",eh->key,"vendor");
|
|
|
|
cw_cfg_set_val(params->cfg,vendor_key,CW_TYPE_DWORD,NULL,data,len);
|
2018-03-09 07:44:17 +01:00
|
|
|
|
2022-08-13 09:47:12 +02:00
|
|
|
readsubelems_wtp_board_data(params->cfg, data + 4, len - 4);
|
2016-02-26 18:55:40 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|