suricata
util-radix4-tree.h File Reference
#include "suricata-common.h"
Include dependency graph for util-radix4-tree.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SCRadix4Node_
 Structure for the node in the radix tree. More...
 
struct  SCRadix4Tree_
 Structure for the radix tree. More...
 
struct  SCRadix4Config_
 

Macros

#define SC_RADIX4_TREE_INITIALIZER
 

Typedefs

typedef struct SCRadix4Node_ SCRadix4Node
 Structure for the node in the radix tree. More...
 
typedef struct SCRadix4Tree_ SCRadix4Tree
 Structure for the radix tree. More...
 
typedef struct SCRadix4Config_ SCRadix4Config
 
typedef int(* SCRadix4ForEachNodeFunc) (const SCRadix4Node *node, void *user_data, const uint8_t netmask, void *data)
 
typedef bool(* SCRadix4TreeCompareFunc) (const void *ud1, const void *ud2)
 compare content of 2 user data entries More...
 

Functions

SCRadix4Tree SCRadix4TreeInitialize (void)
 
void SCRadix4TreeRelease (SCRadix4Tree *, const SCRadix4Config *)
 
SCRadix4NodeSCRadix4AddKeyIPV4 (SCRadix4Tree *, const SCRadix4Config *, const uint8_t *, void *)
 Adds a new IPV4 address to the Radix4 tree. More...
 
SCRadix4NodeSCRadix4AddKeyIPV4Netblock (SCRadix4Tree *, const SCRadix4Config *, const uint8_t *, uint8_t, void *)
 Adds a new IPV4 netblock to the Radix4 tree. More...
 
bool SCRadix4AddKeyIPV4String (SCRadix4Tree *, const SCRadix4Config *, const char *, void *)
 Adds a new IPV4/netblock to the Radix4 tree from a string. More...
 
void SCRadix4RemoveKeyIPV4Netblock (SCRadix4Tree *, const SCRadix4Config *, const uint8_t *, uint8_t)
 Removes an IPV4 address netblock key from the Radix4 tree. More...
 
void SCRadix4RemoveKeyIPV4 (SCRadix4Tree *, const SCRadix4Config *, const uint8_t *)
 Removes an IPV4 address key(not a netblock) from the Radix4 tree. Instead of using this function, we can also used SCRadix4RemoveKeyIPV4Netblock(), by supplying a netmask value of 32. More...
 
SCRadix4NodeSCRadix4TreeFindExactMatch (const SCRadix4Tree *, const uint8_t *, void **)
 
SCRadix4NodeSCRadix4TreeFindNetblock (const SCRadix4Tree *, const uint8_t *, const uint8_t, void **)
 
SCRadix4NodeSCRadix4TreeFindBestMatch (const SCRadix4Tree *, const uint8_t *, void **)
 
SCRadix4NodeSCRadix4TreeFindBestMatch2 (const SCRadix4Tree *, const uint8_t *, void **, uint8_t *)
 
void SCRadix4PrintTree (SCRadix4Tree *, const SCRadix4Config *config)
 
void SCRadix4PrintNodeInfo (SCRadix4Node *, int, void(*PrintData)(void *))
 
void SCRadix4RegisterTests (void)
 
int SCRadix4ForEachNode (const SCRadix4Tree *tree, SCRadix4ForEachNodeFunc Callback, void *data)
 
bool SCRadix4CompareTrees (const SCRadix4Tree *t1, const SCRadix4Tree *t2, SCRadix4TreeCompareFunc Callback)
 

Detailed Description

Author
Victor Julien victo.nosp@m.r@in.nosp@m.linia.nosp@m.c.ne.nosp@m.t Based on util-radix-tree.[ch] by:
Anoop Saldanha anoop.nosp@m.sald.nosp@m.anha@.nosp@m.gmai.nosp@m.l.com

Definition in file util-radix4-tree.h.

Macro Definition Documentation

◆ SC_RADIX4_TREE_INITIALIZER

#define SC_RADIX4_TREE_INITIALIZER
Value:
{ \
.head = NULL \
}

Definition at line 79 of file util-radix4-tree.h.

Typedef Documentation

◆ SCRadix4Config

◆ SCRadix4ForEachNodeFunc

typedef int(* SCRadix4ForEachNodeFunc) (const SCRadix4Node *node, void *user_data, const uint8_t netmask, void *data)

Definition at line 106 of file util-radix4-tree.h.

◆ SCRadix4Node

typedef struct SCRadix4Node_ SCRadix4Node

Structure for the node in the radix tree.

◆ SCRadix4Tree

typedef struct SCRadix4Tree_ SCRadix4Tree

Structure for the radix tree.

◆ SCRadix4TreeCompareFunc

typedef bool(* SCRadix4TreeCompareFunc) (const void *ud1, const void *ud2)

compare content of 2 user data entries

Return values
trueequal
falsenot equal

Definition at line 115 of file util-radix4-tree.h.

Function Documentation

◆ SCRadix4AddKeyIPV4()

SCRadix4Node* SCRadix4AddKeyIPV4 ( SCRadix4Tree tree,
const SCRadix4Config config,
const uint8_t *  key_stream,
void *  user 
)

Adds a new IPV4 address to the Radix4 tree.

Parameters
key_streamData that has to be added to the Radix4 tree. In this case a pointer to an IPV4 address
treePointer to the Radix4 tree
userPointer to the user data that has to be associated with the key
Return values
nodePointer to the newly created node

Definition at line 188 of file util-radix4-tree.c.

◆ SCRadix4AddKeyIPV4Netblock()

