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];
|
||||
|
||||
memset(&val,0,sizeof(cw_Val_t));
|
||||
|
||||
if (!handler->type){
|
||||
|
||||
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,18 +22,18 @@
|
|||
#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;
|
||||
while (sub < len) {
|
||||
int i;
|
||||
|
||||
|
||||
if (len - sub < 8) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -41,25 +41,24 @@ 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;
|
||||
|
||||
char dbgstr[1048];
|
||||
char key[1024];
|
||||
|
||||
|
||||
if (elems[i].maxlen < sublen) {
|
||||
cw_dbg(DBG_ELEM_ERR,
|
||||
"SubType %d Too long (truncating), len = %d,max. len=%d",
|
||||
|
@ -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++;
|
||||
}
|
||||
|
||||
|
|