Deleted Added
full compact
yp_dnslookup.c (90298) yp_dnslookup.c (103717)
1/*
2 * Copyright (c) 1995, 1996
3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 18 unchanged lines hidden (view full) ---

27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33#ifndef lint
34static const char rcsid[] =
1/*
2 * Copyright (c) 1995, 1996
3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 18 unchanged lines hidden (view full) ---

27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33#ifndef lint
34static const char rcsid[] =
35 "$FreeBSD: head/usr.sbin/ypserv/yp_dnslookup.c 90298 2002-02-06 15:26:07Z des $";
35 "$FreeBSD: head/usr.sbin/ypserv/yp_dnslookup.c 103717 2002-09-20 20:09:27Z markm $";
36#endif /* not lint */
37
38/*
39 * Do standard and reverse DNS lookups using the resolver library.
40 * Take care of all the dirty work here so the main program only has to
41 * pass us a pointer to an array of characters.
42 *
43 * We have to use direct resolver calls here otherwise the YP server

--- 127 unchanged lines hidden (view full) ---

171 int rval;
172 unsigned long id;
173
174 bzero(buf, sizeof(buf));
175
176 n = res_mkquery(QUERY,name,C_IN,type,NULL,0,NULL,buf,sizeof(buf));
177
178 if (n <= 0) {
36#endif /* not lint */
37
38/*
39 * Do standard and reverse DNS lookups using the resolver library.
40 * Take care of all the dirty work here so the main program only has to
41 * pass us a pointer to an array of characters.
42 *
43 * We have to use direct resolver calls here otherwise the YP server

--- 127 unchanged lines hidden (view full) ---

171 int rval;
172 unsigned long id;
173
174 bzero(buf, sizeof(buf));
175
176 n = res_mkquery(QUERY,name,C_IN,type,NULL,0,NULL,buf,sizeof(buf));
177
178 if (n <= 0) {
179 yp_error("res_mkquery failed");
179 yp_error("res_mkquery failed for %s type %d", name, type);
180 return(0);
181 }
182
183 hptr = (HEADER *)&buf;
184 id = ntohs(hptr->id);
185
186 for (ns = 0; ns < _res.nscount; ns++) {
187 rval = sendto(resfd, buf, n, 0,

--- 193 unchanged lines hidden (view full) ---

381 return;
382 }
383
384 if (debug)
385 yp_error("got dns reply from %s", inet_ntoa(sin.sin_addr));
386
387 hent = __dns_getanswer(buf, rval, q->name, q->type);
388
180 return(0);
181 }
182
183 hptr = (HEADER *)&buf;
184 id = ntohs(hptr->id);
185
186 for (ns = 0; ns < _res.nscount; ns++) {
187 rval = sendto(resfd, buf, n, 0,

--- 193 unchanged lines hidden (view full) ---

381 return;
382 }
383
384 if (debug)
385 yp_error("got dns reply from %s", inet_ntoa(sin.sin_addr));
386
387 hent = __dns_getanswer(buf, rval, q->name, q->type);
388
389 /*
390 * If the lookup failed, try appending one of the domains
391 * from resolv.conf. If we have no domains to test, the
392 * query has failed.
393 */
394 if (hent == NULL) {
395 if ((h_errno == TRY_AGAIN || h_errno == NO_RECOVERY)
396 && q->domain && *q->domain) {
397 snprintf(retrybuf, sizeof(retrybuf), "%s.%s",
398 q->name, *q->domain);
399 if (debug)
400 yp_error("retrying with: %s", retrybuf);
401 q->id = yp_send_dns_query(retrybuf, q->type);
402 q->ttl = DEF_TTL;
403 q->domain++;
404 return;
405 }
406 } else {
389 if (hent != NULL) {
407 if (q->type == T_PTR) {
408 hent->h_addr = (char *)&q->addr.s_addr;
409 hent->h_length = sizeof(struct in_addr);
410 }
411 }
412
413 /* Got an answer ready for a client -- send it off. */
414 yp_send_dns_reply(q, parse(hent));

--- 127 unchanged lines hidden ---
390 if (q->type == T_PTR) {
391 hent->h_addr = (char *)&q->addr.s_addr;
392 hent->h_length = sizeof(struct in_addr);
393 }
394 }
395
396 /* Got an answer ready for a client -- send it off. */
397 yp_send_dns_reply(q, parse(hent));

--- 127 unchanged lines hidden ---