32static void DefragPolicyFreeUserData(
void *data)
40static SCRadix4Config defrag4_config = { DefragPolicyFreeUserData, NULL };
41static SCRadix6Config defrag6_config = { DefragPolicyFreeUserData, NULL };
43static int default_timeout = 0;
45static 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);
75static int DefragPolicyGetIPv4HostTimeout(
const uint8_t *ipv4_addr)
77 void *user_data = NULL;
79 if (user_data == NULL)
82 return *((
int *)user_data);
85static 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;
110static void DefragParseParameters(
SCConfNode *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);
struct HtpBodyChunk_ * next
SCConfNode * SCConfGetNode(const char *name)
Get a SCConfNode by name.
#define GET_IPV6_DST_ADDR(p)
#define GET_IPV4_DST_ADDR_PTR(p)
int DefragPolicyGetHostTimeout(Packet *p)
void DefragPolicyLoadFromConfig(void)
void DefragTreeDestroy(void)
void DefragSetDefaultTimeout(int timeout)
#define TAILQ_FOREACH(var, head, field)
Structure for the radix tree.
Structure for the radix tree.
#define SCLogWarning(...)
Macro used to log WARNING messages.
#define SCLogError(...)
Macro used to log ERROR messages.
thread_local SCError sc_errno
int ParseSizeStringU64(const char *size, uint64_t *res)
SCRadix4Node * SCRadix4TreeFindBestMatch(const SCRadix4Tree *tree, const uint8_t *key, void **user_data)
bool SCRadix4AddKeyIPV4String(SCRadix4Tree *tree, const SCRadix4Config *config, const char *str, void *user)
Adds a new IPV4/netblock to the Radix4 tree from a string.
void SCRadix4TreeRelease(SCRadix4Tree *tree, const SCRadix4Config *config)
#define SC_RADIX4_TREE_INITIALIZER
SCRadix6Node * SCRadix6TreeFindBestMatch(const SCRadix6Tree *tree, const uint8_t *key, void **user_data)
void SCRadix6TreeRelease(SCRadix6Tree *tree, const SCRadix6Config *config)
bool SCRadix6AddKeyIPV6String(SCRadix6Tree *tree, const SCRadix6Config *config, const char *str, void *user)
Adds a new IPV6/netblock to the Radix6 tree from a string.
#define SC_RADIX6_TREE_INITIALIZER