2016-03-06 19:14:02 +01:00
|
|
|
/*
|
|
|
|
This file is part of actube.
|
2015-04-10 17:16:33 +02:00
|
|
|
|
2016-03-06 19:14:02 +01:00
|
|
|
actube 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/>.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief Implements cw_in_capwap_control_ip_address
|
|
|
|
*/
|
2015-04-12 21:25:33 +02:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
|
|
|
|
2015-04-10 17:16:33 +02:00
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include "action.h"
|
2015-04-10 17:52:01 +02:00
|
|
|
#include "log.h"
|
2015-04-19 23:27:44 +02:00
|
|
|
#include "mbag.h"
|
2016-03-11 22:23:00 +01:00
|
|
|
#include "cw.h"
|
2015-04-10 17:16:33 +02:00
|
|
|
#include "capwap_items.h"
|
|
|
|
#include "aciplist.h"
|
|
|
|
#include "sock.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-03-06 13:34:34 +01:00
|
|
|
int cw_in_capwap_control_ip_address(struct conn *conn, struct cw_action_in *a,
|
2015-04-12 23:28:55 +02:00
|
|
|
uint8_t * data, int len,struct sockaddr *from)
|
2015-04-10 17:16:33 +02:00
|
|
|
{
|
|
|
|
cw_aciplist_t list =
|
2015-05-01 00:16:54 +02:00
|
|
|
mbag_get_mavl_c(conn->incomming,a->item_id,cw_aciplist_create);
|
2015-04-10 17:16:33 +02:00
|
|
|
|
|
|
|
if (!list) {
|
2016-03-06 13:34:34 +01:00
|
|
|
cw_log(LOG_ERR, "Error: Can't allocate CAWPAP IP Adress List");
|
2015-04-12 19:19:29 +02:00
|
|
|
return 0;
|
2015-04-10 17:16:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cw_acip_t * acip;
|
|
|
|
acip = malloc(sizeof(cw_acip_t));
|
|
|
|
if (!acip) {
|
|
|
|
cw_log(LOG_ERR,"Can't allocate memory for acv4ip: %s",strerror(errno));
|
2015-04-12 19:19:29 +02:00
|
|
|
return 0;
|
2015-04-10 17:16:33 +02:00
|
|
|
}
|
|
|
|
|
2016-03-06 11:04:34 +01:00
|
|
|
|
|
|
|
if (a->elem_id == CW_ELEM_CAPWAP_CONTROL_IPV4_ADDRESS) {
|
|
|
|
struct sockaddr_in addr;
|
|
|
|
memcpy(&addr.sin_addr,data,4);
|
|
|
|
addr.sin_family=AF_INET;
|
|
|
|
sock_setport((struct sockaddr*)&addr,CAPWAP_CONTROL_PORT);
|
|
|
|
memcpy(&acip->ip,&addr,sizeof(addr));
|
|
|
|
acip->wtp_count = cw_get_word(data+4);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (a->elem_id == CW_ELEM_CAPWAP_CONTROL_IPV6_ADDRESS) {
|
|
|
|
struct sockaddr_in6 addr;
|
|
|
|
memset (&addr,0,sizeof(addr));
|
|
|
|
memcpy(&addr.sin6_addr,data,16);
|
|
|
|
addr.sin6_family=AF_INET6;
|
|
|
|
sock_setport((struct sockaddr*)&addr,CAPWAP_CONTROL_PORT);
|
|
|
|
memcpy(&acip->ip,&addr,sizeof(addr));
|
|
|
|
acip->wtp_count = cw_get_word(data+16);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-10 17:16:33 +02:00
|
|
|
cw_aciplist_replace(list,acip);
|
|
|
|
|
2015-04-12 19:19:29 +02:00
|
|
|
return 1;
|
2015-04-10 17:16:33 +02:00
|
|
|
}
|
2016-03-06 19:14:02 +01:00
|
|
|
|