Rusty Russell | 79dee07 | 2000-05-02 16:45:16 +0000 | [diff] [blame] | 1 | /* Library which manipulates firewall rules. Version 0.1. */ |
| 2 | |
| 3 | /* Architecture of firewall rules is as follows: |
| 4 | * |
| 5 | * Chains go INPUT, FORWARD, OUTPUT then user chains. |
| 6 | * Each user chain starts with an ERROR node. |
| 7 | * Every chain ends with an unconditional jump: a RETURN for user chains, |
| 8 | * and a POLICY for built-ins. |
| 9 | */ |
| 10 | |
| 11 | /* (C)1999 Paul ``Rusty'' Russell - Placed under the GNU GPL (See |
| 12 | COPYING for details). */ |
| 13 | |
| 14 | #include <assert.h> |
| 15 | #include <string.h> |
| 16 | #include <errno.h> |
| 17 | #include <stdlib.h> |
| 18 | #include <stdio.h> |
| 19 | #include <arpa/inet.h> |
| 20 | |
| 21 | #ifdef DEBUG_CONNTRACK |
| 22 | #define inline |
| 23 | #endif |
| 24 | |
| 25 | #if !defined(__GLIBC__) || (__GLIBC__ < 2) |
| 26 | typedef unsigned int socklen_t; |
| 27 | #endif |
| 28 | |
| 29 | #include "libiptc/libip6tc.h" |
| 30 | |
| 31 | #define HOOK_PRE_ROUTING NF_IP6_PRE_ROUTING |
| 32 | #define HOOK_LOCAL_IN NF_IP6_LOCAL_IN |
| 33 | #define HOOK_FORWARD NF_IP6_FORWARD |
| 34 | #define HOOK_LOCAL_OUT NF_IP6_LOCAL_OUT |
| 35 | #define HOOK_POST_ROUTING NF_IP6_POST_ROUTING |
| 36 | |
| 37 | #define STRUCT_ENTRY_TARGET struct ip6t_entry_target |
| 38 | #define STRUCT_ENTRY struct ip6t_entry |
| 39 | #define STRUCT_ENTRY_MATCH struct ip6t_entry_match |
| 40 | #define STRUCT_GETINFO struct ip6t_getinfo |
| 41 | #define STRUCT_GET_ENTRIES struct ip6t_get_entries |
| 42 | #define STRUCT_COUNTERS struct ip6t_counters |
| 43 | #define STRUCT_COUNTERS_INFO struct ip6t_counters_info |
| 44 | #define STRUCT_STANDARD_TARGET struct ip6t_standard_target |
| 45 | #define STRUCT_REPLACE struct ip6t_replace |
| 46 | |
| 47 | #define STRUCT_TC_HANDLE struct ip6tc_handle |
| 48 | #define TC_HANDLE_T ip6tc_handle_t |
| 49 | |
| 50 | #define ENTRY_ITERATE IP6T_ENTRY_ITERATE |
| 51 | #define TABLE_MAXNAMELEN IP6T_TABLE_MAXNAMELEN |
| 52 | #define FUNCTION_MAXNAMELEN IP6T_FUNCTION_MAXNAMELEN |
| 53 | |
| 54 | #define GET_TARGET ip6t_get_target |
| 55 | |
| 56 | #define ERROR_TARGET IP6T_ERROR_TARGET |
| 57 | #define NUMHOOKS NF_IP6_NUMHOOKS |
| 58 | |
| 59 | #define IPT_CHAINLABEL ip6t_chainlabel |
| 60 | |
| 61 | #define TC_DUMP_ENTRIES dump_entries6 |
| 62 | #define TC_IS_CHAIN ip6tc_is_chain |
Philip Blundell | 8c70090 | 2000-05-15 02:17:52 +0000 | [diff] [blame] | 63 | #define TC_FIRST_CHAIN ip6tc_first_chain |
Rusty Russell | 79dee07 | 2000-05-02 16:45:16 +0000 | [diff] [blame] | 64 | #define TC_NEXT_CHAIN ip6tc_next_chain |
Philip Blundell | 8c70090 | 2000-05-15 02:17:52 +0000 | [diff] [blame] | 65 | #define TC_FIRST_RULE ip6tc_first_rule |
| 66 | #define TC_NEXT_RULE ip6tc_next_rule |
Rusty Russell | 79dee07 | 2000-05-02 16:45:16 +0000 | [diff] [blame] | 67 | #define TC_GET_TARGET ip6tc_get_target |
| 68 | #define TC_BUILTIN ip6tc_builtin |
| 69 | #define TC_GET_POLICY ip6tc_get_policy |
| 70 | #define TC_INSERT_ENTRY ip6tc_insert_entry |
| 71 | #define TC_REPLACE_ENTRY ip6tc_replace_entry |
| 72 | #define TC_APPEND_ENTRY ip6tc_append_entry |
| 73 | #define TC_DELETE_ENTRY ip6tc_delete_entry |
| 74 | #define TC_DELETE_NUM_ENTRY ip6tc_delete_num_entry |
| 75 | #define TC_CHECK_PACKET ip6tc_check_packet |
| 76 | #define TC_FLUSH_ENTRIES ip6tc_flush_entries |
| 77 | #define TC_ZERO_ENTRIES ip6tc_zero_entries |
| 78 | #define TC_CREATE_CHAIN ip6tc_create_chain |
| 79 | #define TC_GET_REFERENCES ip6tc_get_references |
| 80 | #define TC_DELETE_CHAIN ip6tc_delete_chain |
| 81 | #define TC_RENAME_CHAIN ip6tc_rename_chain |
| 82 | #define TC_SET_POLICY ip6tc_set_policy |
| 83 | #define TC_GET_RAW_SOCKET ip6tc_get_raw_socket |
| 84 | #define TC_INIT ip6tc_init |
| 85 | #define TC_COMMIT ip6tc_commit |
| 86 | #define TC_STRERROR ip6tc_strerror |
| 87 | |
| 88 | #define TC_AF AF_INET6 |
| 89 | #define TC_IPPROTO IPPROTO_IPV6 |
| 90 | |
| 91 | #define SO_SET_REPLACE IP6T_SO_SET_REPLACE |
| 92 | #define SO_SET_ADD_COUNTERS IP6T_SO_SET_ADD_COUNTERS |
| 93 | #define SO_GET_INFO IP6T_SO_GET_INFO |
| 94 | #define SO_GET_ENTRIES IP6T_SO_GET_ENTRIES |
| 95 | #define SO_GET_VERSION IP6T_SO_GET_VERSION |
| 96 | |
| 97 | #define STANDARD_TARGET IP6T_STANDARD_TARGET |
| 98 | #define LABEL_RETURN IP6TC_LABEL_RETURN |
| 99 | #define LABEL_ACCEPT IP6TC_LABEL_ACCEPT |
| 100 | #define LABEL_DROP IP6TC_LABEL_DROP |
Philip Blundell | 88eb835 | 2000-05-10 00:25:04 +0000 | [diff] [blame] | 101 | #define LABEL_QUEUE IP6TC_LABEL_QUEUE |
Rusty Russell | 79dee07 | 2000-05-02 16:45:16 +0000 | [diff] [blame] | 102 | |
| 103 | #define ALIGN IP6T_ALIGN |
| 104 | #define RETURN IP6T_RETURN |
| 105 | |
| 106 | #include "libiptc.c" |
| 107 | |
| 108 | #define BIT6(a, l) \ |
| 109 | (((a->in6_u.u6_addr32[(l) / 32]) >> ((l) & 31)) & 1) |
| 110 | |
| 111 | int |
| 112 | ipv6_prefix_length(const struct in6_addr *a) |
| 113 | { |
| 114 | int l, i; |
| 115 | for (l = 0; l < 128; l++) { |
| 116 | if (BIT6(a, l) == 0) |
| 117 | break; |
| 118 | } |
| 119 | for (i = l + 1; i < 128; i++) { |
| 120 | if (BIT6(a, i) == 1) |
| 121 | return -1; |
| 122 | } |
| 123 | return l; |
| 124 | } |
| 125 | |
| 126 | static int |
| 127 | dump_entry(struct ip6t_entry *e, const ip6tc_handle_t handle) |
| 128 | { |
| 129 | size_t i; |
| 130 | char buf[40]; |
| 131 | int len; |
| 132 | struct ip6t_entry_target *t; |
| 133 | |
| 134 | printf("Entry %u (%lu):\n", entry2index(handle, e), |
| 135 | entry2offset(handle, e)); |
| 136 | puts("SRC IP: "); |
| 137 | inet_ntop(AF_INET6, &e->ipv6.src, buf, sizeof buf); |
| 138 | puts(buf); |
| 139 | putchar('/'); |
| 140 | len = ipv6_prefix_length(&e->ipv6.smsk); |
| 141 | if (len != -1) |
| 142 | printf("%d", len); |
| 143 | else { |
| 144 | inet_ntop(AF_INET6, &e->ipv6.smsk, buf, sizeof buf); |
| 145 | puts(buf); |
| 146 | } |
| 147 | putchar('\n'); |
| 148 | |
| 149 | puts("DST IP: "); |
| 150 | inet_ntop(AF_INET6, &e->ipv6.dst, buf, sizeof buf); |
| 151 | puts(buf); |
| 152 | putchar('/'); |
| 153 | len = ipv6_prefix_length(&e->ipv6.dmsk); |
| 154 | if (len != -1) |
| 155 | printf("%d", len); |
| 156 | else { |
| 157 | inet_ntop(AF_INET6, &e->ipv6.dmsk, buf, sizeof buf); |
| 158 | puts(buf); |
| 159 | } |
| 160 | putchar('\n'); |
| 161 | |
| 162 | printf("Interface: `%s'/", e->ipv6.iniface); |
| 163 | for (i = 0; i < IFNAMSIZ; i++) |
| 164 | printf("%c", e->ipv6.iniface_mask[i] ? 'X' : '.'); |
| 165 | printf("to `%s'/", e->ipv6.outiface); |
| 166 | for (i = 0; i < IFNAMSIZ; i++) |
| 167 | printf("%c", e->ipv6.outiface_mask[i] ? 'X' : '.'); |
| 168 | printf("\nProtocol: %u\n", e->ipv6.proto); |
| 169 | if (e->ipv6.flags & IP6T_F_TOS) |
| 170 | printf("TOS: %u\n", e->ipv6.tos); |
| 171 | printf("Flags: %02X\n", e->ipv6.flags); |
| 172 | printf("Invflags: %02X\n", e->ipv6.invflags); |
| 173 | printf("Counters: %llu packets, %llu bytes\n", |
| 174 | e->counters.pcnt, e->counters.bcnt); |
| 175 | printf("Cache: %08X ", e->nfcache); |
| 176 | if (e->nfcache & NFC_ALTERED) printf("ALTERED "); |
| 177 | if (e->nfcache & NFC_UNKNOWN) printf("UNKNOWN "); |
| 178 | if (e->nfcache & NFC_IP6_SRC) printf("IP6_SRC "); |
| 179 | if (e->nfcache & NFC_IP6_DST) printf("IP6_DST "); |
| 180 | if (e->nfcache & NFC_IP6_IF_IN) printf("IP6_IF_IN "); |
| 181 | if (e->nfcache & NFC_IP6_IF_OUT) printf("IP6_IF_OUT "); |
| 182 | if (e->nfcache & NFC_IP6_TOS) printf("IP6_TOS "); |
| 183 | if (e->nfcache & NFC_IP6_PROTO) printf("IP6_PROTO "); |
| 184 | if (e->nfcache & NFC_IP6_OPTIONS) printf("IP6_OPTIONS "); |
| 185 | if (e->nfcache & NFC_IP6_TCPFLAGS) printf("IP6_TCPFLAGS "); |
| 186 | if (e->nfcache & NFC_IP6_SRC_PT) printf("IP6_SRC_PT "); |
| 187 | if (e->nfcache & NFC_IP6_DST_PT) printf("IP6_DST_PT "); |
| 188 | if (e->nfcache & NFC_IP6_PROTO_UNKNOWN) printf("IP6_PROTO_UNKNOWN "); |
| 189 | printf("\n"); |
| 190 | |
| 191 | IP6T_MATCH_ITERATE(e, print_match); |
| 192 | |
| 193 | t = ip6t_get_target(e); |
Philip Blundell | 88eb835 | 2000-05-10 00:25:04 +0000 | [diff] [blame] | 194 | printf("Target name: `%s' [%u]\n", t->u.user.name, t->u.target_size); |
| 195 | if (strcmp(t->u.user.name, IP6T_STANDARD_TARGET) == 0) { |
Rusty Russell | 79dee07 | 2000-05-02 16:45:16 +0000 | [diff] [blame] | 196 | int pos = *(int *)t->data; |
| 197 | if (pos < 0) |
| 198 | printf("verdict=%s\n", |
| 199 | pos == -NF_ACCEPT-1 ? "NF_ACCEPT" |
| 200 | : pos == -NF_DROP-1 ? "NF_DROP" |
| 201 | : pos == IP6T_RETURN ? "RETURN" |
| 202 | : "UNKNOWN"); |
| 203 | else |
| 204 | printf("verdict=%u\n", pos); |
Philip Blundell | 88eb835 | 2000-05-10 00:25:04 +0000 | [diff] [blame] | 205 | } else if (strcmp(t->u.user.name, IP6T_ERROR_TARGET) == 0) |
Rusty Russell | 79dee07 | 2000-05-02 16:45:16 +0000 | [diff] [blame] | 206 | printf("error=`%s'\n", t->data); |
| 207 | |
| 208 | printf("\n"); |
| 209 | return 0; |
| 210 | } |
| 211 | |
Philip Blundell | 88eb835 | 2000-05-10 00:25:04 +0000 | [diff] [blame] | 212 | static int |
| 213 | is_same(const STRUCT_ENTRY *a, const STRUCT_ENTRY *b, |
Rusty Russell | 79dee07 | 2000-05-02 16:45:16 +0000 | [diff] [blame] | 214 | unsigned char *matchmask) |
| 215 | { |
| 216 | unsigned int i; |
Philip Blundell | 88eb835 | 2000-05-10 00:25:04 +0000 | [diff] [blame] | 217 | STRUCT_ENTRY_TARGET *ta, *tb; |
Rusty Russell | 79dee07 | 2000-05-02 16:45:16 +0000 | [diff] [blame] | 218 | unsigned char *mptr; |
| 219 | |
| 220 | /* Always compare head structures: ignore mask here. */ |
| 221 | if (memcmp(&a->ipv6.src, &b->ipv6.src, sizeof(struct in6_addr)) |
| 222 | || memcmp(&a->ipv6.dst, &b->ipv6.dst, sizeof(struct in6_addr)) |
| 223 | || memcmp(&a->ipv6.smsk, &b->ipv6.smsk, sizeof(struct in6_addr)) |
| 224 | || memcmp(&a->ipv6.dmsk, &b->ipv6.dmsk, sizeof(struct in6_addr)) |
| 225 | || a->ipv6.proto != b->ipv6.proto |
| 226 | || a->ipv6.tos != b->ipv6.tos |
| 227 | || a->ipv6.flags != b->ipv6.flags |
| 228 | || a->ipv6.invflags != b->ipv6.invflags) |
| 229 | return 0; |
| 230 | |
| 231 | for (i = 0; i < IFNAMSIZ; i++) { |
| 232 | if (a->ipv6.iniface_mask[i] != b->ipv6.iniface_mask[i]) |
| 233 | return 0; |
| 234 | if ((a->ipv6.iniface[i] & a->ipv6.iniface_mask[i]) |
| 235 | != (b->ipv6.iniface[i] & b->ipv6.iniface_mask[i])) |
| 236 | return 0; |
| 237 | if (a->ipv6.outiface_mask[i] != b->ipv6.outiface_mask[i]) |
| 238 | return 0; |
| 239 | if ((a->ipv6.outiface[i] & a->ipv6.outiface_mask[i]) |
| 240 | != (b->ipv6.outiface[i] & b->ipv6.outiface_mask[i])) |
| 241 | return 0; |
| 242 | } |
| 243 | |
| 244 | if (a->nfcache != b->nfcache |
| 245 | || a->target_offset != b->target_offset |
| 246 | || a->next_offset != b->next_offset) |
| 247 | return 0; |
| 248 | |
Philip Blundell | 88eb835 | 2000-05-10 00:25:04 +0000 | [diff] [blame] | 249 | mptr = matchmask + sizeof(STRUCT_ENTRY); |
| 250 | if (IP6T_MATCH_ITERATE(a, match_different, a->elems, b->elems, &mptr)) |
Rusty Russell | 79dee07 | 2000-05-02 16:45:16 +0000 | [diff] [blame] | 251 | return 0; |
| 252 | |
Philip Blundell | 88eb835 | 2000-05-10 00:25:04 +0000 | [diff] [blame] | 253 | ta = GET_TARGET((STRUCT_ENTRY *)a); |
| 254 | tb = GET_TARGET((STRUCT_ENTRY *)b); |
| 255 | if (ta->u.target_size != tb->u.target_size) |
Rusty Russell | 79dee07 | 2000-05-02 16:45:16 +0000 | [diff] [blame] | 256 | return 0; |
Philip Blundell | 88eb835 | 2000-05-10 00:25:04 +0000 | [diff] [blame] | 257 | if (strcmp(ta->u.user.name, tb->u.user.name) != 0) |
Rusty Russell | 79dee07 | 2000-05-02 16:45:16 +0000 | [diff] [blame] | 258 | return 0; |
| 259 | mptr += sizeof(*ta); |
| 260 | |
| 261 | if (target_different(ta->data, tb->data, |
| 262 | ta->u.target_size - sizeof(*ta), mptr)) |
| 263 | return 0; |
| 264 | |
| 265 | return 1; |
| 266 | } |
Philip Blundell | 8c70090 | 2000-05-15 02:17:52 +0000 | [diff] [blame] | 267 | |
Rusty Russell | 5eed48a | 2000-06-02 20:12:24 +0000 | [diff] [blame^] | 268 | /* All zeroes == unconditional rule. */ |
| 269 | static inline int |
| 270 | unconditional(const struct ip6t_ip6 *ipv6) |
| 271 | { |
| 272 | unsigned int i; |
| 273 | |
| 274 | for (i = 0; i < sizeof(*ipv6); i++) |
| 275 | if (((char *)ipv6)[i]) |
| 276 | break; |
| 277 | |
| 278 | return (i == sizeof(*ipv6)); |
| 279 | } |
| 280 | |
Philip Blundell | 8c70090 | 2000-05-15 02:17:52 +0000 | [diff] [blame] | 281 | #ifndef NDEBUG |
| 282 | /* Do every conceivable sanity check on the handle */ |
| 283 | static void |
| 284 | do_check(TC_HANDLE_T h, unsigned int line) |
| 285 | { |
| 286 | unsigned int i, n; |
| 287 | unsigned int user_offset; /* Offset of first user chain */ |
| 288 | int was_return; |
| 289 | |
| 290 | assert(h->changed == 0 || h->changed == 1); |
| 291 | if (strcmp(h->info.name, "filter") == 0) { |
| 292 | assert(h->info.valid_hooks |
| 293 | == (1 << NF_IP6_LOCAL_IN |
| 294 | | 1 << NF_IP6_FORWARD |
| 295 | | 1 << NF_IP6_LOCAL_OUT)); |
| 296 | |
| 297 | /* Hooks should be first three */ |
| 298 | assert(h->info.hook_entry[NF_IP6_LOCAL_IN] == 0); |
| 299 | |
| 300 | n = get_chain_end(h, 0); |
| 301 | n += get_entry(h, n)->next_offset; |
| 302 | assert(h->info.hook_entry[NF_IP6_FORWARD] == n); |
| 303 | |
| 304 | n = get_chain_end(h, n); |
| 305 | n += get_entry(h, n)->next_offset; |
| 306 | assert(h->info.hook_entry[NF_IP6_LOCAL_OUT] == n); |
| 307 | |
| 308 | user_offset = h->info.hook_entry[NF_IP6_LOCAL_OUT]; |
| 309 | } else if (strcmp(h->info.name, "nat") == 0) { |
| 310 | assert(h->info.valid_hooks |
| 311 | == (1 << NF_IP6_PRE_ROUTING |
| 312 | | 1 << NF_IP6_POST_ROUTING |
| 313 | | 1 << NF_IP6_LOCAL_OUT)); |
| 314 | |
| 315 | assert(h->info.hook_entry[NF_IP6_PRE_ROUTING] == 0); |
| 316 | |
| 317 | n = get_chain_end(h, 0); |
| 318 | n += get_entry(h, n)->next_offset; |
| 319 | assert(h->info.hook_entry[NF_IP6_POST_ROUTING] == n); |
| 320 | |
| 321 | n = get_chain_end(h, n); |
| 322 | n += get_entry(h, n)->next_offset; |
| 323 | assert(h->info.hook_entry[NF_IP6_LOCAL_OUT] == n); |
| 324 | |
| 325 | user_offset = h->info.hook_entry[NF_IP6_LOCAL_OUT]; |
| 326 | } else if (strcmp(h->info.name, "mangle") == 0) { |
| 327 | assert(h->info.valid_hooks |
| 328 | == (1 << NF_IP6_PRE_ROUTING |
| 329 | | 1 << NF_IP6_LOCAL_OUT)); |
| 330 | |
| 331 | /* Hooks should be first three */ |
| 332 | assert(h->info.hook_entry[NF_IP6_PRE_ROUTING] == 0); |
| 333 | |
| 334 | n = get_chain_end(h, 0); |
| 335 | n += get_entry(h, n)->next_offset; |
| 336 | assert(h->info.hook_entry[NF_IP6_LOCAL_OUT] == n); |
| 337 | |
| 338 | user_offset = h->info.hook_entry[NF_IP6_LOCAL_OUT]; |
| 339 | } else |
| 340 | abort(); |
| 341 | |
| 342 | /* User chain == end of last builtin + policy entry */ |
| 343 | user_offset = get_chain_end(h, user_offset); |
| 344 | user_offset += get_entry(h, user_offset)->next_offset; |
| 345 | |
| 346 | /* Overflows should be end of entry chains, and unconditional |
| 347 | policy nodes. */ |
| 348 | for (i = 0; i < NUMHOOKS; i++) { |
| 349 | STRUCT_ENTRY *e; |
| 350 | STRUCT_STANDARD_TARGET *t; |
| 351 | |
| 352 | if (!(h->info.valid_hooks & (1 << i))) |
| 353 | continue; |
| 354 | assert(h->info.underflow[i] |
| 355 | == get_chain_end(h, h->info.hook_entry[i])); |
| 356 | |
| 357 | e = get_entry(h, get_chain_end(h, h->info.hook_entry[i])); |
Rusty Russell | 5eed48a | 2000-06-02 20:12:24 +0000 | [diff] [blame^] | 358 | assert(unconditional(&e->ipv6)); |
Philip Blundell | 8c70090 | 2000-05-15 02:17:52 +0000 | [diff] [blame] | 359 | assert(e->target_offset == sizeof(*e)); |
| 360 | t = (STRUCT_STANDARD_TARGET *)GET_TARGET(e); |
| 361 | assert(t->target.u.target_size == ALIGN(sizeof(*t))); |
| 362 | assert(e->next_offset == sizeof(*e) + ALIGN(sizeof(*t))); |
| 363 | |
| 364 | assert(strcmp(t->target.u.user.name, STANDARD_TARGET)==0); |
| 365 | assert(t->verdict == -NF_DROP-1 || t->verdict == -NF_ACCEPT-1); |
| 366 | |
| 367 | /* Hooks and underflows must be valid entries */ |
| 368 | entry2index(h, get_entry(h, h->info.hook_entry[i])); |
| 369 | entry2index(h, get_entry(h, h->info.underflow[i])); |
| 370 | } |
| 371 | |
| 372 | assert(h->info.size |
| 373 | >= h->info.num_entries * (sizeof(STRUCT_ENTRY) |
| 374 | +sizeof(STRUCT_STANDARD_TARGET))); |
| 375 | |
| 376 | assert(h->entries.size |
| 377 | >= (h->new_number |
| 378 | * (sizeof(STRUCT_ENTRY) |
| 379 | + sizeof(STRUCT_STANDARD_TARGET)))); |
| 380 | assert(strcmp(h->info.name, h->entries.name) == 0); |
| 381 | |
| 382 | i = 0; n = 0; |
| 383 | was_return = 0; |
| 384 | |
Rusty Russell | 5eed48a | 2000-06-02 20:12:24 +0000 | [diff] [blame^] | 385 | #if 0 |
Philip Blundell | 8c70090 | 2000-05-15 02:17:52 +0000 | [diff] [blame] | 386 | /* Check all the entries. */ |
Rusty Russell | 5eed48a | 2000-06-02 20:12:24 +0000 | [diff] [blame^] | 387 | ENTRY_ITERATE(h->entries.entries, h->entries.size, |
| 388 | check_entry, &i, &n, user_offset, &was_return, h); |
Philip Blundell | 8c70090 | 2000-05-15 02:17:52 +0000 | [diff] [blame] | 389 | |
| 390 | assert(i == h->new_number); |
| 391 | assert(n == h->entries.size); |
| 392 | |
| 393 | /* Final entry must be error node */ |
| 394 | assert(strcmp(GET_TARGET(index2entry(h, h->new_number-1)) |
| 395 | ->u.user.name, |
| 396 | ERROR_TARGET) == 0); |
Rusty Russell | 5eed48a | 2000-06-02 20:12:24 +0000 | [diff] [blame^] | 397 | #endif |
Philip Blundell | 8c70090 | 2000-05-15 02:17:52 +0000 | [diff] [blame] | 398 | } |
| 399 | #endif /*NDEBUG*/ |