2016-02-24 14:46:11 +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/>.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2016-03-11 22:23:00 +01:00
|
|
|
#include "cw/cw.h"
|
2018-03-12 11:22:06 +01:00
|
|
|
#include "cw/ktv.h"
|
2018-02-24 00:30:44 +01:00
|
|
|
#include "cw/log.h"
|
2018-03-19 20:00:58 +01:00
|
|
|
#include "cw/dbg.h"
|
2016-02-24 14:46:11 +01:00
|
|
|
|
2018-03-12 11:22:06 +01:00
|
|
|
#include "cw/msgset.h"
|
2018-03-15 20:20:19 +01:00
|
|
|
#include "cw/keys.h"
|
2016-03-06 19:14:02 +01:00
|
|
|
|
2016-02-26 18:52:29 +01:00
|
|
|
#include "mod_capwap.h"
|
2016-02-24 14:46:11 +01:00
|
|
|
|
2018-03-19 20:00:58 +01:00
|
|
|
|
2018-03-03 17:42:28 +01:00
|
|
|
static struct cw_ElemHandler handlers[] = {
|
2018-02-23 20:14:10 +01:00
|
|
|
|
2018-03-03 08:15:19 +01:00
|
|
|
{
|
2018-03-24 07:56:05 +01:00
|
|
|
"Discovery Type", /* name */
|
|
|
|
CAPWAP_ELEM_DISCOVERY_TYPE, /* Element ID */
|
|
|
|
0,0, /* Vendor / Proto */
|
|
|
|
1,1, /* min/max length */
|
|
|
|
CW_TYPE_BYTE, /* type */
|
|
|
|
CW_KEY_DISCOVERY_TYPE, /* Key */
|
|
|
|
cw_in_generic, /* get */
|
|
|
|
cw_out_generic /* put */
|
2018-03-03 08:15:19 +01:00
|
|
|
}
|
|
|
|
,
|
|
|
|
{
|
2018-03-24 07:56:05 +01:00
|
|
|
"WTP Mac Type", /* name */
|
|
|
|
CAPWAP_ELEM_WTP_MAC_TYPE, /* Element ID */
|
|
|
|
0,0, /* Vendor / Proto */
|
|
|
|
1,1, /* min/max length */
|
|
|
|
CW_TYPE_BYTE, /* type */
|
|
|
|
CW_KEY_WTP_MAC_TYPE, /* Key */
|
|
|
|
cw_in_generic, /* get */
|
|
|
|
cw_out_generic /* put */
|
2018-03-06 03:08:14 +01:00
|
|
|
}
|
|
|
|
,
|
|
|
|
{
|
2018-03-24 07:56:05 +01:00
|
|
|
"WTP Board Data", /* name */
|
|
|
|
CAPWAP_ELEM_WTP_BOARD_DATA, /* Element ID */
|
|
|
|
0,0, /* Vendor / Proto */
|
|
|
|
14,1024, /* min/max length */
|
|
|
|
NULL, /* type */
|
|
|
|
CW_KEY_WTP_BOARD_DATA, /* Key */
|
|
|
|
capwap_in_wtp_board_data, /* get */
|
|
|
|
capwap_out_wtp_board_data /* put */
|
2018-03-03 08:15:19 +01:00
|
|
|
}
|
|
|
|
,
|
2018-03-06 03:08:14 +01:00
|
|
|
{
|
2018-03-24 07:56:05 +01:00
|
|
|
"WTP Descriptor", /* name */
|
|
|
|
CAPWAP_ELEM_WTP_DESCRIPTOR, /* Element ID */
|
|
|
|
0,0, /* Vendor / Proto */
|
|
|
|
33,1024, /* min/max length */
|
|
|
|
NULL, /* type */
|
|
|
|
CW_KEY_WTP_DESCRIPTOR, /* Key */
|
|
|
|
capwap_in_wtp_descriptor, /* get */
|
|
|
|
capwap_out_wtp_descriptor, /* put */
|
2018-03-06 03:08:14 +01:00
|
|
|
}
|
|
|
|
,
|
2018-03-07 13:13:58 +01:00
|
|
|
{
|
|
|
|
"WTP Frame Tunnel Mode", /* name */
|
|
|
|
CAPWAP_ELEM_WTP_FRAME_TUNNEL_MODE, /* Element ID */
|
|
|
|
0,0, /* Vendor / Proto */
|
|
|
|
1,1, /* min/max length */
|
2018-03-09 07:44:17 +01:00
|
|
|
CW_TYPE_BYTE, /* type */
|
2018-03-15 20:20:19 +01:00
|
|
|
CW_KEY_WTP_FRAME_TUNNEL_MODE, /* Key */
|
2018-03-12 18:01:40 +01:00
|
|
|
cw_in_generic, /* get */
|
|
|
|
cw_out_generic /* put */
|
2018-03-09 07:44:17 +01:00
|
|
|
}
|
|
|
|
,
|
|
|
|
{
|
|
|
|
"Vendor Specific Payload", /* name */
|
|
|
|
CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD, /* Element ID */
|
|
|
|
0,0, /* Vendor / Proto */
|
|
|
|
0,0, /* min/max length */
|
|
|
|
NULL, /* type */
|
|
|
|
"vendor_specific_payload", /* Key */
|
2018-03-12 18:01:40 +01:00
|
|
|
capwap_in_vendor_specific_payload, /* get */
|
|
|
|
NULL /* put */
|
2018-03-07 13:13:58 +01:00
|
|
|
}
|
|
|
|
,
|
2018-03-11 10:34:20 +01:00
|
|
|
{
|
|
|
|
"MTU Discovery Padding", /* name */
|
|
|
|
CAPWAP_ELEM_MTU_DISCOVERY_PADDING, /* Element ID */
|
|
|
|
0,0, /* Vendor / Proto */
|
|
|
|
0,0, /* min/max length */
|
|
|
|
NULL, /* type */
|
2018-03-11 11:29:00 +01:00
|
|
|
"mtu_discovery_padding", /* Key */
|
2018-03-12 18:01:40 +01:00
|
|
|
capwap_in_mtu_discovery_padding, /* get */
|
|
|
|
NULL /* put */
|
2018-03-11 10:34:20 +01:00
|
|
|
}
|
|
|
|
,
|
|
|
|
|
2018-03-17 12:32:40 +01:00
|
|
|
{
|
|
|
|
"AC Descriptor", /* name */
|
|
|
|
CAPWAP_ELEM_AC_DESCRIPTOR, /* Element ID */
|
|
|
|
0,0, /* Vendor / Proto */
|
|
|
|
0,0, /* min/max length */
|
|
|
|
NULL, /* type */
|
|
|
|
CW_KEY_AC_DESCRIPTOR, /* Key */
|
2018-03-25 08:34:32 +02:00
|
|
|
capwap_in_ac_descriptor, /* get */
|
2018-03-17 12:32:40 +01:00
|
|
|
capwap_out_ac_descriptor /* put */
|
|
|
|
}
|
|
|
|
,
|
|
|
|
|
2018-03-20 07:09:09 +01:00
|
|
|
{
|
|
|
|
"AC Name", /* name */
|
|
|
|
CAPWAP_ELEM_AC_NAME, /* Element ID */
|
|
|
|
0,0, /* Vendor / Proto */
|
|
|
|
0,0, /* min/max length */
|
|
|
|
CW_TYPE_BSTR16, /* type */
|
|
|
|
"ac-name", /* Key */
|
|
|
|
cw_in_generic, /* get */
|
|
|
|
cw_out_generic /* put */
|
|
|
|
}
|
|
|
|
,
|
2018-03-17 12:32:40 +01:00
|
|
|
|
2018-03-21 20:01:36 +01:00
|
|
|
{
|
|
|
|
"CAPWAP Control IPv4 Address", /* name */
|
|
|
|
CW_ELEM_CAPWAP_CONTROL_IPV4_ADDRESS, /* Element ID */
|
|
|
|
0,0, /* Vendor / Proto */
|
2018-03-24 07:56:05 +01:00
|
|
|
6,6, /* min/max length */
|
2018-03-21 20:01:36 +01:00
|
|
|
CW_TYPE_BSTR16, /* type */
|
|
|
|
"capwap-control-ip-address", /* Key */
|
2018-03-24 07:56:05 +01:00
|
|
|
capwap_in_capwap_control_ip_address, /* get */
|
2018-03-21 20:01:36 +01:00
|
|
|
capwap_out_capwap_control_ip_address /* put */
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
"CAPWAP Control IPv6 Address", /* name */
|
|
|
|
CW_ELEM_CAPWAP_CONTROL_IPV6_ADDRESS, /* Element ID */
|
|
|
|
0,0, /* Vendor / Proto */
|
2018-03-24 07:56:05 +01:00
|
|
|
18,18, /* min/max length */
|
2018-03-21 20:01:36 +01:00
|
|
|
CW_TYPE_BSTR16, /* type */
|
|
|
|
"capwap-control-ip-address", /* Key */
|
2018-03-24 07:56:05 +01:00
|
|
|
capwap_in_capwap_control_ip_address, /* get */
|
2018-03-21 20:01:36 +01:00
|
|
|
capwap_out_capwap_control_ip_address /* put */
|
|
|
|
}
|
|
|
|
|
|
|
|
,
|
2018-03-17 12:32:40 +01:00
|
|
|
|
2018-03-03 08:15:19 +01:00
|
|
|
{0,0,0,0,0,0,0,0}
|
2018-02-24 01:52:39 +01:00
|
|
|
|
2018-02-24 23:57:12 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-03-03 08:15:19 +01:00
|
|
|
static int discovery_request_states[] = {CAPWAP_STATE_DISCOVERY,0};
|
|
|
|
static struct cw_ElemDef discovery_request_elements[] ={
|
2018-03-09 07:44:17 +01:00
|
|
|
{0,0,CAPWAP_ELEM_DISCOVERY_TYPE, 1, 0},
|
|
|
|
{0,0,CAPWAP_ELEM_WTP_BOARD_DATA, 1, 0},
|
2018-03-11 10:34:20 +01:00
|
|
|
{0,0,CAPWAP_ELEM_WTP_DESCRIPTOR, 1, 0},
|
2018-03-09 07:44:17 +01:00
|
|
|
{0,0,CAPWAP_ELEM_WTP_FRAME_TUNNEL_MODE, 1, 0},
|
2018-03-11 10:34:20 +01:00
|
|
|
{0,0,CAPWAP_ELEM_WTP_MAC_TYPE, 1, 0},
|
|
|
|
{0,0,CAPWAP_ELEM_MTU_DISCOVERY_PADDING, 0, 0},
|
2018-03-12 18:01:40 +01:00
|
|
|
{0,0,CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD, 0, CW_IGNORE},
|
2018-03-06 03:08:14 +01:00
|
|
|
{0,0,0,0,0}
|
|
|
|
|
2018-02-23 20:14:10 +01:00
|
|
|
};
|
|
|
|
|
2018-03-17 12:32:40 +01:00
|
|
|
|
|
|
|
static int discovery_response_states[] = {CAPWAP_STATE_DISCOVERY,0};
|
|
|
|
static struct cw_ElemDef discovery_response_elements[] ={
|
|
|
|
{0,0,CAPWAP_ELEM_AC_DESCRIPTOR, 1, 0},
|
|
|
|
{0,0,CAPWAP_ELEM_AC_NAME, 1, 0},
|
2018-03-21 20:01:36 +01:00
|
|
|
{0,0,CW_ELEM_CAPWAP_CONTROL_IPV4_ADDRESS, 1, 0},
|
|
|
|
{0,0,CW_ELEM_CAPWAP_CONTROL_IPV6_ADDRESS, 1, 0},
|
2018-03-17 12:32:40 +01:00
|
|
|
{0,0,CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD, 0, CW_IGNORE},
|
|
|
|
{0,0,0,0,0}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-03-03 08:15:19 +01:00
|
|
|
static struct cw_MsgDef messages[] = {
|
|
|
|
{
|
|
|
|
"Discovery Request",
|
|
|
|
CAPWAP_MSG_DISCOVERY_REQUEST,
|
|
|
|
CW_RECEIVER_AC,
|
|
|
|
discovery_request_states,
|
|
|
|
discovery_request_elements
|
|
|
|
},
|
2018-03-17 12:32:40 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
"Discovery Response",
|
|
|
|
CAPWAP_MSG_DISCOVERY_RESPONSE,
|
|
|
|
CW_RECEIVER_WTP,
|
|
|
|
discovery_response_states,
|
|
|
|
discovery_response_elements
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-03-03 08:15:19 +01:00
|
|
|
/* {
|
|
|
|
"Discovery Request",
|
|
|
|
CAPWAP_MSG_DISCOVERY_REQUEST,
|
|
|
|
CW_RECEIVER_AC,
|
|
|
|
(int[]){CAPWAP_STATE_DISCOVERY,0}
|
|
|
|
|
|
|
|
},
|
|
|
|
*/
|
2018-02-23 20:14:10 +01:00
|
|
|
|
|
|
|
/* Discovery Request Message*/
|
2018-03-03 08:15:19 +01:00
|
|
|
/* {
|
2018-02-24 01:52:39 +01:00
|
|
|
.name = "Discovery Request",
|
2018-02-28 07:38:02 +01:00
|
|
|
.type = CAPWAP_MSG_DISCOVERY_REQUEST,
|
|
|
|
.receiver = CW_RECEIVER_AC,
|
2018-02-23 20:14:10 +01:00
|
|
|
.states = (int[]){CAPWAP_STATE_DISCOVERY,0},
|
2018-03-02 08:49:37 +01:00
|
|
|
.elements = (cw_ElemDef_t []){
|
2018-02-24 23:57:12 +01:00
|
|
|
{&_DISCOVERY_TYPE,1},
|
|
|
|
{&_WTP_BOARD_DATA,1},
|
|
|
|
{&_WTP_DESCRIPTOR,1},
|
|
|
|
{&_WTP_FRAME_TUNNEL_MODE,1},
|
|
|
|
{&_WTP_MAC_TYPE,1},
|
|
|
|
{&_MTU_DISCOVERY_PADDING,0},
|
|
|
|
{&_VENDOR_SPECIFIC_PAYLOAD,0},
|
|
|
|
{0,0},
|
|
|
|
}
|
|
|
|
},
|
2018-03-03 08:15:19 +01:00
|
|
|
*/
|
2018-02-24 23:57:12 +01:00
|
|
|
/* Discovery Request Response */
|
2018-03-03 08:15:19 +01:00
|
|
|
/* {
|
2018-02-24 23:57:12 +01:00
|
|
|
.name = "Discovery Response",
|
|
|
|
.type = CAPWAP_MSG_DISCOVERY_RESPONSE,
|
2018-02-28 07:38:02 +01:00
|
|
|
.receiver = CW_RECEIVER_WTP,
|
2018-02-24 23:57:12 +01:00
|
|
|
.states = (int[]){CAPWAP_STATE_DISCOVERY,0},
|
2018-03-02 08:49:37 +01:00
|
|
|
.elements = (cw_ElemDef_t[]){
|
2018-02-24 23:57:12 +01:00
|
|
|
{&_AC_DESCRIPTOR,1},
|
|
|
|
{0,0},
|
2018-02-23 20:14:10 +01:00
|
|
|
}
|
2018-02-26 18:28:12 +01:00
|
|
|
},
|
2018-03-03 08:15:19 +01:00
|
|
|
*/ {0,0,0,0}
|
2018-02-26 18:28:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-23 20:14:10 +01:00
|
|
|
};
|
|
|
|
|
2018-02-24 01:52:39 +01:00
|
|
|
|
2018-02-26 23:14:32 +01:00
|
|
|
struct cw_MsgSet * capwap_register_msg_set(struct cw_MsgSet * set, int mode){
|
2018-02-26 18:28:12 +01:00
|
|
|
if (mode != CW_MOD_MODE_CAPWAP)
|
|
|
|
return NULL;
|
2018-03-19 20:00:58 +01:00
|
|
|
|
|
|
|
cw_dbg(DBG_INFO,"CAPWAP: Register messages");
|
|
|
|
|
2018-03-03 17:42:28 +01:00
|
|
|
cw_msgset_add(set,messages, handlers);
|
2018-03-17 12:32:40 +01:00
|
|
|
mavl_add_ptr(set->types_tree,CW_TYPE_BSTR16);
|
|
|
|
mavl_add_ptr(set->types_tree,CW_TYPE_BYTE);
|
|
|
|
mavl_add_ptr(set->types_tree,CW_TYPE_DWORD);
|
|
|
|
mavl_add_ptr(set->types_tree,CW_TYPE_WORD);
|
|
|
|
|
2018-03-19 20:00:58 +01:00
|
|
|
cw_dbg(DBG_INFO,"CAPWAP: Done register messages");
|
2018-02-26 20:18:53 +01:00
|
|
|
return set;
|
2018-02-25 19:12:28 +01:00
|
|
|
}
|
|
|
|
|
2018-02-24 00:30:44 +01:00
|
|
|
void test_sets(){
|
2018-02-23 20:14:10 +01:00
|
|
|
|
2018-03-03 08:15:19 +01:00
|
|
|
struct cw_MsgSet * set = cw_msgset_create();
|
2018-02-24 00:30:44 +01:00
|
|
|
if (set==NULL){
|
|
|
|
cw_log(LOG_ERR,"No mem");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-03-03 17:42:28 +01:00
|
|
|
cw_msgset_add(set,messages, handlers);
|
2018-03-17 12:32:40 +01:00
|
|
|
|
|
|
|
|
2018-03-03 08:15:19 +01:00
|
|
|
}
|
|
|
|
/*
|
2018-02-25 19:12:28 +01:00
|
|
|
cw_msgset_add(set,messages);
|
2018-02-24 01:52:39 +01:00
|
|
|
|
2018-02-25 00:52:45 +01:00
|
|
|
cw_elem_handler_t el;
|
2018-02-24 01:52:39 +01:00
|
|
|
memset(&el,0,sizeof(el));
|
|
|
|
el.id=CAPWAP_ELEM_DISCOVERY_TYPE;
|
|
|
|
|
2018-03-02 08:49:37 +01:00
|
|
|
cw_ElemDef_t search, *result;;
|
|
|
|
search.handler = ⪙
|
2018-02-24 23:58:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
result = mavl_find(set->all_elems,&search);
|
2018-02-24 01:52:39 +01:00
|
|
|
|
|
|
|
if (result!=NULL){
|
2018-02-24 23:58:31 +01:00
|
|
|
printf("Found: %d %s %d\n",
|
2018-03-02 08:49:37 +01:00
|
|
|
result->handler->id,
|
|
|
|
result->handler->name,
|
2018-02-24 23:58:31 +01:00
|
|
|
result->mand
|
2018-02-24 01:52:39 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
printf("not found\n");
|
|
|
|
}
|
2018-02-24 23:58:31 +01:00
|
|
|
|
|
|
|
mlist_t m;
|
|
|
|
m = cw_msgset_get_msg(set,CAPWAP_MSG_DISCOVERY_REQUEST);
|
|
|
|
printf("Hey: %p\n",m);
|
|
|
|
|
|
|
|
struct mlist_elem * i;
|
|
|
|
mlist_foreach(i,m){
|
2018-03-02 08:49:37 +01:00
|
|
|
cw_ElemDef_t * le = i->data;
|
|
|
|
printf("Element: %d %s\n",le->handler->id, le->handler->name, le->mand);
|
2018-02-24 23:58:31 +01:00
|
|
|
}
|
2018-02-24 01:52:39 +01:00
|
|
|
|
2018-02-24 23:58:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-24 00:30:44 +01:00
|
|
|
}
|
2018-02-23 20:14:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-03-06 20:54:15 +01:00
|
|
|
*/
|
2016-02-24 14:46:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|