iPXE
ipv6_test.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2013 Michael Brown <mbrown@fensystems.co.uk>.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License as
00006  * published by the Free Software Foundation; either version 2 of the
00007  * License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301, USA.
00018  *
00019  * You can also choose to distribute this program under the terms of
00020  * the Unmodified Binary Distribution Licence (as given in the file
00021  * COPYING.UBDL), provided that you have satisfied its requirements.
00022  */
00023 
00024 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00025 
00026 /** @file
00027  *
00028  * IPv6 tests
00029  *
00030  */
00031 
00032 /* Forcibly enable assertions */
00033 #undef NDEBUG
00034 
00035 #include <stdint.h>
00036 #include <string.h>
00037 #include <byteswap.h>
00038 #include <ipxe/ipv6.h>
00039 #include <ipxe/test.h>
00040 
00041 /** Define inline IPv6 address */
00042 #define IPV6(...) { __VA_ARGS__ }
00043 
00044 /** An IPv6 test routing table entry */
00045 struct ipv6_test_route {
00046         /** Local address */
00047         const char *address;
00048         /** Prefix length */
00049         unsigned int prefix_len;
00050         /** Router address (if any) */
00051         const char *router;
00052 };
00053 
00054 /** An IPv6 test routing table */
00055 struct ipv6_test_table {
00056         /** Test routing table entries */
00057         const struct ipv6_test_route *routes;
00058         /** Number of table entries */
00059         unsigned int count;
00060         /** Constructed routing table */
00061         struct list_head list;
00062 };
00063 
00064 /** Define a test routing table */
00065 #define TABLE( name, ... )                                              \
00066         static const struct ipv6_test_route name ## _routes[] = {       \
00067                 __VA_ARGS__                                             \
00068         };                                                              \
00069         static struct ipv6_test_table name = {                          \
00070                 .routes = name ## _routes,                              \
00071                 .count = ( sizeof ( name ## _routes ) /                 \
00072                            sizeof ( name ## _routes[0] ) ),             \
00073                 .list = LIST_HEAD_INIT ( name.list ),                   \
00074         };
00075 
00076 /** The unspecified IPv6 address */
00077 static const struct in6_addr sample_unspecified = {
00078         .s6_addr = IPV6 ( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00079                           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ),
00080 };
00081 
00082 /** A sample link-local IPv6 address */
00083 static const struct in6_addr sample_link_local = {
00084         .s6_addr = IPV6 ( 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00085                           0x00, 0x00, 0x69, 0xff, 0xfe, 0x50, 0x58, 0x45 ),
00086 };
00087 
00088 /** A sample site-local IPv6 address */
00089 static const struct in6_addr sample_site_local = {
00090         .s6_addr = IPV6 ( 0xfe, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00091                           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 ),
00092 };
00093 
00094 /** A sample ULA IPv6 address */
00095 static const struct in6_addr sample_ula = {
00096         .s6_addr = IPV6 ( 0xfd, 0x44, 0x91, 0x12, 0x64, 0x42, 0x00, 0x00,
00097                           0x00, 0x00, 0x69, 0xff, 0xfe, 0x50, 0x58, 0x45 ),
00098 };
00099 
00100 /** A sample global IPv6 address */
00101 static const struct in6_addr sample_global = {
00102         .s6_addr = IPV6 ( 0x20, 0x01, 0x0b, 0xa8, 0x00, 0x00, 0x01, 0xd4,
00103                           0x00, 0x00, 0x00, 0x00, 0x69, 0x50, 0x58, 0x45 ),
00104 };
00105 
00106 /** A sample multicast IPv6 address */
00107 static const struct in6_addr sample_multicast = {
00108         .s6_addr = IPV6 ( 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00109                           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 ),
00110 };
00111 
00112 /** Dummy network device used for routing tests */
00113 static struct net_device ipv6_test_netdev = {
00114         .refcnt = REF_INIT ( ref_no_free ),
00115         .index = 42,
00116         .state = NETDEV_OPEN,
00117 };
00118 
00119 /** Routing table with only a link-local address */
00120 TABLE ( table_link_local,
00121         { "fe80::69ff:fe50:5845", 64, NULL } );
00122 
00123 /** Routing table with a global address */
00124 TABLE ( table_normal,
00125         { "fe80::69ff:fe50:5845", 64, NULL },
00126         { "2001:db8:3::1", 64, "fe80::1" } );
00127 
00128 /** Routing table with multiple addresses and routers */
00129 TABLE ( table_multi,
00130         { "fe80::69ff:fe50:5845", 64, NULL },
00131         { "2001:db8:3::1", 64, "fe80::1" },
00132         { "2001:db8:5::1", 64, NULL },
00133         { "2001:db8:42::1", 64, "fe80::2" },
00134         { "fd44:9112:6442::69ff:fe50:5845", 64, "fe80::1" },
00135         { "fd70:6ba9:50ae::69ff:fe50:5845", 64, "fe80::3" } );
00136 
00137 /**
00138  * Report an inet6_ntoa() test result
00139  *
00140  * @v addr              IPv6 address
00141  * @v text              Expected textual representation
00142  * @v file              Test code file
00143  * @v line              Test code line
00144  */
00145 static void inet6_ntoa_okx ( const struct in6_addr *addr, const char *text,
00146                              const char *file, unsigned int line ) {
00147         char *actual;
00148 
00149         actual = inet6_ntoa ( addr );
00150         DBG ( "inet6_ntoa ( %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x ) "
00151               "= %s\n", ntohs ( addr->s6_addr16[0] ),
00152               ntohs ( addr->s6_addr16[1] ), ntohs ( addr->s6_addr16[2] ),
00153               ntohs ( addr->s6_addr16[3] ), ntohs ( addr->s6_addr16[4] ),
00154               ntohs ( addr->s6_addr16[5] ), ntohs ( addr->s6_addr16[6] ),
00155               ntohs ( addr->s6_addr16[7] ), actual );
00156         okx ( strcmp ( actual, text ) == 0, file, line );
00157 }
00158 #define inet6_ntoa_ok( addr, text ) do {                                \
00159         static const struct in6_addr in = {                             \
00160                 .s6_addr = addr,                                        \
00161         };                                                              \
00162         inet6_ntoa_okx ( &in, text, __FILE__, __LINE__ );               \
00163         } while ( 0 )
00164 
00165 /**
00166  * Report an inet6_aton() test result
00167  *
00168  * @v text              Textual representation
00169  * @v addr              Expected IPv6 address
00170  * @v file              Test code file
00171  * @v line              Test code line
00172  */
00173 static void inet6_aton_okx ( const char *text, const struct in6_addr *addr,
00174                              const char *file, unsigned int line ) {
00175         struct in6_addr actual;
00176 
00177         okx ( inet6_aton ( text, &actual ) == 0, file, line );
00178         DBG ( "inet6_aton ( \"%s\" ) = %s\n", text, inet6_ntoa ( &actual ) );
00179         okx ( memcmp ( &actual, addr, sizeof ( actual ) ) == 0,
00180               file, line );
00181 }
00182 #define inet6_aton_ok( text, addr ) do {                                \
00183         static const struct in6_addr in = {                             \
00184                 .s6_addr = addr,                                        \
00185         };                                                              \
00186         inet6_aton_okx ( text, &in, __FILE__, __LINE__ );               \
00187         } while ( 0 )
00188 
00189 /**
00190  * Report an inet6_aton() failure test result
00191  *
00192  * @v text              Textual representation
00193  * @v file              Test code file
00194  * @v line              Test code line
00195  */
00196 static void inet6_aton_fail_okx ( const char *text, const char *file,
00197                                   unsigned int line ) {
00198         struct in6_addr dummy;
00199 
00200         okx ( inet6_aton ( text, &dummy ) != 0, file, line );
00201 }
00202 #define inet6_aton_fail_ok( text )                                      \
00203         inet6_aton_fail_okx ( text, __FILE__, __LINE__ )
00204 
00205 /**
00206  * Create test routing table
00207  *
00208  * @v table             Test routing table
00209  * @v file              Test code file
00210  * @v line              Test code line
00211  */
00212 static void ipv6_table_okx ( struct ipv6_test_table *table, const char *file,
00213                              unsigned int line ) {
00214         const struct ipv6_test_route *route;
00215         struct in6_addr address;
00216         struct in6_addr router;
00217         struct list_head saved;
00218         unsigned int i;
00219 
00220         /* Sanity check */
00221         okx ( list_empty ( &table->list ), file, line );
00222 
00223         /* Save existing routing table */
00224         INIT_LIST_HEAD ( &saved );
00225         list_splice_init ( &ipv6_miniroutes, &saved );
00226 
00227         /* Construct routing table */
00228         for ( i = 0 ; i < table->count ; i++ ) {
00229 
00230                 /* Parse address and router (if applicable) */
00231                 route = &table->routes[i];
00232                 okx ( inet6_aton ( route->address, &address ) == 0,
00233                       file, line );
00234                 if ( route->router ) {
00235                         okx ( inet6_aton ( route->router, &router ) == 0,
00236                               file, line );
00237                 }
00238 
00239                 /* Add routing table entry */
00240                 okx ( ipv6_add_miniroute ( &ipv6_test_netdev, &address,
00241                                            route->prefix_len,
00242                                            ( route->router ?
00243                                              &router : NULL ) ) == 0,
00244                       file, line );
00245         }
00246 
00247         /* Save constructed routing table */
00248         list_splice_init ( &ipv6_miniroutes, &table->list );
00249 
00250         /* Restore original routing table */
00251         list_splice ( &saved, &ipv6_miniroutes );
00252 }
00253 #define ipv6_table_ok( table )                                          \
00254         ipv6_table_okx ( table, __FILE__, __LINE__ )
00255 
00256 /**
00257  * Report an ipv6_route() test result
00258  *
00259  * @v table             Test routing table
00260  * @v dest              Destination address
00261  * @v src               Expected source address, or NULL to expect failure
00262  * @v next              Expected next hop address, or NULL to expect destination
00263  * @v file              Test code file
00264  * @v line              Test code line
00265  */
00266 static void ipv6_route_okx ( struct ipv6_test_table *table, const char *dest,
00267                              const char *src, const char *next,
00268                              const char *file, unsigned int line ) {
00269         struct in6_addr in_dest;
00270         struct in6_addr in_src;
00271         struct in6_addr in_next;
00272         struct in6_addr *actual;
00273         struct ipv6_miniroute *miniroute;
00274         struct list_head saved;
00275 
00276         /* Switch to test routing table */
00277         INIT_LIST_HEAD ( &saved );
00278         list_splice_init ( &ipv6_miniroutes, &saved );
00279         list_splice_init ( &table->list, &ipv6_miniroutes );
00280 
00281         /* Parse addresses */
00282         okx ( inet6_aton ( dest, &in_dest ) == 0, file, line );
00283         if ( src )
00284                 okx ( inet6_aton ( src, &in_src ) == 0, file, line );
00285         if ( next ) {
00286                 okx ( inet6_aton ( next, &in_next ) == 0, file, line );
00287         } else {
00288                 memcpy ( &in_next, &in_dest, sizeof ( in_next ) );
00289         }
00290 
00291         /* Perform routing */
00292         actual = &in_dest;
00293         miniroute = ipv6_route ( ipv6_test_netdev.index, &actual );
00294 
00295         /* Validate result */
00296         if ( src ) {
00297 
00298                 /* Check that a route was found */
00299                 okx ( miniroute != NULL, file, line );
00300                 DBG ( "ipv6_route ( %s ) = %s", dest, inet6_ntoa ( actual ) );
00301                 DBG ( " from %s\n", inet6_ntoa ( &miniroute->address ) );
00302 
00303                 /* Check that expected source address was used */
00304                 okx ( memcmp ( &miniroute->address, &in_src,
00305                                sizeof ( in_src ) ) == 0, file, line );
00306 
00307                 /* Check that expected next hop address was used */
00308                 okx ( memcmp ( actual, &in_next, sizeof ( *actual ) ) == 0,
00309                       file, line );
00310 
00311         } else {
00312 
00313                 /* Routing is expected to fail */
00314                 okx ( miniroute == NULL, file, line );
00315         }
00316 
00317         /* Restore original routing table */
00318         list_splice_init ( &ipv6_miniroutes, &table->list );
00319         list_splice ( &saved, &ipv6_miniroutes );
00320 }
00321 #define ipv6_route_ok( table, dest, src, next )                         \
00322         ipv6_route_okx ( table, dest, src, next, __FILE__, __LINE__ )
00323 
00324 /**
00325  * Destroy test routing table
00326  *
00327  * @v table             Test routing table
00328  */
00329 static void ipv6_table_del ( struct ipv6_test_table *table ) {
00330         struct ipv6_miniroute *miniroute;
00331         struct ipv6_miniroute *tmp;
00332         struct list_head saved;
00333 
00334         /* Switch to test routing table */
00335         INIT_LIST_HEAD ( &saved );
00336         list_splice_init ( &ipv6_miniroutes, &saved );
00337         list_splice_init ( &table->list, &ipv6_miniroutes );
00338 
00339         /* Delete all existing routes */
00340         list_for_each_entry_safe ( miniroute, tmp, &ipv6_miniroutes, list )
00341                 ipv6_del_miniroute ( miniroute );
00342 
00343         /* Restore original routing table */
00344         list_splice ( &saved, &ipv6_miniroutes );
00345 }
00346 
00347 /**
00348  * Perform IPv6 self-tests
00349  *
00350  */
00351 static void ipv6_test_exec ( void ) {
00352 
00353         /* Address testing macros */
00354         ok (   IN6_IS_ADDR_UNSPECIFIED ( &sample_unspecified ) );
00355         ok ( ! IN6_IS_ADDR_UNSPECIFIED ( &sample_link_local ) );
00356         ok ( ! IN6_IS_ADDR_UNSPECIFIED ( &sample_site_local ) );
00357         ok ( ! IN6_IS_ADDR_UNSPECIFIED ( &sample_ula ) );
00358         ok ( ! IN6_IS_ADDR_UNSPECIFIED ( &sample_global ) );
00359         ok ( ! IN6_IS_ADDR_UNSPECIFIED ( &sample_multicast ) );
00360         ok ( ! IN6_IS_ADDR_MULTICAST ( &sample_unspecified ) );
00361         ok ( ! IN6_IS_ADDR_MULTICAST ( &sample_link_local ) );
00362         ok ( ! IN6_IS_ADDR_MULTICAST ( &sample_site_local ) );
00363         ok ( ! IN6_IS_ADDR_MULTICAST ( &sample_ula ) );
00364         ok ( ! IN6_IS_ADDR_MULTICAST ( &sample_global ) );
00365         ok (   IN6_IS_ADDR_MULTICAST ( &sample_multicast ) );
00366         ok ( ! IN6_IS_ADDR_LINKLOCAL ( &sample_unspecified ) );
00367         ok (   IN6_IS_ADDR_LINKLOCAL ( &sample_link_local ) );
00368         ok ( ! IN6_IS_ADDR_LINKLOCAL ( &sample_site_local ) );
00369         ok ( ! IN6_IS_ADDR_LINKLOCAL ( &sample_ula ) );
00370         ok ( ! IN6_IS_ADDR_LINKLOCAL ( &sample_global ) );
00371         ok ( ! IN6_IS_ADDR_LINKLOCAL ( &sample_multicast ) );
00372         ok ( ! IN6_IS_ADDR_SITELOCAL ( &sample_unspecified ) );
00373         ok ( ! IN6_IS_ADDR_SITELOCAL ( &sample_link_local ) );
00374         ok (   IN6_IS_ADDR_SITELOCAL ( &sample_site_local ) );
00375         ok ( ! IN6_IS_ADDR_SITELOCAL ( &sample_ula ) );
00376         ok ( ! IN6_IS_ADDR_SITELOCAL ( &sample_global ) );
00377         ok ( ! IN6_IS_ADDR_SITELOCAL ( &sample_multicast ) );
00378         ok ( ! IN6_IS_ADDR_ULA ( &sample_unspecified ) );
00379         ok ( ! IN6_IS_ADDR_ULA ( &sample_link_local ) );
00380         ok ( ! IN6_IS_ADDR_ULA ( &sample_site_local ) );
00381         ok (   IN6_IS_ADDR_ULA ( &sample_ula ) );
00382         ok ( ! IN6_IS_ADDR_ULA ( &sample_global ) );
00383         ok ( ! IN6_IS_ADDR_ULA ( &sample_multicast ) );
00384 
00385         /* inet6_ntoa() tests */
00386         inet6_ntoa_ok ( IPV6 ( 0x20, 0x01, 0x0b, 0xa8, 0x00, 0x00, 0x01, 0xd4,
00387                                0x00, 0x00, 0x00, 0x00, 0x69, 0x50, 0x58, 0x45 ),
00388                         "2001:ba8:0:1d4::6950:5845" );
00389         /* No zeros */
00390         inet6_ntoa_ok ( IPV6 ( 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x01, 0x00, 0x01,
00391                                0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01 ),
00392                         "2001:db8:1:1:1:1:1:1" );
00393         /* Run of zeros */
00394         inet6_ntoa_ok ( IPV6 ( 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00,
00395                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 ),
00396                         "2001:db8::1" );
00397         /* No "::" for single zero */
00398         inet6_ntoa_ok ( IPV6 ( 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x01,
00399                                0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01 ),
00400                         "2001:db8:0:1:1:1:1:1" );
00401         /* Use "::" for longest run of zeros */
00402         inet6_ntoa_ok ( IPV6 ( 0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
00403                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 ),
00404                         "2001:0:0:1::1" );
00405         /* Use "::" for leftmost equal-length run of zeros */
00406         inet6_ntoa_ok ( IPV6 ( 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00,
00407                                0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 ),
00408                         "2001:db8::1:0:0:1" );
00409         /* Trailing run of zeros */
00410         inet6_ntoa_ok ( IPV6 ( 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00411                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ),
00412                         "fe80::" );
00413         /* Leading run of zeros */
00414         inet6_ntoa_ok ( IPV6 ( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00415                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 ),
00416                         "::1" );
00417         /* All zeros */
00418         inet6_ntoa_ok ( IPV6 ( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00419                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ),
00420                         "::" );
00421         /* Maximum length */
00422         inet6_ntoa_ok ( IPV6 ( 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
00423                                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff ),
00424                         "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" );
00425 
00426         /* inet6_aton() tests */
00427         inet6_aton_ok ( "2001:ba8:0:1d4::6950:5845",
00428                         IPV6 ( 0x20, 0x01, 0x0b, 0xa8, 0x00, 0x00, 0x01, 0xd4,
00429                                0x00, 0x00, 0x00, 0x00, 0x69, 0x50, 0x58, 0x45));
00430         /* No zeros */
00431         inet6_aton_ok ( "2001:db8:1:1:1:1:1:1",
00432                         IPV6 ( 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x01, 0x00, 0x01,
00433                                0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01));
00434         /* All intervening zeros */
00435         inet6_aton_ok ( "fe80::1",
00436                         IPV6 ( 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00437                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01));
00438         /* Trailing run of zeros */
00439         inet6_aton_ok ( "fe80::",
00440                         IPV6 ( 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00441                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00));
00442         /* Leading run of zeros */
00443         inet6_aton_ok ( "::1",
00444                         IPV6 ( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00445                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01));
00446         /* All zeros */
00447         inet6_aton_ok ( "::",
00448                         IPV6 ( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00449                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00));
00450 
00451         /* inet6_aton() failure tests */
00452         inet6_aton_fail_ok ( "20012:ba8:0:1d4::6950:5845" );
00453         inet6_aton_fail_ok ( "200z:ba8:0:1d4::6950:5845" );
00454         inet6_aton_fail_ok ( "2001.ba8:0:1d4::6950:5845" );
00455         inet6_aton_fail_ok ( "2001:db8:1:1:1:1:1" );
00456         inet6_aton_fail_ok ( "2001:db8:1:1:1:1:1:1:2" );
00457         inet6_aton_fail_ok ( "2001:db8::1::2" );
00458         inet6_aton_fail_ok ( "2001:ba8:0:1d4:::6950:5845" );
00459         inet6_aton_fail_ok ( ":::" );
00460 
00461         /* Create test routing tables */
00462         ipv6_table_ok ( &table_link_local );
00463         ipv6_table_ok ( &table_normal );
00464         ipv6_table_ok ( &table_multi );
00465 
00466         /* Routing table with only a link-local address */
00467         ipv6_route_ok ( &table_link_local, "fe80::1",
00468                         "fe80::69ff:fe50:5845", NULL );
00469         ipv6_route_ok ( &table_link_local, "2001:db8:1::1",
00470                         NULL, NULL );
00471         ipv6_route_ok ( &table_link_local, "ff02::1",
00472                         "fe80::69ff:fe50:5845", NULL );
00473 
00474         /** Routing table with a global address */
00475         ipv6_route_ok ( &table_normal, "fe80::1",
00476                         "fe80::69ff:fe50:5845", NULL );
00477         ipv6_route_ok ( &table_normal, "2001:db8:3::42",
00478                         "2001:db8:3::1", NULL );
00479         ipv6_route_ok ( &table_normal, "2001:ba8:0:1d4::6950:5845",
00480                         "2001:db8:3::1", "fe80::1" );
00481         ipv6_route_ok ( &table_normal, "ff02::1",
00482                         "fe80::69ff:fe50:5845", NULL );
00483         ipv6_route_ok ( &table_normal, "ff0e::1",
00484                         "2001:db8:3::1", NULL );
00485 
00486         /** Routing table with multiple addresses and routers */
00487         ipv6_route_ok ( &table_multi, "fe80::1",
00488                         "fe80::69ff:fe50:5845", NULL );
00489         ipv6_route_ok ( &table_multi, "2001:db8:3::17",
00490                         "2001:db8:3::1", NULL );
00491         ipv6_route_ok ( &table_multi, "2001:db8:5::92",
00492                         "2001:db8:5::1", NULL );
00493         ipv6_route_ok ( &table_multi, "2001:db8:42::17",
00494                         "2001:db8:42::1", NULL );
00495         ipv6_route_ok ( &table_multi, "2001:db8:5:1::17",
00496                         "2001:db8:3::1", "fe80::1" );
00497         ipv6_route_ok ( &table_multi, "fd44:9112:6442::1",
00498                         "fd44:9112:6442::69ff:fe50:5845", NULL );
00499         ipv6_route_ok ( &table_multi, "fd70:6ba9:50ae::1",
00500                         "fd70:6ba9:50ae::69ff:fe50:5845", NULL );
00501         ipv6_route_ok ( &table_multi, "fd40::3",
00502                         "fd44:9112:6442::69ff:fe50:5845", "fe80::1" );
00503         ipv6_route_ok ( &table_multi, "fd70::2",
00504                         "fd70:6ba9:50ae::69ff:fe50:5845", "fe80::3" );
00505         ipv6_route_ok ( &table_multi, "ff02::1",
00506                         "fe80::69ff:fe50:5845", NULL );
00507 
00508         /* Destroy test routing tables */
00509         ipv6_table_del ( &table_link_local );
00510         ipv6_table_del ( &table_normal );
00511         ipv6_table_del ( &table_multi );
00512 }
00513 
00514 /** IPv6 self-test */
00515 struct self_test ipv6_test __self_test = {
00516         .name = "ipv6",
00517         .exec = ipv6_test_exec,
00518 };