From 071e38492003244ba705683459daf54f76d46f5a Mon Sep 17 00:00:00 2001 From: hladu357 Date: Sat, 8 Jun 2024 12:51:50 +0200 Subject: [PATCH] header refactor --- radix/radix.h | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/radix/radix.h b/radix/radix.h index 5c583d2..04b8d9d 100644 --- a/radix/radix.h +++ b/radix/radix.h @@ -9,19 +9,17 @@ #define INVALID_RULE 0 #define RULE_NOT_FOUND -1 -union ipv6 { - unsigned short s[8]; - unsigned int i[4]; - unsigned long l[2]; +struct routing_record { + unsigned long long _ip; + unsigned short _rule; + unsigned _ip_end_bit:7; + unsigned _rule_valid:1; }; struct radix_node { struct radix_node* _l; struct radix_node* _r; - union ipv6 _ip; - unsigned short _rule; - unsigned _ip_end_bit:7; - unsigned _rule_valid:1; + struct routing_record _data; }; struct radix_holder { @@ -29,20 +27,19 @@ struct radix_holder { size_t _size; }; -typedef struct radix_node* radix_node_t; -typedef struct radix_holder* radix_holder_t; -typedef union ipv6 ipv6_t; -typedef int rule_t; +typedef struct radix_node* radix_node_t; +typedef struct radix_holder* radix_holder_t; +typedef struct routing_record* record_t; struct radix_holder* create_holder(); -struct radix_node* create_node(ipv6_t key, unsigned end_bit, unsigned rule); -static struct radix_node* clone_node(struct radix_node* n); +struct radix_node* create_node(record_t record); +static struct radix_node* clone_node(radix_node_t n); static void split_node(struct radix_node* n, unsigned bit); int destory_holder(struct radix_holder*); int destory_node(struct radix_node*); -int radix_insert(struct radix_holder*, ipv6_t key, int val, int mask); -rule_t radix_search(struct radix_holder*, ipv6_t key); +int radix_insert(radix_holder_t, record_t); +int radix_search(radix_holder_t, record_t); #endif \ No newline at end of file