Go to the documentation of this file.
33 static int default_timeout = 0;
35 static void DefragPolicyFreeUserData(
void *data)
41 static void DefragPolicyAddHostInfo(
char *host_ip_range, uint64_t timeout)
43 uint64_t *user_data = NULL;
45 if ( (user_data =
SCMalloc(
sizeof(uint64_t))) == NULL) {
46 FatalError(
"Error allocating memory. Exiting");
51 if (strchr(host_ip_range,
':') != NULL) {
52 SCLogDebug(
"adding ipv6 host %s", host_ip_range);
56 SCLogWarning(
"failed to add ipv6 host %s", host_ip_range);
60 SCLogDebug(
"adding ipv4 host %s", host_ip_range);
64 SCLogWarning(
"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);
96 else if (PacketIsIPv6(p))
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) {
139 FatalError(
"Can't alloc memory for the defrag config tree.");
143 if (server_config == NULL) {
148 SCLogDebug(
"configuring host config %p", server_config);
156 DefragParseParameters(p);
163 if (defrag_tree != NULL) {
bool 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)
bool SCRadixAddKeyIPV4String(const char *str, SCRadixTree *tree, void *user)
Adds a new IPV4/netblock to the Radix tree from a string.
#define GET_IPV4_DST_ADDR_PTR(p)
void SCRadixReleaseRadixTree(SCRadixTree *tree)
Frees a Radix tree and all its nodes.
#define SCLogWarning(...)
Macro used to log WARNING messages.
SCRadixTree * SCRadixCreateRadixTree(void(*Free)(void *), void(*PrintData)(void *))
Creates a new Radix tree.
void DefragSetDefaultTimeout(int timeout)
void DefragTreeDestroy(void)
void DefragPolicyLoadFromConfig(void)
#define SCLogError(...)
Macro used to log ERROR messages.
thread_local SCError sc_errno