lwres_getnameinfo.html revision 135446
1<!-- 2 - Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") 3 - Copyright (C) 2001 Internet Software Consortium. 4 - 5 - Permission to use, copy, modify, and distribute this software for any 6 - purpose with or without fee is hereby granted, provided that the above 7 - copyright notice and this permission notice appear in all copies. 8 - 9 - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 10 - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 11 - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 12 - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 13 - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 14 - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 15 - PERFORMANCE OF THIS SOFTWARE. 16--> 17 18<!-- $Id: lwres_getnameinfo.html,v 1.5.2.1.4.2 2004/08/22 23:39:04 marka Exp $ --> 19 20<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 21<HTML 22><HEAD 23><TITLE 24>lwres_getnameinfo</TITLE 25><META 26NAME="GENERATOR" 27CONTENT="Modular DocBook HTML Stylesheet Version 1.7"></HEAD 28><BODY 29CLASS="REFENTRY" 30BGCOLOR="#FFFFFF" 31TEXT="#000000" 32LINK="#0000FF" 33VLINK="#840084" 34ALINK="#0000FF" 35><H1 36><A 37NAME="AEN1" 38></A 39>lwres_getnameinfo</H1 40><DIV 41CLASS="REFNAMEDIV" 42><A 43NAME="AEN8" 44></A 45><H2 46>Name</H2 47>lwres_getnameinfo -- lightweight resolver socket address structure to hostname and service name</DIV 48><DIV 49CLASS="REFSYNOPSISDIV" 50><A 51NAME="AEN11" 52></A 53><H2 54>Synopsis</H2 55><DIV 56CLASS="FUNCSYNOPSIS" 57><P 58></P 59><A 60NAME="AEN12" 61></A 62><PRE 63CLASS="FUNCSYNOPSISINFO" 64>#include <lwres/netdb.h></PRE 65><P 66><CODE 67><CODE 68CLASS="FUNCDEF" 69>int 70lwres_getnameinfo</CODE 71>(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags);</CODE 72></P 73><P 74></P 75></DIV 76></DIV 77><DIV 78CLASS="REFSECT1" 79><A 80NAME="AEN24" 81></A 82><H2 83>DESCRIPTION</H2 84><P 85> This function is equivalent to the <SPAN 86CLASS="CITEREFENTRY" 87><SPAN 88CLASS="REFENTRYTITLE" 89>getnameinfo</SPAN 90>(3)</SPAN 91> function defined in RFC2133. 92<CODE 93CLASS="FUNCTION" 94>lwres_getnameinfo()</CODE 95> returns the hostname for the 96<SPAN 97CLASS="TYPE" 98>struct sockaddr</SPAN 99> <VAR 100CLASS="PARAMETER" 101>sa</VAR 102> which is 103<VAR 104CLASS="PARAMETER" 105>salen</VAR 106> bytes long. The hostname is of length 107<VAR 108CLASS="PARAMETER" 109>hostlen</VAR 110> and is returned via 111<VAR 112CLASS="PARAMETER" 113>*host.</VAR 114> The maximum length of the hostname is 1151025 bytes: <CODE 116CLASS="CONSTANT" 117>NI_MAXHOST</CODE 118>.</P 119><P 120> The name of the service associated with the port number in 121<VAR 122CLASS="PARAMETER" 123>sa</VAR 124> is returned in <VAR 125CLASS="PARAMETER" 126>*serv.</VAR 127> 128It is <VAR 129CLASS="PARAMETER" 130>servlen</VAR 131> bytes long. The maximum length 132of the service name is <CODE 133CLASS="CONSTANT" 134>NI_MAXSERV</CODE 135> - 32 bytes.</P 136><P 137> The <VAR 138CLASS="PARAMETER" 139>flags</VAR 140> argument sets the following 141bits: 142<P 143></P 144><DIV 145CLASS="VARIABLELIST" 146><DL 147><DT 148><CODE 149CLASS="CONSTANT" 150>NI_NOFQDN</CODE 151></DT 152><DD 153><P 154>A fully qualified domain name is not required for local hosts. 155The local part of the fully qualified domain name is returned instead.</P 156></DD 157><DT 158><CODE 159CLASS="CONSTANT" 160>NI_NUMERICHOST</CODE 161></DT 162><DD 163><P 164>Return the address in numeric form, as if calling inet_ntop(), 165instead of a host name.</P 166></DD 167><DT 168><CODE 169CLASS="CONSTANT" 170>NI_NAMEREQD</CODE 171></DT 172><DD 173><P 174>A name is required. If the hostname cannot be found in the DNS and 175this flag is set, a non-zero error code is returned. 176If the hostname is not found and the flag is not set, the 177address is returned in numeric form.</P 178></DD 179><DT 180><CODE 181CLASS="CONSTANT" 182>NI_NUMERICSERV</CODE 183></DT 184><DD 185><P 186>The service name is returned as a digit string representing the port number.</P 187></DD 188><DT 189><CODE 190CLASS="CONSTANT" 191>NI_DGRAM</CODE 192></DT 193><DD 194><P 195>Specifies that the service being looked up is a datagram 196service, and causes getservbyport() to be called with a second 197argument of "udp" instead of its default of "tcp". This is required 198for the few ports (512-514) that have different services for UDP and 199TCP.</P 200></DD 201></DL 202></DIV 203></P 204></DIV 205><DIV 206CLASS="REFSECT1" 207><A 208NAME="AEN70" 209></A 210><H2 211>RETURN VALUES</H2 212><P 213><CODE 214CLASS="FUNCTION" 215>lwres_getnameinfo()</CODE 216> 217returns 0 on success or a non-zero error code if an error occurs.</P 218></DIV 219><DIV 220CLASS="REFSECT1" 221><A 222NAME="AEN74" 223></A 224><H2 225>SEE ALSO</H2 226><P 227><SPAN 228CLASS="CITEREFENTRY" 229><SPAN 230CLASS="REFENTRYTITLE" 231>RFC2133</SPAN 232></SPAN 233>, 234<SPAN 235CLASS="CITEREFENTRY" 236><SPAN 237CLASS="REFENTRYTITLE" 238>getservbyport</SPAN 239>(3)</SPAN 240>, 241<SPAN 242CLASS="CITEREFENTRY" 243><SPAN 244CLASS="REFENTRYTITLE" 245>lwres</SPAN 246>(3)</SPAN 247>, 248<SPAN 249CLASS="CITEREFENTRY" 250><SPAN 251CLASS="REFENTRYTITLE" 252>lwres_getnameinfo</SPAN 253>(3)</SPAN 254>, 255<SPAN 256CLASS="CITEREFENTRY" 257><SPAN 258CLASS="REFENTRYTITLE" 259>lwres_getnamebyaddr</SPAN 260>(3)</SPAN 261>. 262<SPAN 263CLASS="CITEREFENTRY" 264><SPAN 265CLASS="REFENTRYTITLE" 266>lwres_net_ntop</SPAN 267>(3)</SPAN 268>.</P 269></DIV 270><DIV 271CLASS="REFSECT1" 272><A 273NAME="AEN94" 274></A 275><H2 276>BUGS</H2 277><P 278>RFC2133 fails to define what the nonzero return values of 279<SPAN 280CLASS="CITEREFENTRY" 281><SPAN 282CLASS="REFENTRYTITLE" 283>getnameinfo</SPAN 284>(3)</SPAN 285> 286are.</P 287></DIV 288></BODY 289></HTML 290> 291