proto specific free function

remotes/origin/master-1.0.x
Gurvinder Singh 16 years ago committed by Victor Julien
parent 55cdf8947e
commit a4ad7939d2

@ -25,7 +25,6 @@
#include "flow-var.h"
#include "flow-private.h"
#include "util-unittest.h"
#include "stream-tcp.h"
//#define FLOW_DEFAULT_HASHSIZE 262144
#define FLOW_DEFAULT_HASHSIZE 65536
@ -43,7 +42,8 @@ static int FlowUpdateSpareFlows(void);
int FlowSetProtoTimeout(uint8_t , uint32_t ,uint32_t );
int FlowSetProtoEmergencyTimeout(uint8_t , uint32_t ,uint32_t );
static int FlowGetProtoMapping(uint8_t );
int FlowSetProtoFreeFunc(uint8_t, Flow *f, void (*Free)(void *));
static int FlowClearMemory(Flow *,uint8_t );
int FlowSetProtoFreeFunc(uint8_t, void (*Free)(void *));
/** \brief Update the flows position in the queue's
* \param f Flow to requeue.
*
@ -156,7 +156,7 @@ static int FlowPrune (FlowQueue *q, struct timeval *ts)
mutex_unlock(&f->fb->m);
f->fb = NULL;
FlowSetProtoFreeFunc (f->proto, f, protocols[proto_map].Freefunc);
FlowClearMemory (f, proto_map);
/* move to spare list */
FlowRequeue(f, q, &flow_spare_q);
@ -515,35 +515,43 @@ void FlowInitProtocols(void) {
protocols[0].est_timeout = FLOW_DEFAULT_EST_TIMEOUT;
protocols[0].emerg_new_timeout = FLOW_DEFAULT_EMERG_NEW_TIMEOUT;
protocols[0].emerg_est_timeout = FLOW_DEFAULT_EMERG_EST_TIMEOUT;
protocols[0].Freefunc = "";
protocols[0].Freefunc = NULL;
/*TCP*/
protocols[1].new_timeout = FLOW_IPPROTO_TCP_NEW_TIMEOUT;
protocols[1].est_timeout = FLOW_IPPROTO_TCP_EST_TIMEOUT;
protocols[1].emerg_new_timeout = FLOW_IPPROTO_TCP_EMERG_NEW_TIMEOUT;
protocols[1].emerg_est_timeout = FLOW_IPPROTO_TCP_EMERG_EST_TIMEOUT;
protocols[1].Freefunc = StreamTcpSessionPoolFree;
protocols[1].Freefunc = NULL;
/*UDP*/
protocols[2].new_timeout = FLOW_IPPROTO_UDP_NEW_TIMEOUT;
protocols[2].est_timeout = FLOW_IPPROTO_UDP_EST_TIMEOUT;
protocols[2].emerg_new_timeout = FLOW_IPPROTO_UDP_EMERG_NEW_TIMEOUT;
protocols[2].emerg_est_timeout = FLOW_IPPROTO_UDP_EMERG_EST_TIMEOUT;
protocols[2].Freefunc = "";
protocols[2].Freefunc = NULL;
/*ICMP*/
protocols[3].new_timeout = FLOW_IPPROTO_ICMP_NEW_TIMEOUT;
protocols[3].est_timeout = FLOW_IPPROTO_ICMP_EST_TIMEOUT;
protocols[3].emerg_new_timeout = FLOW_IPPROTO_ICMP_EMERG_NEW_TIMEOUT;
protocols[3].emerg_est_timeout = FLOW_IPPROTO_ICMP_EMERG_EST_TIMEOUT;
protocols[3].Freefunc = "";
protocols[3].Freefunc = NULL;
}
int FlowSetProtoFreeFunc (uint8_t proto, Flow *f, void (*Free)(void *)) {
/*XXX GS WIP*/
//uint8_t proto_map;
//proto_map = FlowGetProtoMapping(proto);
Free(f->stream);
static int FlowClearMemory(Flow* f, uint8_t proto_map) {
/*This check should be removed later*/
if (protocols[proto_map].Freefunc != NULL)
protocols[proto_map].Freefunc(f->stream);
memset(f, 0, sizeof(Flow));
//FlowSetProtoFreeFunc(f->proto, );
return 1;
}
int FlowSetProtoFreeFunc (uint8_t proto, void (*Free)(void *)) {
uint8_t proto_map;
proto_map = FlowGetProtoMapping(proto);
protocols[proto_map].Freefunc = Free;
return 1;
}

@ -84,12 +84,12 @@ typedef struct Flow_
struct FlowBucket_ *fb;
} Flow;
/*enum {
NEW = 0,
ESTABLISHED,
EMERG_NEW,
EMERG_ESTABLISHED,
};*/
enum {
FLOW_PROTO_DEFAULT = 0,
FLOW_PROTO_TCP,
FLOW_PROTO_UDP,
FLOW_PROTO_ICMP,
};
typedef struct Protocols_ {
uint32_t new_timeout;
@ -110,7 +110,9 @@ void *FlowManagerThread(void *td);
void FlowManagerThreadSpawn(void);
void FlowRegisterTests (void);
int FlowSetProtoTimout(uint8_t ,uint8_t, uint32_t ,uint32_t );
int FlowSetProtoTimout(uint8_t ,uint32_t ,uint32_t );
int FlowSetProtoEmergencyTimeout(uint8_t ,uint32_t ,uint32_t );
int FlowSetProtoFreeFunc (uint8_t , void (*Free)(void *))
#endif /* __FLOW_H__ */

@ -158,6 +158,8 @@ void StreamTcpInitConfig(char quiet) {
}
pthread_mutex_init(&ssn_pool_mutex, NULL);
FlowSetProtoFreeFunc(IPPROTO_TCP, StreamTcpSessionPoolFree);
}
/** \brief The function is used to to fetch a TCP session from the

@ -16,7 +16,6 @@ typedef struct TcpStreamCnf_ {
TcpStreamCnf stream_config;
void TmModuleStreamTcpRegister (void);
void StreamTcpInitConfig (char);
void StreamTcpSessionPoolFree(void *);
#endif /* __STREAM_TCP_H__ */

Loading…
Cancel
Save