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