1scan_ip6if(3) Library Functions Manual scan_ip6if(3)
2
3
4
6 scan_ip6 - parse an IPv6 number and interface in ASCII representation
7
9 #include <ip6.h>
10
11 int scan_ip6if(const char *src,char ip[16],uint32* scope_id);
12
14 scan_ip6if parses an IPv6 number in RFC1884 ASCII representation from
15 src and writes the result into ip. If the IPv6 number is followed by
16 the percent sign, scan_ip6if takes the word following that, tries to
17 parse it as network interface and writes the result to scope_id.
18
19 It returns the number of bytes read from src or 0 if the parsing
20 failed.
21
22 scan_ip6if accepts upper and lower case hex letters, it understands
23 "::" compression and partial IPv4 addresses as in
24 "::FFFF:129.144.52.38".
25
26 To allow transparent usage of IPv4 in IPv6 applications, scan_ip6if
27 also understands IPv4 addresses in dotted-decimal notation and will
28 return an IPv4-mapped IPv6 address (i.e. "127.0.0.1" will be parsed as
29 "::FFFF:127.0.0.1".
30
31 Unlike many other IP parsing routines, scan_ip6if does not recognize
32 octal (like 0177.0.0.1) or hexadecimal numbers (like 0x7f000001) in the
33 IPv4 part.
34
36 #include <str.h>
37 #include <ip6.h>
38
39 char buf[]="::1%lo";
40 char ip[16];
41 uint32 scope_id;
42 if (scan_ip6if(buf,ip,&scope_id) != str_len(buf))
43 parse_error();
44
45
47 fmt_ip6(3), scan_ip4(3), fmt_ip6if(3)
48
49
50
51 scan_ip6if(3)