res_findzonecut.c (158787) | res_findzonecut.c (170244) |
---|---|
1#if !defined(lint) && !defined(SABER) | 1#if !defined(lint) && !defined(SABER) |
2static const char rcsid[] = "$Id: res_findzonecut.c,v 1.2.2.3.4.4 2005/10/11 00:48:16 marka Exp $"; | 2static const char rcsid[] = "$Id: res_findzonecut.c,v 1.7.18.3 2005/10/11 00:25:11 marka Exp $"; |
3#endif /* not lint */ 4 5/* 6 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") 7 * Copyright (c) 1999 by Internet Software Consortium. 8 * 9 * Permission to use, copy, modify, and distribute this software for any 10 * purpose with or without fee is hereby granted, provided that the above --- 4 unchanged lines hidden (view full) --- 15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR 16 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 18 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 19 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 20 */ 21 22#include <sys/cdefs.h> | 3#endif /* not lint */ 4 5/* 6 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") 7 * Copyright (c) 1999 by Internet Software Consortium. 8 * 9 * Permission to use, copy, modify, and distribute this software for any 10 * purpose with or without fee is hereby granted, provided that the above --- 4 unchanged lines hidden (view full) --- 15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR 16 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 18 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 19 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 20 */ 21 22#include <sys/cdefs.h> |
23__FBSDID("$FreeBSD: head/lib/libc/resolv/res_findzonecut.c 158787 2006-05-21 11:19:36Z ume $"); | 23__FBSDID("$FreeBSD: head/lib/libc/resolv/res_findzonecut.c 170244 2007-06-03 17:20:27Z ume $"); |
24 25/* Import. */ 26 27#include "port_before.h" 28 29#include <sys/param.h> 30#include <sys/socket.h> 31#include <sys/time.h> --- 62 unchanged lines hidden (view full) --- 94#define DPRINTF(x) do {\ 95 int save_errno = errno; \ 96 if ((statp->options & RES_DEBUG) != 0U) res_dprintf x; \ 97 errno = save_errno; \ 98 } while (0) 99 100/* Public. */ 101 | 24 25/* Import. */ 26 27#include "port_before.h" 28 29#include <sys/param.h> 30#include <sys/socket.h> 31#include <sys/time.h> --- 62 unchanged lines hidden (view full) --- 94#define DPRINTF(x) do {\ 95 int save_errno = errno; \ 96 if ((statp->options & RES_DEBUG) != 0U) res_dprintf x; \ 97 errno = save_errno; \ 98 } while (0) 99 100/* Public. */ 101 |
102/* 103 * int 104 * res_findzonecut(res, dname, class, zname, zsize, addrs, naddrs) | 102/*% |
105 * find enclosing zone for a <dname,class>, and some server addresses | 103 * find enclosing zone for a <dname,class>, and some server addresses |
104 * |
|
106 * parameters: | 105 * parameters: |
107 * res - resolver context to work within (is modified) 108 * dname - domain name whose enclosing zone is desired 109 * class - class of dname (and its enclosing zone) 110 * zname - found zone name 111 * zsize - allocated size of zname 112 * addrs - found server addresses 113 * naddrs - max number of addrs | 106 *\li res - resolver context to work within (is modified) 107 *\li dname - domain name whose enclosing zone is desired 108 *\li class - class of dname (and its enclosing zone) 109 *\li zname - found zone name 110 *\li zsize - allocated size of zname 111 *\li addrs - found server addresses 112 *\li naddrs - max number of addrs 113 * |
114 * return values: | 114 * return values: |
115 * < 0 - an error occurred (check errno) 116 * = 0 - zname is now valid, but addrs[] wasn't changed 117 * > 0 - zname is now valid, and return value is number of addrs[] found | 115 *\li < 0 - an error occurred (check errno) 116 *\li = 0 - zname is now valid, but addrs[] wasn't changed 117 *\li > 0 - zname is now valid, and return value is number of addrs[] found 118 * |
118 * notes: | 119 * notes: |
119 * this function calls res_nsend() which means it depends on correctly | 120 *\li this function calls res_nsend() which means it depends on correctly |
120 * functioning recursive nameservers (usually defined in /etc/resolv.conf 121 * or its local equivilent). 122 * | 121 * functioning recursive nameservers (usually defined in /etc/resolv.conf 122 * or its local equivilent). 123 * |
123 * we start by asking for an SOA | 124 *\li we start by asking for an SOA<dname,class>. if we get one as an |
124 * answer, that just means <dname,class> is a zone top, which is fine. 125 * more than likely we'll be told to go pound sand, in the form of a 126 * negative answer. 127 * | 125 * answer, that just means <dname,class> is a zone top, which is fine. 126 * more than likely we'll be told to go pound sand, in the form of a 127 * negative answer. 128 * |
128 * note that we are not prepared to deal with referrals since that would | 129 *\li note that we are not prepared to deal with referrals since that would |
129 * only come from authority servers and our correctly functioning local 130 * recursive server would have followed the referral and got us something 131 * more definite. 132 * | 130 * only come from authority servers and our correctly functioning local 131 * recursive server would have followed the referral and got us something 132 * more definite. 133 * |
133 * if the authority section contains an SOA, this SOA should also be the | 134 *\li if the authority section contains an SOA, this SOA should also be the |
134 * closest enclosing zone, since any intermediary zone cuts would've been 135 * returned as referrals and dealt with by our correctly functioning local 136 * recursive name server. but an SOA in the authority section should NOT 137 * match our dname (since that would have been returned in the answer 138 * section). an authority section SOA has to be "above" our dname. 139 * | 135 * closest enclosing zone, since any intermediary zone cuts would've been 136 * returned as referrals and dealt with by our correctly functioning local 137 * recursive name server. but an SOA in the authority section should NOT 138 * match our dname (since that would have been returned in the answer 139 * section). an authority section SOA has to be "above" our dname. 140 * |
140 * however, since authority section SOA's were once optional, it's | 141 *\li however, since authority section SOA's were once optional, it's |
141 * possible that we'll have to go hunting for the enclosing SOA by 142 * ripping labels off the front of our dname -- this is known as "doing 143 * it the hard way." 144 * | 142 * possible that we'll have to go hunting for the enclosing SOA by 143 * ripping labels off the front of our dname -- this is known as "doing 144 * it the hard way." 145 * |
145 * ultimately we want some server addresses, which are ideally the ones | 146 *\li ultimately we want some server addresses, which are ideally the ones |
146 * pertaining to the SOA.MNAME, but only if there is a matching NS RR. 147 * so the second phase (after we find an SOA) is to go looking for the 148 * NS RRset for that SOA's zone. 149 * | 147 * pertaining to the SOA.MNAME, but only if there is a matching NS RR. 148 * so the second phase (after we find an SOA) is to go looking for the 149 * NS RRset for that SOA's zone. 150 * |
150 * no answer section processed by this code is allowed to contain CNAME | 151 *\li no answer section processed by this code is allowed to contain CNAME |
151 * or DNAME RR's. for the SOA query this means we strip a label and 152 * keep going. for the NS and A queries this means we just give up. 153 */ 154 155#ifndef _LIBC 156int 157res_findzonecut(res_state statp, const char *dname, ns_class class, int opts, 158 char *zname, size_t zsize, struct in_addr *addrs, int naddrs) --- 558 unchanged lines hidden (view full) --- 717 va_list ap; 718 719 va_start(ap, fmt); 720 fputs(";; res_findzonecut: ", stderr); 721 vfprintf(stderr, fmt, ap); 722 fputc('\n', stderr); 723 va_end(ap); 724} | 152 * or DNAME RR's. for the SOA query this means we strip a label and 153 * keep going. for the NS and A queries this means we just give up. 154 */ 155 156#ifndef _LIBC 157int 158res_findzonecut(res_state statp, const char *dname, ns_class class, int opts, 159 char *zname, size_t zsize, struct in_addr *addrs, int naddrs) --- 558 unchanged lines hidden (view full) --- 718 va_list ap; 719 720 va_start(ap, fmt); 721 fputs(";; res_findzonecut: ", stderr); 722 vfprintf(stderr, fmt, ap); 723 fputc('\n', stderr); 724 va_end(ap); 725} |
726 727/*! \file */ |
|