Code reorganized.
FossilOrigin-Name: f0cd261531de060a6ad8dd4030a1a47587fd7b6f37101286b7d0dcf57d1de838
This commit is contained in:
parent
17fd4dc1b6
commit
9971e36a6d
@ -10,7 +10,7 @@ USE_CONTRIB_OPENSSL=1
|
||||
|
||||
# GnuTLS definitions
|
||||
GNUTLS_VERSION=3.3.9
|
||||
USE_CONTRIB_GNUTLS=0
|
||||
USE_CONTRIB_GNUTLS=1
|
||||
|
||||
# Compiler to use
|
||||
CC=clang
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include "capwap.h"
|
||||
#include "capwap_80211.h"
|
||||
#include "capwap_cisco.h"
|
||||
|
||||
#include "cw_util.h"
|
||||
@ -428,7 +429,7 @@ static void wtpman_run_run(void *arg)
|
||||
|
||||
|
||||
int i;
|
||||
for (i=0; i<10; i++){
|
||||
for (i=0; i<1; i++){
|
||||
time_t t = cw_timer_start(1);
|
||||
printf("Wait...\n");
|
||||
conn_wait_for_message(conn,t);
|
||||
@ -442,17 +443,38 @@ static void wtpman_run_run(void *arg)
|
||||
cwmsg_addelem(&conn->req_msg,CWMSGELEM_WTP_NAME,(uint8_t*)"Tube7u83",strlen("Tube7u83")+1);
|
||||
cwmsg_addelem(&conn->req_msg,CWMSGELEM_LOCATION_DATA,(uint8_t*)"Berlin",strlen("Berlin")+1);
|
||||
|
||||
// cwmsg_addelem_vendor_specific_payload(&conn->req_msg,CW_VENDOR_ID_CISCO,CWVENDOR_CISCO_RAD_NAME,(uint8_t*)"Schlumpf",strlen("Schlumpf"));
|
||||
cwmsg_addelem_vendor_specific_payload(&conn->req_msg,CW_VENDOR_ID_CISCO,CWVENDOR_CISCO_RAD_NAME,(uint8_t*)"Schlumpf",strlen("Schlumpf"));
|
||||
|
||||
cwrmsg = conn_send_request(conn);
|
||||
|
||||
|
||||
for (i=0; i<10; i++){
|
||||
for (i=0; i<3; i++){
|
||||
time_t t = cw_timer_start(1);
|
||||
printf("Wait...\n");
|
||||
conn_wait_for_message(conn,t);
|
||||
}
|
||||
|
||||
|
||||
|
||||
printf("Adding WLAN\n");
|
||||
struct cwwlan wlan;
|
||||
memset(&wlan,0,sizeof(wlan));
|
||||
|
||||
const char * wl = "wl7u83";
|
||||
wlan.ssid = bstr_create(wl,strlen(wl));
|
||||
|
||||
conn_prepare_request(conn,CWMSG_80211_WLAN_CONFIGURATION_REQUEST);
|
||||
struct cwmsg * cwmsg = &conn->req_msg;
|
||||
cwmsg_addelem_80211_add_wlan(cwmsg,&wlan);
|
||||
|
||||
cwrmsg = conn_send_request(conn);
|
||||
|
||||
printf("WLAN CONF sent\n");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* conn_prepare_request(conn,CWMSG_RESET_REQUEST);
|
||||
cwmsg_addelem_image_identifier(&conn->req_msg,CW_VENDOR_ID_CISCO,"image00",strlen("image00"));
|
||||
cwrmsg = conn_send_request(conn);
|
||||
|
@ -172,7 +172,7 @@ endif
|
||||
|
||||
DTLSOBJS+=dtls_bio.o
|
||||
|
||||
CONNOBJS= conn.o \
|
||||
CONNOBJS= conn_create.o \
|
||||
conn_detect_capwap.o \
|
||||
conn_send_packet.o \
|
||||
conn_send_cwmsg.o \
|
||||
@ -191,7 +191,8 @@ CONNOBJS= conn.o \
|
||||
conn_prepare_request.o \
|
||||
conn_prepare_image_data_request.o \
|
||||
conn_send_request.o \
|
||||
conn_wait_for_message.o
|
||||
conn_wait_for_message.o \
|
||||
conn_init.o
|
||||
|
||||
|
||||
|
||||
|
@ -193,6 +193,7 @@ struct cwrmsg * conn_wait_for_message(struct conn * conn, time_t timer);
|
||||
|
||||
#define conn_is_error(conn) (conn->dtls_error)
|
||||
|
||||
void conn_init(struct conn * conn);
|
||||
|
||||
|
||||
#endif /* __CONLIST_H */
|
||||
|
@ -16,6 +16,11 @@
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
@ -26,6 +31,7 @@
|
||||
#include "capwap.h"
|
||||
|
||||
|
||||
/*
|
||||
void conn_init(struct conn * conn)
|
||||
{
|
||||
memset(conn,0,sizeof(struct conn));
|
||||
@ -35,13 +41,18 @@ void conn_init(struct conn * conn)
|
||||
conn->wait_join=CAPWAP_WAIT_JOIN;
|
||||
conn->mtu_discovery=1;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* function
|
||||
* @retval 1 Success
|
||||
* @retval 0 failure, conslt errno for more details
|
||||
* Create a conn object
|
||||
* @param socket a socket
|
||||
* @param addr the address associated
|
||||
* @param qsize size of packet queue
|
||||
* @return A pointer to the created object
|
||||
* This function creates a conn obnject with queueing functionality
|
||||
* for asynchronous operation.
|
||||
* To create a conn object without queue functionallity use #conn_create_noq.
|
||||
*/
|
||||
struct conn * conn_create(int sock, struct sockaddr * addr, int qsize)
|
||||
{
|
||||
|
@ -16,6 +16,11 @@
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Implement conn_create_noq
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
@ -26,7 +31,7 @@
|
||||
#include "cw_log.h"
|
||||
|
||||
/**
|
||||
* function
|
||||
* Create a connection object without queueing
|
||||
* @retval 1 Success
|
||||
* @retval 0 failure, conslt errno for more details
|
||||
*/
|
||||
@ -37,7 +42,8 @@ struct conn * conn_create_noq(int sock, struct sockaddr * addr)
|
||||
if (!conn)
|
||||
return NULL;
|
||||
|
||||
memset(conn,0,sizeof(struct conn));
|
||||
conn_init(conn);
|
||||
|
||||
|
||||
conn->sock=sock;
|
||||
|
||||
|
@ -9,5 +9,4 @@ void conn_prepare_configuration_update_request(struct conn * conn)
|
||||
struct cwmsg * cwmsg = &conn->req_msg;
|
||||
uint8_t * buffer = conn->req_buffer;
|
||||
cwmsg_init(cwmsg,buffer,CWMSG_CONFIGURATION_UPDATE_REQUEST,conn_get_next_seqnum(conn),0);
|
||||
|
||||
}
|
||||
|
@ -6,4 +6,5 @@ void conn_prepare_request(struct conn * conn, int type)
|
||||
struct cwmsg * cwmsg = &conn->req_msg;
|
||||
uint8_t * buffer = conn->req_buffer;
|
||||
cwmsg_init(cwmsg,buffer,type,conn_get_next_seqnum(conn),0);
|
||||
cwmsg->capwap_mode=conn->capwap_mode;
|
||||
}
|
||||
|
@ -9,6 +9,8 @@
|
||||
|
||||
/**
|
||||
* Send a request message and wait for response
|
||||
* @param conn the connection
|
||||
*
|
||||
*/
|
||||
struct cwrmsg * conn_send_request(struct conn * conn)
|
||||
{
|
||||
@ -16,7 +18,8 @@ struct cwrmsg * conn_send_request(struct conn * conn)
|
||||
|
||||
struct cwrmsg * cwrmsg;
|
||||
struct cwmsg * cwmsg = &conn->req_msg;
|
||||
|
||||
|
||||
|
||||
for (i=0; i<conn->max_retransmit; i++) {
|
||||
|
||||
time_t r_timer = cw_timer_start(conn->retransmit_interval);
|
||||
|
@ -163,6 +163,11 @@ int read_config(const char * filename){
|
||||
if (str)
|
||||
conf_vendor_id=atoi(str);
|
||||
|
||||
str = uci_lookup_option_string(ctx,section,"echo_interval");
|
||||
if (str)
|
||||
conf_echo_interval=atoi(str);
|
||||
|
||||
|
||||
str = uci_lookup_option_string(ctx,section,"software_version");
|
||||
if (str){
|
||||
uint8_t * s = bstr_create_from_cfgstr(str);
|
||||
@ -208,6 +213,8 @@ int read_config(const char * filename){
|
||||
bstr_replace(&conf_model_no,s);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return 1;
|
||||
|
@ -164,5 +164,7 @@ conn->capwap_mode = CWMODE_CISCO;
|
||||
|
||||
join_state(conn);
|
||||
|
||||
printf("Joined with conn %p\n",conn);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -1,11 +1,14 @@
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "capwap/capwap.h"
|
||||
#include "capwap/conn.h"
|
||||
#include "capwap/radioinfo.h"
|
||||
#include "capwap/cw_log.h"
|
||||
#include "capwap/dtls.h"
|
||||
#include "capwap/sock.h"
|
||||
|
||||
|
||||
#include "wtp_conf.h"
|
||||
@ -59,9 +62,14 @@ struct cwrmsg * send_request(struct conn * conn,struct cwmsg *cwmsg)
|
||||
|
||||
|
||||
|
||||
extern struct conn * get_conn();
|
||||
|
||||
int run(struct conn * conn)
|
||||
{
|
||||
|
||||
conn = get_conn();
|
||||
printf("Running with conn %p\n");
|
||||
|
||||
struct radioinfo radioinfo;
|
||||
memset(&radioinfo,0,sizeof(radioinfo));
|
||||
|
||||
@ -69,19 +77,30 @@ int run(struct conn * conn)
|
||||
while (1){
|
||||
if (time(NULL)-echo_interval_timer >= conf_echo_interval)
|
||||
{
|
||||
struct cwmsg cwmsg;
|
||||
uint8_t buffer[CWMSG_MAX_SIZE];
|
||||
// struct cwmsg cwmsg;
|
||||
// uint8_t buffer[CWMSG_MAX_SIZE];
|
||||
|
||||
// cwsend_echo_request(conn,&radioinfo);
|
||||
|
||||
// cw_log_debug1("Sending echo request");
|
||||
cwmsg_init_echo_request(&cwmsg,buffer,conn,&radioinfo);
|
||||
struct cwrmsg * rc = send_request(conn,&cwmsg);
|
||||
struct cwmsg *cwmsg=&conn->req_msg;
|
||||
uint8_t * buffer = conn->req_buffer;
|
||||
cwmsg_init_echo_request(cwmsg,buffer,conn,&radioinfo);
|
||||
|
||||
|
||||
printf("Conn target is %s",sock_addr2str(&conn->addr));
|
||||
printf("Calling conn send req\n");
|
||||
printf("conn max retrans: %d\n",conn->max_retransmit);
|
||||
struct cwrmsg * rc = conn_send_request(conn);
|
||||
printf("Back from conn send req\n");
|
||||
|
||||
// printf("conn->seqnum %i\n",conn->seqnum);
|
||||
// struct cwrmsg * rc = get_response(conn,CWMSG_ECHO_RESPONSE,conn->seqnum);
|
||||
if (rc==0){
|
||||
|
||||
printf("Error !\n");
|
||||
exit(0);
|
||||
|
||||
dtls_shutdown(conn);
|
||||
// cw_log_debug1("Connection lost, no echo response");
|
||||
return 0;
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "capwap/wtpinfo.h"
|
||||
#include "capwap/acinfo.h"
|
||||
#include "capwap/conn.h"
|
||||
#include "capwap/capwap_ieee80211.h"
|
||||
#include "capwap/capwap_80211.h"
|
||||
|
||||
#include "wtp_conf.h"
|
||||
#include "wtp_interface.h"
|
||||
@ -96,5 +96,6 @@ struct conn * get_conn()
|
||||
}
|
||||
conn->mtu_discovery=conf_mtu_discovery;
|
||||
}
|
||||
printf("Get conn returns %p\n",conn);
|
||||
return conn;
|
||||
}
|
||||
|
@ -31,6 +31,11 @@ config 'wtp'
|
||||
option discovery_interval 5
|
||||
|
||||
|
||||
# capwap mmode
|
||||
# possible values: capwap, cisco
|
||||
# default is "capwap"
|
||||
option capwap_mode "capwap"
|
||||
|
||||
|
||||
config 'dbg'
|
||||
# debug options
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "capwap/cw_log.h"
|
||||
#include "capwap/radioinfo.h"
|
||||
#include "capwap/sock.h"
|
||||
#include "capwap/capwap_ieee80211.h"
|
||||
#include "capwap/capwap_80211.h"
|
||||
|
||||
int wpa_printf()
|
||||
{
|
||||
@ -1222,7 +1222,7 @@ int wtpdrv_get_radioinfo(int rid,struct radioinfo * radioinfo)
|
||||
|
||||
radioinfo->rmac = bstr_create(rm,6);
|
||||
|
||||
radioinfo->type|=CW_IEEE80211_RADIO_TYPE_B; //CWRADIO_TYPE_N;
|
||||
radioinfo->type|=CW_80211_RADIO_TYPE_B; //CWRADIO_TYPE_N;
|
||||
|
||||
/*
|
||||
struct wpa_driver_ops * drv = wpa_drivers[0];
|
||||
|
Loading…
Reference in New Issue
Block a user