| OLD | NEW |
| 1 #include <sys/socket.h> | 1 #include <sys/socket.h> |
| 2 #include <netinet/in.h> | 2 #include <netinet/in.h> |
| 3 #include <netdb.h> | 3 #include <netdb.h> |
| 4 #include <net/if.h> | 4 #include <net/if.h> |
| 5 #include <arpa/inet.h> | 5 #include <arpa/inet.h> |
| 6 #include <ctype.h> | 6 #include <ctype.h> |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <fcntl.h> | 9 #include <fcntl.h> |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 static const struct policy { | 262 static const struct policy { |
| 263 unsigned char addr[16]; | 263 unsigned char addr[16]; |
| 264 unsigned char len, mask; | 264 unsigned char len, mask; |
| 265 unsigned char prec, label; | 265 unsigned char prec, label; |
| 266 } defpolicy[] = { | 266 } defpolicy[] = { |
| 267 {"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1", 15, 0xff, 50, 0}, | 267 {"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1", 15, 0xff, 50, 0}, |
| 268 {"\0\0\0\0\0\0\0\0\0\0\xff\xff", 11, 0xff, 35, 4}, | 268 {"\0\0\0\0\0\0\0\0\0\0\xff\xff", 11, 0xff, 35, 4}, |
| 269 {"\x20\2", 1, 0xff, 30, 2}, | 269 {"\x20\2", 1, 0xff, 30, 2}, |
| 270 {"\x20\1", 3, 0xff, 5, 5}, | 270 {"\x20\1", 3, 0xff, 5, 5}, |
| 271 {"\xfc", 0, 0xfe, 3, 13}, | 271 {"\xfc", 0, 0xfe, 3, 13}, |
| 272 #if 0 | 272 /* These are deprecated and/or returned to the address |
| 273 » /* These are deprecated and/or returned to the address | 273 * pool, so despite the RFC, treating them as special |
| 274 » * pool, so despite the RFC, treating them as special | 274 * is probably wrong. |
| 275 » * is probably wrong. */ | 275 * {"", 11, 0xff, 1, 3}, |
| 276 » { "", 11, 0xff, 1, 3 }, | 276 * {"\xfe\xc0", 1, 0xc0, 1, 11}, |
| 277 » { "\xfe\xc0", 1, 0xc0, 1, 11 }, | 277 * {"\x3f\xfe", 1, 0xff, 1, 12}, |
| 278 » { "\x3f\xfe", 1, 0xff, 1, 12 }, | 278 * Last rule must match all addresses to stop loop. */ |
| 279 #endif | |
| 280 /* Last rule must match all addresses to stop loop. */ | |
| 281 {"", 0, 0, 40, 1}, | 279 {"", 0, 0, 40, 1}, |
| 282 }; | 280 }; |
| 283 | 281 |
| 284 static const struct policy* policyof(const struct in6_addr* a) { | 282 static const struct policy* policyof(const struct in6_addr* a) { |
| 285 int i; | 283 int i; |
| 286 for (i = 0;; i++) { | 284 for (i = 0;; i++) { |
| 287 if (memcmp(a->s6_addr, defpolicy[i].addr, defpolicy[i].len)) | 285 if (memcmp(a->s6_addr, defpolicy[i].addr, defpolicy[i].len)) |
| 288 continue; | 286 continue; |
| 289 if ((a->s6_addr[defpolicy[i].len] & defpolicy[i].mask) != | 287 if ((a->s6_addr[defpolicy[i].len] & defpolicy[i].mask) != |
| 290 defpolicy[i].addr[defpolicy[i].len]) | 288 defpolicy[i].addr[defpolicy[i].len]) |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 key |= prefixlen << DAS_PREFIX_SHIFT; | 446 key |= prefixlen << DAS_PREFIX_SHIFT; |
| 449 key |= (MAXADDRS - i) << DAS_ORDER_SHIFT; | 447 key |= (MAXADDRS - i) << DAS_ORDER_SHIFT; |
| 450 buf[i].sortkey = key; | 448 buf[i].sortkey = key; |
| 451 } | 449 } |
| 452 qsort(buf, cnt, sizeof *buf, addrcmp); | 450 qsort(buf, cnt, sizeof *buf, addrcmp); |
| 453 | 451 |
| 454 pthread_setcancelstate(cs, 0); | 452 pthread_setcancelstate(cs, 0); |
| 455 | 453 |
| 456 return cnt; | 454 return cnt; |
| 457 } | 455 } |
| OLD | NEW |