2014-08-03 13:25:37 +02: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/>.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
#include "capwap.h"
|
2015-03-19 21:51:28 +01:00
|
|
|
#include "capwap_80211.h"
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2014-08-03 13:25:37 +02:00
|
|
|
#include <stdio.h>
|
2014-07-11 22:12:11 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "wtpinfo.h"
|
|
|
|
|
2014-08-03 13:25:37 +02:00
|
|
|
#include "cw_util.h"
|
2014-08-13 10:31:29 +02:00
|
|
|
#include "cw_log.h"
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2015-01-06 00:39:43 +01:00
|
|
|
struct eparm {
|
|
|
|
int *mand;
|
|
|
|
struct wtpinfo *wtpinfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static int process_elem(void *eparm,int type,uint8_t* msgelem,int len)
|
2014-07-11 22:12:11 +02:00
|
|
|
{
|
2015-01-05 00:33:45 +01:00
|
|
|
|
2015-01-06 00:39:43 +01:00
|
|
|
struct eparm *e = (struct eparm *) eparm;
|
2015-01-05 00:33:45 +01:00
|
|
|
|
2015-01-06 00:39:43 +01:00
|
|
|
struct wtpinfo * wtpinfo = e->wtpinfo;
|
2015-01-05 00:33:45 +01:00
|
|
|
|
2014-08-13 10:31:29 +02:00
|
|
|
|
2015-01-06 00:39:43 +01:00
|
|
|
cw_dbg_msgelem(CWMSG_JOIN_REQUEST, type, msgelem, len);
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2015-01-06 00:39:43 +01:00
|
|
|
|
|
|
|
/* mandatory elements */
|
2014-07-11 22:12:11 +02:00
|
|
|
if (wtpinfo_readelem_location_data(wtpinfo,type,msgelem,len))
|
2015-01-06 00:39:43 +01:00
|
|
|
goto foundX;
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
if (wtpinfo_readelem_wtp_board_data(wtpinfo,type,msgelem,len))
|
2015-01-06 00:39:43 +01:00
|
|
|
goto foundX;
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
if (wtpinfo_readelem_wtp_descriptor(wtpinfo,type,msgelem,len))
|
2015-01-06 00:39:43 +01:00
|
|
|
goto foundX;
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
if (wtpinfo_readelem_wtp_name(wtpinfo,type,msgelem,len))
|
2015-01-06 00:39:43 +01:00
|
|
|
goto foundX;
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
if (wtpinfo_readelem_session_id(wtpinfo,type,msgelem,len))
|
2015-01-06 00:39:43 +01:00
|
|
|
goto foundX;
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
if (wtpinfo_readelem_wtp_frame_tunnel_mode(wtpinfo,type,msgelem,len))
|
2015-01-06 00:39:43 +01:00
|
|
|
goto foundX;
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
if (wtpinfo_readelem_wtp_mac_type(wtpinfo,type,msgelem,len))
|
2015-01-06 00:39:43 +01:00
|
|
|
goto foundX;
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
if (wtpinfo_readelem_ecn_support(wtpinfo,type,msgelem,len))
|
2015-01-06 00:39:43 +01:00
|
|
|
goto foundX;
|
|
|
|
|
2015-03-16 21:41:33 +01:00
|
|
|
if (cw_readelem_capwap_local_ip_addr((struct sockaddr*)&wtpinfo->local_ip,type,msgelem,len)){
|
2015-01-06 00:39:43 +01:00
|
|
|
cw_mand_elem_found(e->mand, XCWMSGELEM_CAPWAP_LOCAL_IP_ADDRESS);
|
2014-07-11 22:12:11 +02:00
|
|
|
return 1;
|
2015-01-06 00:39:43 +01:00
|
|
|
}
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2015-01-06 00:39:43 +01:00
|
|
|
/* understood capwap bindings */
|
|
|
|
if (wtpinfo_readelem_wtp_radio_info(wtpinfo,type,msgelem,len)){
|
|
|
|
cw_mand_elem_found(e->mand, XCWMSGELEM_CAPWAP_RADIO_INFO);
|
2014-07-11 22:12:11 +02:00
|
|
|
return 1;
|
2015-01-06 00:39:43 +01:00
|
|
|
}
|
|
|
|
|
2015-01-08 19:34:22 +01:00
|
|
|
/* non-mandatory messages */
|
|
|
|
|
|
|
|
uint16_t ml;
|
|
|
|
if (cw_readelem_maximum_message_length(&ml,type,msgelem,len)){
|
|
|
|
return 1;
|
|
|
|
}
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2015-01-08 19:34:22 +01:00
|
|
|
if (cw_readelem_wtp_reboot_statistics(&e->wtpinfo->reboot_statistics,type,msgelem,len))
|
|
|
|
goto foundX;
|
2015-01-05 00:33:45 +01:00
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
return 0;
|
2015-01-06 00:39:43 +01:00
|
|
|
|
|
|
|
foundX:
|
|
|
|
cw_mand_elem_found(e->mand, type);
|
|
|
|
return 1;
|
2014-07-11 22:12:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void process_join_request(struct wtpinfo * wtpinfo, uint8_t * msg, int len)
|
|
|
|
{
|
2015-01-06 00:39:43 +01:00
|
|
|
int mand[] = {
|
|
|
|
CWMSGELEM_LOCATION_DATA,
|
|
|
|
CWMSGELEM_WTP_BOARD_DATA,
|
|
|
|
CWMSGELEM_WTP_DESCRIPTOR,
|
2015-03-29 15:36:23 +02:00
|
|
|
CW_ELEM_WTP_NAME,
|
2015-01-06 00:39:43 +01:00
|
|
|
CWMSGELEM_WTP_FRAME_TUNNEL_MODE,
|
2015-03-29 15:36:23 +02:00
|
|
|
CW_ELEM_WTP_MAC_TYPE,
|
2015-01-06 00:39:43 +01:00
|
|
|
CWMSGELEM_ECN_SUPPORT,
|
|
|
|
XCWMSGELEM_CAPWAP_LOCAL_IP_ADDRESS,
|
|
|
|
XCWMSGELEM_CAPWAP_RADIO_INFO,
|
|
|
|
-1
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct eparm eparm;
|
|
|
|
eparm.wtpinfo = wtpinfo;
|
|
|
|
eparm.mand = mand;
|
|
|
|
|
|
|
|
cw_foreach_msgelem(msg, len, process_elem,
|
|
|
|
&eparm);
|
|
|
|
|
2015-03-29 15:36:23 +02:00
|
|
|
cw_dbg_missing_mand_elems_(0, CWMSG_JOIN_REQUEST, eparm.mand);
|
2015-01-06 00:39:43 +01:00
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
}
|
|
|
|
|