Merge branch 'master' of https://github.com/7u83/actube
FossilOrigin-Name: ebb5b562f760757e4bbbcb91440118294eb6a24492595e4b4b8e2a6b318b4ab4
This commit is contained in:
commit
86740f3411
@ -150,7 +150,7 @@ CAPWAPOBJS= \
|
||||
cw_in_ac_descriptor.o\
|
||||
cw_out_capwap_local_ip_address.o\
|
||||
cw_out_capwap_control_ip_addr_list.o \
|
||||
cw_in_capwap_control_ipv4_address.o\
|
||||
cw_in_capwap_control_ip_address.o\
|
||||
cw_in_radio_administrative_state.o \
|
||||
cw_in_radio_administrative_state_wtp.o \
|
||||
strheap.o \
|
||||
|
@ -164,7 +164,7 @@ CW_MSG_JOIN_RESPONSE = 4,
|
||||
CW_MSG_CONFIGURATION_STATUS_REQUEST = 5,
|
||||
/** Config. Status Response = 6 */
|
||||
CW_MSG_CONFIGURATION_STATUS_RESPONSE = 6,
|
||||
|
||||
/** Config. Update Request = 7 */
|
||||
CW_MSG_CONFIGURATION_UPDATE_REQUEST = 7,
|
||||
CW_MSG_CONFIGURATION_UPDATE_RESPONSE = 8,
|
||||
|
||||
@ -278,7 +278,7 @@ CW_MSG_MAXMSG = 26
|
||||
#define CW_ELEM_DISCOVERY_TYPE 20
|
||||
#define CW_ELEM_DUPLICATE_IPV4_ADDRESS 21
|
||||
#define CW_ELEM_DUPLICATE_IPV6_ADRESS 22
|
||||
#define CWMSGELEM_ECN_SUPPORT 53
|
||||
#define CW_ELEM_ECN_SUPPORT 53
|
||||
#define CW_ELEM_IDLE_TIMEOUT 23
|
||||
#define CW_ELEM_IMAGE_DATA 24
|
||||
#define CW_ELEM_IMAGE_IDENTIFIER 25
|
||||
@ -1031,9 +1031,6 @@ extern int cw_in_wtp_board_data(struct conn *conn, struct cw_action_in *a, uint8
|
||||
int len,struct sockaddr *from);
|
||||
extern int cw_in_wtp_descriptor(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len,struct sockaddr *from);
|
||||
extern int cw_in_capwap_control_ipv4_address(struct conn *conn, struct cw_action_in *a,
|
||||
uint8_t * data, int len, struct sockaddr *from);
|
||||
|
||||
//extern int cw_out_generic(struct conn *conn,struct cw_action_in * a,uint8_t *data,int len);
|
||||
extern int cw_out_generic(struct conn *conn, struct cw_action_out *a, uint8_t * dst); //, struct mbag_item *item);
|
||||
|
||||
@ -1140,7 +1137,7 @@ int cw_in_ac_descriptor(struct conn *conn,struct cw_action_in * a,uint8_t *data,
|
||||
int cw_in_radio_generic(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
|
||||
struct sockaddr *from);
|
||||
|
||||
int cw_out_capwap_local_ip_address(struct conn *conn, struct cw_action_out *action, uint8_t * dst);
|
||||
//int cw_out_capwap_local_ip_address(struct conn *conn, struct cw_action_out *action, uint8_t * dst);
|
||||
|
||||
int cw_in_check_chng_state_evnt_req(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len,struct sockaddr *from);
|
||||
|
@ -114,14 +114,14 @@
|
||||
|
||||
#define CW_ACTION_IN_CAPWAP_CONTROL_IPV4_ADDRESS \
|
||||
CW_ELEM_CAPWAP_CONTROL_IPV4_ADDRESS, /* Element ID*/ \
|
||||
cw_in_capwap_control_ipv4_address, 0, /* start/end callback */ \
|
||||
cw_in_capwap_control_ip_address, 0, /* start/end callback */ \
|
||||
MBAG_AVLTREE, /* Type of element */ \
|
||||
CW_ITEM_CAPWAP_CONTROL_IP_ADDRESS_LIST, /* ID to use store */ \
|
||||
6, 6 /* min/max length */
|
||||
|
||||
#define CW_ACTION_IN_CAPWAP_CONTROL_IPV6_ADDRESS \
|
||||
CW_ELEM_CAPWAP_CONTROL_IPV6_ADDRESS, /* Element ID*/ \
|
||||
cw_in_capwap_control_ipv4_address, 0, /* start/end callback */ \
|
||||
cw_in_capwap_control_ip_address, 0, /* start/end callback */ \
|
||||
MBAG_AVLTREE, /* Type of element */ \
|
||||
CW_ITEM_CAPWAP_CONTROL_IP_ADDRESS_LIST, /* ID to use store */ \
|
||||
18,18 /* min/max length */
|
||||
|
@ -6,7 +6,7 @@
|
||||
const char CW_ITEM_IDLE_TIMEOUT[]="idle_timeout";
|
||||
const char CW_ITEM_DISCOVERY_TYPE[]="discovery_type";
|
||||
const char CW_ITEM_WTP_NAME[]="wtp_name";
|
||||
|
||||
const char CW_ITEM_ECN_SUPPORT[]="ecn_support";
|
||||
|
||||
|
||||
const char CW_ITEM_WTP_MAC_TYPE[]="wtp_mac_type";
|
||||
|
@ -170,7 +170,7 @@ extern const char CW_ITEM_WTP_BOOTLOADER_VERSION[];
|
||||
extern const char CW_ITEM_WTP_RADIOS_IN_USE[];
|
||||
extern const char CW_ITEM_WTP_MAX_RADIOS[];
|
||||
extern const char CW_ITEM_RADIO_INFOS[];
|
||||
|
||||
extern const char CW_ITEM_ECN_SUPPORT[];
|
||||
|
||||
|
||||
|
||||
|
@ -28,7 +28,7 @@ struct cw_strlist_elem capwap_strings_elem[] = {
|
||||
{CW_ELEM_DISCOVERY_TYPE, "Discovery Type"},
|
||||
{CW_ELEM_DUPLICATE_IPV4_ADDRESS, "Duplicate IPv4 Address"},
|
||||
{CW_ELEM_DUPLICATE_IPV6_ADRESS, "Duplicate IPv6 Address"},
|
||||
{CWMSGELEM_ECN_SUPPORT, "ECN Support"},
|
||||
{CW_ELEM_ECN_SUPPORT, "ECN Support"},
|
||||
{CW_ELEM_IDLE_TIMEOUT, "Idle Timeout"},
|
||||
{CW_ELEM_IMAGE_DATA, "Image Data"},
|
||||
{CW_ELEM_IMAGE_IDENTIFIER, "Image Identifier"},
|
||||
|
16
src/cw/cw.h
16
src/cw/cw.h
@ -90,7 +90,21 @@ extern int cw_in_check_generic_resp(struct conn *conn, struct cw_action_in *a,
|
||||
|
||||
|
||||
extern int cw_in_vendor_specific_payload(struct conn *conn, struct cw_action_in *a,
|
||||
uint8_t * data, int len,struct sockaddr *from);
|
||||
uint8_t * data, int len, struct sockaddr *from);
|
||||
|
||||
extern int cw_in_capwap_control_ip_address(struct conn *conn, struct cw_action_in *a,
|
||||
uint8_t * data, int len,
|
||||
struct sockaddr *from);
|
||||
|
||||
/**
|
||||
* @defgroup CWELEMOUT Output Handlers for Message Elements
|
||||
* @{
|
||||
*/
|
||||
extern int cw_out_capwap_local_ip_address(struct conn *conn, struct cw_action_out *action,
|
||||
uint8_t * dst);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
|
@ -18,14 +18,14 @@
|
||||
|
||||
|
||||
|
||||
int cw_in_capwap_control_ipv4_address(struct conn *conn, struct cw_action_in *a,
|
||||
int cw_in_capwap_control_ip_address(struct conn *conn, struct cw_action_in *a,
|
||||
uint8_t * data, int len,struct sockaddr *from)
|
||||
{
|
||||
cw_aciplist_t list =
|
||||
mbag_get_mavl_c(conn->incomming,a->item_id,cw_aciplist_create);
|
||||
|
||||
if (!list) {
|
||||
cw_log(LOG_ERR, "Error: Can't allocate CAWAP IP Adress List");
|
||||
cw_log(LOG_ERR, "Error: Can't allocate CAWPAP IP Adress List");
|
||||
return 0;
|
||||
}
|
||||
|
@ -16,6 +16,12 @@
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Implementation output handler of capwap cw_out_local_ip_address
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
@ -29,43 +35,66 @@
|
||||
#include "capwap.h"
|
||||
#include "conn.h"
|
||||
|
||||
int cw_out_capwap_local_ip_address(struct conn *conn, struct cw_action_out *action, uint8_t * dst)
|
||||
|
||||
/**
|
||||
* Output handler for Capwap Local IP Address message element.
|
||||
*
|
||||
* @param conn Connection object
|
||||
* @param action Pointer to action which called this handler
|
||||
* @param dst Destination buffer
|
||||
*
|
||||
* This handler determines the IP address from #conn->sock.
|
||||
* It can deal both with IPv4 and IPv6 sockets.
|
||||
*
|
||||
*/
|
||||
int cw_out_capwap_local_ip_address(struct conn *conn, struct cw_action_out *action,
|
||||
uint8_t * dst)
|
||||
{
|
||||
struct sockaddr_storage a;
|
||||
socklen_t alen = sizeof(struct sockaddr_storage);
|
||||
getsockname (conn->sock,(struct sockaddr *)&a,&alen);
|
||||
struct sockaddr_storage a;
|
||||
socklen_t alen = sizeof(struct sockaddr_storage);
|
||||
int rc = getsockname(conn->sock, (struct sockaddr *) &a, &alen);
|
||||
|
||||
if (rc != 0){
|
||||
cw_log(LOG_ERR,"Can't determine sock IP address - %s\n",strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
switch (((struct sockaddr*)&a)->sa_family){
|
||||
int id;
|
||||
|
||||
switch (((struct sockaddr *) &a)->sa_family) {
|
||||
case AF_INET:
|
||||
{
|
||||
struct sockaddr_in * sain = (struct sockaddr_in*)&a;
|
||||
int id;
|
||||
if (conn->capwap_mode == CW_MODE_CISCO)
|
||||
id = CW_ELEM_WTP_IPV4_IP_ADDRESS;
|
||||
struct sockaddr_in *sain = (struct sockaddr_in *) &a;
|
||||
|
||||
id = CW_ELEM_CAPWAP_LOCAL_IPV4_ADDRESS;
|
||||
|
||||
/* if (conn->capwap_mode == CW_MODE_CISCO)
|
||||
id = CW_ELEM_WTP_IPV4_IP_ADDRESS;
|
||||
else
|
||||
id = CW_ELEM_CAPWAP_LOCAL_IPV4_ADDRESS;
|
||||
|
||||
cw_put_data(dst+4,(uint8_t*)&sain->sin_addr,4);
|
||||
return 4+cw_put_elem_hdr(dst,id,4);
|
||||
*/
|
||||
cw_put_data(dst + 4, (uint8_t *) & sain->sin_addr, 4);
|
||||
return 4 + cw_put_elem_hdr(dst, id, 4);
|
||||
}
|
||||
|
||||
case AF_INET6:
|
||||
{
|
||||
int id;
|
||||
if (conn->capwap_mode == CW_MODE_CISCO)
|
||||
id = CW_ELEM_WTP_IPV6_IP_ADDRESS;
|
||||
id = CW_ELEM_CAPWAP_LOCAL_IPV6_ADDRESS;
|
||||
|
||||
/* if (conn->capwap_mode == CW_MODE_CISCO)
|
||||
id = CW_ELEM_WTP_IPV6_IP_ADDRESS;
|
||||
else
|
||||
id = CW_ELEM_CAPWAP_LOCAL_IPV6_ADDRESS;
|
||||
struct sockaddr_in6 * sain = (struct sockaddr_in6*)&a;
|
||||
cw_put_data(dst,(uint8_t*)&sain->sin6_addr,16);
|
||||
return 16+cw_put_elem_hdr(dst,id,16);
|
||||
*/
|
||||
|
||||
struct sockaddr_in6 *sain = (struct sockaddr_in6 *) &a;
|
||||
cw_put_data(dst + 4, (uint8_t *) & sain->sin6_addr, 16);
|
||||
return 16 + cw_put_elem_hdr(dst, id, 16);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cw_log(DBG_MSG_ERR, "Can't determine CAPWAP Local IP Adress");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,7 +48,7 @@ static cw_action_in_t actions_in[] = {
|
||||
.msg_id = CW_MSG_DISCOVERY_RESPONSE,
|
||||
.elem_id = CW_ELEM_CAPWAP_CONTROL_IPV4_ADDRESS,
|
||||
.item_id = CW_ITEM_CAPWAP_CONTROL_IP_ADDRESS_LIST,
|
||||
.start = cw_in_capwap_control_ipv4_address,
|
||||
.start = cw_in_capwap_control_ip_address,
|
||||
.min_len = 6,
|
||||
.max_len = 6,
|
||||
.mand = 1
|
||||
@ -62,7 +62,7 @@ static cw_action_in_t actions_in[] = {
|
||||
.msg_id = CW_MSG_DISCOVERY_RESPONSE,
|
||||
.elem_id = CW_ELEM_CAPWAP_CONTROL_IPV6_ADDRESS,
|
||||
.item_id = CW_ITEM_CAPWAP_CONTROL_IP_ADDRESS_LIST,
|
||||
.start = cw_in_capwap_control_ipv4_address, // Change to v6 handler
|
||||
.start = cw_in_capwap_control_ip_address, // Change to v6 handler
|
||||
.min_len = 6,
|
||||
.max_len = 6,
|
||||
.mand = 1
|
||||
@ -251,13 +251,13 @@ static cw_action_out_t actions_out[] = {
|
||||
}
|
||||
,
|
||||
|
||||
/* WTP MAC Type - Join Request */
|
||||
/* Session ID - Join Request */
|
||||
{
|
||||
.msg_id = CW_MSG_JOIN_REQUEST,
|
||||
.elem_id = CW_ELEM_WTP_MAC_TYPE,
|
||||
.item_id = CW_ITEM_WTP_MAC_TYPE,
|
||||
.elem_id = CW_ELEM_SESSION_ID,
|
||||
.item_id = CW_ITEM_SESSION_ID,
|
||||
.out = cw_out_generic,
|
||||
.get = cw_out_get_local,
|
||||
.get = cw_out_get_session_id,
|
||||
.mand = 1
|
||||
}
|
||||
,
|
||||
@ -273,17 +273,42 @@ static cw_action_out_t actions_out[] = {
|
||||
}
|
||||
,
|
||||
|
||||
/* Session ID - Join Request */
|
||||
|
||||
/* WTP MAC Type - Join Request */
|
||||
{
|
||||
.msg_id = CW_MSG_JOIN_REQUEST,
|
||||
.elem_id = CW_ELEM_SESSION_ID,
|
||||
.item_id = CW_ITEM_SESSION_ID,
|
||||
.elem_id = CW_ELEM_WTP_MAC_TYPE,
|
||||
.item_id = CW_ITEM_WTP_MAC_TYPE,
|
||||
.out = cw_out_generic,
|
||||
.get = cw_out_get_session_id,
|
||||
.get = cw_out_get_local,
|
||||
.mand = 1
|
||||
}
|
||||
,
|
||||
|
||||
/* ECN Support - Join Request */
|
||||
{
|
||||
.msg_id = CW_MSG_JOIN_REQUEST,
|
||||
.elem_id = CW_ELEM_ECN_SUPPORT,
|
||||
.item_id = CW_ITEM_ECN_SUPPORT,
|
||||
.out = cw_out_generic,
|
||||
.get = cw_out_get_config,
|
||||
.mand = 1
|
||||
}
|
||||
,
|
||||
|
||||
/* CAPWAP Local IP Address - Join Request */
|
||||
{
|
||||
.msg_id = CW_MSG_JOIN_REQUEST,
|
||||
.item_id = CW_ITEM_CAPWAP_LOCAL_IP_ADDRESS,
|
||||
.out = cw_out_capwap_local_ip_address,
|
||||
// .get = cw_out_get_config,
|
||||
.mand = 1
|
||||
}
|
||||
,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------
|
||||
* Configuration Status Request - Out
|
||||
|
@ -1,4 +1,5 @@
|
||||
{
|
||||
"ecn_support":"0",
|
||||
"location_data":"Superposition",
|
||||
"wtp_bootloader_version":"11591,W-FAT-BL-0.1",
|
||||
"wtp_hardware_version":"11591,0.1",
|
||||
|
@ -42,74 +42,67 @@
|
||||
|
||||
|
||||
|
||||
cw_aciplist_t cw_select_ac(struct conn *conn, mbag_t dis)
|
||||
cw_aciplist_t cw_select_ac(struct conn *conn, mbag_t discs)
|
||||
{
|
||||
|
||||
/* create a list for results */
|
||||
cw_aciplist_t resultlist=cw_aciplist_create();
|
||||
if (!resultlist)
|
||||
return NULL;
|
||||
if (!dis)
|
||||
if (!discs)
|
||||
return resultlist;
|
||||
|
||||
|
||||
/*
|
||||
cw_aciplist_t aciplist = cw_aciplist_create();
|
||||
if (!aciplist) {
|
||||
cw_log(LOG_ERROR, "Can't allocate aciplist");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// mbag_t aclist = mbag_get_mbag(conn->config, CW_ITEM_AC_NAME_WITH_PRIORITY);
|
||||
|
||||
*/
|
||||
|
||||
/* get the AC Name with Priority list */
|
||||
cw_acpriolist_t priolist;
|
||||
priolist = mbag_get_mavl(conn->config, CW_ITEM_AC_NAME_WITH_PRIORITY);
|
||||
// if (priolist )
|
||||
if (!priolist )
|
||||
priolist=cw_acpriolist_create();
|
||||
|
||||
|
||||
|
||||
DEFINE_AVLITER(i, dis);
|
||||
/* for each discovery reponse */
|
||||
DEFINE_AVLITER(i, discs);
|
||||
avliter_foreach(&i){
|
||||
|
||||
|
||||
|
||||
mbag_t ac = ((mbag_item_t *) (avliter_get(&i)))->data;
|
||||
|
||||
/* get the ac name */
|
||||
char *ac_name = mbag_get_str(ac, CW_ITEM_AC_NAME,NULL);
|
||||
|
||||
int prio = 256;
|
||||
|
||||
if (ac_name) {
|
||||
/* See if we can find AC Name in Priority List */
|
||||
if (priolist)
|
||||
prio = cw_acpriolist_get(priolist, ac_name);
|
||||
else
|
||||
prio = 256;
|
||||
printf("Prio for %s is %d\n",ac_name,prio);
|
||||
printf("nprio: %d\n",priolist->count);
|
||||
|
||||
}
|
||||
|
||||
/* get the IP list, the current AC has sent */
|
||||
cw_aciplist_t acips =
|
||||
mbag_get_mavl(ac, CW_ITEM_CAPWAP_CONTROL_IP_ADDRESS_LIST);
|
||||
|
||||
printf("Number of acips =%d\n",acips->count);
|
||||
|
||||
|
||||
/* for each IP from the current AC add it to the result list
|
||||
* and give it the priority whe have determined */
|
||||
DEFINE_AVLITER(i2, acips);
|
||||
avliter_foreach(&i2){
|
||||
|
||||
|
||||
cw_acip_t *acip = avliter_get(&i2);
|
||||
|
||||
printf("The acip: %s\n",sock_addr2str(&acip->ip));
|
||||
|
||||
cw_acip_t *n = malloc(sizeof(cw_acip_t));
|
||||
memcpy(n,acip,sizeof(cw_acip_t));
|
||||
|
||||
|
||||
/* we missuse the wtp_count to sort by
|
||||
* priority and wp_count */
|
||||
n->wtp_count |= prio<<16;
|
||||
|
||||
cw_aciplist_del(resultlist,n);
|
||||
cw_aciplist_add(resultlist,n);
|
||||
}
|
||||
@ -117,7 +110,6 @@ printf("The acip: %s\n",sock_addr2str(&acip->ip));
|
||||
}
|
||||
|
||||
return resultlist;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,7 +111,10 @@ int run_join_d(struct sockaddr *sa)
|
||||
conn->sock = sockfd;
|
||||
sock_copyaddr(&conn->addr, sa);
|
||||
|
||||
/* rc = connect(sockfd, (struct sockaddr *) sa,
|
||||
|
||||
/* we call connect to bind this socket to a local IP address,
|
||||
* which we can later obtain by getsockname */
|
||||
rc = connect(sockfd, (struct sockaddr *) sa,
|
||||
sock_addrlen((struct sockaddr *) sa));
|
||||
|
||||
if (rc < 0) {
|
||||
@ -120,7 +123,7 @@ int run_join_d(struct sockaddr *sa)
|
||||
close(sockfd);
|
||||
return -1;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
cw_dbg(DBG_DTLS, "Establishing DTLS session with %s", sock_addr2str(sa));
|
||||
|
||||
|
@ -59,6 +59,7 @@ int setup_conf(struct conn * conn)
|
||||
|
||||
|
||||
|
||||
mbag_set_byte(conn->config,CW_ITEM_ECN_SUPPORT,get_ecn_support());
|
||||
|
||||
|
||||
return 0;
|
||||
|
@ -21,3 +21,7 @@ bstr_t get_base_rmac()
|
||||
}
|
||||
|
||||
|
||||
uint8_t get_ecn_support()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
#ifndef __WTP_INTERFACE_H
|
||||
#define __WTP_INTERFACE_H
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include "cw/bstr.h"
|
||||
|
||||
extern struct conn * get_conn();
|
||||
extern bstr_t get_base_rmac();
|
||||
uint8_t get_ecn_support();
|
||||
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user