1bc7413d0SPeter Wemm.\" Copyright (c) 1985, 1991, 1993 2bc7413d0SPeter Wemm.\" The Regents of the University of California. All rights reserved. 3fdf4c7afSPeter Wemm.\" 4bc7413d0SPeter Wemm.\" Redistribution and use in source and binary forms, with or without 5bc7413d0SPeter Wemm.\" modification, are permitted provided that the following conditions 6bc7413d0SPeter Wemm.\" are met: 7bc7413d0SPeter Wemm.\" 1. Redistributions of source code must retain the above copyright 8bc7413d0SPeter Wemm.\" notice, this list of conditions and the following disclaimer. 9bc7413d0SPeter Wemm.\" 2. Redistributions in binary form must reproduce the above copyright 10bc7413d0SPeter Wemm.\" notice, this list of conditions and the following disclaimer in the 11bc7413d0SPeter Wemm.\" documentation and/or other materials provided with the distribution. 12fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors 13bc7413d0SPeter Wemm.\" may be used to endorse or promote products derived from this software 14bc7413d0SPeter Wemm.\" without specific prior written permission. 15fdf4c7afSPeter Wemm.\" 16bc7413d0SPeter Wemm.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17bc7413d0SPeter Wemm.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18bc7413d0SPeter Wemm.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19bc7413d0SPeter Wemm.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20bc7413d0SPeter Wemm.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21bc7413d0SPeter Wemm.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22bc7413d0SPeter Wemm.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23bc7413d0SPeter Wemm.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24bc7413d0SPeter Wemm.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25bc7413d0SPeter Wemm.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26bc7413d0SPeter Wemm.\" SUCH DAMAGE. 27fdf4c7afSPeter Wemm.\" 28*58cf91d3SJan Beich.Dd January 8, 2024 29bc7413d0SPeter Wemm.Dt RESOLVER 3 30a307d598SRuslan Ermilov.Os 31bc7413d0SPeter Wemm.Sh NAME 32bc7413d0SPeter Wemm.Nm res_query , 33bc7413d0SPeter Wemm.Nm res_search , 34bc7413d0SPeter Wemm.Nm res_mkquery , 35bc7413d0SPeter Wemm.Nm res_send , 36bc7413d0SPeter Wemm.Nm res_init , 37bc7413d0SPeter Wemm.Nm dn_comp , 38b5b2871fSAnton Berezin.Nm dn_expand , 39b5b2871fSAnton Berezin.Nm dn_skipname , 40b5b2871fSAnton Berezin.Nm ns_get16 , 41b5b2871fSAnton Berezin.Nm ns_get32 , 42b5b2871fSAnton Berezin.Nm ns_put16 , 43b5b2871fSAnton Berezin.Nm ns_put32 44bc7413d0SPeter Wemm.Nd resolver routines 4525bb73e0SAlexey Zelkin.Sh LIBRARY 4625bb73e0SAlexey Zelkin.Lb libc 47bc7413d0SPeter Wemm.Sh SYNOPSIS 4832eef9aeSRuslan Ermilov.In resolv.h 491eda21cbSBruce Evans.Ft int 50bc7413d0SPeter Wemm.Fo res_query 51c293d821SPeter Wemm.Fa "const char *dname" 52bc7413d0SPeter Wemm.Fa "int class" 53bc7413d0SPeter Wemm.Fa "int type" 54bc7413d0SPeter Wemm.Fa "u_char *answer" 55bc7413d0SPeter Wemm.Fa "int anslen" 56bc7413d0SPeter Wemm.Fc 571eda21cbSBruce Evans.Ft int 58bc7413d0SPeter Wemm.Fo res_search 59c293d821SPeter Wemm.Fa "const char *dname" 60bc7413d0SPeter Wemm.Fa "int class" 61bc7413d0SPeter Wemm.Fa "int type" 62bc7413d0SPeter Wemm.Fa "u_char *answer" 63bc7413d0SPeter Wemm.Fa "int anslen" 64bc7413d0SPeter Wemm.Fc 651eda21cbSBruce Evans.Ft int 66bc7413d0SPeter Wemm.Fo res_mkquery 67bc7413d0SPeter Wemm.Fa "int op" 68c293d821SPeter Wemm.Fa "const char *dname" 69bc7413d0SPeter Wemm.Fa "int class" 70bc7413d0SPeter Wemm.Fa "int type" 711eda21cbSBruce Evans.Fa "const u_char *data" 72bc7413d0SPeter Wemm.Fa "int datalen" 731eda21cbSBruce Evans.Fa "const u_char *newrr_in" 741eda21cbSBruce Evans.Fa "u_char *buf" 75bc7413d0SPeter Wemm.Fa "int buflen" 76bc7413d0SPeter Wemm.Fc 771eda21cbSBruce Evans.Ft int 78bc7413d0SPeter Wemm.Fo res_send 7990afb6a5SBruce Evans.Fa "const u_char *msg" 80bc7413d0SPeter Wemm.Fa "int msglen" 8190afb6a5SBruce Evans.Fa "u_char *answer" 82bc7413d0SPeter Wemm.Fa "int anslen" 83bc7413d0SPeter Wemm.Fc 841eda21cbSBruce Evans.Ft int 8533ef612eSStefan Farfeleder.Fn res_init void 86b5b2871fSAnton Berezin.Ft int 87bc7413d0SPeter Wemm.Fo dn_comp 88c293d821SPeter Wemm.Fa "const char *exp_dn" 8990afb6a5SBruce Evans.Fa "u_char *comp_dn" 90bc7413d0SPeter Wemm.Fa "int length" 9190afb6a5SBruce Evans.Fa "u_char **dnptrs" 9290afb6a5SBruce Evans.Fa "u_char **lastdnptr" 93bc7413d0SPeter Wemm.Fc 941eda21cbSBruce Evans.Ft int 95bc7413d0SPeter Wemm.Fo dn_expand 96c293d821SPeter Wemm.Fa "const u_char *msg" 97c293d821SPeter Wemm.Fa "const u_char *eomorig" 98c293d821SPeter Wemm.Fa "const u_char *comp_dn" 991eda21cbSBruce Evans.Fa "char *exp_dn" 100bc7413d0SPeter Wemm.Fa "int length" 101bc7413d0SPeter Wemm.Fc 102b5b2871fSAnton Berezin.Ft int 103b5b2871fSAnton Berezin.Fn dn_skipname "const u_char *comp_dn" "const u_char *eom" 104b5b2871fSAnton Berezin.Ft u_int 105b5b2871fSAnton Berezin.Fn ns_get16 "const u_char *src" 106b5b2871fSAnton Berezin.Ft u_long 107b5b2871fSAnton Berezin.Fn ns_get32 "const u_char *src" 108b5b2871fSAnton Berezin.Ft void 109b5b2871fSAnton Berezin.Fn ns_put16 "u_int src" "u_char *dst" 110b5b2871fSAnton Berezin.Ft void 111b5b2871fSAnton Berezin.Fn ns_put32 "u_long src" "u_char *dst" 112bc7413d0SPeter Wemm.Sh DESCRIPTION 113fdf4c7afSPeter WemmThese routines are used for making, sending and interpreting 114fdf4c7afSPeter Wemmquery and reply messages with Internet domain name servers. 115bc7413d0SPeter Wemm.Pp 116fdf4c7afSPeter WemmGlobal configuration and state information that is used by the 117fdf4c7afSPeter Wemmresolver routines is kept in the structure 1185c564baeSRuslan Ermilov.Va _res . 119fdf4c7afSPeter WemmMost of the values have reasonable defaults and can be ignored. 120fdf4c7afSPeter WemmOptions 121fdf4c7afSPeter Wemmstored in 1225c564baeSRuslan Ermilov.Va _res.options 123fdf4c7afSPeter Wemmare defined in 124743d5d51SRuslan Ermilov.In resolv.h 125fdf4c7afSPeter Wemmand are as follows. 126fdf4c7afSPeter WemmOptions are stored as a simple bit mask containing the bitwise ``or'' 127fdf4c7afSPeter Wemmof the options enabled. 128ce6282dbSHajimu UMEMOTO.Bl -tag -width RES_USE_INET6 129bc7413d0SPeter Wemm.It Dv RES_INIT 130fdf4c7afSPeter WemmTrue if the initial name server address and default domain name are 131fdf4c7afSPeter Wemminitialized (i.e., 132bc7413d0SPeter Wemm.Fn res_init 133fdf4c7afSPeter Wemmhas been called). 134bc7413d0SPeter Wemm.It Dv RES_DEBUG 135fdf4c7afSPeter WemmPrint debugging messages. 136bc7413d0SPeter Wemm.It Dv RES_AAONLY 137fdf4c7afSPeter WemmAccept authoritative answers only. 138fdf4c7afSPeter WemmWith this option, 139bc7413d0SPeter Wemm.Fn res_send 140fdf4c7afSPeter Wemmshould continue until it finds an authoritative answer or finds an error. 141fdf4c7afSPeter WemmCurrently this is not implemented. 142bc7413d0SPeter Wemm.It Dv RES_USEVC 143bc7413d0SPeter WemmUse 144bc7413d0SPeter Wemm.Tn TCP 145bc7413d0SPeter Wemmconnections for queries instead of 146bc7413d0SPeter Wemm.Tn UDP 147bc7413d0SPeter Wemmdatagrams. 148bc7413d0SPeter Wemm.It Dv RES_STAYOPEN 149bc7413d0SPeter WemmUsed with 150bc7413d0SPeter Wemm.Dv RES_USEVC 151bc7413d0SPeter Wemmto keep the 152bc7413d0SPeter Wemm.Tn TCP 153bc7413d0SPeter Wemmconnection open between 154fdf4c7afSPeter Wemmqueries. 155fdf4c7afSPeter WemmThis is useful only in programs that regularly do many queries. 156bc7413d0SPeter Wemm.Tn UDP 157bc7413d0SPeter Wemmshould be the normal mode used. 158bc7413d0SPeter Wemm.It Dv RES_IGNTC 1590227791bSRuslan ErmilovUnused currently (ignore truncation errors, i.e., do not retry with 160bc7413d0SPeter Wemm.Tn TCP ) . 161bc7413d0SPeter Wemm.It Dv RES_RECURSE 162fdf4c7afSPeter WemmSet the recursion-desired bit in queries. 163fdf4c7afSPeter WemmThis is the default. 164bc7413d0SPeter Wemm.Pf ( Fn res_send 165fdf4c7afSPeter Wemmdoes not do iterative queries and expects the name server 166fdf4c7afSPeter Wemmto handle recursion.) 167bc7413d0SPeter Wemm.It Dv RES_DEFNAMES 168fdf4c7afSPeter WemmIf set, 169bc7413d0SPeter Wemm.Fn res_search 170fdf4c7afSPeter Wemmwill append the default domain name to single-component names 171fdf4c7afSPeter Wemm(those that do not contain a dot). 172fdf4c7afSPeter WemmThis option is enabled by default. 173bc7413d0SPeter Wemm.It Dv RES_DNSRCH 174fdf4c7afSPeter WemmIf this option is set, 175bc7413d0SPeter Wemm.Fn res_search 176fdf4c7afSPeter Wemmwill search for host names in the current domain and in parent domains; see 177bc7413d0SPeter Wemm.Xr hostname 7 . 178fdf4c7afSPeter WemmThis is used by the standard host lookup routine 179bc7413d0SPeter Wemm.Xr gethostbyname 3 . 180fdf4c7afSPeter WemmThis option is enabled by default. 181c293d821SPeter Wemm.It Dv RES_NOALIASES 182c293d821SPeter WemmThis option turns off the user level aliasing feature controlled by the 183c293d821SPeter Wemm.Dq Ev HOSTALIASES 1841a0a9345SRuslan Ermilovenvironment variable. 1851a0a9345SRuslan ErmilovNetwork daemons should set this option. 186ce6282dbSHajimu UMEMOTO.It Dv RES_USE_INET6 187ce6282dbSHajimu UMEMOTOEnables support for IPv6-only applications. 188ce6282dbSHajimu UMEMOTOThis causes IPv4 addresses to be returned as an IPv4 mapped address. 189c155ff5cSRuslan ErmilovFor example, 190c155ff5cSRuslan Ermilov.Li 10.1.1.1 191c155ff5cSRuslan Ermilovwill be returned as 192c155ff5cSRuslan Ermilov.Li ::ffff:10.1.1.1 . 193ce6282dbSHajimu UMEMOTOThe option is meaningful with certain kernel configuration only. 194ce6282dbSHajimu UMEMOTO.It Dv RES_USE_EDNS0 195ce6282dbSHajimu UMEMOTOEnables support for OPT pseudo-RR for EDNS0 extension. 196ce6282dbSHajimu UMEMOTOWith the option, resolver code will attach OPT pseudo-RR into DNS queries, 197ce6282dbSHajimu UMEMOTOto inform of our receive buffer size. 198ce6282dbSHajimu UMEMOTOThe option will allow DNS servers to take advantage of non-default receive 199ce6282dbSHajimu UMEMOTObuffer size, and to send larger replies. 200ce6282dbSHajimu UMEMOTODNS query packets with EDNS0 extension is not compatible with 201ce6282dbSHajimu UMEMOTOnon-EDNS0 DNS servers. 202bc7413d0SPeter Wemm.El 203bc7413d0SPeter Wemm.Pp 204fdf4c7afSPeter WemmThe 205bc7413d0SPeter Wemm.Fn res_init 206fdf4c7afSPeter Wemmroutine 207fdf4c7afSPeter Wemmreads the configuration file (if any; see 208bc7413d0SPeter Wemm.Xr resolver 5 ) 209fdf4c7afSPeter Wemmto get the default domain name, 210fdf4c7afSPeter Wemmsearch list and 211fdf4c7afSPeter Wemmthe Internet address of the local name server(s). 212fdf4c7afSPeter WemmIf no server is configured, the host running 213fdf4c7afSPeter Wemmthe resolver is tried. 214fdf4c7afSPeter WemmThe current domain name is defined by the hostname 215fdf4c7afSPeter Wemmif not specified in the configuration file; 216bc7413d0SPeter Wemmit can be overridden by the environment variable 217bc7413d0SPeter Wemm.Ev LOCALDOMAIN . 218c293d821SPeter WemmThis environment variable may contain several blank-separated 219c293d821SPeter Wemmtokens if you wish to override the 220c293d821SPeter Wemm.Em "search list" 2211a0a9345SRuslan Ermilovon a per-process basis. 2221a0a9345SRuslan ErmilovThis is similar to the 2235c564baeSRuslan Ermilov.Ic search 224c293d821SPeter Wemmcommand in the configuration file. 22594ba280cSRuslan ErmilovAnother environment variable 226c293d821SPeter Wemm.Dq Ev RES_OPTIONS 227c293d821SPeter Wemmcan be set to 228c293d821SPeter Wemmoverride certain internal resolver options which are otherwise 229c293d821SPeter Wemmset by changing fields in the 2305c564baeSRuslan Ermilov.Va _res 231c293d821SPeter Wemmstructure or are inherited from the configuration file's 2325c564baeSRuslan Ermilov.Ic options 2331a0a9345SRuslan Ermilovcommand. 2341a0a9345SRuslan ErmilovThe syntax of the 235c293d821SPeter Wemm.Dq Ev RES_OPTIONS 236c293d821SPeter Wemmenvironment variable is explained in 237c293d821SPeter Wemm.Xr resolver 5 . 238fdf4c7afSPeter WemmInitialization normally occurs on the first call 239bc7413d0SPeter Wemmto one of the following routines. 240bc7413d0SPeter Wemm.Pp 241fdf4c7afSPeter WemmThe 242bc7413d0SPeter Wemm.Fn res_query 243fdf4c7afSPeter Wemmfunction provides an interface to the server query mechanism. 244fdf4c7afSPeter WemmIt constructs a query, sends it to the local server, 245fdf4c7afSPeter Wemmawaits a response, and makes preliminary checks on the reply. 246fdf4c7afSPeter WemmThe query requests information of the specified 247bc7413d0SPeter Wemm.Fa type 248fdf4c7afSPeter Wemmand 249bc7413d0SPeter Wemm.Fa class 250fdf4c7afSPeter Wemmfor the specified fully-qualified domain name 251bc7413d0SPeter Wemm.Fa dname . 252fdf4c7afSPeter WemmThe reply message is left in the 253bc7413d0SPeter Wemm.Fa answer 254fdf4c7afSPeter Wemmbuffer with length 255bc7413d0SPeter Wemm.Fa anslen 256fdf4c7afSPeter Wemmsupplied by the caller. 257bc7413d0SPeter Wemm.Pp 258fdf4c7afSPeter WemmThe 259bc7413d0SPeter Wemm.Fn res_search 260fdf4c7afSPeter Wemmroutine makes a query and awaits a response like 261bc7413d0SPeter Wemm.Fn res_query , 262fdf4c7afSPeter Wemmbut in addition, it implements the default and search rules 263bc7413d0SPeter Wemmcontrolled by the 264bc7413d0SPeter Wemm.Dv RES_DEFNAMES 265bc7413d0SPeter Wemmand 266bc7413d0SPeter Wemm.Dv RES_DNSRCH 267bc7413d0SPeter Wemmoptions. 268fdf4c7afSPeter WemmIt returns the first successful reply. 269bc7413d0SPeter Wemm.Pp 270fdf4c7afSPeter WemmThe remaining routines are lower-level routines used by 271bc7413d0SPeter Wemm.Fn res_query . 272fdf4c7afSPeter WemmThe 273bc7413d0SPeter Wemm.Fn res_mkquery 274fdf4c7afSPeter Wemmfunction 275fdf4c7afSPeter Wemmconstructs a standard query message and places it in 276bc7413d0SPeter Wemm.Fa buf . 277fdf4c7afSPeter WemmIt returns the size of the query, or \-1 if the query is 278fdf4c7afSPeter Wemmlarger than 279bc7413d0SPeter Wemm.Fa buflen . 280fdf4c7afSPeter WemmThe query type 281bc7413d0SPeter Wemm.Fa op 282bc7413d0SPeter Wemmis usually 283bc7413d0SPeter Wemm.Dv QUERY , 284bc7413d0SPeter Wemmbut can be any of the query types defined in 285fe08efe6SRuslan Ermilov.In arpa/nameser.h . 286fdf4c7afSPeter WemmThe domain name for the query is given by 287bc7413d0SPeter Wemm.Fa dname . 2882efeeba5SRuslan ErmilovThe 2892efeeba5SRuslan Ermilov.Fa newrr_in 2902efeeba5SRuslan Ermilovargument 291fdf4c7afSPeter Wemmis currently unused but is intended for making update messages. 292bc7413d0SPeter Wemm.Pp 293fdf4c7afSPeter WemmThe 294bc7413d0SPeter Wemm.Fn res_send 295fdf4c7afSPeter Wemmroutine 296fdf4c7afSPeter Wemmsends a pre-formatted query and returns an answer. 297fdf4c7afSPeter WemmIt will call 298bc7413d0SPeter Wemm.Fn res_init 299bc7413d0SPeter Wemmif 300bc7413d0SPeter Wemm.Dv RES_INIT 301bc7413d0SPeter Wemmis not set, send the query to the local name server, and 302fdf4c7afSPeter Wemmhandle timeouts and retries. 303fdf4c7afSPeter WemmThe length of the reply message is returned, or 304fdf4c7afSPeter Wemm\-1 if there were errors. 305bc7413d0SPeter Wemm.Pp 306fdf4c7afSPeter WemmThe 307bc7413d0SPeter Wemm.Fn dn_comp 308fdf4c7afSPeter Wemmfunction 309fdf4c7afSPeter Wemmcompresses the domain name 310bc7413d0SPeter Wemm.Fa exp_dn 311fdf4c7afSPeter Wemmand stores it in 312bc7413d0SPeter Wemm.Fa comp_dn . 313fdf4c7afSPeter WemmThe size of the compressed name is returned or \-1 if there were errors. 314fdf4c7afSPeter WemmThe size of the array pointed to by 315bc7413d0SPeter Wemm.Fa comp_dn 316fdf4c7afSPeter Wemmis given by 317bc7413d0SPeter Wemm.Fa length . 318fdf4c7afSPeter WemmThe compression uses 319fdf4c7afSPeter Wemman array of pointers 320bc7413d0SPeter Wemm.Fa dnptrs 321fdf4c7afSPeter Wemmto previously-compressed names in the current message. 322fdf4c7afSPeter WemmThe first pointer points to 32343d1df33SAlexander Langerthe beginning of the message and the list ends with 324bc7413d0SPeter Wemm.Dv NULL . 325fdf4c7afSPeter WemmThe limit to the array is specified by 326bc7413d0SPeter Wemm.Fa lastdnptr . 327fdf4c7afSPeter WemmA side effect of 328bc7413d0SPeter Wemm.Fn dn_comp 329fdf4c7afSPeter Wemmis to update the list of pointers for 330fdf4c7afSPeter Wemmlabels inserted into the message 331fdf4c7afSPeter Wemmas the name is compressed. 332fdf4c7afSPeter WemmIf 3335c564baeSRuslan Ermilov.Fa dnptr 334bc7413d0SPeter Wemmis 335d0353b83SRuslan Ermilov.Dv NULL , 336d0353b83SRuslan Ermilovnames are not compressed. 337fdf4c7afSPeter WemmIf 338bc7413d0SPeter Wemm.Fa lastdnptr 339bc7413d0SPeter Wemmis 340bc7413d0SPeter Wemm.Dv NULL , 341bc7413d0SPeter Wemmthe list of labels is not updated. 342bc7413d0SPeter Wemm.Pp 343fdf4c7afSPeter WemmThe 344bc7413d0SPeter Wemm.Fn dn_expand 345fdf4c7afSPeter Wemmentry 346fdf4c7afSPeter Wemmexpands the compressed domain name 347bc7413d0SPeter Wemm.Fa comp_dn 348fdf4c7afSPeter Wemmto a full domain name 349fdf4c7afSPeter WemmThe compressed name is contained in a query or reply message; 350bc7413d0SPeter Wemm.Fa msg 351fdf4c7afSPeter Wemmis a pointer to the beginning of the message. 352fdf4c7afSPeter WemmThe uncompressed name is placed in the buffer indicated by 353bc7413d0SPeter Wemm.Fa exp_dn 354fdf4c7afSPeter Wemmwhich is of size 355bc7413d0SPeter Wemm.Fa length . 356fdf4c7afSPeter WemmThe size of compressed name is returned or \-1 if there was an error. 357b5b2871fSAnton Berezin.Pp 358b5b2871fSAnton BerezinThe 359b5b2871fSAnton Berezin.Fn dn_skipname 360b5b2871fSAnton Berezinfunction skips over a compressed domain name, which starts at a location 361b5b2871fSAnton Berezinpointed to by 362b5b2871fSAnton Berezin.Fa comp_dn . 363b5b2871fSAnton BerezinThe compressed name is contained in a query or reply message; 364b5b2871fSAnton Berezin.Fa eom 365b5b2871fSAnton Berezinis a pointer to the end of the message. 366b5b2871fSAnton BerezinThe size of compressed name is returned or \-1 if there was 367b5b2871fSAnton Berezinan error. 368b5b2871fSAnton Berezin.Pp 369b5b2871fSAnton BerezinThe 370b5b2871fSAnton Berezin.Fn ns_get16 371b5b2871fSAnton Berezinfunction gets a 16-bit quantity from a buffer pointed to by 372b5b2871fSAnton Berezin.Fa src . 373b5b2871fSAnton Berezin.Pp 374b5b2871fSAnton BerezinThe 375b5b2871fSAnton Berezin.Fn ns_get32 376b5b2871fSAnton Berezinfunction gets a 32-bit quantity from a buffer pointed to by 377b5b2871fSAnton Berezin.Fa src . 378b5b2871fSAnton Berezin.Pp 379b5b2871fSAnton BerezinThe 380b5b2871fSAnton Berezin.Fn ns_put16 381b5b2871fSAnton Berezinfunction puts a 16-bit quantity 382b5b2871fSAnton Berezin.Fa src 383b5b2871fSAnton Berezinto a buffer pointed to by 384b5b2871fSAnton Berezin.Fa dst . 385b5b2871fSAnton Berezin.Pp 386b5b2871fSAnton BerezinThe 387b5b2871fSAnton Berezin.Fn ns_put32 388b5b2871fSAnton Berezinfunction puts a 32-bit quantity 389b5b2871fSAnton Berezin.Fa src 390b5b2871fSAnton Berezinto a buffer pointed to by 391b5b2871fSAnton Berezin.Fa dst . 39233dee819SBrian Feldman.Sh IMPLEMENTATION NOTES 39333dee819SBrian FeldmanThis implementation of the resolver is thread-safe, but it will not 39433dee819SBrian Feldmanfunction properly if the programmer attempts to declare his or her own 39533dee819SBrian Feldman.Va _res 39633dee819SBrian Feldmanstructure in an attempt to replace the per-thread version referred to 39733dee819SBrian Feldmanby that macro. 3985512745eSXin LI.Pp 3995512745eSXin LIThe following compile-time option can be specified to change the default 4005512745eSXin LIbehavior of resolver routines when necessary. 4015512745eSXin LI.Bl -tag -width RES_ENFORCE_RFC1034 4025512745eSXin LI.It Dv RES_ENFORCE_RFC1034 4035512745eSXin LIIf this symbol is defined during compile-time, 4045512745eSXin LI.Fn res_search 4055512745eSXin LIwill enforce RFC 1034 check, namely, disallow using of underscore character 4065512745eSXin LIwithin host names. 4075512745eSXin LIThis is used by the standard host lookup routines like 4085512745eSXin LI.Xr gethostbyname 3 . 4095512745eSXin LIFor compatibility reasons this option is not enabled by default. 4105512745eSXin LI.El 41124a0682cSRuslan Ermilov.Sh RETURN VALUES 41224a0682cSRuslan ErmilovThe 41324a0682cSRuslan Ermilov.Fn res_init 41424a0682cSRuslan Ermilovfunction will return 0 on success, or \-1 in a threaded program if 41524a0682cSRuslan Ermilovper-thread storage could not be allocated. 4166b0a380fSSam Lawrance.Pp 4176b0a380fSSam LawranceThe 4186b0a380fSSam Lawrance.Fn res_mkquery , 4196b0a380fSSam Lawrance.Fn res_search , 4206b0a380fSSam Lawranceand 4216b0a380fSSam Lawrance.Fn res_query 4226b0a380fSSam Lawrancefunctions return the size of the response on success, or \-1 if an 4236b0a380fSSam Lawranceerror occurs. 4246b0a380fSSam LawranceThe integer 4256b0a380fSSam Lawrance.Vt h_errno 4266b0a380fSSam Lawrancemay be checked to determine the reason for error. 4276b0a380fSSam LawranceSee 4286b0a380fSSam Lawrance.Xr gethostbyname 3 4296b0a380fSSam Lawrancefor more information. 430bc7413d0SPeter Wemm.Sh FILES 43142635956SRuslan Ermilov.Bl -tag -width /etc/resolv.conf 43242635956SRuslan Ermilov.It Pa /etc/resolv.conf 43342635956SRuslan ErmilovThe configuration file, 434bc7413d0SPeter Wemmsee 435bc7413d0SPeter Wemm.Xr resolver 5 . 436bc7413d0SPeter Wemm.El 437bc7413d0SPeter Wemm.Sh SEE ALSO 438bc7413d0SPeter Wemm.Xr gethostbyname 3 , 439bc7413d0SPeter Wemm.Xr resolver 5 , 440942e234dSFernando Apesteguía.Xr hostname 7 441bc7413d0SPeter Wemm.Pp 442bc7413d0SPeter Wemm.%T RFC1032 , 443bc7413d0SPeter Wemm.%T RFC1033 , 444bc7413d0SPeter Wemm.%T RFC1034 , 445bc7413d0SPeter Wemm.%T RFC1035 , 446bc7413d0SPeter Wemm.%T RFC974 447bc7413d0SPeter Wemm.Sh HISTORY 448fdf4c7afSPeter WemmThe 449bc7413d0SPeter Wemm.Nm 450bc7413d0SPeter Wemmfunction appeared in 451bc7413d0SPeter Wemm.Bx 4.3 . 452