Work on mods.

FossilOrigin-Name: 2933314d1c705fae5022e022409b5f77a878656baead522ceb629b7f648c8307
This commit is contained in:
7u83@mail.ru
2016-02-27 04:35:25 +00:00
parent 8f325f2f6f
commit a704463acf
11 changed files with 35 additions and 68 deletions

View File

@ -62,7 +62,7 @@ UTILOBJS= \
stravltree.o \
intavltree.o \
cw_util.o \
send.o
send.o \
MAVLOBJS= \
mavl_del.o \

View File

@ -34,8 +34,7 @@
#include "intavltree.h"
#include "item.h"
struct conn;
/* Generic functions and structs */
void * cw_actionlist_add(struct avltree *t, void *a, size_t s);

View File

@ -170,13 +170,16 @@ 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;
if (conn->mods) {
struct mod_ac **mods = (struct mod_ac **) conn->mods;
int i;
for (i=0; mods[i]; i++){
if (mods[i]->detect){
if (mods[i]->detect(conn,rawmsg,len,from)){
cw_dbg(DBG_INFO,"Using mod '%s' to handle connection from %s",mods[i]->name,sock_addr2str(from));
for (i = 0; mods[i]; i++) {
if (mods[i]->detect) {
if (mods[i]->detect(conn, rawmsg, len, from)) {
cw_dbg(DBG_INFO,
"Using mod '%s' to handle connection from %s",
mods[i]->name,
sock_addr2str(from));
break;
}
}
@ -184,11 +187,12 @@ 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",sock_addr2str(from));
errno=EAGAIN;
if (!conn->detected) {
cw_dbg(DBG_INFO, "Cant't detect capwap, discarding message from %s",
sock_addr2str(from));
errno = EAGAIN;
return -1;
}
@ -328,7 +332,7 @@ 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)
struct sockaddr *from)
{
uint8_t *msgptr = rawmsg + cw_get_hdr_msg_offset(rawmsg);

View File

@ -6,6 +6,9 @@
#include "capwap/sock.h"
#include "capwap/conn.h"
#include "action.h"
struct cw_actiondef;
struct mod_ac
{
@ -21,6 +24,9 @@ struct mod_ac
/** used for private data */
void *data;
int (*register_actions)(struct cw_actiondef *def);
};