17 #include <linux/module.h>
19 #include <linux/kernel.h>
22 #include <linux/net.h>
23 #include <linux/string.h>
24 #include <linux/types.h>
32 #include <asm/byteorder.h>
33 #include <asm/uaccess.h>
61 for (i = 0; i < 4; i++) {
65 while (*str !=
'\0' && *str !=
'.' && *str !=
'\n') {
79 #define IN6PTON_XDIGIT 0x00010000
80 #define IN6PTON_DIGIT 0x00020000
81 #define IN6PTON_COLON_MASK 0x00700000
82 #define IN6PTON_COLON_1 0x00100000
83 #define IN6PTON_COLON_2 0x00200000
84 #define IN6PTON_COLON_1_2 0x00400000
85 #define IN6PTON_DOT 0x00800000
86 #define IN6PTON_DELIM 0x10000000
87 #define IN6PTON_NULL 0x20000000
88 #define IN6PTON_UNKNOWN 0x40000000
90 static inline int xdigit2bin(
char c,
int delim)
94 if (c == delim || c ==
'\0')
124 int delim,
const char **
end)
140 c = xdigit2bin(srclen > 0 ? *s :
'\0', delim);
158 if ((w & 0xffff) > 255) {
168 memcpy(dst, dbuf,
sizeof(dbuf));
190 int delim,
const char **
end)
192 const char *
s, *tok =
NULL;
200 memset(dbuf, 0,
sizeof(dbuf));
210 c = xdigit2bin(srclen > 0 ? *s :
'\0', delim);
216 *d++ = (w >> 8) & 0xff;
233 if (dc - dbuf >=
sizeof(dbuf))
234 state |= IN6PTON_NULL;
253 ret =
in4_pton(tok ? tok : s, srclen + (
int)(s - tok), d, delim, &s);
261 w = (w << 4) | (0xff & c);
266 if (!dc && d + 2 < dbuf +
sizeof(dbuf)) {
270 if (d + 2 >= dbuf +
sizeof(dbuf)) {
274 if ((dc && d + 4 < dbuf +
sizeof(dbuf)) ||
275 d + 4 == dbuf +
sizeof(dbuf)) {
278 if (d >= dbuf +
sizeof(dbuf)) {
290 while(i >= dc - dbuf)
295 memcpy(dst, dbuf,
sizeof(dbuf));
308 __be32 diff[] = { ~from, to };
311 ~csum_unfold(*sum)));
315 }
else if (pseudohdr)
326 ~from[0], ~from[1], ~from[2], ~from[3],
327 to[0], to[1], to[2], to[3],
331 ~csum_unfold(*sum)));
335 }
else if (pseudohdr)
351 if (!
strchr(
"0123456789abcdefABCDEF", s[i * 3]))
353 if (!
strchr(
"0123456789abcdefABCDEF", s[i * 3 + 1]))
355 if (i != ETH_ALEN - 1 && s[i * 3 + 2] !=
':')