32 static void DefragPolicyFreeUserData(
void *data)
40 static SCRadix4Config defrag4_config = { DefragPolicyFreeUserData, NULL };
41 static SCRadix6Config defrag6_config = { DefragPolicyFreeUserData, NULL };
43 static int default_timeout = 0;
45 static void DefragPolicyAddHostInfo(
const char *host_ip_range, uint64_t timeout)
47 uint64_t *user_data = NULL;
49 if ( (user_data =
SCMalloc(
sizeof(uint64_t))) == NULL) {
50 FatalError(
"Error allocating memory. Exiting");
55 if (strchr(host_ip_range,
':') != NULL) {
56 SCLogDebug(
"adding ipv6 host %s", host_ip_range);
58 &defrag6_tree, &defrag6_config, host_ip_range, (
void *)user_data)) {
61 SCLogWarning(
"failed to add ipv6 host %s", host_ip_range);
65 SCLogDebug(
"adding ipv4 host %s", host_ip_range);
67 &defrag4_tree, &defrag4_config, host_ip_range, (
void *)user_data)) {
69 SCLogWarning(
"failed to add ipv4 host %s", host_ip_range);
75 static int DefragPolicyGetIPv4HostTimeout(
const uint8_t *ipv4_addr)
77 void *user_data = NULL;
79 if (user_data == NULL)
82 return *((
int *)user_data);
85 static int DefragPolicyGetIPv6HostTimeout(
const uint8_t *ipv6_addr)
87 void *user_data = NULL;
89 if (user_data == NULL)
92 return *((
int *)user_data);
101 else if (PacketIsIPv6(p))
105 timeout = default_timeout;
110 static void DefragParseParameters(
ConfNode *n)
113 uint64_t timeout = 0;
116 if (strcasecmp(
"timeout", si->
name) == 0) {
123 if (strcasecmp(
"address", si->
name) == 0) {
126 DefragPolicyAddHostInfo(pval->
val, timeout);
134 default_timeout = timeout;
135 SCLogDebug(
"default timeout %d", default_timeout);
143 if (server_config == NULL) {
148 SCLogDebug(
"configuring host config %p", server_config);
156 DefragParseParameters(p);