Deleted Added
full compact
res_query.c (170244) res_query.c (186090)
1/*
2 * Copyright (c) 1988, 1993
3 * The Regents of the University of California. 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

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

61 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
62 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
63 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
64 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
65 */
66
67#if defined(LIBC_SCCS) && !defined(lint)
68static const char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93";
1/*
2 * Copyright (c) 1988, 1993
3 * The Regents of the University of California. 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

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

61 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
62 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
63 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
64 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
65 */
66
67#if defined(LIBC_SCCS) && !defined(lint)
68static const char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93";
69static const char rcsid[] = "$Id: res_query.c,v 1.7.18.1 2005/04/27 05:01:11 sra Exp $";
69static const char rcsid[] = "$Id: res_query.c,v 1.7.18.2 2008/04/03 23:15:15 marka Exp $";
70#endif /* LIBC_SCCS and not lint */
71#include <sys/cdefs.h>
70#endif /* LIBC_SCCS and not lint */
71#include <sys/cdefs.h>
72__FBSDID("$FreeBSD: head/lib/libc/resolv/res_query.c 170244 2007-06-03 17:20:27Z ume $");
72__FBSDID("$FreeBSD: head/lib/libc/resolv/res_query.c 186090 2008-12-14 19:39:53Z ume $");
73
74#include "port_before.h"
75#include <sys/types.h>
76#include <sys/param.h>
77#include <netinet/in.h>
78#include <arpa/inet.h>
79#include <arpa/nameser.h>
80#include <ctype.h>

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

110res_nquery(res_state statp,
111 const char *name, /*%< domain name */
112 int class, int type, /*%< class and type of query */
113 u_char *answer, /*%< buffer to put answer */
114 int anslen) /*%< size of answer buffer */
115{
116 u_char buf[MAXPACKET];
117 HEADER *hp = (HEADER *) answer;
73
74#include "port_before.h"
75#include <sys/types.h>
76#include <sys/param.h>
77#include <netinet/in.h>
78#include <arpa/inet.h>
79#include <arpa/nameser.h>
80#include <ctype.h>

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

110res_nquery(res_state statp,
111 const char *name, /*%< domain name */
112 int class, int type, /*%< class and type of query */
113 u_char *answer, /*%< buffer to put answer */
114 int anslen) /*%< size of answer buffer */
115{
116 u_char buf[MAXPACKET];
117 HEADER *hp = (HEADER *) answer;
118 int n;
119 u_int oflags;
118 u_int oflags;
119 u_char *rdata;
120 int n;
120
121 oflags = statp->_flags;
122
123again:
124 hp->rcode = NOERROR; /*%< default */
125#ifdef DEBUG
126 if (statp->options & RES_DEBUG)
127 printf(";; res_query(%s, %d, %d)\n", name, class, type);
128#endif
129
130 n = res_nmkquery(statp, QUERY, name, class, type, NULL, 0, NULL,
131 buf, sizeof(buf));
132#ifdef RES_USE_EDNS0
133 if (n > 0 && (statp->_flags & RES_F_EDNS0ERR) == 0 &&
121
122 oflags = statp->_flags;
123
124again:
125 hp->rcode = NOERROR; /*%< default */
126#ifdef DEBUG
127 if (statp->options & RES_DEBUG)
128 printf(";; res_query(%s, %d, %d)\n", name, class, type);
129#endif
130
131 n = res_nmkquery(statp, QUERY, name, class, type, NULL, 0, NULL,
132 buf, sizeof(buf));
133#ifdef RES_USE_EDNS0
134 if (n > 0 && (statp->_flags & RES_F_EDNS0ERR) == 0 &&
134 (statp->options & (RES_USE_EDNS0|RES_USE_DNSSEC)) != 0U)
135 (statp->options & (RES_USE_EDNS0|RES_USE_DNSSEC|RES_NSID))) {
135 n = res_nopt(statp, n, buf, sizeof(buf), anslen);
136 n = res_nopt(statp, n, buf, sizeof(buf), anslen);
137 rdata = &buf[n];
138 if (n > 0 && (statp->options & RES_NSID) != 0U) {
139 n = res_nopt_rdata(statp, n, buf, sizeof(buf), rdata,
140 NS_OPT_NSID, 0, NULL);
141 }
142 }
136#endif
137 if (n <= 0) {
138#ifdef DEBUG
139 if (statp->options & RES_DEBUG)
140 printf(";; res_query: mkquery failed\n");
141#endif
142 RES_SET_H_ERRNO(statp, NO_RECOVERY);
143 return (n);
144 }
143#endif
144 if (n <= 0) {
145#ifdef DEBUG
146 if (statp->options & RES_DEBUG)
147 printf(";; res_query: mkquery failed\n");
148#endif
149 RES_SET_H_ERRNO(statp, NO_RECOVERY);
150 return (n);
151 }
152
145 n = res_nsend(statp, buf, n, answer, anslen);
146 if (n < 0) {
147#ifdef RES_USE_EDNS0
148 /* if the query choked with EDNS0, retry without EDNS0 */
149 if ((statp->options & (RES_USE_EDNS0|RES_USE_DNSSEC)) != 0U &&
150 ((oflags ^ statp->_flags) & RES_F_EDNS0ERR) != 0) {
151 statp->_flags |= RES_F_EDNS0ERR;
152 if (statp->options & RES_DEBUG)

--- 329 unchanged lines hidden ---
153 n = res_nsend(statp, buf, n, answer, anslen);
154 if (n < 0) {
155#ifdef RES_USE_EDNS0
156 /* if the query choked with EDNS0, retry without EDNS0 */
157 if ((statp->options & (RES_USE_EDNS0|RES_USE_DNSSEC)) != 0U &&
158 ((oflags ^ statp->_flags) & RES_F_EDNS0ERR) != 0) {
159 statp->_flags |= RES_F_EDNS0ERR;
160 if (statp->options & RES_DEBUG)

--- 329 unchanged lines hidden ---