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 <netinet/in.h>
|
|
|
|
|
|
|
|
#include "capwap.h"
|
|
|
|
#include "acinfo.h"
|
2014-07-27 10:31:11 +02:00
|
|
|
#include "cw_log.h"
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
#include "sock.h"
|
|
|
|
|
|
|
|
//static int cwmsg_addelem_acip(struct cwmsg * msg,ACIP *ip,int ctr)
|
2014-07-27 10:31:11 +02:00
|
|
|
static int cwmsg_addelem_acip(void * priv,void *data) //,int ctr)
|
2014-07-11 22:12:11 +02:00
|
|
|
{
|
2014-08-12 15:49:49 +02:00
|
|
|
cw_log_debug2("Adding Ctrl IP %s",sock_addr2str((struct sockaddr*)data));
|
2014-07-27 10:31:11 +02:00
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
struct cwmsg * msg = (struct cwmsg*)priv;
|
|
|
|
ACIP * acip = (ACIP*)data;
|
|
|
|
|
|
|
|
uint8_t ipmsg [18];
|
|
|
|
|
|
|
|
switch (acip->ip.ss_family){
|
|
|
|
case AF_INET:
|
|
|
|
{
|
|
|
|
struct sockaddr_in * sain = (struct sockaddr_in*)&acip->ip;
|
|
|
|
memcpy(ipmsg,&sain->sin_addr.s_addr, sizeof(sain->sin_addr.s_addr));
|
|
|
|
*((uint16_t*)(ipmsg+4))= htons(acip->wtp_count); /* number of wtps */
|
|
|
|
cwmsg_addelem(msg,CWMSGELEM_CONTROL_IPV4_ADDRESS,ipmsg,6);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#ifdef WITH_IPV6
|
|
|
|
case AF_INET6:
|
|
|
|
{
|
|
|
|
struct sockaddr_in6 * sain = (struct sockaddr_in6*)&acip->ip;
|
|
|
|
memcpy(ipmsg,&sain->sin6_addr.s6_addr, sizeof(sain->sin6_addr.s6_addr));
|
|
|
|
*((uint16_t*)(ipmsg+16))= htons(acip->wtp_count); /* number of wtps */
|
|
|
|
cwmsg_addelem(msg,CWMSGELEM_CONTROL_IPV6_ADDRESS,ipmsg,18);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void cwmsg_addelem_ctrl_ip_addrs(struct cwmsg *msg, struct ac_info *acinfo)
|
|
|
|
{
|
|
|
|
// printf("Counter in the list: %i\n",acinfo->aciplist->count);
|
|
|
|
aciplist_foreach(acinfo->aciplist,cwmsg_addelem_acip,msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-27 10:31:11 +02:00
|
|
|
/*
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
void ucwmsg_addelem_ctrl_ip_addrs(struct cwmsg *msg, struct ac_info *acinfo)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
for (i=0; i<acinfo->salist_len; i++)
|
|
|
|
{
|
|
|
|
uint8_t ipmsg [18];
|
|
|
|
switch (acinfo->salist[i].sa_family){
|
|
|
|
case AF_INET:
|
|
|
|
{
|
|
|
|
struct sockaddr_in * sain = (struct sockaddr_in*)&acinfo->salist[i];
|
|
|
|
memcpy(ipmsg,&sain->sin_addr, sizeof(sain->sin_addr));
|
2014-07-27 10:31:11 +02:00
|
|
|
*((uint16_t*)(ipmsg+4))= htons(0); // number of wtps
|
2014-07-11 22:12:11 +02:00
|
|
|
cwmsg_addelem(msg,CWMSGELEM_CONTROL_IPV4_ADDRESS,ipmsg,6);
|
|
|
|
}
|
2014-07-27 10:31:11 +02:00
|
|
|
break;
|
2014-07-11 22:12:11 +02:00
|
|
|
#ifdef WITH_IPV6
|
|
|
|
case AF_INET6:
|
|
|
|
{
|
|
|
|
struct sockaddr_in6 * sain = (struct sockaddr_in6*)&acinfo->salist[i];
|
|
|
|
memcpy(ipmsg,&sain->sin6_addr, sizeof(sain->sin6_addr));
|
2014-07-27 10:31:11 +02:00
|
|
|
*((uint16_t*)(ipmsg+16))= htons(0); // number of wtps
|
2014-07-11 22:12:11 +02:00
|
|
|
cwmsg_addelem(msg,CWMSGELEM_CONTROL_IPV6_ADDRESS,ipmsg,18);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-27 10:31:11 +02:00
|
|
|
*/
|