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

Go to the source code of this file.

Data Structures

struct  SCRadix6Node_
 Structure for the node in the radix tree. More...
 
struct  SCRadix6Tree_
 Structure for the radix tree. More...
 
struct  SCRadix6Config_
 

Macros

#define SC_RADIX6_TREE_INITIALIZER
 

Typedefs

typedef struct SCRadix6Node_ SCRadix6Node
 Structure for the node in the radix tree. More...
 
typedef struct SCRadix6Tree_ SCRadix6Tree
 Structure for the radix tree. More...
 
typedef struct SCRadix6Config_ SCRadix6Config
 
typedef int(* SCRadix6ForEachNodeFunc) (const SCRadix6Node *node, void *user_data, const uint8_t netmask, void *data)
 
typedef bool(* SCRadix6TreeCompareFunc) (const void *ud1, const void *ud2)
 compare content of 2 user data entries More...
 

Functions

SCRadix6Tree SCRadix6TreeInitialize (void)
 
void SCRadix6TreeRelease (SCRadix6Tree *, const SCRadix6Config *)
 
SCRadix6NodeSCRadix6AddKeyIPV6 (SCRadix6Tree *, const SCRadix6Config *, const uint8_t *, void *)
 Adds a new IPV6 address to the Radix6 tree. More...
 
SCRadix6NodeSCRadix6AddKeyIPV6Netblock (SCRadix6Tree *, const SCRadix6Config *, const uint8_t *, uint8_t, void *)
 Adds a new IPV6 netblock to the Radix6 tree. More...
 
bool SCRadix6AddKeyIPV6String (SCRadix6Tree *, const SCRadix6Config *, const char *, void *)
 Adds a new IPV6/netblock to the Radix6 tree from a string. More...
 
void SCRadix6RemoveKeyIPV6Netblock (SCRadix6Tree *, const SCRadix6Config *, const uint8_t *, uint8_t)
 Removes an IPV6 address netblock key from the tree. More...
 
void SCRadix6RemoveKeyIPV6 (SCRadix6Tree *, const SCRadix6Config *, const uint8_t *)
 Removes an IPV6 address key(not a netblock) from the Radix6 tree. Instead of using this function, we can also used SCRadix6RemoveKeyIPV6Netblock(), by supplying a netmask value of 32. More...
 
SCRadix6NodeSCRadix6TreeFindExactMatch (const SCRadix6Tree *, const uint8_t *, void **)
 
SCRadix6NodeSCRadix6TreeFindNetblock (const SCRadix6Tree *, const uint8_t *, const uint8_t, void **)
 
SCRadix6NodeSCRadix6TreeFindBestMatch (const SCRadix6Tree *, const uint8_t *, void **)
 
SCRadix6NodeSCRadix6TreeFindBestMatch2 (const SCRadix6Tree *, const uint8_t *, void **, uint8_t *)
 
void SCRadix6PrintTree (SCRadix6Tree *, const SCRadix6Config *)
 
void SCRadix6PrintNodeInfo (SCRadix6Node *, int, void(*PrintData)(void *))
 
void SCRadix6RegisterTests (void)
 
int SCRadix6ForEachNode (const SCRadix6Tree *tree, SCRadix6ForEachNodeFunc Callback, void *data)
 
