AC reads capwap local ip address element.
FossilOrigin-Name: e45588aa4449d1e321ed4e71236f2a21dab2fcfd7ebcd10b0a6cef3bf9645702
This commit is contained in:
parent
75caae955e
commit
9d13a68fd1
@ -151,6 +151,8 @@ CAPWAPOBJS= \
|
||||
cw_out_capwap_local_ip_address.o\
|
||||
cw_out_capwap_control_ip_addr_list.o \
|
||||
cw_in_capwap_control_ip_address.o\
|
||||
cw_in_capwap_local_ipv4_address.o \
|
||||
cw_in_capwap_local_ipv6_address.o \
|
||||
cw_in_radio_administrative_state.o \
|
||||
cw_in_radio_administrative_state_wtp.o \
|
||||
strheap.o \
|
||||
|
@ -588,8 +588,8 @@ extern void cw_read_image_data_request(struct cwimage_data *, uint8_t * msg, int
|
||||
|
||||
//extern int cw_readelem_ac_descriptor(struct ac_info *acinfo, int type, uint8_t * msgelem,
|
||||
// int len);
|
||||
extern int cw_readelem_capwap_local_ip_addr(struct sockaddr *local_ip, int type,
|
||||
uint8_t * msgelem, int len);
|
||||
//extern int cw_readelem_capwap_local_ip_addr(struct sockaddr *local_ip, int type,
|
||||
// uint8_t * msgelem, int len);
|
||||
|
||||
|
||||
|
||||
|
@ -99,6 +99,13 @@ extern int cw_in_vendor_specific_payload(struct conn *conn, struct cw_action_in
|
||||
extern int cw_in_capwap_control_ip_address(struct conn *conn, struct cw_action_in *a,
|
||||
uint8_t * data, int len,
|
||||
struct sockaddr *from);
|
||||
|
||||
extern int cw_in_capwap_local_ipv4_address(struct conn *conn, struct cw_action_in *a,
|
||||
uint8_t * data, int len,struct sockaddr *from);
|
||||
|
||||
extern int cw_in_capwap_local_ipv6_address(struct conn *conn, struct cw_action_in *a,
|
||||
uint8_t * data, int len,struct sockaddr *from);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
@ -1,4 +1,25 @@
|
||||
/*
|
||||
This file is part of actube.
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
@ -57,11 +78,8 @@ int cw_in_capwap_control_ip_address(struct conn *conn, struct cw_action_in *a,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cw_aciplist_replace(list,acip);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
26
src/cw/cw_in_capwap_local_ipv4_address.c
Normal file
26
src/cw/cw_in_capwap_local_ipv4_address.c
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
|
||||
#include "cw.h"
|
||||
#include "capwap_items.h"
|
||||
#include "mbag.h"
|
||||
|
||||
|
||||
int cw_in_capwap_local_ipv4_address(struct conn *conn, struct cw_action_in *a,
|
||||
uint8_t * data, int len,struct sockaddr *from)
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
memcpy(&addr.sin_addr,data,4);
|
||||
addr.sin_family=AF_INET;
|
||||
|
||||
mbag_set_sockaddr(conn->incomming,CW_ITEM_CAPWAP_LOCAL_IP_ADDRESS,(struct sockaddr*)&addr);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
25
src/cw/cw_in_capwap_local_ipv6_address.c
Normal file
25
src/cw/cw_in_capwap_local_ipv6_address.c
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include "cw.h"
|
||||
#include "capwap_items.h"
|
||||
#include "mbag.h"
|
||||
|
||||
int cw_in_capwap_local_ipv6_address(struct conn *conn, struct cw_action_in *a,
|
||||
uint8_t * data, int len,struct sockaddr *from)
|
||||
{
|
||||
struct sockaddr_in6 addr;
|
||||
memcpy(&addr.sin6_addr,data,4);
|
||||
addr.sin6_family=AF_INET6;
|
||||
|
||||
mbag_set_sockaddr(conn->incomming,CW_ITEM_CAPWAP_LOCAL_IP_ADDRESS,(struct sockaddr*)&addr);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1,49 +0,0 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include "capwap.h"
|
||||
|
||||
int cw_readelem_capwap_local_ip_addr(struct sockaddr * local_ip, int type, uint8_t * msgelem, int len)
|
||||
{
|
||||
switch (type){
|
||||
case CW_ELEM_CAPWAP_LOCAL_IPV4_ADDRESS:
|
||||
case CW_ELEM_WTP_IPV4_IP_ADDRESS:
|
||||
{
|
||||
if (len!=4)
|
||||
return -1;
|
||||
struct sockaddr_in * sain = (struct sockaddr_in*)local_ip;
|
||||
memset(sain,0,sizeof(struct sockaddr_in));
|
||||
#ifdef HAVE_SIN_LEN
|
||||
sain->sa_len=sizeof(struct sockaddr_in);
|
||||
#endif
|
||||
memcpy(&sain->sin_addr,msgelem,len);
|
||||
sain->sin_family=AF_INET;
|
||||
return 1;
|
||||
}
|
||||
#ifdef WITH_IPV6
|
||||
case CW_ELEM_CAPWAP_LOCAL_IPV6_ADDRESS:
|
||||
case CW_ELEM_WTP_IPV6_IP_ADDRESS:
|
||||
{
|
||||
if (len!=16)
|
||||
return -1;
|
||||
|
||||
struct sockaddr_in6 * sain = (struct sockaddr_in6*)local_ip;
|
||||
memset(sain,0,sizeof(struct sockaddr_in6));
|
||||
#ifdef HAVE_SIN6_LEN
|
||||
sain->sa_len=sizeof(struct sockaddr_in);
|
||||
#endif
|
||||
memcpy(&sain->sin6_addr,msgelem,len);
|
||||
sain->sin6_family=AF_INET6;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <stdint.h>
|
||||
#include "mavl.h"
|
||||
#include "bstr.h"
|
||||
#include "sock.h"
|
||||
|
||||
|
||||
struct mbag_item;
|
||||
@ -109,6 +110,7 @@ extern const struct mbag_typedef mbag_type_str;
|
||||
extern const struct mbag_typedef mbag_type_avltree;
|
||||
extern const struct mbag_typedef mbag_type_const_data;
|
||||
extern const struct mbag_typedef mbag_type_mbag_dyn;
|
||||
extern const struct mbag_typedef mbag_type_sockaddr;
|
||||
|
||||
/**
|
||||
*@defgroup MbagTypes MBAG Types
|
||||
@ -127,6 +129,7 @@ extern const struct mbag_typedef mbag_type_mbag_dyn;
|
||||
#define MBAG_AVLTREE (&mbag_type_avltree)
|
||||
#define MBAG_FUN MBAG_STR
|
||||
#define MBAG_CONST_DATA (&mbag_type_const_data)
|
||||
#define MBAG_SOCKADDR (&mbag_type_sockaddr)
|
||||
/**@}*/
|
||||
|
||||
extern mbag_t mbag_create();
|
||||
@ -497,6 +500,24 @@ static inline int mbag_set_str(mbag_t s, const char *id, const char *str)
|
||||
}
|
||||
|
||||
|
||||
static inline int mbag_set_sockaddr(mbag_t s, const char *id, const struct sockaddr * sa)
|
||||
{
|
||||
struct mbag_item *i = mbag_item_create(s, id);
|
||||
if (!i)
|
||||
return 0;
|
||||
struct sockaddr_storage * sad = malloc(sizeof(struct sockaddr_storage));
|
||||
if (!sad){
|
||||
free(i);
|
||||
return 0;
|
||||
}
|
||||
sock_copyaddr(sad,sa);
|
||||
i->type = MBAG_SOCKADDR;
|
||||
i->data = sad;
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct mbag_item_fundef {
|
||||
void *(*get) (void *arg);
|
||||
|
@ -18,44 +18,18 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Implementation of mbag_type_word
|
||||
* @brief Implementation of mbag_type_sockaddr
|
||||
* @addtogroup MbagFunctions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
|
||||
#include "mbag.h"
|
||||
#include "format.h"
|
||||
|
||||
/*
|
||||
static struct mbag_item * from_str(const char *src)
|
||||
{
|
||||
struct mbag_item *i= malloc(sizeof(struct sockaddr_storage));
|
||||
if (!i)
|
||||
return NULL;
|
||||
|
||||
i->type = MBAG_WORD;
|
||||
i->word=atoi(src);
|
||||
return i;
|
||||
}
|
||||
|
||||
static int to_str(void *item,char *dst)
|
||||
{
|
||||
mbag_item_t *i= item;
|
||||
return sprintf(dst, "%d", i->word);
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* MBAG items of this type hold an struct sockaddr element.
|
||||
*/
|
||||
const struct mbag_typedef mbag_type_sockaddr = {
|
||||
"WORD",free,
|
||||
"SocakAddr",free,
|
||||
};
|
||||
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "cw/strheap.h"
|
||||
#include "cw/radio.h"
|
||||
|
||||
|
||||
#include "mod_capwap.h"
|
||||
|
||||
static cw_action_in_t actions_in[] = {
|
||||
@ -209,6 +210,33 @@ static cw_action_in_t actions_in[] = {
|
||||
}
|
||||
,
|
||||
|
||||
/* Local IPv4 Address - Join Request */
|
||||
{
|
||||
.capwap_state = CW_STATE_JOIN,
|
||||
.msg_id = CW_MSG_JOIN_REQUEST,
|
||||
.elem_id = CW_ELEM_CAPWAP_LOCAL_IPV4_ADDRESS,
|
||||
.item_id = CW_ITEM_CAPWAP_LOCAL_IP_ADDRESS,
|
||||
.start = cw_in_capwap_local_ipv4_address,
|
||||
.mand = 1,
|
||||
.min_len = 4,
|
||||
.max_len = 4
|
||||
}
|
||||
,
|
||||
|
||||
/* Local IPv6 Address - Join Request */
|
||||
{
|
||||
.capwap_state = CW_STATE_JOIN,
|
||||
.msg_id = CW_MSG_JOIN_REQUEST,
|
||||
.elem_id = CW_ELEM_CAPWAP_LOCAL_IPV6_ADDRESS,
|
||||
.item_id = CW_ITEM_CAPWAP_LOCAL_IP_ADDRESS,
|
||||
.start = cw_in_capwap_local_ipv4_address,
|
||||
.mand = 1,
|
||||
.min_len = 16,
|
||||
.max_len = 16
|
||||
}
|
||||
,
|
||||
|
||||
|
||||
|
||||
|
||||
/* Vendor Specific Payload - Join Request*/
|
||||
|
Loading…
Reference in New Issue
Block a user