CDN_DNS/radix/radix.h

42 lines
1001 B
C

#ifndef RADIX_HEADER_736213980973149671328765
#define RADIX_HEADER_736213980973149671328765
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#define INVALID_RULE 0xffff
struct routing_record {
unsigned long _ip[2];
unsigned short _rule;
unsigned char _mask;
};
struct radix_node {
struct radix_node* _l;
struct radix_node* _r;
struct routing_record _data;
};
struct radix_holder {
struct radix_node* _root;
size_t _size;
};
typedef struct radix_node* radix_node_t;
typedef struct radix_holder* radix_holder_t;
typedef struct routing_record* record_t;
radix_holder_t create_holder();
static radix_node_t create_node(record_t record);
static radix_node_t clone_node(radix_node_t n);
static void split_node(struct radix_node* n, unsigned bit);
int destory_holder(struct radix_holder*);
static int destory_node(struct radix_node*);
int radix_insert(radix_holder_t, record_t);
int radix_search(radix_holder_t, record_t);
#endif