Radix Tree structure for the engine

remotes/origin/master-1.0.x
Anoop Saldanha 15 years ago committed by Victor Julien
parent bc42aebdd5
commit 3c21df69d2

@ -92,6 +92,7 @@ util-debug.c util-debug.h \
util-debug-filters.c util-debug-filters.h \
util-error.c util-error.h \
util-enum.c util-enum.h \
util-radix-tree.c util-radix-tree.h \
tm-modules.c tm-modules.h \
tm-queues.c tm-queues.h \
tm-queuehandlers.c tm-queuehandlers.h \

@ -61,6 +61,7 @@
#include "app-layer-http.h"
#include "app-layer-tls.h"
#include "util-radix-tree.h"
#include "util-cidr.h"
#include "util-unittest.h"
#include "util-time.h"
@ -427,6 +428,7 @@ int main(int argc, char **argv)
FlowRegisterTests();
SCSigRegisterSignatureOrderingTests();
SCLogRegisterTests();
SCRadixRegisterTests();
uint32_t failed = UtRunTests();
UtCleanup();
if (failed) exit(EXIT_FAILURE);

File diff suppressed because it is too large Load Diff

@ -0,0 +1,70 @@
/** Copyright (c) 2009 Open Information Security Foundation.
* \author Anoop Saldanha <poonaatsoc@gmail.com>
*/
#ifndef __UTIL_RADIX_TREE_H__
#define __UTIL_RADIX_TREE_H__
#define SC_RADIX_BITTEST(x, y) ((x) & (y))
/**
* \brief Structure for the prefix/key in the radix tree
*/
typedef struct SCRadixPrefix_ {
/* length of the stream */
uint16_t bitlen;
/* the key that has been stored in the tree */
uint8_t *stream;
} SCRadixPrefix;
/**
* \brief Structure for the node in the radix tree
*/
typedef struct SCRadixNode_ {
/* the bit position where the bits differ in the nodes children. Used
* to determine the path to be taken during a lookup*/
uint16_t bit;
/* Holds the prefix that the path to this node holds */
SCRadixPrefix *prefix;
/* the left and the right children of a node */
struct SCRadixNode_ *left, *right;
/* the parent node for this tree */
struct SCRadixNode_ *parent;
/* any user data that has to be associated with this node */
void *user;
} SCRadixNode;
/**
* \brief Structure for the radix tree
*/
typedef struct SCRadixTree_ {
/* the root node in the radix tree */
SCRadixNode *head;
} SCRadixTree;
SCRadixTree *SCRadixCreateRadixTree();
void SCRadixReleaseRadixTree(SCRadixTree *);
SCRadixPrefix *SCRadixCreatePrefix(uint8_t *, uint16_t);
SCRadixPrefix *SCRadixCreateIPV4Prefix(uint8_t *);
SCRadixPrefix *SCRadixCreateIPV6Preix(uint8_t *);
void SCRadixReleasePrefix(SCRadixPrefix *prefix);
SCRadixNode *SCRadixAddKey(SCRadixPrefix *, SCRadixTree *);
void SCRadixRemoveKey(SCRadixPrefix *, SCRadixTree *);
SCRadixNode *SCRadixFindKey(SCRadixPrefix *, SCRadixTree *);
void SCRadixPrintTree(SCRadixTree *);
void SCRadixRegisterTests(void);
#endif /* __UTIL_RADIX_TREE_H__ */
Loading…
Cancel
Save