Code reorganized.

FossilOrigin-Name: f0cd261531de060a6ad8dd4030a1a47587fd7b6f37101286b7d0dcf57d1de838
This commit is contained in:
7u83@mail.ru
2015-03-20 21:31:09 +00:00
parent 17fd4dc1b6
commit 9971e36a6d
15 changed files with 99 additions and 21 deletions

View File

@ -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

View File

@ -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 */

View File

@ -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)
{

View File

@ -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;

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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);