Work on mods..

FossilOrigin-Name: 4c4034e76e9a8525d1f1bb528eacbe7510339a83032d22c3da9c362923f37455
This commit is contained in:
7u83@mail.ru 2016-03-01 18:10:08 +00:00
parent 31ab5e0989
commit f84cbc22af
5 changed files with 61 additions and 18 deletions

View File

@ -1,7 +1,7 @@
#ifndef __ACIPLIST_H
#define __ACIPLIST_H
#include "avltree.h"
#include "mavl.h"
struct cw_acip{
struct sockaddr_storage ip;
@ -10,15 +10,15 @@ struct cw_acip{
typedef struct cw_acip cw_acip_t;
typedef struct avltree * cw_aciplist_t;
typedef struct mavl * cw_aciplist_t;
extern cw_aciplist_t cw_aciplist_create();
#define cw_aciplist_destroy(l) avltree_destroy(l)
#define cw_aciplist_add(l,elem) avltree_add(l,elem)
#define cw_aciplist_del(l,elem) avltree_del(l,elem)
#define cw_aciplist_foreach(l,callback,cbpriv) avltree_foreach_asc(l,callback,cbpriv)
#define cw_aciplist_replace(l,r) avltree_replace(l,r)
#define cw_aciplist_destroy(l) mavl_destroy(l)
#define cw_aciplist_add(l,elem) mavl_add(l,elem)
#define cw_aciplist_del(l,elem) mavl_del(l,elem)
#define cw_aciplist_foreach(l,callback,cbpriv) mavl_foreach_asc(l,callback,cbpriv)
#define cw_aciplist_replace(l,r) mavl_replace(l,r)
#endif

View File

@ -143,6 +143,7 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
int payloadlen = len - offset;
/* pre-check message */
if (payloadlen - 8 != elems_len) {
@ -153,6 +154,8 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
errno = EAGAIN;
return -1;
}
if (elems_len < payloadlen - 8) {
cw_dbg(DBG_RFC,
"Packet from from %s has %d bytes of extra data, ignoring.",
@ -161,6 +164,7 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
}
if (elems_len > payloadlen - 8) {
cw_dbg(DBG_RFC,
"Packet from from %s has msgelems len of %d bytes, but has only %d bytes of data, truncating.",
sock_addr2str(&conn->addr), elems_len, payloadlen - 8);
@ -169,6 +173,7 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
}
if (!conn->detected) {
if (conn->mods) {
struct mod_ac **mods = (struct mod_ac **) conn->mods;
@ -187,11 +192,13 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
}
}
if (!conn->detected) {
cw_dbg(DBG_INFO, "Cant't detect capwap, discarding message from %s",
cw_dbg(DBG_MSG_ERR, "Cant't detect capwap, discarding message from %s",
sock_addr2str(from));
errno = EAGAIN;
return -1;
// errno = EAGAIN;
// return -1;
}
@ -334,6 +341,9 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
int process_message(struct conn *conn, uint8_t * rawmsg, int rawlen,
struct sockaddr *from)
{
uint8_t *msgptr = rawmsg + cw_get_hdr_msg_offset(rawmsg);
@ -370,6 +380,7 @@ int process_message(struct conn *conn, uint8_t * rawmsg, int rawlen,
/* the received request message was retransmittet by our peer,
* let's retransmit our response message if we have one*/
cw_dbg(DBG_MSG_ERR,
"Retransmitted request message from %s detected, seqnum=%d, type=%d",
sock_addr2str(&conn->addr), s2, type);

View File

@ -6,12 +6,12 @@
#include "sock.h"
static int put_ip(void *priv, void *data)
static int put_ip(uint8_t *dst /*void *priv*/, cw_acip_t * acip /*void *data*/)
{
uint8_t ** dptr = (uint8_t **)priv;
cw_acip_t *acip=(cw_acip_t*)data;
// uint8_t ** dptr = (uint8_t **)priv;
// cw_acip_t *acip=(cw_acip_t*)data;
uint8_t * dst = *dptr;
// uint8_t * dst = *dptr;
uint8_t *d = dst+4;
@ -34,10 +34,14 @@ static int put_ip(void *priv, void *data)
if (elem_id != -1 ) {
d+=cw_put_elem_hdr(dst,elem_id,d-dst-4);
*dptr = d-4;
return 0;
// *dptr = d-4;
}
return 1;
return d-4-dst;
// return 1;
}
@ -55,7 +59,17 @@ int cw_out_capwap_control_ip_addr_list(struct conn *conn,struct cw_action_out *a
uint8_t *d = dst;
cw_aciplist_foreach(aciplist, put_ip, &d);
MAVLITER_DEFINE(i,aciplist);
mavliter_foreach(&i){
struct cw_acip * acip = mavliter_get(&i);
d+=put_ip(d,acip);
}
// cw_aciplist_foreach(aciplist, put_ip, &d);
mbag_item_release_data_ptr(item,aciplist);
return d-dst;

View File

@ -43,9 +43,15 @@ static struct uci_section * get_anon_section(struct uci_package * pkg, const ch
static void set_dbg_opt(struct uci_context *ctx,struct uci_section * section,int opt,const char * optstr)
{
printf("Setting debug opt: %s %d - ",optstr, opt);
const char *str = uci_lookup_option_string(ctx,section,optstr);
if (!str)
if (!str){
printf("no\n");
return;
}
printf("%s\n",str);
if ((strcmp(str,"1")==0) || (strcmp(str,"true")==0))
//conf_dbg_level |= opt;
cw_dbg_set_level(opt,1);

View File

@ -39,9 +39,21 @@ config 'wtp'
config 'dbg'
# debug options
option info 0
option dtls 0
option dtls_detail 0
option dtls_bio 0
option dtls_bio_dmp 0
option pkt_in 0
option pkt_out 0
option pkt_err 0
option msg_in 0
option msg_out 0
option msg_err 0
option elem 0
option elem_err 0
option rfc 0