]>
Commit | Line | Data |
---|---|---|
3f2457aa A |
1 | .\" Copyright (C) 1995, 1996, 1997, 1998, 1999, and 2000 WIDE Project. |
2 | .\" All rights reserved. | |
3 | .\" | |
4 | .\" Redistribution and use in source and binary forms, with or without | |
5 | .\" modification, are permitted provided that the following conditions | |
6 | .\" are met: | |
7 | .\" 1. Redistributions of source code must retain the above copyright | |
8 | .\" notice, this list of conditions and the following disclaimer. | |
9 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
10 | .\" notice, this list of conditions and the following disclaimer in the | |
11 | .\" documentation and/or other materials provided with the distribution. | |
12 | .\" 3. Neither the name of the project nor the names of its contributors | |
13 | .\" may be used to endorse or promote products derived from this software | |
14 | .\" without specific prior written permission. | |
15 | .\" | |
16 | .\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND | |
17 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
18 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE | |
20 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
21 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
22 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
23 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
24 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
25 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | .\" SUCH DAMAGE. | |
27 | .\" | |
28 | .\" Copyright (c) 1999 Brian Somers <brian@Awfulhak.org> | |
29 | .\" All rights reserved. | |
30 | .\" | |
31 | .\" Redistribution and use in source and binary forms, with or without | |
32 | .\" modification, are permitted provided that the following conditions | |
33 | .\" are met: | |
34 | .\" 1. Redistributions of source code must retain the above copyright | |
35 | .\" notice, this list of conditions and the following disclaimer. | |
36 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
37 | .\" notice, this list of conditions and the following disclaimer in the | |
38 | .\" documentation and/or other materials provided with the distribution. | |
39 | .\" | |
40 | .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | |
41 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
42 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
43 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
44 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
45 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
46 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
47 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
48 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
49 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
50 | .\" SUCH DAMAGE. | |
51 | .\" | |
52 | .\" $FreeBSD: src/lib/libutil/realhostname_sa.3,v 1.11 2005/02/13 22:25:14 ru Exp $ | |
53 | .\" | |
54 | .Dd January 11, 2000 | |
55 | .Os | |
56 | .Dt REALHOSTNAME_SA 3 | |
57 | .Sh NAME | |
58 | .Nm realhostname_sa | |
59 | .Nd "convert a" | |
60 | .Vt "struct sockaddr" | |
61 | to the real host name | |
62 | .Sh LIBRARY | |
63 | .Lb libutil | |
64 | .Sh SYNOPSIS | |
65 | .In sys/types.h | |
66 | .In netinet/in.h | |
67 | .In libutil.h | |
68 | .Ft int | |
69 | .Fn realhostname_sa "char *host" "size_t hsize" "struct sockaddr *addr" "int addrlen" | |
70 | .Sh DESCRIPTION | |
71 | The function | |
72 | .Fn realhostname_sa | |
73 | converts | |
74 | .Ar addr | |
75 | to the corresponding host name. | |
76 | This is done by resolving | |
77 | .Ar addr | |
78 | to a host name and then ensuring that the host name resolves | |
79 | back to | |
80 | .Ar addr . | |
81 | .Pp | |
82 | .Ar host | |
83 | must point to a buffer of at least | |
84 | .Ar hsize | |
85 | bytes, and will always be written to by this function. | |
86 | .Pp | |
87 | If the name resolution does not work both ways or if the host name is longer | |
88 | than | |
89 | .Ar hsize | |
90 | bytes, | |
91 | .Xr getnameinfo 3 | |
92 | with NI_NUMERICHOST specified, is used to convert | |
93 | .Ar addr | |
94 | to an ASCII form. | |
95 | .Pp | |
96 | If the string written to | |
97 | .Ar host | |
98 | is | |
99 | .Ar hsize | |
100 | bytes long, | |
101 | .Ar host | |
102 | will not be NUL terminated. | |
103 | .Sh RETURN VALUES | |
104 | The | |
105 | .Fn realhostname_sa | |
106 | function will return one of the following constants which are defined in | |
107 | .In libutil.h : | |
108 | .Pp | |
109 | .Bl -tag -width XXX -offset XXX | |
110 | .It Li HOSTNAME_FOUND | |
111 | A valid host name was found. | |
112 | .It Li HOSTNAME_INCORRECTNAME | |
113 | A host name was found, but it did not resolve back to the passed | |
114 | .Ar ip . | |
115 | .Ar host | |
116 | now contains the numeric value of | |
117 | .Ar ip . | |
118 | .It Li HOSTNAME_INVALIDADDR | |
119 | .Ar ip | |
120 | could not be resolved. | |
121 | .Ar host | |
122 | now contains the numeric value of | |
123 | .Ar ip . | |
124 | .It Li HOSTNAME_INVALIDNAME | |
125 | A host name was found, but it could not be resolved back to any ip number. | |
126 | .Ar host | |
127 | now contains the numeric value of | |
128 | .Ar ip . | |
129 | .El | |
130 | .Sh SEE ALSO | |
131 | .Xr getaddrinfo 3 , | |
132 | .Xr getnameinfo 3 , | |
133 | .Xr realhostname 3 |