SCRadix4Node* SCRadix4AddKeyIPV4Netblock ( SCRadix4Tree tree,
const SCRadix4Config config,
const uint8_t *  key_stream,
uint8_t  netmask,
void *  user 
)

Adds a new IPV4 netblock to the Radix4 tree.

Parameters
key_streamData that has to be added to the Radix4 tree. In this case a pointer to an IPV4 netblock
treePointer to the Radix4 tree
userPointer to the user data that has to be associated with the key
netmaskThe netmask (cidr) if we are adding a netblock
Return values
nodePointer to the newly created node

Definition at line 206 of file util-radix4-tree.c.

◆ SCRadix4AddKeyIPV4String()

bool SCRadix4AddKeyIPV4String ( SCRadix4Tree tree,
const SCRadix4Config config,
const char *  str,
void *  user 
)

Adds a new IPV4/netblock to the Radix4 tree from a string.

Parameters
strIPV4 string with optional /cidr netmask
treePointer to the Radix4 tree
userPointer to the user data that has to be associated with the key
Return values
booltrue if node was added, false otherwise

If the function returns false, sc_errno is set:

  • SC_EEXIST: Node already exists
  • SC_EINVAL: Parameter value error
  • SC_ENOMEM: Memory allocation failed

Definition at line 227 of file util-radix4-tree.c.

References RadixUserData::netmask, SC_EINVAL, sc_errno, str, StringParseU8RangeCheck(), and strlcpy().

Here is the call graph for this function:

◆ SCRadix4CompareTrees()

bool SCRadix4CompareTrees ( const SCRadix4Tree t1,
const SCRadix4Tree t2,
SCRadix4TreeCompareFunc  Callback 
)

Definition at line 359 of file util-radix4-tree.c.

◆ SCRadix4ForEachNode()

int SCRadix4ForEachNode ( const SCRadix4Tree tree,
SCRadix4ForEachNodeFunc  Callback,
void *  data 
)

Definition at line 352 of file util-radix4-tree.c.

References SCRadix4Tree_::head.

◆ SCRadix4PrintNodeInfo()

void SCRadix4PrintNodeInfo ( SCRadix4Node ,
int  ,
void(*)(void *)  PrintData 
)

◆ SCRadix4PrintTree()

void SCRadix4PrintTree ( SCRadix4Tree ,
const SCRadix4Config config 
)

Definition at line 303 of file util-radix4-tree.c.

◆ SCRadix4RegisterTests()

void SCRadix4RegisterTests ( void  )

Definition at line 922 of file util-radix4-tree.c.

References UtRegisterTest().

Here is the call graph for this function:

◆ SCRadix4RemoveKeyIPV4()

void SCRadix4RemoveKeyIPV4 ( SCRadix4Tree tree,
const SCRadix4Config config,
const uint8_t *  key_stream 
)

Removes an IPV4 address key(not a netblock) from the Radix4 tree. Instead of using this function, we can also used SCRadix4RemoveKeyIPV4Netblock(), by supplying a netmask value of 32.

Parameters
key_streamData that has to be removed from the Radix4 tree. In this case an IPV4 address
treePointer to the Radix4 tree from which the key has to be removed

Definition at line 282 of file util-radix4-tree.c.

◆ SCRadix4RemoveKeyIPV4Netblock()

void SCRadix4RemoveKeyIPV4Netblock ( SCRadix4Tree tree,
const SCRadix4Config config,
const uint8_t *  key_stream,
uint8_t  netmask 
)

Removes an IPV4 address netblock key from the Radix4 tree.

Parameters
key_streamData that has to be removed from the Radix4 tree. In this case an IPV4 address
treePointer to the Radix4 tree from which the key has to be removed

Definition at line 296 of file util-radix4-tree.c.

References SCLogNotice.

◆ SCRadix4TreeFindBestMatch()

SCRadix4Node* SCRadix4TreeFindBestMatch ( const SCRadix4Tree ,
const uint8_t *  ,
void **   
)

Definition at line 154 of file util-radix4-tree.c.

Referenced by IPOnlyMatchPacket(), and SCHInfoGetIPv4HostOSFlavour().

Here is the caller graph for this function:

◆ SCRadix4TreeFindBestMatch2()

SCRadix4Node* SCRadix4TreeFindBestMatch2 ( const SCRadix4Tree ,
const uint8_t *  ,
void **  ,
uint8_t *   
)

Definition at line 160 of file util-radix4-tree.c.

◆ SCRadix4TreeFindExactMatch()

SCRadix4Node* SCRadix4TreeFindExactMatch ( const SCRadix4Tree ,
const uint8_t *  ,
void **   
)

Definition at line 142 of file util-radix4-tree.c.

◆ SCRadix4TreeFindNetblock()

SCRadix4Node* SCRadix4TreeFindNetblock ( const SCRadix4Tree ,
const uint8_t *  ,
const uint8_t  ,
void **   
)

Definition at line 148 of file util-radix4-tree.c.

◆ SCRadix4TreeInitialize()

SCRadix4Tree SCRadix4TreeInitialize ( void  )

Definition at line 166 of file util-radix4-tree.c.

References SC_RADIX4_TREE_INITIALIZER.

Referenced by IPOnlyInit(), and SRepInit().

Here is the caller graph for this function:

◆ SCRadix4TreeRelease()

void SCRadix4TreeRelease ( SCRadix4Tree ,
const SCRadix4Config  
)

Definition at line 172 of file util-radix4-tree.c.

Referenced by DefragTreeDestroy(), IPOnlyDeinit(), SCHInfoCleanResources(), and SRepDestroy().

Here is the caller graph for this function: