You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ipv6_test.c 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. /*
  2. * Copyright (C) 2013 Michael Brown <mbrown@fensystems.co.uk>.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  17. * 02110-1301, USA.
  18. *
  19. * You can also choose to distribute this program under the terms of
  20. * the Unmodified Binary Distribution Licence (as given in the file
  21. * COPYING.UBDL), provided that you have satisfied its requirements.
  22. */
  23. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  24. /** @file
  25. *
  26. * IPv6 tests
  27. *
  28. */
  29. /* Forcibly enable assertions */
  30. #undef NDEBUG
  31. #include <stdint.h>
  32. #include <string.h>
  33. #include <byteswap.h>
  34. #include <ipxe/ipv6.h>
  35. #include <ipxe/test.h>
  36. /** Define inline IPv6 address */
  37. #define IPV6(...) { __VA_ARGS__ }
  38. /** An IPv6 test routing table entry */
  39. struct ipv6_test_route {
  40. /** Local address */
  41. const char *address;
  42. /** Prefix length */
  43. unsigned int prefix_len;
  44. /** Router address (if any) */
  45. const char *router;
  46. };
  47. /** An IPv6 test routing table */
  48. struct ipv6_test_table {
  49. /** Test routing table entries */
  50. const struct ipv6_test_route *routes;
  51. /** Number of table entries */
  52. unsigned int count;
  53. /** Constructed routing table */
  54. struct list_head list;
  55. };
  56. /** Define a test routing table */
  57. #define TABLE( name, ... ) \
  58. static const struct ipv6_test_route name ## _routes[] = { \
  59. __VA_ARGS__ \
  60. }; \
  61. static struct ipv6_test_table name = { \
  62. .routes = name ## _routes, \
  63. .count = ( sizeof ( name ## _routes ) / \
  64. sizeof ( name ## _routes[0] ) ), \
  65. .list = LIST_HEAD_INIT ( name.list ), \
  66. };
  67. /** The unspecified IPv6 address */
  68. static const struct in6_addr sample_unspecified = {
  69. .s6_addr = IPV6 ( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  70. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ),
  71. };
  72. /** A sample link-local IPv6 address */
  73. static const struct in6_addr sample_link_local = {
  74. .s6_addr = IPV6 ( 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  75. 0x00, 0x00, 0x69, 0xff, 0xfe, 0x50, 0x58, 0x45 ),
  76. };
  77. /** A sample site-local IPv6 address */
  78. static const struct in6_addr sample_site_local = {
  79. .s6_addr = IPV6 ( 0xfe, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  80. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 ),
  81. };
  82. /** A sample ULA IPv6 address */
  83. static const struct in6_addr sample_ula = {
  84. .s6_addr = IPV6 ( 0xfd, 0x44, 0x91, 0x12, 0x64, 0x42, 0x00, 0x00,
  85. 0x00, 0x00, 0x69, 0xff, 0xfe, 0x50, 0x58, 0x45 ),
  86. };
  87. /** A sample global IPv6 address */
  88. static const struct in6_addr sample_global = {
  89. .s6_addr = IPV6 ( 0x20, 0x01, 0x0b, 0xa8, 0x00, 0x00, 0x01, 0xd4,
  90. 0x00, 0x00, 0x00, 0x00, 0x69, 0x50, 0x58, 0x45 ),
  91. };
  92. /** A sample multicast IPv6 address */
  93. static const struct in6_addr sample_multicast = {
  94. .s6_addr = IPV6 ( 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  95. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 ),
  96. };
  97. /** Dummy network device used for routing tests */
  98. static struct net_device ipv6_test_netdev = {
  99. .refcnt = REF_INIT ( ref_no_free ),
  100. .index = 42,
  101. .state = NETDEV_OPEN,
  102. };
  103. /** Routing table with only a link-local address */
  104. TABLE ( table_link_local,
  105. { "fe80::69ff:fe50:5845", 64, NULL } );
  106. /** Routing table with a global address */
  107. TABLE ( table_normal,
  108. { "fe80::69ff:fe50:5845", 64, NULL },
  109. { "2001:db8:3::1", 64, "fe80::1" } );
  110. /** Routing table with multiple addresses and routers */
  111. TABLE ( table_multi,
  112. { "fe80::69ff:fe50:5845", 64, NULL },
  113. { "2001:db8:3::1", 64, "fe80::1" },
  114. { "2001:db8:5::1", 64, NULL },
  115. { "2001:db8:42::1", 64, "fe80::2" },
  116. { "fd44:9112:6442::69ff:fe50:5845", 64, "fe80::1" },
  117. { "fd70:6ba9:50ae::69ff:fe50:5845", 64, "fe80::3" } );
  118. /**
  119. * Report an inet6_ntoa() test result
  120. *
  121. * @v addr IPv6 address
  122. * @v text Expected textual representation
  123. * @v file Test code file
  124. * @v line Test code line
  125. */
  126. static void inet6_ntoa_okx ( const struct in6_addr *addr, const char *text,
  127. const char *file, unsigned int line ) {
  128. char *actual;
  129. actual = inet6_ntoa ( addr );
  130. DBG ( "inet6_ntoa ( %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x ) "
  131. "= %s\n", ntohs ( addr->s6_addr16[0] ),
  132. ntohs ( addr->s6_addr16[1] ), ntohs ( addr->s6_addr16[2] ),
  133. ntohs ( addr->s6_addr16[3] ), ntohs ( addr->s6_addr16[4] ),
  134. ntohs ( addr->s6_addr16[5] ), ntohs ( addr->s6_addr16[6] ),
  135. ntohs ( addr->s6_addr16[7] ), actual );
  136. okx ( strcmp ( actual, text ) == 0, file, line );
  137. }
  138. #define inet6_ntoa_ok( addr, text ) do { \
  139. static const struct in6_addr in = { \
  140. .s6_addr = addr, \
  141. }; \
  142. inet6_ntoa_okx ( &in, text, __FILE__, __LINE__ ); \
  143. } while ( 0 )
  144. /**
  145. * Report an inet6_aton() test result
  146. *
  147. * @v text Textual representation
  148. * @v addr Expected IPv6 address
  149. * @v file Test code file
  150. * @v line Test code line
  151. */
  152. static void inet6_aton_okx ( const char *text, const struct in6_addr *addr,
  153. const char *file, unsigned int line ) {
  154. struct in6_addr actual;
  155. okx ( inet6_aton ( text, &actual ) == 0, file, line );
  156. DBG ( "inet6_aton ( \"%s\" ) = %s\n", text, inet6_ntoa ( &actual ) );
  157. okx ( memcmp ( &actual, addr, sizeof ( actual ) ) == 0,
  158. file, line );
  159. }
  160. #define inet6_aton_ok( text, addr ) do { \
  161. static const struct in6_addr in = { \
  162. .s6_addr = addr, \
  163. }; \
  164. inet6_aton_okx ( text, &in, __FILE__, __LINE__ ); \
  165. } while ( 0 )
  166. /**
  167. * Report an inet6_aton() failure test result
  168. *
  169. * @v text Textual representation
  170. * @v file Test code file
  171. * @v line Test code line
  172. */
  173. static void inet6_aton_fail_okx ( const char *text, const char *file,
  174. unsigned int line ) {
  175. struct in6_addr dummy;
  176. okx ( inet6_aton ( text, &dummy ) != 0, file, line );
  177. }
  178. #define inet6_aton_fail_ok( text ) \
  179. inet6_aton_fail_okx ( text, __FILE__, __LINE__ )
  180. /**
  181. * Create test routing table
  182. *
  183. * @v table Test routing table
  184. * @v file Test code file
  185. * @v line Test code line
  186. */
  187. static void ipv6_table_okx ( struct ipv6_test_table *table, const char *file,
  188. unsigned int line ) {
  189. const struct ipv6_test_route *route;
  190. struct in6_addr address;
  191. struct in6_addr router;
  192. struct list_head saved;
  193. unsigned int i;
  194. /* Sanity check */
  195. okx ( list_empty ( &table->list ), file, line );
  196. /* Save existing routing table */
  197. INIT_LIST_HEAD ( &saved );
  198. list_splice_init ( &ipv6_miniroutes, &saved );
  199. /* Construct routing table */
  200. for ( i = 0 ; i < table->count ; i++ ) {
  201. /* Parse address and router (if applicable) */
  202. route = &table->routes[i];
  203. okx ( inet6_aton ( route->address, &address ) == 0,
  204. file, line );
  205. if ( route->router ) {
  206. okx ( inet6_aton ( route->router, &router ) == 0,
  207. file, line );
  208. }
  209. /* Add routing table entry */
  210. okx ( ipv6_add_miniroute ( &ipv6_test_netdev, &address,
  211. route->prefix_len,
  212. ( route->router ?
  213. &router : NULL ) ) == 0,
  214. file, line );
  215. }
  216. /* Save constructed routing table */
  217. list_splice_init ( &ipv6_miniroutes, &table->list );
  218. /* Restore original routing table */
  219. list_splice ( &saved, &ipv6_miniroutes );
  220. }
  221. #define ipv6_table_ok( table ) \
  222. ipv6_table_okx ( table, __FILE__, __LINE__ )
  223. /**
  224. * Report an ipv6_route() test result
  225. *
  226. * @v table Test routing table
  227. * @v dest Destination address
  228. * @v src Expected source address, or NULL to expect failure
  229. * @v next Expected next hop address, or NULL to expect destination
  230. * @v file Test code file
  231. * @v line Test code line
  232. */
  233. static void ipv6_route_okx ( struct ipv6_test_table *table, const char *dest,
  234. const char *src, const char *next,
  235. const char *file, unsigned int line ) {
  236. struct in6_addr in_dest;
  237. struct in6_addr in_src;
  238. struct in6_addr in_next;
  239. struct in6_addr *actual;
  240. struct ipv6_miniroute *miniroute;
  241. struct list_head saved;
  242. /* Switch to test routing table */
  243. INIT_LIST_HEAD ( &saved );
  244. list_splice_init ( &ipv6_miniroutes, &saved );
  245. list_splice_init ( &table->list, &ipv6_miniroutes );
  246. /* Parse addresses */
  247. okx ( inet6_aton ( dest, &in_dest ) == 0, file, line );
  248. if ( src )
  249. okx ( inet6_aton ( src, &in_src ) == 0, file, line );
  250. if ( next ) {
  251. okx ( inet6_aton ( next, &in_next ) == 0, file, line );
  252. } else {
  253. memcpy ( &in_next, &in_dest, sizeof ( in_next ) );
  254. }
  255. /* Perform routing */
  256. actual = &in_dest;
  257. miniroute = ipv6_route ( ipv6_test_netdev.index, &actual );
  258. /* Validate result */
  259. if ( src ) {
  260. /* Check that a route was found */
  261. okx ( miniroute != NULL, file, line );
  262. DBG ( "ipv6_route ( %s ) = %s", dest, inet6_ntoa ( actual ) );
  263. DBG ( " from %s\n", inet6_ntoa ( &miniroute->address ) );
  264. /* Check that expected source address was used */
  265. okx ( memcmp ( &miniroute->address, &in_src,
  266. sizeof ( in_src ) ) == 0, file, line );
  267. /* Check that expected next hop address was used */
  268. okx ( memcmp ( actual, &in_next, sizeof ( *actual ) ) == 0,
  269. file, line );
  270. } else {
  271. /* Routing is expected to fail */
  272. okx ( miniroute == NULL, file, line );
  273. }
  274. /* Restore original routing table */
  275. list_splice_init ( &ipv6_miniroutes, &table->list );
  276. list_splice ( &saved, &ipv6_miniroutes );
  277. }
  278. #define ipv6_route_ok( table, dest, src, next ) \
  279. ipv6_route_okx ( table, dest, src, next, __FILE__, __LINE__ )
  280. /**
  281. * Destroy test routing table
  282. *
  283. * @v table Test routing table
  284. */
  285. static void ipv6_table_del ( struct ipv6_test_table *table ) {
  286. struct ipv6_miniroute *miniroute;
  287. struct ipv6_miniroute *tmp;
  288. struct list_head saved;
  289. /* Switch to test routing table */
  290. INIT_LIST_HEAD ( &saved );
  291. list_splice_init ( &ipv6_miniroutes, &saved );
  292. list_splice_init ( &table->list, &ipv6_miniroutes );
  293. /* Delete all existing routes */
  294. list_for_each_entry_safe ( miniroute, tmp, &ipv6_miniroutes, list )
  295. ipv6_del_miniroute ( miniroute );
  296. /* Restore original routing table */
  297. list_splice ( &saved, &ipv6_miniroutes );
  298. }
  299. /**
  300. * Perform IPv6 self-tests
  301. *
  302. */
  303. static void ipv6_test_exec ( void ) {
  304. /* Address testing macros */
  305. ok ( IN6_IS_ADDR_UNSPECIFIED ( &sample_unspecified ) );
  306. ok ( ! IN6_IS_ADDR_UNSPECIFIED ( &sample_link_local ) );
  307. ok ( ! IN6_IS_ADDR_UNSPECIFIED ( &sample_site_local ) );
  308. ok ( ! IN6_IS_ADDR_UNSPECIFIED ( &sample_ula ) );
  309. ok ( ! IN6_IS_ADDR_UNSPECIFIED ( &sample_global ) );
  310. ok ( ! IN6_IS_ADDR_UNSPECIFIED ( &sample_multicast ) );
  311. ok ( ! IN6_IS_ADDR_MULTICAST ( &sample_unspecified ) );
  312. ok ( ! IN6_IS_ADDR_MULTICAST ( &sample_link_local ) );
  313. ok ( ! IN6_IS_ADDR_MULTICAST ( &sample_site_local ) );
  314. ok ( ! IN6_IS_ADDR_MULTICAST ( &sample_ula ) );
  315. ok ( ! IN6_IS_ADDR_MULTICAST ( &sample_global ) );
  316. ok ( IN6_IS_ADDR_MULTICAST ( &sample_multicast ) );
  317. ok ( ! IN6_IS_ADDR_LINKLOCAL ( &sample_unspecified ) );
  318. ok ( IN6_IS_ADDR_LINKLOCAL ( &sample_link_local ) );
  319. ok ( ! IN6_IS_ADDR_LINKLOCAL ( &sample_site_local ) );
  320. ok ( ! IN6_IS_ADDR_LINKLOCAL ( &sample_ula ) );
  321. ok ( ! IN6_IS_ADDR_LINKLOCAL ( &sample_global ) );
  322. ok ( ! IN6_IS_ADDR_LINKLOCAL ( &sample_multicast ) );
  323. ok ( ! IN6_IS_ADDR_SITELOCAL ( &sample_unspecified ) );
  324. ok ( ! IN6_IS_ADDR_SITELOCAL ( &sample_link_local ) );
  325. ok ( IN6_IS_ADDR_SITELOCAL ( &sample_site_local ) );
  326. ok ( ! IN6_IS_ADDR_SITELOCAL ( &sample_ula ) );
  327. ok ( ! IN6_IS_ADDR_SITELOCAL ( &sample_global ) );
  328. ok ( ! IN6_IS_ADDR_SITELOCAL ( &sample_multicast ) );
  329. ok ( ! IN6_IS_ADDR_ULA ( &sample_unspecified ) );
  330. ok ( ! IN6_IS_ADDR_ULA ( &sample_link_local ) );
  331. ok ( ! IN6_IS_ADDR_ULA ( &sample_site_local ) );
  332. ok ( IN6_IS_ADDR_ULA ( &sample_ula ) );
  333. ok ( ! IN6_IS_ADDR_ULA ( &sample_global ) );
  334. ok ( ! IN6_IS_ADDR_ULA ( &sample_multicast ) );
  335. /* inet6_ntoa() tests */
  336. inet6_ntoa_ok ( IPV6 ( 0x20, 0x01, 0x0b, 0xa8, 0x00, 0x00, 0x01, 0xd4,
  337. 0x00, 0x00, 0x00, 0x00, 0x69, 0x50, 0x58, 0x45 ),
  338. "2001:ba8:0:1d4::6950:5845" );
  339. /* No zeros */
  340. inet6_ntoa_ok ( IPV6 ( 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x01, 0x00, 0x01,
  341. 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01 ),
  342. "2001:db8:1:1:1:1:1:1" );
  343. /* Run of zeros */
  344. inet6_ntoa_ok ( IPV6 ( 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00,
  345. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 ),
  346. "2001:db8::1" );
  347. /* No "::" for single zero */
  348. inet6_ntoa_ok ( IPV6 ( 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x01,
  349. 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01 ),
  350. "2001:db8:0:1:1:1:1:1" );
  351. /* Use "::" for longest run of zeros */
  352. inet6_ntoa_ok ( IPV6 ( 0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
  353. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 ),
  354. "2001:0:0:1::1" );
  355. /* Use "::" for leftmost equal-length run of zeros */
  356. inet6_ntoa_ok ( IPV6 ( 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00,
  357. 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 ),
  358. "2001:db8::1:0:0:1" );
  359. /* Trailing run of zeros */
  360. inet6_ntoa_ok ( IPV6 ( 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  361. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ),
  362. "fe80::" );
  363. /* Leading run of zeros */
  364. inet6_ntoa_ok ( IPV6 ( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  365. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 ),
  366. "::1" );
  367. /* All zeros */
  368. inet6_ntoa_ok ( IPV6 ( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  369. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ),
  370. "::" );
  371. /* Maximum length */
  372. inet6_ntoa_ok ( IPV6 ( 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  373. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff ),
  374. "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" );
  375. /* inet6_aton() tests */
  376. inet6_aton_ok ( "2001:ba8:0:1d4::6950:5845",
  377. IPV6 ( 0x20, 0x01, 0x0b, 0xa8, 0x00, 0x00, 0x01, 0xd4,
  378. 0x00, 0x00, 0x00, 0x00, 0x69, 0x50, 0x58, 0x45));
  379. /* No zeros */
  380. inet6_aton_ok ( "2001:db8:1:1:1:1:1:1",
  381. IPV6 ( 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x01, 0x00, 0x01,
  382. 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01));
  383. /* All intervening zeros */
  384. inet6_aton_ok ( "fe80::1",
  385. IPV6 ( 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  386. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01));
  387. /* Trailing run of zeros */
  388. inet6_aton_ok ( "fe80::",
  389. IPV6 ( 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  390. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00));
  391. /* Leading run of zeros */
  392. inet6_aton_ok ( "::1",
  393. IPV6 ( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  394. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01));
  395. /* All zeros */
  396. inet6_aton_ok ( "::",
  397. IPV6 ( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  398. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00));
  399. /* inet6_aton() failure tests */
  400. inet6_aton_fail_ok ( "20012:ba8:0:1d4::6950:5845" );
  401. inet6_aton_fail_ok ( "200z:ba8:0:1d4::6950:5845" );
  402. inet6_aton_fail_ok ( "2001.ba8:0:1d4::6950:5845" );
  403. inet6_aton_fail_ok ( "2001:db8:1:1:1:1:1" );
  404. inet6_aton_fail_ok ( "2001:db8:1:1:1:1:1:1:2" );
  405. inet6_aton_fail_ok ( "2001:db8::1::2" );
  406. inet6_aton_fail_ok ( "2001:ba8:0:1d4:::6950:5845" );
  407. inet6_aton_fail_ok ( ":::" );
  408. /* Create test routing tables */
  409. ipv6_table_ok ( &table_link_local );
  410. ipv6_table_ok ( &table_normal );
  411. ipv6_table_ok ( &table_multi );
  412. /* Routing table with only a link-local address */
  413. ipv6_route_ok ( &table_link_local, "fe80::1",
  414. "fe80::69ff:fe50:5845", NULL );
  415. ipv6_route_ok ( &table_link_local, "2001:db8:1::1",
  416. NULL, NULL );
  417. ipv6_route_ok ( &table_link_local, "ff02::1",
  418. "fe80::69ff:fe50:5845", NULL );
  419. /** Routing table with a global address */
  420. ipv6_route_ok ( &table_normal, "fe80::1",
  421. "fe80::69ff:fe50:5845", NULL );
  422. ipv6_route_ok ( &table_normal, "2001:db8:3::42",
  423. "2001:db8:3::1", NULL );
  424. ipv6_route_ok ( &table_normal, "2001:ba8:0:1d4::6950:5845",
  425. "2001:db8:3::1", "fe80::1" );
  426. ipv6_route_ok ( &table_normal, "ff02::1",
  427. "fe80::69ff:fe50:5845", NULL );
  428. ipv6_route_ok ( &table_normal, "ff0e::1",
  429. "2001:db8:3::1", NULL );
  430. /** Routing table with multiple addresses and routers */
  431. ipv6_route_ok ( &table_multi, "fe80::1",
  432. "fe80::69ff:fe50:5845", NULL );
  433. ipv6_route_ok ( &table_multi, "2001:db8:3::17",
  434. "2001:db8:3::1", NULL );
  435. ipv6_route_ok ( &table_multi, "2001:db8:5::92",
  436. "2001:db8:5::1", NULL );
  437. ipv6_route_ok ( &table_multi, "2001:db8:42::17",
  438. "2001:db8:42::1", NULL );
  439. ipv6_route_ok ( &table_multi, "2001:db8:5:1::17",
  440. "2001:db8:3::1", "fe80::1" );
  441. ipv6_route_ok ( &table_multi, "fd44:9112:6442::1",
  442. "fd44:9112:6442::69ff:fe50:5845", NULL );
  443. ipv6_route_ok ( &table_multi, "fd70:6ba9:50ae::1",
  444. "fd70:6ba9:50ae::69ff:fe50:5845", NULL );
  445. ipv6_route_ok ( &table_multi, "fd40::3",
  446. "fd44:9112:6442::69ff:fe50:5845", "fe80::1" );
  447. ipv6_route_ok ( &table_multi, "fd70::2",
  448. "fd70:6ba9:50ae::69ff:fe50:5845", "fe80::3" );
  449. ipv6_route_ok ( &table_multi, "ff02::1",
  450. "fe80::69ff:fe50:5845", NULL );
  451. /* Destroy test routing tables */
  452. ipv6_table_del ( &table_link_local );
  453. ipv6_table_del ( &table_normal );
  454. ipv6_table_del ( &table_multi );
  455. }
  456. /** IPv6 self-test */
  457. struct self_test ipv6_test __self_test = {
  458. .name = "ipv6",
  459. .exec = ipv6_test_exec,
  460. };