]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright 2000 Sam Varshavchik <mrsam@courier-mta.com> |
2 | .\" | |
3 | .\" Permission is granted to make and distribute verbatim copies of this | |
4 | .\" manual provided the copyright notice and this permission notice are | |
5 | .\" preserved on all copies. | |
6 | .\" | |
7 | .\" Permission is granted to copy and distribute modified versions of this | |
8 | .\" manual under the conditions for verbatim copying, provided that the | |
9 | .\" entire resulting derived work is distributed under the terms of a | |
10 | .\" permission notice identical to this one. | |
c13182ef | 11 | .\" |
fea681da MK |
12 | .\" Since the Linux kernel and libraries are constantly changing, this |
13 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
14 | .\" responsibility for errors or omissions, or for damages resulting from | |
15 | .\" the use of the information contained herein. The author(s) may not | |
16 | .\" have taken the same level of care in the production of this manual, | |
17 | .\" which is licensed free of charge, as they might when working | |
18 | .\" professionally. | |
c13182ef | 19 | .\" |
fea681da MK |
20 | .\" Formatted or processed versions of this manual, if unaccompanied by |
21 | .\" the source, must acknowledge the copyright and authors of this work. | |
22 | .\" | |
23 | .\" References: RFC 2553 | |
24 | .TH inet_pton 3 2000-12-18 "Linux Man Page" "Linux Programmer's Manual" | |
25 | .SH NAME | |
26 | inet_pton \- Create a network address structure | |
27 | .SH SYNOPSIS | |
28 | .nf | |
29 | .B #include <sys/types.h> | |
30 | .B #include <sys/socket.h> | |
31 | .B #include <arpa/inet.h> | |
32 | .sp | |
33 | .BI "int inet_pton(int " "af" ", const char *" "src" ", void *" "dst" ); | |
34 | .SH DESCRIPTION | |
35 | This function converts the character string | |
36 | .I src | |
37 | into a network address structure in the | |
38 | .I af | |
39 | address family, then | |
40 | copies | |
41 | the network address structure to | |
42 | .IR dst . | |
43 | .PP | |
44 | .BR inet_pton (3) | |
45 | extends the | |
46 | .BR inet_addr (3) | |
47 | function to support multiple address families, | |
48 | .BR inet_addr (3) | |
49 | is now considered to be deprecated in favor of | |
50 | .BR inet_pton (3). | |
51 | The following address families are currently supported: | |
52 | .TP | |
53 | .B AF_INET | |
54 | .I src | |
55 | points to a character string containing an IPv4 network address in | |
56 | the dotted-quad format, "\fIddd.ddd.ddd.ddd\fP". | |
57 | The address is converted | |
58 | to a | |
59 | .I struct in_addr | |
60 | and copied to | |
a5e0a0e4 | 61 | .IR dst , |
fea681da MK |
62 | which must be |
63 | .I sizeof(struct in_addr) | |
64 | bytes long. | |
65 | .TP | |
66 | .B AF_INET6 | |
67 | .I src | |
68 | points to a character string containing an IPv6 network address in | |
69 | any allowed IPv6 address format. | |
70 | The address is converted | |
71 | to a | |
72 | .I struct in6_addr | |
73 | and copied to | |
a5e0a0e4 | 74 | .IR dst , |
fea681da MK |
75 | which must be |
76 | .I sizeof(struct in6_addr) | |
77 | bytes long. | |
78 | .PP | |
79 | Certain legacy hex and octal formats of | |
80 | .B AF_INET | |
81 | addresses are not supported by | |
31e9a9ec | 82 | .BR inet_pton (), |
fea681da MK |
83 | which rejects them. |
84 | .SH "RETURN VALUE" | |
e511ffb6 | 85 | .BR inet_pton () |
fea681da MK |
86 | returns a negative value and sets |
87 | .I errno | |
88 | to | |
89 | .B EAFNOSUPPORT | |
90 | if | |
91 | .I af | |
92 | does not contain a valid address family. | |
93 | 0 is returned if | |
94 | .I src | |
95 | does not contain a character string representing a valid network | |
96 | address in the specified address family. | |
97 | A positive value is returned if the network address was successfully | |
98 | converted. | |
68e1685c MK |
99 | .SH "CONFORMING TO" |
100 | POSIX.1-2001. | |
fea681da MK |
101 | .SH "SEE ALSO" |
102 | .BR inet_ntop (3) | |
103 | .SH BUGS | |
104 | .B AF_INET6 | |
105 | does not recognize IPv4 addresses. | |
106 | An explicit IPv6-mapped IPv4 address must be supplied in | |
107 | .I src | |
108 | instead. |