]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/inet_pton.3
Improve st_blocks description.
[thirdparty/man-pages.git] / man3 / inet_pton.3
CommitLineData
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.
11.\"
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.
19.\"
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
26inet_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
35This function converts the character string
36.I src
37into a network address structure in the
38.I af
39address family, then
40copies
41the network address structure to
42.IR dst .
43.PP
44.BR inet_pton (3)
45extends the
46.BR inet_addr (3)
47function to support multiple address families,
48.BR inet_addr (3)
49is now considered to be deprecated in favor of
50.BR inet_pton (3).
51The following address families are currently supported:
52.TP
53.B AF_INET
54.I src
55points to a character string containing an IPv4 network address in
56the dotted-quad format, "\fIddd.ddd.ddd.ddd\fP".
57The address is converted
58to a
59.I struct in_addr
60and copied to
61.IR dst,
62which must be
63.I sizeof(struct in_addr)
64bytes long.
65.TP
66.B AF_INET6
67.I src
68points to a character string containing an IPv6 network address in
69any allowed IPv6 address format.
70The address is converted
71to a
72.I struct in6_addr
73and copied to
74.IR dst,
75which must be
76.I sizeof(struct in6_addr)
77bytes long.
78.PP
79Certain legacy hex and octal formats of
80.B AF_INET
81addresses are not supported by
82.IR inet_pton ,
83which rejects them.
84.SH "RETURN VALUE"
85.B inet_pton
86returns a negative value and sets
87.I errno
88to
89.B EAFNOSUPPORT
90if
91.I af
92does not contain a valid address family.
930 is returned if
94.I src
95does not contain a character string representing a valid network
96address in the specified address family.
97A positive value is returned if the network address was successfully
98converted.
99.SH "SEE ALSO"
100.BR inet_ntop (3)
101.SH BUGS
102.B AF_INET6
103does not recognize IPv4 addresses.
104An explicit IPv6-mapped IPv4 address must be supplied in
105.I src
106instead.