bool SCRadix6CompareTrees (const SCRadix6Tree *t1, const SCRadix6Tree *t2, SCRadix6TreeCompareFunc 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-radix6-tree.h.

Macro Definition Documentation

◆ SC_RADIX6_TREE_INITIALIZER

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

Definition at line 77 of file util-radix6-tree.h.

Typedef Documentation

◆ SCRadix6Config

◆ SCRadix6ForEachNodeFunc

typedef int(* SCRadix6ForEachNodeFunc) (const SCRadix6Node *node, void *user_data, const uint8_t netmask, void *data)

Definition at line 104 of file util-radix6-tree.h.

◆ SCRadix6Node

typedef struct SCRadix6Node_ SCRadix6Node

Structure for the node in the radix tree.

◆ SCRadix6Tree

typedef struct SCRadix6Tree_ SCRadix6Tree

Structure for the radix tree.

◆ SCRadix6TreeCompareFunc

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

compare content of 2 user data entries

Return values
trueequal
falsenot equal

Definition at line 113 of file util-radix6-tree.h.

Function Documentation

◆ SCRadix6AddKeyIPV6()

SCRadix6Node* SCRadix6AddKeyIPV6 ( SCRadix6Tree tree,
const SCRadix6Config config,
const uint8_t *  key_stream,
void *  user 
)

Adds a new IPV6 address to the Radix6 tree.

Parameters
key_streamData that has to be added to the Radix6 tree. In this case a pointer to an IPV6 address
treePointer to the Radix6 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 196 of file util-radix6-tree.c.

◆ SCRadix6AddKeyIPV6Netblock()

SCRadix6Node* SCRadix6AddKeyIPV6Netblock ( SCRadix6Tree tree,
const SCRadix6Config config,
const uint8_t *  key_stream,
uint8_t  netmask,
void *  user 
)

Adds a new IPV6 netblock to the Radix6 tree.

Parameters
key_streamData that has to be added to the Radix6 tree. In this case a pointer to an IPV6 netblock
treePointer to the Radix6 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 214 of file util-radix6-tree.c.

◆ SCRadix6AddKeyIPV6String()

bool SCRadix6AddKeyIPV6String ( SCRadix6Tree tree,
const SCRadix6Config config,
const char *  str,
void *  user 
)

Adds a new IPV6/netblock to the Radix6 tree from a string.

Parameters
strIPV6 string with optional /cidr netmask
treePointer to the Radix6 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 262 of file util-radix6-tree.c.

References CIDRGetIPv6(), PrintInet(), SC_EINVAL, sc_errno, SCLogWarning, str, StringParseU8RangeCheck(), and strlcpy().

Here is the call graph for this function:

◆ SCRadix6CompareTrees()

bool SCRadix6CompareTrees ( const SCRadix6Tree t1,
const SCRadix6Tree t2,
SCRadix6TreeCompareFunc  Callback 
)

Definition at line 418 of file util-radix6-tree.c.

◆ SCRadix6ForEachNode()

int SCRadix6ForEachNode ( const SCRadix6Tree tree,
SCRadix6ForEachNodeFunc  Callback,
void *  data 
)

Definition at line 411 of file util-radix6-tree.c.

References SCRadix6Tree_::head.

◆ SCRadix6PrintNodeInfo()

void SCRadix6PrintNodeInfo ( SCRadix6Node ,
int  ,
void(*)(void *)  PrintData 
)

◆ SCRadix6PrintTree()

void SCRadix6PrintTree ( SCRadix6Tree ,
const SCRadix6Config  
)

Definition at line 355 of file util-radix6-tree.c.

◆ SCRadix6RegisterTests()

void SCRadix6RegisterTests ( void  )

Definition at line 946 of file util-radix6-tree.c.

References UtRegisterTest().

Here is the call graph for this function:

◆ SCRadix6RemoveKeyIPV6()

void SCRadix6RemoveKeyIPV6 ( SCRadix6Tree tree,
const SCRadix6Config config,
const uint8_t *  key_stream 
)

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

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

Definition at line 335 of file util-radix6-tree.c.

◆ SCRadix6RemoveKeyIPV6Netblock()

void SCRadix6RemoveKeyIPV6Netblock ( SCRadix6Tree tree,
const SCRadix6Config config,
const uint8_t *  key_stream,
uint8_t  netmask 
)

Removes an IPV6 address netblock key from the tree.

Parameters
key_streamData that has to be removed from the tree. In this case an IPV6 address with netmask.
treePointer to the tree from which the key has to be removed

Definition at line 349 of file util-radix6-tree.c.

◆ SCRadix6TreeFindBestMatch()

SCRadix6Node* SCRadix6TreeFindBestMatch ( const SCRadix6Tree ,
const uint8_t *  ,
void **   
)

Definition at line 173 of file util-radix6-tree.c.

Referenced by IPOnlyMatchPacket(), and SCHInfoGetIPv6HostOSFlavour().

Here is the caller graph for this function:

◆ SCRadix6TreeFindBestMatch2()

SCRadix6Node* SCRadix6TreeFindBestMatch2 ( const SCRadix6Tree ,
const uint8_t *  ,
void **  ,
uint8_t *   
)

Definition at line 179 of file util-radix6-tree.c.

◆ SCRadix6TreeFindExactMatch()

SCRadix6Node* SCRadix6TreeFindExactMatch ( const SCRadix6Tree ,
const uint8_t *  ,
void **   
)

Definition at line 161 of file util-radix6-tree.c.

◆ SCRadix6TreeFindNetblock()

SCRadix6Node* SCRadix6TreeFindNetblock ( const SCRadix6Tree ,
const uint8_t *  ,
const uint8_t  ,
void **   
)

Definition at line 167 of file util-radix6-tree.c.

◆ SCRadix6TreeInitialize()

SCRadix6Tree SCRadix6TreeInitialize ( void  )

Definition at line 360 of file util-radix6-tree.c.

References SC_RADIX6_TREE_INITIALIZER.

Referenced by IPOnlyInit(), and SRepInit().

Here is the caller graph for this function:

◆ SCRadix6TreeRelease()

void SCRadix6TreeRelease ( SCRadix6Tree ,
const SCRadix6Config  
)

Definition at line 366 of file util-radix6-tree.c.