Renamed struct conn to struct cw_Conn
This commit is contained in:
parent
3da4805c06
commit
4b5b00009c
@ -36,7 +36,7 @@ void wlan0_cmd(struct shelldata *sd, const char * cmd);
|
||||
void show_cfg (FILE *out, mavl_t ktv);
|
||||
void show_aps (FILE *out);
|
||||
|
||||
struct conn * find_ap(const char *name);
|
||||
struct cw_Conn * find_ap(const char *name);
|
||||
|
||||
struct command{
|
||||
char * cmd;
|
||||
@ -72,7 +72,7 @@ void list_cmd(struct shelldata *sd, const char *cmd)
|
||||
|
||||
void cfg_cmd(struct shelldata *sd, const char *cmd)
|
||||
{
|
||||
struct conn * conn;
|
||||
struct cw_Conn * conn;
|
||||
wtplist_lock();
|
||||
conn = find_ap(sd->prompt);
|
||||
if (conn==NULL){
|
||||
@ -86,7 +86,7 @@ void cfg_cmd(struct shelldata *sd, const char *cmd)
|
||||
|
||||
void ucfg_cmd(struct shelldata *sd, const char *cmd)
|
||||
{
|
||||
struct conn * conn;
|
||||
struct cw_Conn * conn;
|
||||
show_cfg(sd->out,sd->update_cfg);
|
||||
|
||||
}
|
||||
@ -96,7 +96,7 @@ void ucfg_cmd(struct shelldata *sd, const char *cmd)
|
||||
void
|
||||
send_cmd(struct shelldata * sd, const char *cmd)
|
||||
{
|
||||
struct conn * conn;
|
||||
struct cw_Conn * conn;
|
||||
wtplist_lock();
|
||||
conn = find_ap(sd->prompt);
|
||||
if (conn==NULL){
|
||||
@ -111,7 +111,7 @@ send_cmd(struct shelldata * sd, const char *cmd)
|
||||
void
|
||||
wlan0_cmd(struct shelldata * sd, const char *cmd)
|
||||
{
|
||||
struct conn * conn;
|
||||
struct cw_Conn * conn;
|
||||
wtplist_lock();
|
||||
conn = find_ap(sd->prompt);
|
||||
if (conn==NULL){
|
||||
@ -129,7 +129,7 @@ wlan0_cmd(struct shelldata * sd, const char *cmd)
|
||||
|
||||
void set_cmd(struct shelldata *sd, const char *str)
|
||||
{
|
||||
struct conn * conn;
|
||||
struct cw_Conn * conn;
|
||||
struct cw_Val_Reader r;
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
char type[CW_KTV_MAX_KEY_LEN];
|
||||
@ -189,7 +189,7 @@ void show_aps (FILE *out)
|
||||
cw_Val_t * result;
|
||||
char addr[SOCK_ADDR_BUFSIZE];
|
||||
char wtp_name[CAPWAP_MAX_WTP_NAME_LEN];
|
||||
struct conn * conn;
|
||||
struct cw_Conn * conn;
|
||||
conn = mavliter_get_ptr (&it);
|
||||
|
||||
sock_addr2str_p (&conn->addr, addr);
|
||||
@ -211,7 +211,7 @@ void show_aps (FILE *out)
|
||||
|
||||
|
||||
|
||||
struct conn * find_ap(const char *name)
|
||||
struct cw_Conn * find_ap(const char *name)
|
||||
{
|
||||
struct connlist * cl;
|
||||
mavliter_t it;
|
||||
@ -224,7 +224,7 @@ struct conn * find_ap(const char *name)
|
||||
mavliter_foreach (&it) {
|
||||
cw_Val_t * result;
|
||||
char wtp_name[CAPWAP_MAX_WTP_NAME_LEN];
|
||||
struct conn * conn;
|
||||
struct cw_Conn * conn;
|
||||
conn = mavliter_get_ptr (&it);
|
||||
|
||||
result = cw_ktv_get (conn->remote_cfg, "wtp-name", NULL);
|
||||
@ -266,7 +266,7 @@ void con (FILE *out)
|
||||
cw_Val_t * result;
|
||||
char addr[SOCK_ADDR_BUFSIZE];
|
||||
char wtp_name[CAPWAP_MAX_WTP_NAME_LEN];
|
||||
struct conn * conn;
|
||||
struct cw_Conn * conn;
|
||||
conn = mavliter_get_ptr (&it);
|
||||
|
||||
sock_addr2str_p (&conn->addr, addr);
|
||||
|
@ -71,7 +71,7 @@ void wtplist_destroy()
|
||||
struct wtpman * wtplist_get(const struct sockaddr * addr)
|
||||
{
|
||||
|
||||
struct conn * conn = connlist_get(connlist,addr);
|
||||
struct cw_Conn * conn = connlist_get(connlist,addr);
|
||||
if (!conn)
|
||||
return 0;
|
||||
return conn->data;
|
||||
@ -80,8 +80,8 @@ struct wtpman * wtplist_get(const struct sockaddr * addr)
|
||||
|
||||
struct wtpman * wtplist_get_by_session_id(bstr16_t *session_id)
|
||||
{
|
||||
struct conn search;
|
||||
struct conn * conn;
|
||||
struct cw_Conn search;
|
||||
struct cw_Conn * conn;
|
||||
|
||||
search.session_id = session_id;
|
||||
/*memcpy (search.session_id, session_id,16);*/
|
||||
|
@ -63,7 +63,7 @@ static void reset_echointerval_timer(struct wtpman *wtpman)
|
||||
}
|
||||
|
||||
|
||||
static int msg_start_handler(struct conn *conn, struct cw_action_in *a,
|
||||
static int msg_start_handler(struct cw_Conn *conn, struct cw_action_in *a,
|
||||
uint8_t * data, int len, struct sockaddr *from)
|
||||
{
|
||||
struct wtpman *wtpman = conn->data;
|
||||
@ -144,7 +144,7 @@ static int wtpman_join(void *arg)
|
||||
int rc;
|
||||
char sock_buf[SOCK_ADDR_BUFSIZE];
|
||||
struct wtpman *wtpman = (struct wtpman *) arg;
|
||||
struct conn *conn = wtpman->conn;
|
||||
struct cw_Conn *conn = wtpman->conn;
|
||||
time_t timer, wait_join;
|
||||
|
||||
cw_dbg(DBG_INFO, "Join State - %s",
|
||||
@ -193,7 +193,7 @@ static int wtpman_join(void *arg)
|
||||
static void wtpman_image_data(struct wtpman *wtpman)
|
||||
{
|
||||
/* char sock_buf[SOCK_ADDR_BUFSIZE];
|
||||
struct conn *conn = wtpman->conn;
|
||||
struct cw_Conn *conn = wtpman->conn;
|
||||
|
||||
// Image upload
|
||||
const char *filename = mbag_get_str(conn->outgoing, CW_ITEM_IMAGE_FILENAME, NULL);
|
||||
@ -255,7 +255,7 @@ void *wtpman_run_data(void *wtpman_arg)
|
||||
return NULL;
|
||||
/*
|
||||
struct wtpman *wtpman = (struct wtpman *) wtpman_arg;
|
||||
struct conn *conn = wtpman->conn;
|
||||
struct cw_Conn *conn = wtpman->conn;
|
||||
|
||||
|
||||
uint8_t data[1001];
|
||||
@ -271,7 +271,7 @@ void *wtpman_run_data(void *wtpman_arg)
|
||||
|
||||
}
|
||||
|
||||
int cw_run_state_machine(struct conn *conn, time_t * timer)
|
||||
int cw_run_state_machine(struct cw_Conn *conn, time_t * timer)
|
||||
{
|
||||
|
||||
int timerval;
|
||||
@ -326,7 +326,7 @@ static void *wtpman_main(void *arg)
|
||||
int rc;
|
||||
time_t timer;
|
||||
char sock_buf[SOCK_ADDR_BUFSIZE];
|
||||
struct conn *conn;
|
||||
struct cw_Conn *conn;
|
||||
int last_state;
|
||||
|
||||
struct wtpman *wtpman = (struct wtpman *) arg;
|
||||
|
@ -15,7 +15,7 @@
|
||||
struct wtpman {
|
||||
pthread_t thread;
|
||||
|
||||
struct conn *conn;
|
||||
struct cw_Conn *conn;
|
||||
|
||||
|
||||
/* wtp data */
|
||||
|
@ -72,10 +72,11 @@ CWSRC=\
|
||||
cw_type_word.c\
|
||||
cw_type_sysptr.c\
|
||||
cw_write_descriptor_subelem.c\
|
||||
cw_read_from.c \
|
||||
cw_write_radio_element.c\
|
||||
cw_detect_nat.c\
|
||||
|
||||
#cw_read_from.c \
|
||||
|
||||
KTVSRC=\
|
||||
cw_ktv_add.c\
|
||||
cw_ktv_cast.c\
|
||||
@ -202,9 +203,9 @@ MISCSRC=\
|
||||
md5sum.c\
|
||||
mod.c\
|
||||
msgset.c\
|
||||
netconn.c\
|
||||
send.c\
|
||||
strheap.c\
|
||||
netconn.c\
|
||||
|
||||
DTLSSRC+=\
|
||||
dtls_bio.c\
|
||||
|
105
src/cw/conn.h
105
src/cw/conn.h
@ -56,7 +56,7 @@ struct cw_action_in;
|
||||
/**
|
||||
* Connection Object
|
||||
*/
|
||||
struct conn {
|
||||
struct cw_Conn {
|
||||
int sock;
|
||||
struct sockaddr_storage addr;
|
||||
|
||||
@ -106,7 +106,7 @@ struct conn {
|
||||
|
||||
|
||||
/** Counter for mandatory message elements */
|
||||
struct avltree *mand;
|
||||
/* struct avltree *mand;*/
|
||||
|
||||
|
||||
/** Actionsdefs - this defines the possible actions for
|
||||
@ -154,19 +154,19 @@ struct conn {
|
||||
|
||||
/* receive and send methods */
|
||||
|
||||
int (*recv_packet) (struct conn *, uint8_t *, int);
|
||||
int (*recv_packet_peek) (struct conn *, uint8_t *, int);
|
||||
int (*send_packet) (struct conn *, const uint8_t *, int);
|
||||
int (*recv_packet) (struct cw_Conn*, uint8_t *, int);
|
||||
int (*recv_packet_peek) (struct cw_Conn*, uint8_t *, int);
|
||||
int (*send_packet) (struct cw_Conn*, const uint8_t *, int);
|
||||
/*
|
||||
// int (*recv_data_packet) (struct conn *, uint8_t *,int);
|
||||
// int (*send_data_packet) (struct conn *, const uint8_t *, int);
|
||||
// int (*recv_data_packet) (struct cw_Conn*, uint8_t *,int);
|
||||
// int (*send_data_packet) (struct cw_Conn*, const uint8_t *, int);
|
||||
*/
|
||||
|
||||
int (*readfrom) (struct conn *, uint8_t *, int, struct sockaddr_storage *);
|
||||
int (*read) (struct conn *, uint8_t *, int);
|
||||
int (*write) (struct conn *, const uint8_t *, int);
|
||||
int (*readfrom) (struct cw_Conn*, uint8_t *, int, struct sockaddr_storage *);
|
||||
int (*read) (struct cw_Conn*, uint8_t *, int);
|
||||
int (*write) (struct cw_Conn*, const uint8_t *, int);
|
||||
/*
|
||||
// int (*write_data) (struct conn *, const uint8_t *, int);
|
||||
// int (*write_data) (struct cw_Conn*, const uint8_t *, int);
|
||||
*/
|
||||
/* optional packet queue */
|
||||
uint8_t **q;
|
||||
@ -179,14 +179,14 @@ struct conn {
|
||||
int cur_packet_pos;
|
||||
|
||||
/* dtls stuff */
|
||||
int (*dtls_start) (struct conn *);
|
||||
int (*dtls_accept) (struct conn *);
|
||||
int (*dtls_start) (struct cw_Conn*);
|
||||
int (*dtls_accept) (struct cw_Conn*);
|
||||
|
||||
bstr16_t dtls_psk;
|
||||
int dtls_psk_enable;
|
||||
|
||||
int dtls_dhbits;
|
||||
int (*dtls_get_psk)(struct conn *,const char *user,uint8_t**psk, int *len);
|
||||
int (*dtls_get_psk)(struct cw_Conn*,const char *user,uint8_t**psk, int *len);
|
||||
|
||||
struct cw_Mod *cmod, *bmod;
|
||||
|
||||
@ -229,8 +229,8 @@ struct conn {
|
||||
int strict_hdr;
|
||||
|
||||
|
||||
int (*process_packet)(struct conn *conn, uint8_t * packet, int len,struct sockaddr *from);
|
||||
int (*process_message)(struct conn *conn, uint8_t * rawmsg, int rawlen,
|
||||
int (*process_packet)(struct cw_Conn*conn, uint8_t * packet, int len,struct sockaddr *from);
|
||||
int (*process_message)(struct cw_Conn*conn, uint8_t * rawmsg, int rawlen,
|
||||
struct sockaddr *from);
|
||||
|
||||
|
||||
@ -238,16 +238,17 @@ struct conn {
|
||||
void * mods;
|
||||
|
||||
|
||||
int (*msg_start)(struct conn *conn,struct cw_action_in *a,uint8_t*data,int len,struct sockaddr *from);
|
||||
int (*msg_end)(struct conn *conn,struct cw_action_in *a,uint8_t*elem,int len,struct sockaddr *from);
|
||||
int (*msg_start)(struct cw_Conn*conn,struct cw_action_in *a,uint8_t*data,int len,struct sockaddr *from);
|
||||
int (*msg_end)(struct cw_Conn*conn,struct cw_action_in *a,uint8_t*elem,int len,struct sockaddr *from);
|
||||
|
||||
int (*elem_end)(struct conn *conn,struct cw_action_in *a,int afrc,uint8_t*elem,int len,struct sockaddr *from);
|
||||
int (*elem_end)(struct cw_Conn*conn,struct cw_action_in *a,int afrc,uint8_t*elem,int len,struct sockaddr *from);
|
||||
|
||||
/*
|
||||
// void (*actions_registered)(struct conn *conn);
|
||||
// void (*actions_registered)(struct cw_Conn*conn);
|
||||
*/
|
||||
|
||||
};
|
||||
typedef struct cw_Conn cw_Conn_t;
|
||||
|
||||
|
||||
|
||||
@ -255,76 +256,76 @@ struct conn {
|
||||
|
||||
|
||||
|
||||
struct conn *conn_create(int sock, struct sockaddr *addr, int qsize);
|
||||
struct conn *conn_create_noq(int sock, struct sockaddr *addr);
|
||||
struct cw_Conn*conn_create(int sock, struct sockaddr *addr, int qsize);
|
||||
struct cw_Conn*conn_create_noq(int sock, struct sockaddr *addr);
|
||||
|
||||
|
||||
extern int conn_send_cwmsg(struct conn *conn, struct cwmsg *cwmsg);
|
||||
extern int conn_send_cwmsg(struct cw_Conn*conn, struct cwmsg *cwmsg);
|
||||
|
||||
/*
|
||||
//extern int conn_process_packet(struct conn *conn, uint8_t * packet, int len,
|
||||
//extern int conn_process_packet(struct cw_Conn*conn, uint8_t * packet, int len,
|
||||
// int (*cb) (void *, uint8_t *,int len), void *cbarg);
|
||||
*/
|
||||
|
||||
extern int conn_process_packet(struct conn *conn, uint8_t * packet, int len,struct sockaddr *from);
|
||||
extern int process_message(struct conn *conn, uint8_t * rawmsg, int rawlen,
|
||||
extern int conn_process_packet(struct cw_Conn*conn, uint8_t * packet, int len,struct sockaddr *from);
|
||||
extern int process_message(struct cw_Conn*conn, uint8_t * rawmsg, int rawlen,
|
||||
struct sockaddr *from);
|
||||
|
||||
extern uint8_t *conn_get_message(struct conn *conn);
|
||||
extern uint8_t *conn_get_message(struct cw_Conn*conn);
|
||||
|
||||
extern int conn_send_packet(struct conn *conn, const uint8_t * buffer, int len);
|
||||
extern int conn_send_data_packet(struct conn * conn, const uint8_t * buffer, int len);
|
||||
extern int conn_send_packet(struct cw_Conn*conn, const uint8_t * buffer, int len);
|
||||
extern int conn_send_data_packet(struct cw_Conn* conn, const uint8_t * buffer, int len);
|
||||
|
||||
extern void conn_destroy(struct conn *conn);
|
||||
extern void conn_destroy(struct cw_Conn*conn);
|
||||
|
||||
uint8_t *conn_q_get_packet(struct conn *conn);
|
||||
extern int conn_q_recv_packet(struct conn *conn, uint8_t * buffer, int len);
|
||||
extern int conn_q_recv_packet_peek(struct conn *conn, uint8_t * buffer, int len);
|
||||
uint8_t *conn_q_get_packet(struct cw_Conn*conn);
|
||||
extern int conn_q_recv_packet(struct cw_Conn*conn, uint8_t * buffer, int len);
|
||||
extern int conn_q_recv_packet_peek(struct cw_Conn*conn, uint8_t * buffer, int len);
|
||||
|
||||
extern int conn_recv_packet(struct conn *conn, uint8_t * buf, int len);
|
||||
extern int conn_recv_packet_peek(struct conn *conn, uint8_t * buf, int len);
|
||||
extern int conn_recv_packet(struct cw_Conn*conn, uint8_t * buf, int len);
|
||||
extern int conn_recv_packet_peek(struct cw_Conn*conn, uint8_t * buf, int len);
|
||||
|
||||
extern int conn_send_response(struct conn *conn, struct cwmsg *cwmsg, int seqnum);
|
||||
extern struct cwrmsg *conn_get_response(struct conn *conn);
|
||||
extern int conn_send_response(struct cw_Conn*conn, struct cwmsg *cwmsg, int seqnum);
|
||||
extern struct cwrmsg *conn_get_response(struct cw_Conn*conn);
|
||||
|
||||
|
||||
#define conn_get_next_seqnum(conn) (conn->seqnum=((conn->seqnum+1)&0xff))
|
||||
#define conn_get_last_seqnum(conn) (conn->seqnum&0xff)
|
||||
|
||||
|
||||
void conn_q_add_packet(struct conn *conn, uint8_t * packet, int len);
|
||||
void conn_q_add_packet(struct cw_Conn*conn, uint8_t * packet, int len);
|
||||
|
||||
struct image_identifier;
|
||||
struct cwimage_data;
|
||||
|
||||
extern void conn_prepare_request(struct conn *conn, int type);
|
||||
extern int conn_prepare_image_data_request(struct conn *conn, struct cwimage_data *,
|
||||
extern void conn_prepare_request(struct cw_Conn*conn, int type);
|
||||
extern int conn_prepare_image_data_request(struct cw_Conn*conn, struct cwimage_data *,
|
||||
struct image_identifier *id);
|
||||
/*
|
||||
//extern void conn_detect_capwap(struct conn *conn, struct wtpinfo *wtpinfo);
|
||||
//extern void conn_detect_capwap(struct cw_Conn*conn, struct wtpinfo *wtpinfo);
|
||||
*/
|
||||
|
||||
struct cwrmsg *conn_send_request(struct conn *conn);
|
||||
struct cwrmsg *conn_wait_for_message(struct conn *conn, time_t timer);
|
||||
struct cwrmsg *conn_send_request(struct cw_Conn*conn);
|
||||
struct cwrmsg *conn_wait_for_message(struct cw_Conn*conn, time_t timer);
|
||||
|
||||
struct cwrmsg *conn_wait_for_request(struct conn *conn, int *msglist, time_t timer);
|
||||
struct cwrmsg *conn_wait_for_request(struct cw_Conn*conn, int *msglist, time_t timer);
|
||||
|
||||
int conn_q_wait_packet(struct conn * conn, int seconds);
|
||||
int conn_q_wait_packet(struct cw_Conn* conn, int seconds);
|
||||
|
||||
#define conn_is_error(conn) (conn->dtls_error)
|
||||
|
||||
void conn_init(struct conn *conn);
|
||||
void conn_init(struct cw_Conn*conn);
|
||||
|
||||
extern int cw_read_messages(struct conn *conn);
|
||||
extern int cw_read_messages(struct cw_Conn*conn);
|
||||
|
||||
extern int conn_recvfrom_packet(struct conn *conn, uint8_t * buf, int len,
|
||||
extern int conn_recvfrom_packet(struct cw_Conn*conn, uint8_t * buf, int len,
|
||||
struct sockaddr_storage *from);
|
||||
|
||||
int conn_send_msg(struct conn * conn, uint8_t *rawmsg);
|
||||
int cw_read_from(struct conn * conn, struct sockaddr_storage * from);
|
||||
int conn_send_msg(struct cw_Conn* conn, uint8_t *rawmsg);
|
||||
int cw_read_from(struct cw_Conn* conn, struct sockaddr_storage * from);
|
||||
|
||||
int conn_send_msg(struct conn *conn, uint8_t * rawmsg);
|
||||
int conn_send_msg(struct cw_Conn *conn, uint8_t * rawmsg);
|
||||
|
||||
void conn_clear_upd(struct conn *conn, int merge);
|
||||
void conn_clear_upd(struct cw_Conn*conn, int merge);
|
||||
|
||||
#endif /* __CONN_H */
|
||||
|
@ -45,10 +45,10 @@
|
||||
* 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)
|
||||
struct cw_Conn * conn_create(int sock, struct sockaddr * addr, int qsize)
|
||||
{
|
||||
struct conn * conn;
|
||||
conn = malloc(sizeof (struct conn));
|
||||
struct cw_Conn * conn;
|
||||
conn = malloc(sizeof (struct cw_Conn ));
|
||||
if (!conn)
|
||||
return NULL;
|
||||
|
||||
|
@ -36,10 +36,10 @@
|
||||
* @retval 1 Success
|
||||
* @retval 0 failure, conslt errno for more details
|
||||
*/
|
||||
struct conn * conn_create_noq(int sock, struct sockaddr * addr)
|
||||
struct cw_Conn * conn_create_noq(int sock, struct sockaddr * addr)
|
||||
{
|
||||
struct conn * conn;
|
||||
conn = malloc(sizeof (struct conn));
|
||||
struct cw_Conn * conn;
|
||||
conn = malloc(sizeof (struct cw_Conn ));
|
||||
if (!conn)
|
||||
return NULL;
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
* Destroy a conn object
|
||||
* @param object to destroy
|
||||
*/
|
||||
void conn_destroy(struct conn * conn)
|
||||
void conn_destroy(struct cw_Conn * conn)
|
||||
{
|
||||
if (conn->fragman)
|
||||
fragman_destroy(conn->fragman);
|
||||
|
@ -47,9 +47,9 @@ static int header_len(struct cw_ElemHandler * handler)
|
||||
* Basic initialization of a conn object
|
||||
* @param conn conn object to initialize
|
||||
*/
|
||||
void conn_init(struct conn * conn)
|
||||
void conn_init(struct cw_Conn * conn)
|
||||
{
|
||||
memset(conn,0,sizeof(struct conn));
|
||||
memset(conn,0,sizeof(struct cw_Conn ));
|
||||
conn->retransmit_interval=CAPWAP_RETRANSMIT_INTERVAL;
|
||||
conn->max_retransmit=CAPWAP_MAX_RETRANSMIT;
|
||||
conn->wait_dtls=CAPWAP_WAIT_DTLS;
|
||||
|
@ -42,7 +42,7 @@
|
||||
/**
|
||||
* Init response message header
|
||||
*/
|
||||
void cw_init_response(struct conn *conn, uint8_t * req)
|
||||
void cw_init_response(struct cw_Conn *conn, uint8_t * req)
|
||||
{
|
||||
uint8_t *buffer;
|
||||
int shbytes, dhbytes;
|
||||
@ -69,7 +69,7 @@ void cw_init_response(struct conn *conn, uint8_t * req)
|
||||
cw_set_msg_flags(dmsgptr, 0);
|
||||
}
|
||||
|
||||
void cw_init_request(struct conn *conn, int msg_id)
|
||||
void cw_init_request(struct cw_Conn *conn, int msg_id)
|
||||
{
|
||||
uint8_t *buffer = conn->req_buffer;
|
||||
uint8_t *msgptr;
|
||||
@ -97,7 +97,7 @@ void cw_init_request(struct conn *conn, int msg_id)
|
||||
cw_set_msg_elems_len(msgptr, 0);
|
||||
}
|
||||
|
||||
void cw_init_data_msg(struct conn *conn)
|
||||
void cw_init_data_msg(struct cw_Conn *conn)
|
||||
{
|
||||
uint8_t *buffer = conn->req_buffer;
|
||||
cw_set_dword(buffer + 0, 0);
|
||||
@ -114,7 +114,7 @@ void cw_init_data_msg(struct conn *conn)
|
||||
/**
|
||||
* send a response
|
||||
*/
|
||||
int cw_send_response(struct conn *conn, uint8_t * rawmsg, int len)
|
||||
int cw_send_response(struct cw_Conn *conn, uint8_t * rawmsg, int len)
|
||||
{
|
||||
int rc;
|
||||
cw_init_response(conn, rawmsg);
|
||||
@ -135,7 +135,7 @@ int cw_send_response(struct conn *conn, uint8_t * rawmsg, int len)
|
||||
* @param result_code result code to send
|
||||
* @return 1
|
||||
*/
|
||||
int cw_send_error_response(struct conn *conn, uint8_t * rawmsg,
|
||||
int cw_send_error_response(struct cw_Conn *conn, uint8_t * rawmsg,
|
||||
uint32_t result_code)
|
||||
{
|
||||
uint8_t *out, *dst;
|
||||
@ -156,7 +156,7 @@ int cw_send_error_response(struct conn *conn, uint8_t * rawmsg,
|
||||
}
|
||||
|
||||
|
||||
static struct cw_MsgSet *load_msg_set(struct conn *conn, uint8_t * rawmsg,
|
||||
static struct cw_MsgSet *load_msg_set(struct cw_Conn *conn, uint8_t * rawmsg,
|
||||
int len, int elems_len,
|
||||
struct sockaddr *from)
|
||||
{
|
||||
@ -188,7 +188,7 @@ static struct cw_MsgSet *load_msg_set(struct conn *conn, uint8_t * rawmsg,
|
||||
}
|
||||
|
||||
/*
|
||||
int cw_in_check_generic(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int cw_in_check_generic(struct cw_Conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len,struct sockaddr *from)
|
||||
{
|
||||
// if (cw_is_request(a->msg_id)){
|
||||
@ -201,7 +201,7 @@ int cw_in_check_generic(struct conn *conn, struct cw_action_in *a, uint8_t * dat
|
||||
*/
|
||||
|
||||
/*
|
||||
void cw_read_elem(struct cw_ElemHandler * handler, struct conn * conn,
|
||||
void cw_read_elem(struct cw_ElemHandler * handler, struct cw_Conn * conn,
|
||||
uint8_t * elem_data, int elem_len, struct sockaddr * from){
|
||||
mavldata_t data, *result;
|
||||
char str[30];
|
||||
@ -215,7 +215,7 @@ void cw_read_elem(struct cw_ElemHandler * handler, struct conn * conn,
|
||||
*/
|
||||
|
||||
|
||||
static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
|
||||
static int process_elements(struct cw_Conn *conn, uint8_t * rawmsg, int len,
|
||||
struct sockaddr *from)
|
||||
{
|
||||
mavl_t mand_found;
|
||||
@ -387,7 +387,7 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
|
||||
message->type, message->name);
|
||||
|
||||
|
||||
|
||||
params.cfg = cw_cfg_create();
|
||||
cw_decode_elements(¶ms,elems_ptr, elems_len);
|
||||
|
||||
exit(0);
|
||||
@ -452,7 +452,7 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
|
||||
|
||||
|
||||
|
||||
int process_message(struct conn *conn, uint8_t * rawmsg, int rawlen,
|
||||
int process_message(struct cw_Conn *conn, uint8_t * rawmsg, int rawlen,
|
||||
struct sockaddr *from)
|
||||
{
|
||||
char sock_buf[SOCK_ADDR_BUFSIZE];
|
||||
@ -526,7 +526,7 @@ int process_message(struct conn *conn, uint8_t * rawmsg, int rawlen,
|
||||
* @param packet pointer to packet data
|
||||
* @param len lenght of packet data
|
||||
*/
|
||||
int conn_process_packet2(struct conn *conn, uint8_t * packet, int len,
|
||||
int conn_process_packet2(struct cw_Conn *conn, uint8_t * packet, int len,
|
||||
struct sockaddr *from)
|
||||
{
|
||||
char sock_buf[SOCK_ADDR_BUFSIZE];
|
||||
@ -622,7 +622,7 @@ int conn_process_packet2(struct conn *conn, uint8_t * packet, int len,
|
||||
return conn->process_message(conn, packet, len, from);
|
||||
}
|
||||
|
||||
int conn_process_packet(struct conn *conn, uint8_t * packet, int len,
|
||||
int conn_process_packet(struct cw_Conn *conn, uint8_t * packet, int len,
|
||||
struct sockaddr *from)
|
||||
{
|
||||
|
||||
@ -633,7 +633,7 @@ int conn_process_packet(struct conn *conn, uint8_t * packet, int len,
|
||||
}
|
||||
|
||||
|
||||
int conn_process_data_packet(struct conn *conn, uint8_t * packet, int len,
|
||||
int conn_process_data_packet(struct cw_Conn *conn, uint8_t * packet, int len,
|
||||
struct sockaddr *from)
|
||||
{
|
||||
|
||||
@ -658,7 +658,7 @@ int conn_process_data_packet(struct conn *conn, uint8_t * packet, int len,
|
||||
/**
|
||||
* Used as main message loop
|
||||
*/
|
||||
int cw_read_messages(struct conn *conn)
|
||||
int cw_read_messages(struct cw_Conn *conn)
|
||||
{
|
||||
uint8_t buf[2024];
|
||||
int len = 2024;
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "sock.h"
|
||||
|
||||
|
||||
void conn_q_add_packet(struct conn * conn,uint8_t *packet,int len)
|
||||
void conn_q_add_packet(struct cw_Conn * conn,uint8_t *packet,int len)
|
||||
{
|
||||
char sock_buf[SOCK_ADDR_BUFSIZE];
|
||||
int qwpos = conn->qwpos;
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <time.h>
|
||||
#include "conn.h"
|
||||
|
||||
uint8_t * conn_q_get_packet(struct conn * conn)
|
||||
uint8_t * conn_q_get_packet(struct cw_Conn * conn)
|
||||
{
|
||||
int qrpos;
|
||||
struct timespec timespec;
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#include "conn.h"
|
||||
|
||||
static int conn_q_recv_packet_(struct conn * conn, uint8_t * buffer,int len,int peek)
|
||||
static int conn_q_recv_packet_(struct cw_Conn * conn, uint8_t * buffer,int len,int peek)
|
||||
{
|
||||
if ( !conn->cur_packet)
|
||||
{
|
||||
@ -58,12 +58,12 @@ static int conn_q_recv_packet_(struct conn * conn, uint8_t * buffer,int len,int
|
||||
return conn->cur_packet_len;
|
||||
}
|
||||
|
||||
int conn_q_recv_packet(struct conn * conn, uint8_t * buffer,int len)
|
||||
int conn_q_recv_packet(struct cw_Conn * conn, uint8_t * buffer,int len)
|
||||
{
|
||||
return conn_q_recv_packet_(conn,buffer,len,0);
|
||||
}
|
||||
|
||||
int conn_q_recv_packet_peek(struct conn * conn, uint8_t * buffer,int len)
|
||||
int conn_q_recv_packet_peek(struct cw_Conn * conn, uint8_t * buffer,int len)
|
||||
{
|
||||
return conn_q_recv_packet_(conn,buffer,len,1);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "conn.h"
|
||||
|
||||
int conn_q_wait_packet(struct conn * conn, int seconds)
|
||||
int conn_q_wait_packet(struct cw_Conn * conn, int seconds)
|
||||
{
|
||||
|
||||
struct timespec timespec;
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
#include "sock.h"
|
||||
|
||||
int conn_recv_packet_(struct conn *conn, uint8_t * buf, int len, int flags)
|
||||
int conn_recv_packet_(struct cw_Conn *conn, uint8_t * buf, int len, int flags)
|
||||
{
|
||||
int n;
|
||||
while ((n = recv(conn->sock, (char *) buf, len, flags)) < 0) {
|
||||
@ -41,7 +41,7 @@ int conn_recv_packet_(struct conn *conn, uint8_t * buf, int len, int flags)
|
||||
}
|
||||
|
||||
|
||||
int conn_recvfrom_packet(struct conn *conn, uint8_t * buf, int len,
|
||||
int conn_recvfrom_packet(struct cw_Conn *conn, uint8_t * buf, int len,
|
||||
struct sockaddr_storage *from)
|
||||
{
|
||||
int n;
|
||||
@ -65,7 +65,7 @@ int conn_recvfrom_packet(struct conn *conn, uint8_t * buf, int len,
|
||||
|
||||
#include "log.h"
|
||||
|
||||
int conn_recv_packet_x(struct conn *conn, uint8_t * buf, int len, int flags)
|
||||
int conn_recv_packet_x(struct cw_Conn *conn, uint8_t * buf, int len, int flags)
|
||||
{
|
||||
int port;
|
||||
socklen_t al;
|
||||
@ -104,12 +104,12 @@ int conn_recv_packet_x(struct conn *conn, uint8_t * buf, int len, int flags)
|
||||
|
||||
/* yes, these functions could be better defined as macros in a .h file */
|
||||
|
||||
int conn_recv_packet(struct conn *conn, uint8_t * buf, int len)
|
||||
int conn_recv_packet(struct cw_Conn *conn, uint8_t * buf, int len)
|
||||
{
|
||||
return conn_recv_packet_x(conn, buf, len, 0);
|
||||
}
|
||||
|
||||
int conn_recv_packet_peek(struct conn *conn, uint8_t * buf, int len)
|
||||
int conn_recv_packet_peek(struct cw_Conn *conn, uint8_t * buf, int len)
|
||||
{
|
||||
int rc = conn_recv_packet_(conn, buf, len, MSG_PEEK);
|
||||
return rc;
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "dbg.h"
|
||||
|
||||
|
||||
int conn_send_data_packet(struct conn * conn, const uint8_t * buffer, int len)
|
||||
int conn_send_data_packet(struct cw_Conn * conn, const uint8_t * buffer, int len)
|
||||
{
|
||||
char sock_buf[SOCK_ADDR_BUFSIZE];
|
||||
int n;
|
||||
|
@ -3,9 +3,9 @@
|
||||
#include "dbg.h"
|
||||
|
||||
#define CW_MODE_ZYXEL 7
|
||||
extern cw_send_msg(struct conn * conn,uint8_t * msg);
|
||||
extern cw_send_msg(struct cw_Conn * conn,uint8_t * msg);
|
||||
|
||||
int conn_send_msg(struct conn * conn, uint8_t *rawmsg)
|
||||
int conn_send_msg(struct cw_Conn * conn, uint8_t *rawmsg)
|
||||
{
|
||||
uint8_t * ptr;
|
||||
int packetlen;
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
|
||||
|
||||
int conn_send_packet(struct conn * conn, const uint8_t * buffer, int len)
|
||||
int conn_send_packet(struct cw_Conn * conn, const uint8_t * buffer, int len)
|
||||
{
|
||||
int n;
|
||||
while((n=sendto( conn->sock, buffer, len, 0,
|
||||
|
@ -39,24 +39,24 @@
|
||||
|
||||
static int cmp_by_addr_p ( const void * d1, const void *d2 )
|
||||
{
|
||||
struct conn * c1 = * ( void ** ) d1 ;
|
||||
struct conn * c2 = * ( void ** ) d2 ;
|
||||
struct cw_Conn * c1 = * ( void ** ) d1 ;
|
||||
struct cw_Conn * c2 = * ( void ** ) d2 ;
|
||||
return sock_cmpaddr ( ( struct sockaddr* ) &c1->addr, ( struct sockaddr* ) &c2->addr, 1 );
|
||||
}
|
||||
|
||||
|
||||
static int cmp_by_addr ( const void * d1, const void *d2 )
|
||||
{
|
||||
struct conn * c1 = * ( void ** ) d1 ;
|
||||
struct conn * c2 = * ( void ** ) d2 ;
|
||||
struct cw_Conn * c1 = * ( void ** ) d1 ;
|
||||
struct cw_Conn * c2 = * ( void ** ) d2 ;
|
||||
return sock_cmpaddr ( ( struct sockaddr* ) &c1->addr, ( struct sockaddr* ) &c2->addr, 0 );
|
||||
}
|
||||
|
||||
|
||||
static int cmp_by_session_id ( const void *d1, const void *d2 )
|
||||
{
|
||||
struct conn * c1 = *( void ** ) d1;
|
||||
struct conn * c2 = *( void ** ) d2;
|
||||
struct cw_Conn * c1 = *( void ** ) d1;
|
||||
struct cw_Conn * c2 = *( void ** ) d2;
|
||||
int len1,len2;
|
||||
|
||||
if (c1->session_id==NULL && c2->session_id==NULL)
|
||||
@ -143,15 +143,15 @@ void connlist_destroy ( struct connlist * cl )
|
||||
}
|
||||
|
||||
|
||||
struct conn * connlist_get ( struct connlist * cl, const struct sockaddr * addr )
|
||||
struct cw_Conn * connlist_get ( struct connlist * cl, const struct sockaddr * addr )
|
||||
{
|
||||
struct conn search;
|
||||
struct cw_Conn search;
|
||||
sock_copyaddr ( &search.addr, addr );
|
||||
return mavl_get_ptr ( cl->by_addr, &search );
|
||||
}
|
||||
|
||||
|
||||
struct conn * connlist_add ( struct connlist * cl, struct conn * conn )
|
||||
struct cw_Conn * connlist_add ( struct connlist * cl, struct cw_Conn * conn )
|
||||
{
|
||||
if ( cl->len != 0 )
|
||||
if ( cl->by_addr->count >= cl->len )
|
||||
@ -161,17 +161,17 @@ struct conn * connlist_add ( struct connlist * cl, struct conn * conn )
|
||||
return mavl_insert_ptr ( cl->by_addr, conn );
|
||||
}
|
||||
|
||||
struct conn * connlist_get_by_session_id ( struct connlist *cl, struct conn * conn )
|
||||
struct cw_Conn * connlist_get_by_session_id ( struct connlist *cl, struct cw_Conn * conn )
|
||||
{
|
||||
return mavl_get_ptr ( cl->by_session_id, conn );
|
||||
}
|
||||
|
||||
struct conn * connlist_add_by_session_id ( struct connlist * cl, struct conn * conn )
|
||||
struct cw_Conn * connlist_add_by_session_id ( struct connlist * cl, struct cw_Conn * conn )
|
||||
{
|
||||
return mavl_insert_ptr ( cl->by_session_id, conn );
|
||||
}
|
||||
|
||||
void connlist_remove ( struct connlist *cl, struct conn * conn )
|
||||
void connlist_remove ( struct connlist *cl, struct cw_Conn * conn )
|
||||
{
|
||||
void * md;
|
||||
md = conn;
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "pthread.h"
|
||||
|
||||
struct connlist {
|
||||
/* struct conn ** connlist; */
|
||||
/* struct cw_Conn ** connlist; */
|
||||
|
||||
struct mavl *by_addr;
|
||||
struct mavl *by_session_id;
|
||||
@ -22,12 +22,12 @@ struct connlist *connlist_create(int len, int cmpports);
|
||||
void connlist_lock(struct connlist *cl);
|
||||
void connlist_unlock(struct connlist *cl);
|
||||
void conlist_destroy(struct connlist *cl);
|
||||
struct conn *connlist_get(struct connlist *cl, const struct sockaddr *addr);
|
||||
struct conn *connlist_add(struct connlist *cl, struct conn *conn);
|
||||
void connlist_remove(struct connlist *cl, struct conn *conn);
|
||||
struct cw_Conn *connlist_get(struct connlist *cl, const struct sockaddr *addr);
|
||||
struct cw_Conn *connlist_add(struct connlist *cl, struct cw_Conn *conn);
|
||||
void connlist_remove(struct connlist *cl, struct cw_Conn *conn);
|
||||
void connlist_destroy(struct connlist *cl);
|
||||
|
||||
struct conn * connlist_get_by_session_id(struct connlist *cl, struct conn * conn);
|
||||
struct conn * connlist_add_by_session_id(struct connlist * cl, struct conn * conn);
|
||||
struct cw_Conn * connlist_get_by_session_id(struct connlist *cl, struct cw_Conn * conn);
|
||||
struct cw_Conn * connlist_add_by_session_id(struct connlist * cl, struct cw_Conn * conn);
|
||||
|
||||
#endif
|
||||
|
32
src/cw/cw.h
32
src/cw/cw.h
@ -327,7 +327,7 @@ int cw_put_elem_result_code(uint8_t * dst, uint32_t code);
|
||||
|
||||
|
||||
|
||||
/*extern int cw_put_ac_status(uint8_t * dst, struct cw_ac_status *s, struct conn *conn);*/
|
||||
/*extern int cw_put_ac_status(uint8_t * dst, struct cw_ac_status *s, struct cw_Conn *conn);*/
|
||||
|
||||
|
||||
struct cw_DescriptorSubelemDef {
|
||||
@ -356,12 +356,12 @@ extern int cw_read_descriptor_subelems(mavl_t store, const char * key, uint8_t *
|
||||
struct cw_DescriptorSubelemDef *elems);
|
||||
|
||||
/*
|
||||
int cw_read_wtp_descriptor(mavl_t mbag, struct conn *conn,
|
||||
int cw_read_wtp_descriptor(mavl_t mbag, struct cw_Conn *conn,
|
||||
struct cw_ElemHandler *eh, uint8_t * data, int len,
|
||||
struct cw_DescriptorSubelemDef *allowed);
|
||||
*/
|
||||
|
||||
int cw_read_wtp_descriptor(mavl_t mbag, struct conn *conn,
|
||||
int cw_read_wtp_descriptor(mavl_t mbag, struct cw_Conn *conn,
|
||||
struct cw_ElemHandler *eh, uint8_t * data, int len,
|
||||
struct cw_DescriptorSubelemDef *allowed);
|
||||
|
||||
@ -372,7 +372,7 @@ int cw_write_radio_element(struct cw_ElemHandler * handler, struct cw_ElemHandle
|
||||
uint8_t * dst);
|
||||
|
||||
|
||||
extern int cw_read_wtp_descriptor_7(mavl_t mbag, struct conn *conn,
|
||||
extern int cw_read_wtp_descriptor_7(mavl_t mbag, struct cw_Conn *conn,
|
||||
struct cw_ElemHandler *eh, uint8_t * data, int len,
|
||||
struct cw_DescriptorSubelemDef *allowed);
|
||||
|
||||
@ -384,7 +384,7 @@ int cw_read_ac_descriptor(mavl_t store,
|
||||
struct cw_DescriptorSubelemDef *allowed);
|
||||
|
||||
|
||||
int cw_setup_dtls(struct conn * conn, mavl_t cfg, const char *prefix, char * default_cipher);
|
||||
int cw_setup_dtls(struct cw_Conn * conn, mavl_t cfg, const char *prefix, char * default_cipher);
|
||||
|
||||
|
||||
|
||||
@ -444,11 +444,11 @@ int cw_out_radio_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerP
|
||||
int cw_out_radio_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
|
||||
, uint8_t * dst);
|
||||
|
||||
extern int cw_in_wtp_reboot_statistics(struct conn *conn, struct cw_action_in *a,
|
||||
extern int cw_in_wtp_reboot_statistics(struct cw_Conn *conn, struct cw_action_in *a,
|
||||
uint8_t * data, int len, struct sockaddr *from);
|
||||
|
||||
|
||||
extern int cw_in_wtp_board_data(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
extern int cw_in_wtp_board_data(struct cw_Conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len, struct sockaddr *from);
|
||||
|
||||
/*
|
||||
@ -457,24 +457,24 @@ int cw_in_vendor_specific_payload(struct cw_ElemHandler *handler,
|
||||
uint8_t * data, int len);
|
||||
*/
|
||||
|
||||
extern int cw_in_capwap_control_ip_address(struct conn *conn, struct cw_action_in *a,
|
||||
extern int cw_in_capwap_control_ip_address(struct cw_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,
|
||||
extern int cw_in_capwap_local_ipv4_address(struct cw_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,
|
||||
extern int cw_in_capwap_local_ipv6_address(struct cw_Conn *conn, struct cw_action_in *a,
|
||||
uint8_t * data, int len,
|
||||
struct sockaddr *from);
|
||||
|
||||
extern int cw_in_radio_operational_state(struct conn *conn, struct cw_action_in *a,
|
||||
extern int cw_in_radio_operational_state(struct cw_Conn *conn, struct cw_action_in *a,
|
||||
uint8_t * data, int len, struct sockaddr *from);
|
||||
|
||||
|
||||
/*
|
||||
int cw_process_element(struct conn * conn,
|
||||
int cw_process_element(struct cw_Conn * conn,
|
||||
struct cw_MsgData * msgdata, int proto, int vendor,
|
||||
uint8_t * elem, int max_len);
|
||||
*/
|
||||
@ -502,7 +502,7 @@ int cw_process_element(struct cw_ElemHandlerParams *params,
|
||||
#define cw_out_capwap_local_ip_address_7 cw_out_wtp_ip_address
|
||||
|
||||
|
||||
void cw_init_request(struct conn *conn, int msg_id);
|
||||
void cw_init_request(struct cw_Conn *conn, int msg_id);
|
||||
|
||||
|
||||
/**
|
||||
@ -527,16 +527,16 @@ int cw_put_elem_radio_administrative_state(uint8_t * dst, int rid, int state);
|
||||
int cw_put_local_ip_address(uint8_t *dst, int id, int ipv_id, int ipv6_id,
|
||||
uint8_t *src, int len);
|
||||
|
||||
int cw_detect_nat(struct conn *conn);
|
||||
int cw_detect_nat(struct cw_Conn *conn);
|
||||
|
||||
uint8_t *cw_init_data_keep_alive_msg(uint8_t * buffer,uint8_t *rmac);
|
||||
|
||||
/*int cw_out_radio_generic(struct conn *conn, struct cw_action_out *a, uint8_t * dst);*/
|
||||
/*int cw_out_radio_generic(struct cw_Conn *conn, struct cw_action_out *a, uint8_t * dst);*/
|
||||
|
||||
int cw_put_elem_session_id(uint8_t *dst, uint8_t *session_id, int len);
|
||||
|
||||
int cw_result_is_ok( int rc );
|
||||
int cw_put_msg(struct conn *conn, uint8_t * rawout);
|
||||
int cw_put_msg(struct cw_Conn *conn, uint8_t * rawout);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
@ -66,10 +66,8 @@ int cw_decode_element(struct cw_ElemHandlerParams *params, int proto,
|
||||
return CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;
|
||||
}
|
||||
|
||||
printf ("USING HANDLER TO DECODE: %d %s\n",handler->id,handler->name);
|
||||
rc = handler->get(handler, params, data, len);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -123,4 +121,7 @@ int cw_decode_elements(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr
|
||||
|
||||
}
|
||||
|
||||
mavl_destroy(mand_found);
|
||||
mlist_destroy(unrecognized);
|
||||
return 0;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
* @retval 1 NAT detected
|
||||
* @retval 0 no NAT was detected
|
||||
*/
|
||||
int cw_detect_nat(struct conn *conn)
|
||||
int cw_detect_nat(struct cw_Conn *conn)
|
||||
{
|
||||
cw_Val_t * result;
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
|
||||
|
||||
int cw_in_capwap_local_ipv6_address(struct conn *conn, struct cw_action_in *a,
|
||||
int cw_in_capwap_local_ipv6_address(struct cw_Conn *conn, struct cw_action_in *a,
|
||||
uint8_t * data, int len,struct sockaddr *from)
|
||||
{
|
||||
struct sockaddr_in6 addr;
|
||||
|
@ -8,14 +8,43 @@ int cw_in_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams *
|
||||
uint8_t * elem_data, int elem_len)
|
||||
{
|
||||
cw_Val_t * result;
|
||||
cw_Val_t val;
|
||||
cw_Type_t * type;
|
||||
int n;
|
||||
char strval[2048];
|
||||
|
||||
if (!handler->type){
|
||||
memset(&val,0,sizeof(cw_Val_t));
|
||||
|
||||
|
||||
type = (cw_Type_t*)handler->type;
|
||||
|
||||
if (!type){
|
||||
cw_log(LOG_ERR,"Can't handle element: %s, no type defined",handler->name);
|
||||
return CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;
|
||||
}
|
||||
|
||||
result = cw_ktv_add(params->remote_cfg, handler->key,
|
||||
handler->type,NULL, elem_data,elem_len);
|
||||
type->read(params->local_cfg, handler->key,elem_data,elem_len,handler->param);
|
||||
|
||||
|
||||
// exit(0);
|
||||
|
||||
/* if (!result){
|
||||
cw_log(LOG_ERR, "Can't create kvstore element for key %s of type %s: %s",
|
||||
handler->key,type->name, strerror(errno));
|
||||
return CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
// n = type->to_str(&val,strval,2048);
|
||||
|
||||
// printf("SETTING: %s: %s (%d)\n",handler->key,strval,n);
|
||||
|
||||
|
||||
// result = cw_ktv_add(params->remote_cfg, handler->key,
|
||||
// handler->type,NULL, elem_data,elem_len);
|
||||
// params->elem=result;
|
||||
return CAPWAP_RESULT_SUCCESS;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "log.h"
|
||||
|
||||
|
||||
int cw_in_wtp_reboot_statistics(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int cw_in_wtp_reboot_statistics(struct cw_Conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len, struct sockaddr *from)
|
||||
{
|
||||
/*
|
||||
|
@ -36,7 +36,7 @@
|
||||
* alread initilaized in buffer
|
||||
* Message alements are taken fom actiondef in #conn->action
|
||||
*/
|
||||
int cw_put_msg(struct conn *conn, uint8_t * rawout)
|
||||
int cw_put_msg(struct cw_Conn *conn, uint8_t * rawout)
|
||||
{
|
||||
char details[1024];
|
||||
uint8_t *msgptr,*dst;
|
||||
@ -174,7 +174,7 @@ printf("Elem: %d %d %d %s\n", data->proto, data->vendor, data->id, handler->name
|
||||
*/
|
||||
|
||||
|
||||
int cw_put_custom_msg(struct conn *conn, uint8_t * rawout, /*mavl_conststr_t elems*/ int t)
|
||||
int cw_put_custom_msg(struct cw_Conn *conn, uint8_t * rawout, /*mavl_conststr_t elems*/ int t)
|
||||
{
|
||||
|
||||
/*
|
||||
|
@ -22,12 +22,12 @@
|
||||
#include "keys.h"
|
||||
|
||||
|
||||
int cw_read_descriptor_subelems(mavl_t cfg, const char * parent_key,
|
||||
int cw_read_descriptor_subelems(mavl_t cfg, const char *parent_key,
|
||||
uint8_t * data, int len,
|
||||
struct cw_DescriptorSubelemDef *elems)
|
||||
{
|
||||
uint32_t vendor_id;
|
||||
int sublen,subtype;
|
||||
int sublen, subtype;
|
||||
int errors = 0;
|
||||
int success = 0;
|
||||
int sub = 0;
|
||||
@ -41,18 +41,17 @@ int cw_read_descriptor_subelems(mavl_t cfg, const char * parent_key,
|
||||
sublen = cw_get_word(data + sub + 6);
|
||||
subtype = cw_get_word(data + sub + 4);
|
||||
|
||||
|
||||
/* search sub-element */
|
||||
for (i = 0; elems[i].maxlen; i++) {
|
||||
|
||||
if (elems[i].type == subtype /* && elems[i].vendor_id==vendor_id*/)
|
||||
if (elems[i].type == subtype)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (!elems[i].maxlen) {
|
||||
cw_dbg_version_subelem(DBG_ELEM_ERR, "Can't handle sub-elem, vendor or type unknown",
|
||||
subtype, vendor_id, data+sub+8, sublen);
|
||||
/* cw_dbg_version_subelem(DBG_ELEM_ERR,
|
||||
"Can't handle sub-elem, vendor or type unknown",
|
||||
subtype, vendor_id,
|
||||
data + sub + 8, sublen);*/
|
||||
errors++;
|
||||
} else {
|
||||
int l = sublen;
|
||||
@ -69,15 +68,24 @@ int cw_read_descriptor_subelems(mavl_t cfg, const char * parent_key,
|
||||
|
||||
|
||||
/* vendor */
|
||||
sprintf(key,"%s/%s/%s",parent_key,elems[i].key,CW_SKEY_VENDOR);
|
||||
cw_ktv_add(cfg,key,CW_TYPE_DWORD,NULL,data + sub,4);
|
||||
sprintf(key, "%s/%s/%s", parent_key, elems[i].key,
|
||||
CW_SKEY_VENDOR);
|
||||
cw_cfg_set_int(cfg, key, vendor_id);
|
||||
|
||||
|
||||
/* version */
|
||||
sprintf(key,"%s/%s/%s",parent_key,elems[i].key,CW_SKEY_VERSION);
|
||||
cw_ktv_add(cfg,key,CW_TYPE_BSTR16,NULL,data+sub+8,l);
|
||||
sprintf(key, "%s/%s/%s", parent_key, elems[i].key,
|
||||
CW_SKEY_VERSION);
|
||||
|
||||
CW_TYPE_BSTR16->read(cfg,key,data+sub+8,l,NULL);
|
||||
|
||||
|
||||
sprintf(dbgstr, "%s", key);
|
||||
cw_dbg_version_subelem(DBG_SUBELEM, dbgstr, subtype, vendor_id, data+sub+8,l);
|
||||
|
||||
|
||||
|
||||
/* cw_dbg_version_subelem(DBG_SUBELEM, dbgstr, subtype,
|
||||
vendor_id, data + sub + 8, l);*/
|
||||
success++;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "log.h"
|
||||
|
||||
|
||||
int cw_read_from(struct conn *conn, struct sockaddr_storage *from)
|
||||
int cw_read_from(struct cw_Conn *conn, struct sockaddr_storage *from)
|
||||
{
|
||||
int n;
|
||||
uint8_t buf[2024];
|
||||
|
@ -16,7 +16,7 @@ static struct cw_DescriptorSubelemDef allowed_default[] = {
|
||||
};
|
||||
|
||||
|
||||
int cw_read_wtp_descriptor(mavl_t cfg, struct conn *conn,
|
||||
int cw_read_wtp_descriptor(mavl_t cfg, struct cw_Conn *conn,
|
||||
struct cw_ElemHandler *eh, uint8_t * data, int len,
|
||||
struct cw_DescriptorSubelemDef *allowed)
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ static struct cw_DescriptorSubelemDef allowed_default[] = {
|
||||
/**
|
||||
* Read WTP Descriptor in Cisco-Style (Draft 7)
|
||||
*/
|
||||
int cw_read_wtp_descriptor_7(mavl_t cfg, struct conn *conn,
|
||||
int cw_read_wtp_descriptor_7(mavl_t cfg, struct cw_Conn *conn,
|
||||
struct cw_ElemHandler *eh, uint8_t * data, int len,
|
||||
struct cw_DescriptorSubelemDef *allowed)
|
||||
{
|
||||
@ -30,11 +30,10 @@ int cw_read_wtp_descriptor_7(mavl_t cfg, struct conn *conn,
|
||||
char key[64];
|
||||
|
||||
sprintf(key,"%s/%s",eh->key, CW_SKEY_MAX_RADIOS);
|
||||
cw_ktv_add(cfg,key,CW_TYPE_BYTE,NULL,data,1);
|
||||
cw_cfg_set_int(cfg,key,cw_get_byte(data));
|
||||
|
||||
sprintf(key,"%s/%s",eh->key, CW_SKEY_RADIOS_IN_USE);
|
||||
cw_ktv_add(cfg,key,CW_TYPE_BYTE,NULL,data+1,1);
|
||||
|
||||
cw_cfg_set_int(cfg,key,cw_get_byte(data+1));
|
||||
|
||||
pos = 2;
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
|
||||
|
||||
static int get_psk(struct conn *conn, const char *username, uint8_t ** psk,
|
||||
static int get_psk(struct cw_Conn *conn, const char *username, uint8_t ** psk,
|
||||
unsigned int *len)
|
||||
{
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
@ -35,7 +35,7 @@ static int get_psk(struct conn *conn, const char *username, uint8_t ** psk,
|
||||
* @param default_cipher
|
||||
* @return
|
||||
*/
|
||||
int cw_setup_dtls(struct conn *conn, mavl_t cfg, const char *prefix,
|
||||
int cw_setup_dtls(struct cw_Conn *conn, mavl_t cfg, const char *prefix,
|
||||
char *default_cipher)
|
||||
{
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
|
@ -104,6 +104,32 @@ static int cast(cw_Val_t * data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bread(cw_Cfg_t *cfg, const char * key, const uint8_t *src, int len, void *param)
|
||||
{
|
||||
char *d, *dst;
|
||||
dst = malloc(len*2+3);
|
||||
if (dst==NULL)
|
||||
return 0;
|
||||
d=dst;
|
||||
|
||||
if ( format_is_utf8 ( src, len) ) {
|
||||
d += sprintf ( d, "%.*s", len, src );
|
||||
|
||||
} else {
|
||||
d += sprintf ( d, ".x" );
|
||||
d += format_hex ( d, src,len);
|
||||
}
|
||||
|
||||
cw_cfg_set(cfg,key,dst);
|
||||
free(dst);
|
||||
return d - dst;
|
||||
}
|
||||
|
||||
static int bwrite(cw_Cfg_t *cfg, const char *key, const uint8_t *dst, void * param)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
const struct cw_Type cw_type_bstr16 = {
|
||||
"Bstr16", /* name */
|
||||
@ -115,7 +141,10 @@ const struct cw_Type cw_type_bstr16 = {
|
||||
len, /* len */
|
||||
data, /* data */
|
||||
get_type_name, /* get_type_name */
|
||||
cast /* cast */
|
||||
cast, /* cast */
|
||||
bread,
|
||||
bwrite
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -35,6 +35,9 @@ static int put(const cw_Val_t *data, uint8_t * dst)
|
||||
|
||||
static const char * get_guardstr(int val, const cw_ValValRange_t * valrange)
|
||||
{
|
||||
if (valrange==NULL)
|
||||
return NULL;
|
||||
|
||||
while(valrange->name!=NULL){
|
||||
if(val>=valrange->min && val<=valrange->max)
|
||||
return valrange->name;
|
||||
@ -121,6 +124,26 @@ static int cast(cw_Val_t * data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bread(cw_Cfg_t *cfg, const char * key, const uint8_t *src, int len, void *param)
|
||||
{
|
||||
uint8_t val;
|
||||
cw_ValValRange_t * valrange = (cw_ValValRange_t *) param;
|
||||
const char *str;
|
||||
|
||||
val = cw_get_byte(src);
|
||||
str = get_guardstr(val, valrange);
|
||||
if (str != NULL)
|
||||
cw_cfg_set(cfg,key,str);
|
||||
else
|
||||
cw_cfg_set_int(cfg,key,val);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int bwrite(cw_Cfg_t *cfg, const char *key, const uint8_t *dst, void * param)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct cw_Type cw_type_byte = {
|
||||
"Byte", /* name */
|
||||
@ -132,5 +155,8 @@ const struct cw_Type cw_type_byte = {
|
||||
len, /* len */
|
||||
data, /* data */
|
||||
get_type_name, /* get_type_name */
|
||||
cast
|
||||
cast,
|
||||
bread,
|
||||
bwrite
|
||||
|
||||
};
|
||||
|
@ -211,7 +211,7 @@ static void cw_dbg_vlog_line(struct cw_LogWriter * writer,
|
||||
/**
|
||||
* Put a list of missing mandatory message elements to debug output
|
||||
*/
|
||||
void cw_dbg_missing_mand(int level, struct conn *conn, int ** ml, int n,
|
||||
void cw_dbg_missing_mand(int level, struct cw_Conn *conn, int ** ml, int n,
|
||||
int * a)
|
||||
{
|
||||
/*
|
||||
@ -246,7 +246,7 @@ void cw_dbg_missing_mand(int level, struct conn *conn, int ** ml, int n,
|
||||
/**
|
||||
* Display a packet on for debugger
|
||||
*/
|
||||
void cw_dbg_pkt(int level, struct conn *conn, uint8_t * packet, int len,
|
||||
void cw_dbg_pkt(int level, struct cw_Conn *conn, uint8_t * packet, int len,
|
||||
struct sockaddr *from)
|
||||
{
|
||||
|
||||
@ -308,7 +308,7 @@ void cw_dbg_dmp(int level, const uint8_t * data, int len, const char *format, ..
|
||||
}
|
||||
|
||||
|
||||
void cw_dbg_msg(int level, struct conn *conn, uint8_t * packet, int len,
|
||||
void cw_dbg_msg(int level, struct cw_Conn *conn, uint8_t * packet, int len,
|
||||
struct sockaddr *from)
|
||||
{
|
||||
|
||||
@ -383,7 +383,7 @@ void cw_dbg(int level, const char *format, ...){
|
||||
|
||||
|
||||
|
||||
void cw_dbg_elem(int level, struct conn *conn, int msg,
|
||||
void cw_dbg_elem(int level, struct cw_Conn *conn, int msg,
|
||||
struct cw_ElemHandler * handler, const uint8_t * msgbuf, int len)
|
||||
{
|
||||
char vendorname[256];
|
||||
|
18
src/cw/dbg.h
18
src/cw/dbg.h
@ -115,6 +115,8 @@ enum cw_dbg_levels{
|
||||
|
||||
DBG_CFG_DMP,
|
||||
|
||||
DBG_CFG_SET,
|
||||
|
||||
/** Debug Mods */
|
||||
DBG_MOD,
|
||||
|
||||
@ -147,14 +149,14 @@ void cw_dbg_set_level (int level, int on);
|
||||
int cw_dbg_set_level_from_str(const char *level);
|
||||
|
||||
/*
|
||||
void cw_dbg_elem_(struct conn * conn, int msg, int msgelem, const uint8_t * msgbuf, int len);
|
||||
void cw_dbg_elem_(struct cw_Conn * conn, int msg, int msgelem, const uint8_t * msgbuf, int len);
|
||||
*/
|
||||
/*
|
||||
void cw_dbg_missing_mand(int level,struct conn *conn,cw_action_in_t ** ml,int n,cw_action_in_t *a);
|
||||
void cw_dbg_missing_mand(int level,struct cw_Conn *conn,cw_action_in_t ** ml,int n,cw_action_in_t *a);
|
||||
*/
|
||||
|
||||
void cw_dbg_packet(struct conn *conn, uint8_t * packet, int len);
|
||||
void cw_dbg_pkt(int level,struct conn *conn, uint8_t * packet, int len,struct sockaddr *from);
|
||||
void cw_dbg_packet(struct cw_Conn *conn, uint8_t * packet, int len);
|
||||
void cw_dbg_pkt(int level,struct cw_Conn *conn, uint8_t * packet, int len,struct sockaddr *from);
|
||||
void cw_dbg(int level, const char *format, ...);
|
||||
void cw_dbg_dmp(int level, const uint8_t * data, int len, const char *format, ...);
|
||||
|
||||
@ -199,16 +201,16 @@ void cw_dbg_dmp_(int level, const uint8_t * data, int len, const char *format, .
|
||||
|
||||
|
||||
|
||||
void cw_dbg_elem(int level, struct conn *conn, int msg,
|
||||
void cw_dbg_elem(int level, struct cw_Conn *conn, int msg,
|
||||
struct cw_ElemHandler * handler, const uint8_t * msgbuf, int len);
|
||||
|
||||
|
||||
void cw_dbg_pkt_nc(int level,struct netconn *nc, uint8_t * packet, int len,struct sockaddr *from);
|
||||
|
||||
void cw_dbg_msg(int level,struct conn *conn, uint8_t * packet, int len,struct sockaddr *from);
|
||||
void cw_dbg_msg(int level,struct cw_Conn *conn, uint8_t * packet, int len,struct sockaddr *from);
|
||||
char * cw_dbg_mkdmp(const uint8_t * data, int len);
|
||||
void cw_dbg_version_subelem(int level, const char *context, int subtype,
|
||||
uint32_t vendor_id, const uint8_t * vstr, int len);
|
||||
//void cw_dbg_version_subelem(int level, const char *context, int subtype,
|
||||
// uint32_t vendor_id, const uint8_t * vstr, int len);
|
||||
void cw_dbg_ktv_dump(mavl_t ktv, uint32_t dbglevel,
|
||||
const char *header, const char *prefix, const char *footer );
|
||||
|
||||
|
@ -63,6 +63,9 @@ struct cw_StrListElem cw_dbg_strings[] = {
|
||||
{ DBG_DTLS_BIO_DMP, "dtls_bio_dmp"},
|
||||
{ DBG_DTLS_DETAIL, "dtls_detail"},
|
||||
|
||||
{ DBG_CFG_SET, "cfg_set" },
|
||||
|
||||
|
||||
{DBG_CFG_DMP, "cfg_dmp" },
|
||||
|
||||
{ DBG_WARN, "warn" },
|
||||
|
@ -37,7 +37,7 @@
|
||||
* @param maxlen maximum number of bytes to read
|
||||
* @return the number of bytes read
|
||||
*/
|
||||
int dtls_bio_read(struct conn *conn, char *out, int maxlen)
|
||||
int dtls_bio_read(struct cw_Conn *conn, char *out, int maxlen)
|
||||
{
|
||||
int ret;
|
||||
if (conn->dtls_buffer_len == 0) {
|
||||
@ -75,7 +75,7 @@ int dtls_bio_read(struct conn *conn, char *out, int maxlen)
|
||||
* @param len number of bytes to write
|
||||
* @return the number of bytes written
|
||||
*/
|
||||
int dtls_bio_write(struct conn *conn, const char *data, int len)
|
||||
int dtls_bio_write(struct cw_Conn *conn, const char *data, int len)
|
||||
{
|
||||
uint8_t buffer[4096];
|
||||
int rc;
|
||||
|
@ -217,7 +217,7 @@ void dtls_openssl_data_destroy(struct dtls_openssl_data * d){
|
||||
free(d);
|
||||
}
|
||||
|
||||
int dtls_openssl_set_certs(struct conn * conn, struct dtls_openssl_data *d)
|
||||
int dtls_openssl_set_certs(struct cw_Conn * conn, struct dtls_openssl_data *d)
|
||||
{
|
||||
int rc;
|
||||
if (conn->dtls_key_file && conn->dtls_cert_file){
|
||||
@ -255,7 +255,7 @@ int dtls_openssl_set_certs(struct conn * conn, struct dtls_openssl_data *d)
|
||||
int generate_session_id(const SSL *ssl, unsigned char * id, unsigned int *id_len)
|
||||
{
|
||||
/* BIO * b = SSL_get_rbio(ssl);
|
||||
struct conn * conn = b->ptr;
|
||||
struct cw_Conn * conn = b->ptr;
|
||||
*/
|
||||
const char * sessid = "9123456789";
|
||||
/* printf ("MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMaking session id\n");*/
|
||||
@ -292,7 +292,7 @@ return 1;
|
||||
static unsigned int psk_server_cb(SSL *ssl,const char *identity, unsigned char * psk, unsigned int max_psk_len)
|
||||
{
|
||||
BIO * b = SSL_get_rbio(ssl);
|
||||
struct conn * conn = BIO_get_data(b); /*->ptr;*/
|
||||
struct cw_Conn * conn = BIO_get_data(b); /*->ptr;*/
|
||||
|
||||
int l = bstr16_len(conn->dtls_psk) < max_psk_len ? bstr16_len(conn->dtls_psk) : max_psk_len;
|
||||
memcpy(psk,conn->dtls_psk,l);
|
||||
@ -304,7 +304,7 @@ static unsigned int psk_server_cb(SSL *ssl,const char *identity, unsigned char *
|
||||
|
||||
|
||||
|
||||
struct dtls_openssl_data * dtls_openssl_data_create(struct conn * conn, const SSL_METHOD * method, BIO_METHOD * bio)
|
||||
struct dtls_openssl_data * dtls_openssl_data_create(struct cw_Conn * conn, const SSL_METHOD * method, BIO_METHOD * bio)
|
||||
{
|
||||
int rc;
|
||||
struct dtls_openssl_data * d = malloc(sizeof(struct dtls_openssl_data));
|
||||
@ -507,7 +507,7 @@ out_err:
|
||||
/*//#include <socket.h>*/
|
||||
#include <netinet/in.h>
|
||||
|
||||
int dtls_openssl_shutdown(struct conn *conn)
|
||||
int dtls_openssl_shutdown(struct cw_Conn *conn)
|
||||
{
|
||||
struct dtls_openssl_data * d ;
|
||||
|
||||
@ -552,7 +552,7 @@ int dtls_openssl_generate_cookie(SSL *ssl, unsigned char *cookie, unsigned int *
|
||||
char sock_buf2[SOCK_ADDR_BUFSIZE];
|
||||
|
||||
BIO * b = SSL_get_rbio(ssl);
|
||||
struct conn * conn = BIO_get_data(b); /*b->ptr;*/
|
||||
struct cw_Conn * conn = BIO_get_data(b); /*b->ptr;*/
|
||||
|
||||
cw_rand(conn->dtls_cookie,sizeof(conn->dtls_cookie));
|
||||
|
||||
@ -571,8 +571,8 @@ int dtls_openssl_verify_cookie(SSL *ssl, const unsigned char *cookie, unsigned i
|
||||
char sock_buf[SOCK_ADDR_BUFSIZE];
|
||||
char sock_buf2[SOCK_ADDR_BUFSIZE];
|
||||
BIO * b = SSL_get_rbio(ssl);
|
||||
/*struct conn * conn = b->ptr;*/
|
||||
struct conn * conn = BIO_get_data(b); /*b->ptr;*/
|
||||
/*struct cw_Conn * conn = b->ptr;*/
|
||||
struct cw_Conn * conn = BIO_get_data(b); /*b->ptr;*/
|
||||
|
||||
cw_dbg(DBG_DTLS,"Verifying DTLS cookie from %s: %s",
|
||||
sock_addr2str(&conn->addr,sock_buf),sock_hwaddr2idstr(conn->dtls_cookie,len,sock_buf2));
|
||||
@ -588,7 +588,7 @@ int dtls_openssl_verify_cookie(SSL *ssl, const unsigned char *cookie, unsigned i
|
||||
}
|
||||
|
||||
|
||||
int dtls_openssl_read(struct conn * conn, uint8_t *buffer, int len)
|
||||
int dtls_openssl_read(struct cw_Conn * conn, uint8_t *buffer, int len)
|
||||
{
|
||||
struct dtls_openssl_data * d = conn->dtls_data;
|
||||
int rc = SSL_read(d->ssl,buffer,len);
|
||||
@ -599,7 +599,7 @@ int dtls_openssl_read(struct conn * conn, uint8_t *buffer, int len)
|
||||
return rc;
|
||||
}
|
||||
|
||||
int dtls_openssl_write(struct conn * conn, const uint8_t *buffer, int len)
|
||||
int dtls_openssl_write(struct cw_Conn * conn, const uint8_t *buffer, int len)
|
||||
{
|
||||
struct dtls_openssl_data * d = conn->dtls_data;
|
||||
int rc = SSL_write(d->ssl,buffer,len);
|
||||
|
@ -48,20 +48,20 @@ extern int dtls_openssl_init();
|
||||
#define CAPWAP_CIPHER "ALL"
|
||||
|
||||
|
||||
struct dtls_openssl_data * dtls_openssl_data_create(struct conn * conn, const SSL_METHOD * method, BIO_METHOD * bio);
|
||||
struct dtls_openssl_data * dtls_openssl_data_create(struct cw_Conn * conn, const SSL_METHOD * method, BIO_METHOD * bio);
|
||||
extern int dtls_openssl_psk_key2bn(const char *psk_key, unsigned char *psk, unsigned int max_psk_len);
|
||||
extern int dtls_openssl_generate_cookie(SSL *ssl, unsigned char *cookie, unsigned int *cookie_len);
|
||||
extern int dtls_openssl_verify_cookie(SSL *ssl, const unsigned char *cookie, unsigned int cookie_len);
|
||||
|
||||
extern int dtls_openssl_read(struct conn * conn, uint8_t *buffer, int len);
|
||||
extern int dtls_openssl_write(struct conn * conn, const uint8_t *buffer, int len);
|
||||
extern int dtls_openssl_connect(struct conn * conn);
|
||||
extern const char * dtls_openssl_get_cipher(struct conn * conn, char *dst);
|
||||
extern int dtls_openssl_read(struct cw_Conn * conn, uint8_t *buffer, int len);
|
||||
extern int dtls_openssl_write(struct cw_Conn * conn, const uint8_t *buffer, int len);
|
||||
extern int dtls_openssl_connect(struct cw_Conn * conn);
|
||||
extern const char * dtls_openssl_get_cipher(struct cw_Conn * conn, char *dst);
|
||||
|
||||
extern int dtls_openssl_log_error(SSL * ssl, int rc, const char *txt);
|
||||
|
||||
extern int dtls_openssl_accept(struct conn * conn);
|
||||
extern int dtls_openssl_set_certs(struct conn * conn, struct dtls_openssl_data *d);
|
||||
extern int dtls_openssl_accept(struct cw_Conn * conn);
|
||||
extern int dtls_openssl_set_certs(struct cw_Conn * conn, struct dtls_openssl_data *d);
|
||||
|
||||
|
||||
|
||||
@ -77,7 +77,7 @@ extern int dtls_openssl_log_error_queue(const char *txt);
|
||||
|
||||
extern BIO_METHOD * dtls_openssl_bio_method();
|
||||
|
||||
extern int dtls_openssl_shutdown(struct conn *conn);
|
||||
extern int dtls_openssl_shutdown(struct cw_Conn *conn);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "dtls_openssl.h"
|
||||
#include "log.h"
|
||||
|
||||
int dtls_openssl_accept(struct conn *conn)
|
||||
int dtls_openssl_accept(struct cw_Conn *conn)
|
||||
{
|
||||
struct dtls_openssl_data *d;
|
||||
char sock_buf[SOCK_ADDR_BUFSIZE];
|
||||
|
@ -75,16 +75,16 @@ BIO_METHOD *dtls_openssl_bio_method()
|
||||
|
||||
int dtls_openssl_bio_write(BIO * b, const char *data, int len)
|
||||
{
|
||||
/* struct conn *conn = b->ptr;*/
|
||||
struct conn *conn = BIO_get_data(b);
|
||||
/* struct cw_Conn *conn = b->ptr;*/
|
||||
struct cw_Conn *conn = BIO_get_data(b);
|
||||
return dtls_bio_write(conn, data, len);
|
||||
}
|
||||
|
||||
|
||||
int dtls_openssl_bio_read(BIO * b, char *out, int maxlen)
|
||||
{
|
||||
/*struct conn *conn = b->ptr;*/
|
||||
struct conn *conn = BIO_get_data(b);
|
||||
/*struct cw_Conn *conn = b->ptr;*/
|
||||
struct cw_Conn *conn = BIO_get_data(b);
|
||||
return dtls_bio_read(conn, out, maxlen);
|
||||
}
|
||||
|
||||
@ -123,8 +123,8 @@ int dtls_openssl_bio_free(BIO * bio)
|
||||
|
||||
long dtls_openssl_bio_ctrl(BIO * b, int cmd, long num, void *ptr)
|
||||
{
|
||||
/*struct conn *conn = b->ptr;*/
|
||||
struct conn *conn = BIO_get_data(b);
|
||||
/*struct cw_Conn *conn = b->ptr;*/
|
||||
struct cw_Conn *conn = BIO_get_data(b);
|
||||
|
||||
long ret = 1;
|
||||
switch (cmd) {
|
||||
|
@ -15,8 +15,8 @@
|
||||
{
|
||||
int l;
|
||||
BIO *b = SSL_get_rbio(ssl);
|
||||
/*struct conn *conn = b->ptr;*/
|
||||
struct conn * conn = BIO_get_data(b); /*b->ptr;*/
|
||||
/*struct cw_Conn *conn = b->ptr;*/
|
||||
struct cw_Conn * conn = BIO_get_data(b); /*b->ptr;*/
|
||||
|
||||
snprintf(identity, max_identity_len, "CLient_identity");
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
|
||||
|
||||
int
|
||||
dtls_openssl_connect(struct conn *conn)
|
||||
dtls_openssl_connect(struct cw_Conn *conn)
|
||||
{
|
||||
struct dtls_openssl_data *d;
|
||||
int rc;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include "dtls_openssl.h"
|
||||
|
||||
const char * dtls_openssl_get_cipher(struct conn * conn, char *dst)
|
||||
const char * dtls_openssl_get_cipher(struct cw_Conn * conn, char *dst)
|
||||
{
|
||||
struct dtls_openssl_data * d;
|
||||
const SSL_CIPHER * c;
|
||||
|
@ -37,7 +37,7 @@
|
||||
|
||||
|
||||
|
||||
int conn_send_data_msg(struct conn * conn, uint8_t *rawmsg,int len)
|
||||
int conn_send_data_msg(struct cw_Conn * conn, uint8_t *rawmsg,int len)
|
||||
{
|
||||
int packetlen = len;
|
||||
int fragoffset;
|
||||
@ -93,7 +93,7 @@ int conn_send_data_msg(struct conn * conn, uint8_t *rawmsg,int len)
|
||||
|
||||
#define MAX_MTU 9500
|
||||
int
|
||||
cw_send_msg( struct conn * conn, uint8_t *msg)
|
||||
cw_send_msg( struct cw_Conn * conn, uint8_t *msg)
|
||||
{
|
||||
uint8_t buf[MAX_MTU];
|
||||
int fragoffset,hlen,mtu;
|
||||
@ -166,7 +166,7 @@ cw_send_msg( struct conn * conn, uint8_t *msg)
|
||||
|
||||
|
||||
|
||||
int cw_send_request(struct conn *conn,int msg_id)
|
||||
int cw_send_request(struct cw_Conn *conn,int msg_id)
|
||||
{
|
||||
time_t timer;
|
||||
int i;
|
||||
@ -218,7 +218,7 @@ int cw_send_request(struct conn *conn,int msg_id)
|
||||
|
||||
|
||||
/*// XXX find a better name for this function */
|
||||
int cw_send_custom_request_2(struct conn *conn,int msg_id)
|
||||
int cw_send_custom_request_2(struct cw_Conn *conn,int msg_id)
|
||||
{
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
#include "cw/mavltypes.h"
|
||||
|
||||
static int postprocess_join_request(struct conn *conn);
|
||||
static int postprocess_join_request(struct cw_Conn *conn);
|
||||
|
||||
|
||||
static cw_ValStruct_t wtp_reboot_statistics[] = {
|
||||
@ -772,7 +772,7 @@ static struct cw_MsgDef messages[] = {
|
||||
};
|
||||
|
||||
|
||||
static int postprocess_join_request(struct conn *conn)
|
||||
static int postprocess_join_request(struct cw_Conn *conn)
|
||||
{
|
||||
cw_Val_t * result;
|
||||
|
||||
|
@ -34,7 +34,7 @@ static int init(struct cw_Mod * mod, mavl_t global_cfg, int role)
|
||||
}
|
||||
|
||||
|
||||
static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int elems_len,
|
||||
static int detect(struct cw_Conn *conn, const uint8_t * rawmsg, int rawlen, int elems_len,
|
||||
struct sockaddr *from, int mode)
|
||||
{
|
||||
if (mode != CW_MOD_MODE_CAPWAP)
|
||||
@ -44,7 +44,7 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele
|
||||
}
|
||||
|
||||
|
||||
int static setup_cfg(struct conn * conn)
|
||||
int static setup_cfg(struct cw_Conn * conn)
|
||||
{
|
||||
int security;
|
||||
|
||||
|
@ -756,10 +756,13 @@ static struct cw_ElemHandler handlers70[] = {
|
||||
CW_CISCO_BOARD_DATA_OPTIONS, /* Element ID */
|
||||
CW_VENDOR_ID_CISCO,0, /* Vendor / Proto */
|
||||
4,4, /* min/max length */
|
||||
cisco_wtp_board_data_options, /* type */
|
||||
CW_TYPE_STRUCT, /* type */
|
||||
"cisco/wtp-board-data/options", /* Key */
|
||||
cw_in_generic_struct, /* handler */
|
||||
cw_out_generic_struct /* put */
|
||||
cw_in_generic, /* handler */
|
||||
cw_out_generic, /* put */
|
||||
NULL,
|
||||
NULL,
|
||||
cisco_wtp_board_data_options, /* struct datae */
|
||||
}
|
||||
,
|
||||
{
|
||||
@ -2141,7 +2144,7 @@ static cw_StateMachineState_t statemachine_states[]={
|
||||
};
|
||||
|
||||
|
||||
static int (*postprocess_join_request_parent)(struct conn * conn);
|
||||
static int (*postprocess_join_request_parent)(struct cw_Conn * conn);
|
||||
struct cw_MsgSet * cisco_register_msg_set(struct cw_MsgSet * set, int mode){
|
||||
|
||||
struct cw_MsgData * md;
|
||||
@ -2161,7 +2164,7 @@ struct cw_MsgSet * cisco_register_msg_set(struct cw_MsgSet * set, int mode){
|
||||
|
||||
|
||||
|
||||
static void set_ac_version(struct conn * conn)
|
||||
static void set_ac_version(struct cw_Conn * conn)
|
||||
{
|
||||
cw_Val_t * wtpver;
|
||||
char verstr[512];
|
||||
@ -2188,7 +2191,7 @@ static void set_ac_version(struct conn * conn)
|
||||
}
|
||||
}
|
||||
|
||||
static int postprocess_discovery(struct conn *conn)
|
||||
static int postprocess_discovery(struct cw_Conn *conn)
|
||||
{
|
||||
if (conn->role == CW_ROLE_AC ){
|
||||
set_ac_version(conn);
|
||||
@ -2197,7 +2200,7 @@ static int postprocess_discovery(struct conn *conn)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int postprocess_join_request(struct conn *conn)
|
||||
static int postprocess_join_request(struct cw_Conn *conn)
|
||||
{
|
||||
if (postprocess_join_request_parent!=NULL){
|
||||
postprocess_join_request_parent(conn);
|
||||
@ -2206,7 +2209,7 @@ static int postprocess_join_request(struct conn *conn)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int preprocess_join_request(struct conn *conn)
|
||||
static int preprocess_join_request(struct cw_Conn *conn)
|
||||
{
|
||||
cw_Val_t * ver;
|
||||
int use_ac_version;
|
||||
|
@ -35,7 +35,7 @@ int cisco_in_wtp_descriptor(struct cw_ElemHandler *eh, struct cw_ElemHandlerPara
|
||||
};
|
||||
|
||||
|
||||
return cw_read_wtp_descriptor_7(params->remote_cfg, NULL /*params->conn*/, eh, data, len, allowed);
|
||||
return cw_read_wtp_descriptor_7(params->cfg, NULL /*params->conn*/, eh, data, len, allowed);
|
||||
}
|
||||
|
||||
|
||||
|
@ -168,7 +168,7 @@ static int init(struct cw_Mod *mod, mavl_t global_cfg, int role)
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int elems_len,
|
||||
static int detect(struct cw_Conn *conn, const uint8_t * rawmsg, int rawlen, int elems_len,
|
||||
struct sockaddr *from, int mode)
|
||||
{
|
||||
|
||||
@ -221,7 +221,7 @@ static struct cw_Mod capwap_ac = {
|
||||
*/
|
||||
|
||||
|
||||
int static setup_cfg(struct conn * conn)
|
||||
int static setup_cfg(struct cw_Conn * conn)
|
||||
{
|
||||
int security;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user