2014-07-11 22:12:11 +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/>.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "capwap.h"
|
2015-03-14 21:41:50 +01:00
|
|
|
#include "capwap_cisco.h"
|
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
#include "conn.h"
|
|
|
|
#include "cwmsg.h"
|
|
|
|
|
2015-03-14 10:15:12 +01:00
|
|
|
int cwsend_join_request(struct conn *conn, struct radioinfo *radioinfo, struct wtpinfo *wtpinfo)
|
2014-07-11 22:12:11 +02:00
|
|
|
{
|
|
|
|
uint8_t buffer[CWMSG_MAX_SIZE];
|
|
|
|
struct cwmsg cwmsg;
|
|
|
|
|
2015-03-14 10:15:12 +01:00
|
|
|
cwmsg_init(&cwmsg, buffer, CWMSG_JOIN_REQUEST, conn_get_next_seqnum(conn), radioinfo);
|
|
|
|
cwmsg.capwap_mode = conn->capwap_mode;
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2015-03-14 10:15:12 +01:00
|
|
|
/* Mandatory elements */
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2015-03-14 10:15:12 +01:00
|
|
|
/* location data */
|
|
|
|
cwmsg_addelem(&cwmsg, CWMSGELEM_LOCATION_DATA, wtpinfo->location,
|
|
|
|
strlen((char *) wtpinfo->location));
|
|
|
|
|
|
|
|
/* wtp board data */
|
|
|
|
cwmsg_addelem_wtp_board_data(&cwmsg, wtpinfo);
|
|
|
|
|
|
|
|
/* wtp descriptor */
|
|
|
|
cwmsg_addelem_wtp_descriptor(&cwmsg, wtpinfo);
|
|
|
|
|
|
|
|
/* wtp name */
|
|
|
|
cwmsg_addelem(&cwmsg, CWMSGELEM_WTP_NAME, wtpinfo->name, strlen((char *) wtpinfo->name));
|
|
|
|
|
|
|
|
/* session id */
|
|
|
|
cwmsg_addelem_session_id(&cwmsg, wtpinfo->session_id);
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2015-03-14 10:15:12 +01:00
|
|
|
/* frame tunnel mode */
|
|
|
|
cwmsg_addelem(&cwmsg, CWMSGELEM_WTP_FRAME_TUNNEL_MODE, &wtpinfo->frame_tunnel_mode,
|
|
|
|
sizeof(uint8_t));
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2015-03-14 10:15:12 +01:00
|
|
|
/* WTP MAC type */
|
|
|
|
cwmsg_addelem(&cwmsg, CWMSGELEM_WTP_MAC_TYPE, &wtpinfo->mac_type, sizeof(uint8_t));
|
|
|
|
|
|
|
|
/* WTP radio information elements */
|
|
|
|
cwmsg_addelem_wtp_radio_infos(&cwmsg, wtpinfo->radioinfo);
|
|
|
|
|
|
|
|
switch (conn->capwap_mode) {
|
|
|
|
case CWMODE_CISCO:
|
|
|
|
cwmsg_addelem_vendor_cisco_mwar_addr(&cwmsg,conn);
|
2015-03-14 21:41:50 +01:00
|
|
|
|
|
|
|
uint8_t data207[4] = {1,1,0,1};
|
|
|
|
|
|
|
|
cwmsg_addelem_vendor_specific_payload(&cwmsg,CW_VENDOR_ID_CISCO,
|
|
|
|
CWVENDOR_CISCO_PL207,data207,4);
|
|
|
|
|
|
|
|
cwmsg_addelem_vendor_specific_payload(&cwmsg,CW_VENDOR_ID_CISCO,
|
|
|
|
CWVENDOR_CISCO_AP_GROUP_NAME,(uint8_t*)"Tobias",strlen("Tobias"));
|
|
|
|
|
|
|
|
|
2015-03-14 10:15:12 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* ECN support */
|
|
|
|
cwmsg_addelem(&cwmsg, CWMSGELEM_ECN_SUPPORT, &wtpinfo->ecn_support,
|
|
|
|
sizeof(uint8_t));
|
2015-03-12 23:21:57 +01:00
|
|
|
}
|
|
|
|
|
2015-03-14 10:15:12 +01:00
|
|
|
/* local ip address */
|
|
|
|
cwmsg_addelem_cw_local_ip_addr(&cwmsg, conn);
|
|
|
|
|
|
|
|
|
|
|
|
/* Non-mandatory elements */
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2015-03-14 10:15:12 +01:00
|
|
|
/* maximum message length */
|
2014-07-11 22:12:11 +02:00
|
|
|
uint16_t l = htons(wtpinfo->max_msg_len);
|
2015-03-14 10:15:12 +01:00
|
|
|
cwmsg_addelem(&cwmsg, CWMSGELEM_MAXIMUM_MESSAGE_LENGTH, (uint8_t *) & l, sizeof(l));
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2015-03-14 10:15:12 +01:00
|
|
|
return conn_send_cwmsg(conn, &cwmsg);
|
2014-07-11 22:12:11 +02:00
|
|
|
}
|