Go to the documentation of this file.
35 static int default_timeout = 0;
37 static void DefragPolicyFreeUserData(
void *data)
45 static void DefragPolicyAddHostInfo(
char *host_ip_range, uint64_t timeout)
47 uint64_t *user_data = NULL;
49 if ( (user_data =
SCMalloc(
sizeof(uint64_t))) == NULL) {
55 if (strchr(host_ip_range,
':') != NULL) {
56 SCLogDebug(
"adding ipv6 host %s", host_ip_range);
59 "failed to add ipv6 host %s", host_ip_range);
62 SCLogDebug(
"adding ipv4 host %s", host_ip_range);
65 "failed to add ipv4 host %s", host_ip_range);
70 static int DefragPolicyGetIPv4HostTimeout(uint8_t *ipv4_addr)
72 void *user_data = NULL;
74 if (user_data == NULL)
77 return *((
int *)user_data);
80 static int DefragPolicyGetIPv6HostTimeout(uint8_t *ipv6_addr)
82 void *user_data = NULL;
84 if (user_data == NULL)
87 return *((
int *)user_data);
100 timeout = default_timeout;
105 static void DefragParseParameters(
ConfNode *n)
108 uint64_t timeout = 0;
111 if (strcasecmp(
"timeout", si->
name) == 0) {
118 if (strcasecmp(
"address", si->
name) == 0) {
121 DefragPolicyAddHostInfo(pval->
val, timeout);
129 default_timeout = timeout;
130 SCLogDebug(
"default timeout %d", default_timeout);
138 if (defrag_tree == NULL) {
140 "Can't alloc memory for the defrag config tree.");
144 if (server_config == NULL) {
149 SCLogDebug(
"configuring host config %p", server_config);
157 DefragParseParameters(p);
164 if (defrag_tree != NULL) {
SCRadixNode * SCRadixAddKeyIPV4String(const char *str, SCRadixTree *tree, void *user)
Adds a new IPV4/netblock to the Radix tree from a string.
SCRadixNode * SCRadixAddKeyIPV6String(const char *str, SCRadixTree *tree, void *user)
Adds a new IPV6/netblock to the Radix tree from a string.
int ParseSizeStringU64(const char *size, uint64_t *res)
struct HtpBodyChunk_ * next
ConfNode * ConfGetNode(const char *name)
Get a ConfNode by name.
Structure for the radix tree.
#define TAILQ_FOREACH(var, head, field)
SCRadixNode * SCRadixFindKeyIPV4BestMatch(uint8_t *key_stream, SCRadixTree *tree, void **user_data_result)
Checks if an IPV4 address is present in the tree under a netblock.
int DefragPolicyGetHostTimeout(Packet *p)
SCRadixNode * SCRadixFindKeyIPV6BestMatch(uint8_t *key_stream, SCRadixTree *tree, void **user_data_result)
Checks if an IPV6 address is present in the tree under a netblock.
#define GET_IPV6_DST_ADDR(p)
#define GET_IPV4_DST_ADDR_PTR(p)
void SCRadixReleaseRadixTree(SCRadixTree *tree)
Frees a Radix tree and all its nodes.
SCRadixTree * SCRadixCreateRadixTree(void(*Free)(void *), void(*PrintData)(void *))
Creates a new Radix tree.
void DefragTreeDestroy(void)
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
#define FatalError(x,...)
void DefragPolicyLoadFromConfig(void)
#define SCLogWarning(err_code,...)
Macro used to log WARNING messages.
void DefragSetDefaultTimeout(intmax_t timeout)