CDN_DNS/trie/trie.h

45 lines
936 B
C
Raw Normal View History

2024-06-05 14:40:59 +02:00
#ifndef TRIE_HEADER_843762518432898246756
#define TRIE_HEADER_843762518432898246756
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
union ipv6 {
unsigned short s[8];
2024-06-05 14:49:30 +02:00
unsigned int i[4];
unsigned long l[2];
2024-06-05 14:40:59 +02:00
};
#define VALID_RULE 1
#define INVALID_RULE 0
struct trie_node {
struct trie_node* _l;
struct trie_node* _r;
int _rule:31;
unsigned _rule_valid:1;
};
struct trie_holder {
struct trie_node* _root;
size_t _size;
};
typedef struct trie_node* trie_node_t;
typedef struct trie_holder* trie_holder_t;
typedef union ipv6 ipv6_t;
typedef int rule_t;
struct trie_holder* create_holder();
struct trie_node* create_node();
int destory_holder(struct trie_holder*);
int destory_node(struct trie_node*);
2024-06-05 14:49:30 +02:00
int trie_insert(struct trie_holder*, ipv6_t key, int val, int mask);
rule_t trie_search(struct trie_holder*, ipv6_t key);
2024-06-05 14:40:59 +02:00
#endif