More work on CAPWAP state machine...
FossilOrigin-Name: c9f31c71d46610612aafb5b4935aece949463d88eb86e4c22afa6991346185eb
This commit is contained in:
@ -50,6 +50,7 @@ AC_OBJS = wtplist.o wtpman.o conf.o ac_main.o \
|
||||
ac_interface.o \
|
||||
socklist.o \
|
||||
db.o \
|
||||
ac_global.o
|
||||
|
||||
AC_SRCS = $(AC_OBJS:.o=.c)
|
||||
AC_DEPS := $(AC_OBJS:.o=.d)
|
||||
@ -61,6 +62,11 @@ AC_NAME = actube
|
||||
# top-level rule, to compile everything.
|
||||
all: $(AC_NAME)
|
||||
|
||||
%.o:%.c
|
||||
@echo " CC "$<
|
||||
@$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
$(AC_NAME): $(AC_OBJS)
|
||||
$(CC) $(AC_OBJS) -o $(AC_NAME) $(LDFLAGS) $(LIBS)
|
||||
|
||||
|
@ -12,42 +12,7 @@
|
||||
|
||||
#include "capwap.h"
|
||||
#include "capwap_80211.h"
|
||||
|
||||
ACIPLIST * get_aciplist()
|
||||
{
|
||||
int i=0;
|
||||
|
||||
ACIPLIST * aciplist = aciplist_create();
|
||||
if(!aciplist)
|
||||
return 0;
|
||||
|
||||
|
||||
for (i=0; i<socklist_len;i++){
|
||||
|
||||
if (socklist[i].type != SOCKLIST_UNICAST_SOCKET)
|
||||
break;
|
||||
|
||||
struct sockaddr_storage sa;
|
||||
unsigned int salen=sizeof(sa);
|
||||
if ( getsockname(socklist[i].sockfd,(struct sockaddr*)&sa,&salen)<0)
|
||||
continue;
|
||||
|
||||
ACIP * acip;
|
||||
acip = malloc(sizeof(ACIP));
|
||||
if (!acip)
|
||||
continue;
|
||||
|
||||
sock_copyaddr(&acip->ip,(struct sockaddr*)&sa);
|
||||
acip->wtp_count=0;
|
||||
|
||||
// printf ("Adding IP %s\n",sock_addr2str(&acip->ip));
|
||||
|
||||
aciplist_add(aciplist,acip);
|
||||
|
||||
|
||||
}
|
||||
return aciplist;
|
||||
}
|
||||
#include "aciplist.h"
|
||||
|
||||
|
||||
|
||||
@ -91,7 +56,7 @@ struct ac_info * get_acinfo()
|
||||
acinfo->security|=AC_SECURITY_X;
|
||||
|
||||
|
||||
acinfo->dtls_policy = AC_DTLS_POLICY_C | AC_DTLS_POLICY_D ;
|
||||
// acinfo->dtls_policy = AC_DTLS_POLICY_C | AC_DTLS_POLICY_D ;
|
||||
// acinfo->ac_ips = conf_ac_ips;
|
||||
// acinfo->ac_ips_len=conf_ac_ips_len;
|
||||
|
||||
@ -101,11 +66,11 @@ struct ac_info * get_acinfo()
|
||||
// acinfo->salist = conf_ac_ips;
|
||||
// acinfo->salist_len = conf_ac_ips_len;
|
||||
|
||||
acinfo->aciplist=get_aciplist();
|
||||
|
||||
//acinfo->aciplist=get_aciplist();
|
||||
|
||||
/*
|
||||
aciplist_foreach(acinfo->aciplist,pr,NULL);
|
||||
|
||||
*/
|
||||
int i;
|
||||
for (i=1; i<=4; i++){
|
||||
acinfo->radioinfos[i].type=
|
||||
|
140
src/ac/ac_main.c
140
src/ac/ac_main.c
@ -38,7 +38,7 @@
|
||||
#include "capwap_items.h"
|
||||
#include "capwap_cisco.h"
|
||||
|
||||
|
||||
#include "ac.h"
|
||||
|
||||
int ac_run();
|
||||
|
||||
@ -50,23 +50,8 @@ void alive_thread(void *data)
|
||||
}
|
||||
}
|
||||
|
||||
#include "cw_action.h"
|
||||
#include "action.h"
|
||||
|
||||
cw_actionlist_t the_tree;
|
||||
|
||||
int dstart(struct conn *conn,struct cw_action_t * a,uint8_t *data,int len)
|
||||
{
|
||||
printf("DISCO STart Action!!\n");
|
||||
|
||||
uint8_t * rmac = cw_get_hdr_rmac(data);
|
||||
printf ("This msg is for %s\n",sock_hwaddr2str(bstr_data(rmac), bstr_len(rmac)));
|
||||
}
|
||||
|
||||
int readelem_discovery_type(struct conn *conn,struct cw_action * a,uint8_t *data,int len)
|
||||
{
|
||||
printf("Discovery Type = %d\n",*data);
|
||||
cw_itemstore_set_byte(conn->itemstore,CW_ITEM_DISCOVERY_TYPE,*data);
|
||||
}
|
||||
|
||||
/*
|
||||
int readelem_vendor_specific_payload(struct conn *conn,struct cw_action * a,uint8_t *data,int len)
|
||||
@ -99,6 +84,7 @@ int readelem_vendor_specific_payload(struct conn *conn,struct cw_action * a,uint
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
int readelem_cisco_rad_name(struct conn *conn,struct cw_action * a,uint8_t *data,int len)
|
||||
{
|
||||
printf("Here is the rad name reader\n");
|
||||
@ -109,7 +95,7 @@ int readelem_cisco_rad_name(struct conn *conn,struct cw_action * a,uint8_t *data
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@ -117,116 +103,32 @@ int readelem_cisco_rad_name(struct conn *conn,struct cw_action * a,uint8_t *data
|
||||
int main (int argc, const char * argv[])
|
||||
{
|
||||
|
||||
|
||||
cw_actionlist_t t = cw_actionlist_create();
|
||||
the_tree=t;
|
||||
|
||||
|
||||
cw_action_t discovery_actions[] = {
|
||||
{ 0,0,CW_STATE_DISCOVERY,CW_MSG_DISCOVERY_REQUEST,-1,
|
||||
dstart,0 },
|
||||
|
||||
{ 0,0,CW_STATE_DISCOVERY,CW_MSG_DISCOVERY_REQUEST, CW_ELEM_DISCOVERY_TYPE,
|
||||
readelem_discovery_type,0 },
|
||||
|
||||
{ 0,0,CW_STATE_DISCOVERY,CW_MSG_DISCOVERY_REQUEST, CW_ELEM_VENDOR_SPECIFIC_PAYLOAD,
|
||||
cw_in_vendor_specific_payload,0 },
|
||||
|
||||
{ CW_VENDOR_ID_CISCO,0,CW_STATE_DISCOVERY,CW_MSG_DISCOVERY_REQUEST, CW_CISCO_RAD_NAME,
|
||||
cw_in_wtp_name,0 },
|
||||
|
||||
|
||||
{ 0,0,CW_STATE_DISCOVERY,CW_MSG_DISCOVERY_REQUEST, CW_ELEM_WTP_BOARD_DATA,
|
||||
cw_in_wtp_board_data,0 },
|
||||
|
||||
/*
|
||||
{ 0,0,CW_STATE_DISCOVERY,CW_MSG_DISCOVERY_REQUEST, CW_ELEM_WTP_DESCRIPTOR},
|
||||
{ 0,0,CW_STATE_DISCOVERY,CW_MSG_DISCOVERY_REQUEST, CW_ELEM_WTP_FRAME_TUNNEL_MODE},
|
||||
{ 0,0,CW_STATE_DISCOVERY,CW_MSG_DISCOVERY_REQUEST, CW_ELEM_WTP_MAC_TYPE},
|
||||
|
||||
*/
|
||||
|
||||
{ 0,0,0}
|
||||
};
|
||||
|
||||
|
||||
|
||||
cw_action_t join_actions[] = {
|
||||
|
||||
{0,0,CW_STATE_JOIN,CW_MSG_JOIN_REQUEST,-1,0,0},
|
||||
{0,0,CW_STATE_JOIN,CW_MSG_JOIN_REQUEST, CW_ELEM_DISCOVERY_TYPE},
|
||||
{0,0,CW_STATE_JOIN,CW_MSG_JOIN_REQUEST, CW_ELEM_WTP_BOARD_DATA},
|
||||
{0,0,CW_STATE_JOIN,CW_MSG_JOIN_REQUEST, CW_ELEM_WTP_DESCRIPTOR},
|
||||
{0,0,CW_STATE_JOIN,CW_MSG_JOIN_REQUEST, CW_ELEM_WTP_FRAME_TUNNEL_MODE},
|
||||
{0,0,CW_STATE_JOIN,CW_MSG_JOIN_REQUEST, CW_ELEM_WTP_MAC_TYPE},
|
||||
{0}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
cw_register_actions(t,discovery_actions);
|
||||
cw_register_actions(t,join_actions);
|
||||
|
||||
|
||||
#define CW_NAME_DISCOVER_REQUEST "Discovery Request"
|
||||
|
||||
/*
|
||||
int i;
|
||||
for(i=0; discovery[i].capwap_state!=CW_STATE_MAX; i++){
|
||||
printf("State: %d MSG_ID: %d ELEM_ID: %d\n",discovery[i].capwap_state,discovery[i].msg_id,discovery[i].elem_id);
|
||||
void * rc = msgtree_add(t,&(discovery[i]));
|
||||
|
||||
printf("Added to tree %p\n",rc);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
e.capwap_state=0;
|
||||
e.msg_id = CW_MSG_DISCOVERY_REQUEST;
|
||||
e.elem_id = CW_ELEM_AC_NAME;
|
||||
e.name = "AC Name";
|
||||
|
||||
msgtree_add(t,&e);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
// send_image_file(0,"/home/tube/Downloads/c1130-rcvk9w8-tar.124-25e.JAP.tar");
|
||||
|
||||
|
||||
|
||||
cw_log_name="AC-Tube";
|
||||
|
||||
read_config("ac.conf");
|
||||
// cw_log_debug_level=conf_debug_level;
|
||||
|
||||
|
||||
|
||||
|
||||
cw_log(LOG_INFO,"Starting AC-Tube, Name=%s, ID=%s",conf_acname,conf_acid);
|
||||
|
||||
// cw_dbg_opt_level= DBG_CW_MSGELEM_DMP |
|
||||
// DBG_CW_MSGELEM | DBG_CW_PKT| DBG_CW_RFC | DBG_ERR | DBG_CW_MSG | DBG_DTLS ; //| DBG_ALL;
|
||||
|
||||
|
||||
cw_dbg_opt_detail=DBG_DETAIL_ASC_DMP;
|
||||
|
||||
// cw_log_dbg(DBG_CW_MSG,"Hello %s","World");
|
||||
|
||||
|
||||
cw_register_actions_capwap_ac(&capwap_actions);
|
||||
ac_global_init();
|
||||
|
||||
/*
|
||||
db_init();
|
||||
db_start();
|
||||
db_ping();
|
||||
|
||||
pthread_t alth;
|
||||
pthread_create (&alth, NULL, alive_thread, (void *)0);
|
||||
|
||||
|
||||
#ifdef WITH_DTLS
|
||||
*/
|
||||
int rc=0;
|
||||
dtls_init();
|
||||
#endif
|
||||
if (!socklist_init())
|
||||
goto errX;
|
||||
|
||||
@ -234,13 +136,19 @@ msgtree_add(t,&e);
|
||||
goto errX;
|
||||
|
||||
|
||||
int rc = ac_run();
|
||||
rc = ac_run();
|
||||
errX:
|
||||
wtplist_destroy();
|
||||
socklist_destroy();
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void process_ctrl_packet(int index, struct sockaddr * addr, uint8_t * buffer, int len);
|
||||
#define AC_PROTO_CAPWAP 0
|
||||
#define AC_PROTO_LWAPP 1
|
||||
@ -300,7 +208,7 @@ int ac_run()
|
||||
|
||||
|
||||
|
||||
get_acinfo();
|
||||
//get_acinfo();
|
||||
|
||||
|
||||
while(1){
|
||||
@ -359,7 +267,7 @@ int ac_run()
|
||||
void process_cw_ctrl_packet(int index,struct sockaddr * addr, uint8_t * buffer, int len)
|
||||
{
|
||||
|
||||
int sock = socklist[index].reply_sockfd;
|
||||
// int sock = socklist[index].reply_sockfd;
|
||||
|
||||
char hdrstr[1024];
|
||||
hdr_print(hdrstr,buffer,len);
|
||||
@ -411,7 +319,7 @@ void process_cw_ctrl_packet(int index,struct sockaddr * addr, uint8_t * buffer,
|
||||
|
||||
void process_lw_ctrl_packet(int index,struct sockaddr * addr, uint8_t * buffer, int len)
|
||||
{
|
||||
int sock = socklist[index].reply_sockfd;
|
||||
//int sock = socklist[index].reply_sockfd;
|
||||
|
||||
uint8_t * m = buffer+6;
|
||||
uint32_t val = ntohl(*((uint32_t*)(m)));
|
||||
@ -457,10 +365,10 @@ void process_lw_ctrl_packet(int index,struct sockaddr * addr, uint8_t * buffer,
|
||||
return;
|
||||
};
|
||||
|
||||
wtpman_lw_start(wtpman);
|
||||
//wtpman_lw_start(wtpman);
|
||||
}
|
||||
|
||||
wtpman_lw_addpacket(wtpman,buffer,len);
|
||||
//wtpman_lw_addpacket(wtpman,buffer,len);
|
||||
wtplist_unlock();
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ static int init_acid()
|
||||
static int init_dtls()
|
||||
{
|
||||
if (conf_dtls_psk!=NULL){
|
||||
conf_security=CWACSECURITY_FLAGS_S;
|
||||
// conf_security=CW_SECURITY_FLAGS_S;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -456,7 +456,7 @@ int init_bcast_addrs()
|
||||
|
||||
conf_bcast_addrs=malloc(t->count*sizeof(char*));
|
||||
|
||||
stravltree_foreach(t,add_bcast_addr,0,1);
|
||||
stravltree_foreach_asc(t,add_bcast_addr,0);
|
||||
stravltree_destroy(t);
|
||||
|
||||
freeifaddrs(ifa0);
|
||||
|
@ -34,6 +34,12 @@
|
||||
|
||||
#include "cw_util.h"
|
||||
|
||||
#include "capwap_items.h"
|
||||
#include "ac.h"
|
||||
|
||||
|
||||
extern struct cw_actiondef capwap_actions;
|
||||
|
||||
|
||||
/* macro to convert our client ip to a string */
|
||||
//#define CLIENT_IP (sock_addrtostr((struct sockaddr*)&wtpman->conn->addr, (char[64]){0},64))
|
||||
@ -352,7 +358,6 @@ static struct cwrmsg * wtpman_wait_for_message(struct wtpman * wtpman, time_t ti
|
||||
static void wtpman_run_discovery(void *arg)
|
||||
{
|
||||
|
||||
|
||||
struct wtpman * wtpman = (struct wtpman *)arg;
|
||||
struct cwrmsg * cwrmsg;
|
||||
|
||||
@ -360,19 +365,20 @@ static void wtpman_run_discovery(void *arg)
|
||||
|
||||
time_t timer = cw_timer_start(10);
|
||||
|
||||
extern cw_actionlist_t the_tree;
|
||||
wtpman->conn->capwap_state=CW_STATE_DISCOVERY;
|
||||
wtpman->conn->msgtr=the_tree;
|
||||
extern cw_actionlist_in_t the_tree;
|
||||
|
||||
wtpman->conn->itemstore = cw_itemstore_create();
|
||||
wtpman->conn->capwap_state=CW_STATE_DISCOVERY;
|
||||
wtpman->conn->actions = &capwap_actions;
|
||||
|
||||
wtpman->conn->itemstore = cw_itemstore_create();
|
||||
|
||||
wtpman->conn->local = ac_config;
|
||||
wtpman->conn->remote = cw_itemstore_create();
|
||||
|
||||
while ( !cw_timer_timeout(timer) && wtpman->conn->capwap_state==CW_STATE_DISCOVERY){
|
||||
conn_msg_processor(wtpman->conn);
|
||||
}
|
||||
|
||||
// cwsend_discovery_response(wtpman->conn,cwrmsg->seqnum,&radioinfo,acinfo,&wtpman->wtpinfo);
|
||||
wtpman_remove(wtpman);
|
||||
return;
|
||||
|
||||
@ -460,7 +466,7 @@ static void wtpman_run_run(void *arg)
|
||||
printf("Update now?\n");
|
||||
|
||||
|
||||
|
||||
/*
|
||||
conn_prepare_request(conn,CW_MSG_CONFIGURATION_UPDATE_REQUEST);
|
||||
cwmsg_addelem(&conn->req_msg,CW_ELEM_WTP_NAME,(uint8_t*)"Tube7u83",strlen("Tube7u83")+1);
|
||||
cwmsg_addelem(&conn->req_msg,CWMSGELEM_LOCATION_DATA,(uint8_t*)"Berlin",strlen("Berlin")+1);
|
||||
@ -475,7 +481,7 @@ static void wtpman_run_run(void *arg)
|
||||
printf("Wait...\n");
|
||||
conn_wait_for_message(conn,t);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
printf("Adding WLAN\n");
|
||||
@ -581,10 +587,40 @@ static int wtpman_join(void *arg,time_t timer)
|
||||
{
|
||||
struct wtpman * wtpman = (struct wtpman *)arg;
|
||||
|
||||
extern cw_actionlist_t the_tree;
|
||||
wtpman->conn->msgtr=the_tree;
|
||||
extern cw_actionlist_in_t the_tree;
|
||||
wtpman->conn->actions=&capwap_actions;
|
||||
wtpman->conn->capwap_state=CW_STATE_JOIN;
|
||||
|
||||
wtpman->conn->capwap_state=CW_STATE_JOIN;
|
||||
wtpman->conn->actions = &capwap_actions;
|
||||
|
||||
wtpman->conn->itemstore = cw_itemstore_create();
|
||||
|
||||
wtpman->conn->local = ac_config;
|
||||
wtpman->conn->remote = cw_itemstore_create();
|
||||
|
||||
while ( !cw_timer_timeout(timer) && wtpman->conn->capwap_state==CW_STATE_JOIN){
|
||||
conn_msg_processor(wtpman->conn);
|
||||
}
|
||||
|
||||
|
||||
exit(0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* timer = cw_timer_start(wtpman->conn->wait_join); */
|
||||
|
||||
int join_msgs[] = { CW_MSG_JOIN_REQUEST, -1 };
|
||||
@ -1055,7 +1091,7 @@ void wtpman_lw_addpacket(struct wtpman *wtpman, uint8_t *packet, int len)
|
||||
void wtpman_start(struct wtpman * wtpman,int dtlsmode)
|
||||
{
|
||||
if ( dtlsmode ){
|
||||
cw_dbg(DBG_CW_INFO,"Starting wtpman in dtls mode");
|
||||
cw_dbg(DBG_CW_INFO,"Starting wtpman in DTLS mode");
|
||||
pthread_create (&wtpman->thread, NULL, (void *) &wtpman_run, (void *) wtpman);
|
||||
}
|
||||
else{
|
||||
|
Reference in New Issue
Block a user