diff options
author | 2023-07-15 08:18:08 -0400 | |
---|---|---|
committer | 2023-07-15 08:18:08 -0400 | |
commit | d2802ce6068e5e9296e7b9a06a9c82e18ca23972 (patch) | |
tree | 7ffd465af9f5e809d9e1661c59b806c82f659bd0 /src/fnettrace/radix.c | |
parent | Merge pull request #5898 from kmk3/build-simplify-man (diff) | |
download | firejail-d2802ce6068e5e9296e7b9a06a9c82e18ca23972.tar.gz firejail-d2802ce6068e5e9296e7b9a06a9c82e18ca23972.tar.zst firejail-d2802ce6068e5e9296e7b9a06a9c82e18ca23972.zip |
fnettrace cleanup
Diffstat (limited to 'src/fnettrace/radix.c')
-rw-r--r-- | src/fnettrace/radix.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/fnettrace/radix.c b/src/fnettrace/radix.c index f0a22da74..f0ac4c094 100644 --- a/src/fnettrace/radix.c +++ b/src/fnettrace/radix.c | |||
@@ -25,12 +25,6 @@ | |||
25 | #include "radix.h" | 25 | #include "radix.h" |
26 | #include "fnettrace.h" | 26 | #include "fnettrace.h" |
27 | 27 | ||
28 | typedef struct rnode_t { | ||
29 | struct rnode_t *zero; | ||
30 | struct rnode_t *one; | ||
31 | char *name; | ||
32 | } RNode; | ||
33 | |||
34 | RNode *head = 0; | 28 | RNode *head = 0; |
35 | int radix_nodes = 0; | 29 | int radix_nodes = 0; |
36 | 30 | ||
@@ -100,8 +94,7 @@ static inline RNode *addZero(RNode *ptr, char *name) { | |||
100 | 94 | ||
101 | 95 | ||
102 | // add to radix tree | 96 | // add to radix tree |
103 | char *radix_add(uint32_t ip, uint32_t mask, char *name) { | 97 | RNode *radix_add(uint32_t ip, uint32_t mask, char *name) { |
104 | assert(name); | ||
105 | uint32_t m = 0x80000000; | 98 | uint32_t m = 0x80000000; |
106 | uint32_t lastm = 0; | 99 | uint32_t lastm = 0; |
107 | if (head == 0) { | 100 | if (head == 0) { |
@@ -124,17 +117,17 @@ char *radix_add(uint32_t ip, uint32_t mask, char *name) { | |||
124 | ptr = addZero(ptr, (valid)? name: NULL); | 117 | ptr = addZero(ptr, (valid)? name: NULL); |
125 | } | 118 | } |
126 | assert(ptr); | 119 | assert(ptr); |
127 | if (!ptr->name) { | 120 | if (name && !ptr->name) { |
128 | ptr->name = duplicate_name(name); | 121 | ptr->name = duplicate_name(name); |
129 | if (!ptr->name) | 122 | if (!ptr->name) |
130 | errExit("duplicate_name"); | 123 | errExit("duplicate_name"); |
131 | } | 124 | } |
132 | 125 | ||
133 | return ptr->name; | 126 | return ptr; |
134 | } | 127 | } |
135 | 128 | ||
136 | // find last match | 129 | // find last match |
137 | char *radix_longest_prefix_match(uint32_t ip) { | 130 | RNode *radix_longest_prefix_match(uint32_t ip) { |
138 | if (!head) | 131 | if (!head) |
139 | return NULL; | 132 | return NULL; |
140 | 133 | ||
@@ -154,7 +147,7 @@ char *radix_longest_prefix_match(uint32_t ip) { | |||
154 | rv = ptr; | 147 | rv = ptr; |
155 | } | 148 | } |
156 | 149 | ||
157 | return (rv)? rv->name: NULL; | 150 | return rv; |
158 | } | 151 | } |
159 | 152 | ||
160 | static uint32_t sum; | 153 | static uint32_t sum; |