xref: /freebsd/lib/libutil/realhostname_sa.3 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
10cac72f4SYoshinobu Inoue.\" Copyright (C) 1995, 1996, 1997, 1998, 1999, and 2000 WIDE Project.
20cac72f4SYoshinobu Inoue.\" All rights reserved.
30cac72f4SYoshinobu Inoue.\"
40cac72f4SYoshinobu Inoue.\" Redistribution and use in source and binary forms, with or without
50cac72f4SYoshinobu Inoue.\" modification, are permitted provided that the following conditions
60cac72f4SYoshinobu Inoue.\" are met:
70cac72f4SYoshinobu Inoue.\" 1. Redistributions of source code must retain the above copyright
80cac72f4SYoshinobu Inoue.\"    notice, this list of conditions and the following disclaimer.
90cac72f4SYoshinobu Inoue.\" 2. Redistributions in binary form must reproduce the above copyright
100cac72f4SYoshinobu Inoue.\"    notice, this list of conditions and the following disclaimer in the
110cac72f4SYoshinobu Inoue.\"    documentation and/or other materials provided with the distribution.
120cac72f4SYoshinobu Inoue.\" 3. Neither the name of the project nor the names of its contributors
130cac72f4SYoshinobu Inoue.\"    may be used to endorse or promote products derived from this software
140cac72f4SYoshinobu Inoue.\"    without specific prior written permission.
150cac72f4SYoshinobu Inoue.\"
160cac72f4SYoshinobu Inoue.\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
170cac72f4SYoshinobu Inoue.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
180cac72f4SYoshinobu Inoue.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
190cac72f4SYoshinobu Inoue.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
200cac72f4SYoshinobu Inoue.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
210cac72f4SYoshinobu Inoue.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
220cac72f4SYoshinobu Inoue.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
230cac72f4SYoshinobu Inoue.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
240cac72f4SYoshinobu Inoue.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
250cac72f4SYoshinobu Inoue.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
260cac72f4SYoshinobu Inoue.\" SUCH DAMAGE.
270cac72f4SYoshinobu Inoue.\"
280cac72f4SYoshinobu Inoue.\" Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
290cac72f4SYoshinobu Inoue.\" All rights reserved.
300cac72f4SYoshinobu Inoue.\"
310cac72f4SYoshinobu Inoue.\" Redistribution and use in source and binary forms, with or without
320cac72f4SYoshinobu Inoue.\" modification, are permitted provided that the following conditions
330cac72f4SYoshinobu Inoue.\" are met:
340cac72f4SYoshinobu Inoue.\" 1. Redistributions of source code must retain the above copyright
350cac72f4SYoshinobu Inoue.\"    notice, this list of conditions and the following disclaimer.
360cac72f4SYoshinobu Inoue.\" 2. Redistributions in binary form must reproduce the above copyright
370cac72f4SYoshinobu Inoue.\"    notice, this list of conditions and the following disclaimer in the
380cac72f4SYoshinobu Inoue.\"    documentation and/or other materials provided with the distribution.
390cac72f4SYoshinobu Inoue.\"
400cac72f4SYoshinobu Inoue.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
410cac72f4SYoshinobu Inoue.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
420cac72f4SYoshinobu Inoue.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
430cac72f4SYoshinobu Inoue.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
440cac72f4SYoshinobu Inoue.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
450cac72f4SYoshinobu Inoue.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
460cac72f4SYoshinobu Inoue.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
470cac72f4SYoshinobu Inoue.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
480cac72f4SYoshinobu Inoue.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
490cac72f4SYoshinobu Inoue.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
500cac72f4SYoshinobu Inoue.\" SUCH DAMAGE.
510cac72f4SYoshinobu Inoue.\"
520cac72f4SYoshinobu Inoue.Dd January 11, 2000
530cac72f4SYoshinobu Inoue.Dt REALHOSTNAME_SA 3
54*aa12cea2SUlrich Spörlein.Os
550cac72f4SYoshinobu Inoue.Sh NAME
560cac72f4SYoshinobu Inoue.Nm realhostname_sa
57522ccf3fSRuslan Ermilov.Nd "convert a"
58522ccf3fSRuslan Ermilov.Vt "struct sockaddr"
59522ccf3fSRuslan Ermilovto the real host name
603dc329d1SAlexey Zelkin.Sh LIBRARY
613dc329d1SAlexey Zelkin.Lb libutil
620cac72f4SYoshinobu Inoue.Sh SYNOPSIS
6332eef9aeSRuslan Ermilov.In sys/types.h
6432eef9aeSRuslan Ermilov.In netinet/in.h
6532eef9aeSRuslan Ermilov.In libutil.h
660cac72f4SYoshinobu Inoue.Ft int
67cc8ffb11SBruce Evans.Fn realhostname_sa "char *host" "size_t hsize" "struct sockaddr *addr" "int addrlen"
680cac72f4SYoshinobu Inoue.Sh DESCRIPTION
690cac72f4SYoshinobu InoueThe function
700cac72f4SYoshinobu Inoue.Fn realhostname_sa
710cac72f4SYoshinobu Inoueconverts
720cac72f4SYoshinobu Inoue.Ar addr
731a0a9345SRuslan Ermilovto the corresponding host name.
741a0a9345SRuslan ErmilovThis is done by resolving
750cac72f4SYoshinobu Inoue.Ar addr
760cac72f4SYoshinobu Inoueto a host name and then ensuring that the host name resolves
770cac72f4SYoshinobu Inoueback to
780cac72f4SYoshinobu Inoue.Ar addr .
790cac72f4SYoshinobu Inoue.Pp
800cac72f4SYoshinobu Inoue.Ar host
810cac72f4SYoshinobu Inouemust point to a buffer of at least
820cac72f4SYoshinobu Inoue.Ar hsize
830cac72f4SYoshinobu Inouebytes, and will always be written to by this function.
840cac72f4SYoshinobu Inoue.Pp
850227791bSRuslan ErmilovIf the name resolution does not work both ways or if the host name is longer
860cac72f4SYoshinobu Inouethan
870cac72f4SYoshinobu Inoue.Ar hsize
880cac72f4SYoshinobu Inouebytes,
890cac72f4SYoshinobu Inoue.Xr getnameinfo 3
900cac72f4SYoshinobu Inouewith NI_NUMERICHOST specified, is used to convert
910cac72f4SYoshinobu Inoue.Ar addr
920cac72f4SYoshinobu Inoueto an ASCII form.
930cac72f4SYoshinobu Inoue.Pp
940cac72f4SYoshinobu InoueIf the string written to
950cac72f4SYoshinobu Inoue.Ar host
960cac72f4SYoshinobu Inoueis
970cac72f4SYoshinobu Inoue.Ar hsize
980cac72f4SYoshinobu Inouebytes long,
990cac72f4SYoshinobu Inoue.Ar host
1000cac72f4SYoshinobu Inouewill not be NUL terminated.
1010cac72f4SYoshinobu Inoue.Sh RETURN VALUES
1020552350eSPhilippe CharnierThe
1030cac72f4SYoshinobu Inoue.Fn realhostname_sa
1040552350eSPhilippe Charnierfunction will return one of the following constants which are defined in
105743d5d51SRuslan Ermilov.In libutil.h :
1060cac72f4SYoshinobu Inoue.Bl -tag -width XXX -offset XXX
1070cac72f4SYoshinobu Inoue.It Li HOSTNAME_FOUND
1080cac72f4SYoshinobu InoueA valid host name was found.
1090cac72f4SYoshinobu Inoue.It Li HOSTNAME_INCORRECTNAME
1100cac72f4SYoshinobu InoueA host name was found, but it did not resolve back to the passed
1110cac72f4SYoshinobu Inoue.Ar ip .
1120cac72f4SYoshinobu Inoue.Ar host
1130cac72f4SYoshinobu Inouenow contains the numeric value of
1140cac72f4SYoshinobu Inoue.Ar ip .
1150cac72f4SYoshinobu Inoue.It Li HOSTNAME_INVALIDADDR
1160cac72f4SYoshinobu Inoue.Ar ip
1170cac72f4SYoshinobu Inouecould not be resolved.
1180cac72f4SYoshinobu Inoue.Ar host
1190cac72f4SYoshinobu Inouenow contains the numeric value of
1200cac72f4SYoshinobu Inoue.Ar ip .
1210cac72f4SYoshinobu Inoue.It Li HOSTNAME_INVALIDNAME
1220cac72f4SYoshinobu InoueA host name was found, but it could not be resolved back to any ip number.
1230cac72f4SYoshinobu Inoue.Ar host
1240cac72f4SYoshinobu Inouenow contains the numeric value of
1250cac72f4SYoshinobu Inoue.Ar ip .
1260cac72f4SYoshinobu Inoue.El
1270cac72f4SYoshinobu Inoue.Sh SEE ALSO
1280cac72f4SYoshinobu Inoue.Xr getaddrinfo 3 ,
1290cac72f4SYoshinobu Inoue.Xr getnameinfo 3 ,
1300cac72f4SYoshinobu Inoue.Xr realhostname 3
131