Deleted Added
full compact
yp_dnslookup.c (74462) yp_dnslookup.c (90297)
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 74462 2001-03-19 12:50:13Z alfred $";
35 "$FreeBSD: head/usr.sbin/ypserv/yp_dnslookup.c 90297 2002-02-06 13:30:31Z des $";
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

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

98}
99
100#define MAXPACKET 1024
101#define DEF_TTL 50
102
103#define BY_DNS_ID 1
104#define BY_RPC_XID 2
105
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

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

98}
99
100#define MAXPACKET 1024
101#define DEF_TTL 50
102
103#define BY_DNS_ID 1
104#define BY_RPC_XID 2
105
106extern struct hostent *__dns_getanswer __P((char *, int, char *, int));
106extern struct hostent *__dns_getanswer(char *, int, char *, int);
107
108static TAILQ_HEAD(dns_qhead, circleq_dnsentry) qhead;
109
110struct circleq_dnsentry {
111 SVCXPRT *xprt;
112 unsigned long xid;
113 struct sockaddr_in client_addr;
114 unsigned long ypvers;

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

197
198static struct circleq_dnsentry *yp_find_dnsqent(id, type)
199 unsigned long id;
200 int type;
201{
202 register struct circleq_dnsentry *q;
203
204 TAILQ_FOREACH(q, &qhead, links) {
107
108static TAILQ_HEAD(dns_qhead, circleq_dnsentry) qhead;
109
110struct circleq_dnsentry {
111 SVCXPRT *xprt;
112 unsigned long xid;
113 struct sockaddr_in client_addr;
114 unsigned long ypvers;

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

197
198static struct circleq_dnsentry *yp_find_dnsqent(id, type)
199 unsigned long id;
200 int type;
201{
202 register struct circleq_dnsentry *q;
203
204 TAILQ_FOREACH(q, &qhead, links) {
205 switch(type) {
205 switch (type) {
206 case BY_RPC_XID:
207 if (id == q->xid)
208 return(q);
209 break;
210 case BY_DNS_ID:
211 default:
212 if (id == q->id)
213 return(q);

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

227 struct sockaddr_in client_addr;
228 xdrproc_t xdrfunc;
229 char *result;
230
231 /*
232 * Set up correct reply struct and
233 * XDR filter depending on ypvers.
234 */
206 case BY_RPC_XID:
207 if (id == q->xid)
208 return(q);
209 break;
210 case BY_DNS_ID:
211 default:
212 if (id == q->id)
213 return(q);

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

227 struct sockaddr_in client_addr;
228 xdrproc_t xdrfunc;
229 char *result;
230
231 /*
232 * Set up correct reply struct and
233 * XDR filter depending on ypvers.
234 */
235 switch(q->ypvers) {
235 switch (q->ypvers) {
236 case YPVERS:
237 bzero((char *)&result_v2, sizeof(result_v2));
238
239 if (buf == NULL)
240 result_v2.stat = YP_NOKEY;
241 else {
242 result_v2.val.valdat_len = strlen(buf);
243 result_v2.val.valdat_val = buf;

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

314 * Decrement TTL on all queue entries, possibly nuking
315 * any that have been around too long without being serviced.
316 */
317void yp_prune_dnsq()
318{
319 register struct circleq_dnsentry *q, *n;
320
321 q = TAILQ_FIRST(&qhead);
236 case YPVERS:
237 bzero((char *)&result_v2, sizeof(result_v2));
238
239 if (buf == NULL)
240 result_v2.stat = YP_NOKEY;
241 else {
242 result_v2.val.valdat_len = strlen(buf);
243 result_v2.val.valdat_val = buf;

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

314 * Decrement TTL on all queue entries, possibly nuking
315 * any that have been around too long without being serviced.
316 */
317void yp_prune_dnsq()
318{
319 register struct circleq_dnsentry *q, *n;
320
321 q = TAILQ_FIRST(&qhead);
322 while(q != NULL) {
322 while (q != NULL) {
323 q->ttl--;
324 n = TAILQ_NEXT(q, links);
325 if (!q->ttl) {
326 TAILQ_REMOVE(&qhead, q, links);
327 free(q->name);
328 free(q);
329 pending--;
330 }

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

492 type = -1; len = sizeof(type);
493 if (getsockopt(rqstp->rq_xprt->xp_fd, SOL_SOCKET,
494 SO_TYPE, &type, &len) == -1) {
495 yp_error("getsockopt failed: %s", strerror(errno));
496 return(YP_YPERR);
497 }
498
499 /* Avoid transmitting dupe requests. */
323 q->ttl--;
324 n = TAILQ_NEXT(q, links);
325 if (!q->ttl) {
326 TAILQ_REMOVE(&qhead, q, links);
327 free(q->name);
328 free(q);
329 pending--;
330 }

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

492 type = -1; len = sizeof(type);
493 if (getsockopt(rqstp->rq_xprt->xp_fd, SOL_SOCKET,
494 SO_TYPE, &type, &len) == -1) {
495 yp_error("getsockopt failed: %s", strerror(errno));
496 return(YP_YPERR);
497 }
498
499 /* Avoid transmitting dupe requests. */
500 if (type == SOCK_DGRAM &&
500 if (type == SOCK_DGRAM &&
501 yp_find_dnsqent(svcudp_get_xid(rqstp->rq_xprt),BY_RPC_XID) != NULL)
502 return(YP_TRUE);
503
504 if ((q = yp_malloc_dnsent()) == NULL)
505 return(YP_YPERR);
506
507 if (sscanf(addr, "%d.%d.%d.%d", &a, &b, &c, &d) != 4)
508 return(YP_NOKEY);

--- 34 unchanged lines hidden ---
501 yp_find_dnsqent(svcudp_get_xid(rqstp->rq_xprt),BY_RPC_XID) != NULL)
502 return(YP_TRUE);
503
504 if ((q = yp_malloc_dnsent()) == NULL)
505 return(YP_YPERR);
506
507 if (sscanf(addr, "%d.%d.%d.%d", &a, &b, &c, &d) != 4)
508 return(YP_NOKEY);

--- 34 unchanged lines hidden ---