|
@@ -60,6 +60,37 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
60
|
60
|
ok ( strcmp ( actual, expected ) == 0 ); \
|
61
|
61
|
} while ( 0 )
|
62
|
62
|
|
|
63
|
+/**
|
|
64
|
+ * Report an inet6_aton() test result
|
|
65
|
+ *
|
|
66
|
+ * @v text Textual representation
|
|
67
|
+ * @v addr Expected IPv6 address
|
|
68
|
+ */
|
|
69
|
+#define inet6_aton_ok( text, addr ) do { \
|
|
70
|
+ static const char string[] = text; \
|
|
71
|
+ static const struct in6_addr expected = { \
|
|
72
|
+ .s6_addr = addr, \
|
|
73
|
+ }; \
|
|
74
|
+ struct in6_addr actual; \
|
|
75
|
+ \
|
|
76
|
+ ok ( inet6_aton ( string, &actual ) == 0 ); \
|
|
77
|
+ DBG ( "inet6_aton ( \"%s\" ) = %s\n", string, \
|
|
78
|
+ inet6_ntoa ( &actual ) ); \
|
|
79
|
+ ok ( memcmp ( &actual, &expected, sizeof ( actual ) ) == 0 ); \
|
|
80
|
+ } while ( 0 )
|
|
81
|
+
|
|
82
|
+/**
|
|
83
|
+ * Report an inet6_aton() failure test result
|
|
84
|
+ *
|
|
85
|
+ * @v text Textual representation
|
|
86
|
+ */
|
|
87
|
+#define inet6_aton_fail_ok( text ) do { \
|
|
88
|
+ static const char string[] = text; \
|
|
89
|
+ struct in6_addr dummy; \
|
|
90
|
+ \
|
|
91
|
+ ok ( inet6_aton ( string, &dummy ) != 0 ); \
|
|
92
|
+ } while ( 0 )
|
|
93
|
+
|
63
|
94
|
/**
|
64
|
95
|
* Perform IPv6 self-tests
|
65
|
96
|
*
|
|
@@ -106,6 +137,41 @@ static void ipv6_test_exec ( void ) {
|
106
|
137
|
inet6_ntoa_ok ( IPV6 ( 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
107
|
138
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff ),
|
108
|
139
|
"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" );
|
|
140
|
+
|
|
141
|
+ /* inet6_aton() tests */
|
|
142
|
+ inet6_aton_ok ( "2001:ba8:0:1d4::6950:5845",
|
|
143
|
+ IPV6 ( 0x20, 0x01, 0x0b, 0xa8, 0x00, 0x00, 0x01, 0xd4,
|
|
144
|
+ 0x00, 0x00, 0x00, 0x00, 0x69, 0x50, 0x58, 0x45));
|
|
145
|
+ /* No zeros */
|
|
146
|
+ inet6_aton_ok ( "2001:db8:1:1:1:1:1:1",
|
|
147
|
+ IPV6 ( 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x01, 0x00, 0x01,
|
|
148
|
+ 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01));
|
|
149
|
+ /* All intervening zeros */
|
|
150
|
+ inet6_aton_ok ( "fe80::1",
|
|
151
|
+ IPV6 ( 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
152
|
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01));
|
|
153
|
+ /* Trailing run of zeros */
|
|
154
|
+ inet6_aton_ok ( "fe80::",
|
|
155
|
+ IPV6 ( 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
156
|
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00));
|
|
157
|
+ /* Leading run of zeros */
|
|
158
|
+ inet6_aton_ok ( "::1",
|
|
159
|
+ IPV6 ( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
160
|
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01));
|
|
161
|
+ /* All zeros */
|
|
162
|
+ inet6_aton_ok ( "::",
|
|
163
|
+ IPV6 ( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
164
|
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00));
|
|
165
|
+
|
|
166
|
+ /* inet6_aton() failure tests */
|
|
167
|
+ inet6_aton_fail_ok ( "20012:ba8:0:1d4::6950:5845" );
|
|
168
|
+ inet6_aton_fail_ok ( "200z:ba8:0:1d4::6950:5845" );
|
|
169
|
+ inet6_aton_fail_ok ( "2001.ba8:0:1d4::6950:5845" );
|
|
170
|
+ inet6_aton_fail_ok ( "2001:db8:1:1:1:1:1" );
|
|
171
|
+ inet6_aton_fail_ok ( "2001:db8:1:1:1:1:1:1:2" );
|
|
172
|
+ inet6_aton_fail_ok ( "2001:db8::1::2" );
|
|
173
|
+ inet6_aton_fail_ok ( "2001:ba8:0:1d4:::6950:5845" );
|
|
174
|
+ inet6_aton_fail_ok ( ":::" );
|
109
|
175
|
}
|
110
|
176
|
|
111
|
177
|
/** IPv6 self-test */
|