mirror of
https://codeberg.org/1414codeforge/ubgpsuite.git
synced 2025-06-05 21:29:11 +02:00
[*] Initial commit
This commit is contained in:
44
lonetix/include/df/bgp/patricia.h
Executable file
44
lonetix/include/df/bgp/patricia.h
Executable file
@@ -0,0 +1,44 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
/**
|
||||
* \file bgp/patricia.h
|
||||
*
|
||||
* PATRICIA trie implementation.
|
||||
*
|
||||
* \copyright The DoubleFourteen Code Forge (C) All Rights Reserved
|
||||
* \author Lorenzo Cogotti
|
||||
*/
|
||||
|
||||
#ifndef DF_BGP_PATRICIA_H_
|
||||
#define DF_BGP_PATRICIA_H_
|
||||
|
||||
#include "bgp/prefix.h"
|
||||
|
||||
/// Opaque type, trie memory chunk block.
|
||||
typedef struct Patblock Patblock;
|
||||
/// Opaque type, concrete trie node.
|
||||
typedef union Patnode Patnode;
|
||||
|
||||
/// PATRICIA trie.
|
||||
typedef struct {
|
||||
Afi afi; ///< AFI type
|
||||
unsigned nprefixes; ///< Prefixes count stored inside trie
|
||||
|
||||
Patnode *head; ///< Trie root node
|
||||
Patblock *blocks; ///< PATRICIA memory blocks
|
||||
Patnode *freeBins[IPV6_SIZE / 4]; ///< Fast free bins
|
||||
} Patricia;
|
||||
|
||||
RawPrefix *Pat_Insert(Patricia *trie, const RawPrefix *pfx);
|
||||
Boolean Pat_Remove(Patricia *trie, const RawPrefix *pfx);
|
||||
|
||||
RawPrefix *Pat_SearchExact(const Patricia *trie, const RawPrefix *pfx);
|
||||
|
||||
Boolean Pat_IsSubnetOf(const Patricia *trie, const RawPrefix *pfx);
|
||||
Boolean Pat_IsSupernetOf(const Patricia *trie, const RawPrefix *pfx);
|
||||
Boolean Pat_IsRelatedOf(const Patricia *trie, const RawPrefix *pfx);
|
||||
|
||||
/// Reset `trie` and free all memory.
|
||||
void Pat_Clear(Patricia *trie);
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user