lwres revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
448987059f6c769c5a4986c178356b90e823bb36Brendan MmillerCopyright (C) 2000, 2001, 2004, 2016 Internet Systems Consortium, Inc. ("ISC")
448987059f6c769c5a4986c178356b90e823bb36Brendan MmillerThis Source Code Form is subject to the terms of the Mozilla Public
448987059f6c769c5a4986c178356b90e823bb36Brendan MmillerLicense, v. 2.0. If a copy of the MPL was not distributed with this
448987059f6c769c5a4986c178356b90e823bb36Brendan Mmillerfile, You can obtain one at http://mozilla.org/MPL/2.0/.
448987059f6c769c5a4986c178356b90e823bb36Brendan Mmiller$Id: lwres,v 1.6 2004/03/05 05:04:46 marka Exp $
448987059f6c769c5a4986c178356b90e823bb36Brendan MmillerThis document describes the bind v9 lightweight resolver.
448987059f6c769c5a4986c178356b90e823bb36Brendan MmillerCurrently, applications make queries directly to a DNS server. With
448987059f6c769c5a4986c178356b90e823bb36Brendan Mmillerv4 records (A records) the client can typically do the proper DNS work
448987059f6c769c5a4986c178356b90e823bb36Brendan Mmillerto get a hostname into an address or vice versa.
448987059f6c769c5a4986c178356b90e823bb36Brendan MmillerWith ipv6 and A6 recods, however, this becomes harder. Add to that
448987059f6c769c5a4986c178356b90e823bb36Brendan MmillerDNAME and CNAME and DNSSEC, and a client is quickly overwhelmed.
448987059f6c769c5a4986c178356b90e823bb36Brendan MmillerTo keep clients from having to make direct DNS queries for address
448987059f6c769c5a4986c178356b90e823bb36Brendan Mmillerinformation, an API was developed to allow clients to ask high-level
448987059f6c769c5a4986c178356b90e823bb36Brendan Mmillerinformation, such as "what addresses does foo.nominum.com have?" and
448987059f6c769c5a4986c178356b90e823bb36Brendan Mmiller"what name does 1.2.3.4 have?"
a3f1c4bb696d904f842314da867a84288809db8bBrendan MmillerGENERAL DESIGN
1233cf61f92cf026493da1465aa5ef6e84f443adBrendan MmillerThe lwres library converts structures into wire-format packets for
a3f1c4bb696d904f842314da867a84288809db8bBrendan Mmillertransmission, and unmarshalls them on receive.
448987059f6c769c5a4986c178356b90e823bb36Brendan MmillerMarshalling and unmarshalling:
448987059f6c769c5a4986c178356b90e823bb36Brendan MmillerEach structure will have two functions defined, one to take a
448987059f6c769c5a4986c178356b90e823bb36Brendan Mmillerwire-format packet and convert it into a structure, and another to
448987059f6c769c5a4986c178356b90e823bb36Brendan Mmillertake a structure and convert it into a wire-format packet. There
448987059f6c769c5a4986c178356b90e823bb36Brendan Mmilleris a structure cleanup function that will take the unmarshalled
448987059f6c769c5a4986c178356b90e823bb36Brendan Mmillerstructure and free any dynamically allocated elements.
448987059f6c769c5a4986c178356b90e823bb36Brendan MmillerAll integer values are in network byte order.
448987059f6c769c5a4986c178356b90e823bb36Brendan MmillerAll addresses are in network byte order. That is, they are directly
448987059f6c769c5a4986c178356b90e823bb36Brendan Mmillerusable and do not need to be byte swapped, at least for ipv4 and ipv6.
448987059f6c769c5a4986c178356b90e823bb36Brendan MmillerAll character strings are prefixed with a length, and are NUL
aaa0f5ddd147facc5c535e28845db1d482c6c6d5Brendan Mmillerterminated C strings. This is a concession for structure handling on
aaa0f5ddd147facc5c535e28845db1d482c6c6d5Brendan Mmillerthe receive side, and allows a mapping structure to point to data
448987059f6c769c5a4986c178356b90e823bb36Brendan Mmillercontained in the actual receive buffer, eliminating copying.
448987059f6c769c5a4986c178356b90e823bb36Brendan MmillerNOOP (aka ping) packet format (request, response):
448987059f6c769c5a4986c178356b90e823bb36Brendan Mmiller lwres_lwpacket_t header;
aaa0f5ddd147facc5c535e28845db1d482c6c6d5Brendan Mmiller isc_uint16_t datalength;
aaa0f5ddd147facc5c535e28845db1d482c6c6d5Brendan Mmiller < datalength bytes >
aaa0f5ddd147facc5c535e28845db1d482c6c6d5Brendan MmillerThe server simply returns the entire data region in the reply. This
aaa0f5ddd147facc5c535e28845db1d482c6c6d5Brendan Mmillerallows the client to determine if the server is operational.
aaa0f5ddd147facc5c535e28845db1d482c6c6d5Brendan MmillerGETADDRSBYNAME (response):
aaa0f5ddd147facc5c535e28845db1d482c6c6d5Brendan Mmiller lwres_lwpacket_t header;
aaa0f5ddd147facc5c535e28845db1d482c6c6d5Brendan Mmiller isc_uint16_t naliases;
a3f1c4bb696d904f842314da867a84288809db8bBrendan Mmiller isc_uint16_t naddrs;
a3f1c4bb696d904f842314da867a84288809db8bBrendan Mmiller isc_uint16_t real_name_len;
a3f1c4bb696d904f842314da867a84288809db8bBrendan Mmiller < real_name_len bytes of name >
448987059f6c769c5a4986c178356b90e823bb36Brendan Mmiller isc_uint8_t \0
448987059f6c769c5a4986c178356b90e823bb36Brendan Mmiller < naliases of
448987059f6c769c5a4986c178356b90e823bb36Brendan Mmiller isc_uint16_t len;
448987059f6c769c5a4986c178356b90e823bb36Brendan Mmiller < len bytes of name >
448987059f6c769c5a4986c178356b90e823bb36Brendan Mmiller isc_uint8_t \0
aaa0f5ddd147facc5c535e28845db1d482c6c6d5Brendan Mmiller isc_uint32_t family;
aaa0f5ddd147facc5c535e28845db1d482c6c6d5Brendan Mmiller isc_uint16_t len;
aaa0f5ddd147facc5c535e28845db1d482c6c6d5Brendan Mmiller < len bytes of address >
aaa0f5ddd147facc5c535e28845db1d482c6c6d5Brendan MmillerGETNAMEBYADDR (response):
448987059f6c769c5a4986c178356b90e823bb36Brendan Mmiller lwres_lwpacket_t header;
There are two structures used in a typical request/response. The
When a client context is created, /etc/resolv.conf is read to find
in the lib/lwres/ directory. These are considered to be examples
not provide NIS support or /etc/hosts support.
The daemon (in bin/lwresd/) implements name->address and address->name
read /etc/resolv.conf and use any "nameserver" lines as forwarders.