res_send.c (7257d1b4) res_send.c (bd0e95e6)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

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

15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

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

15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright 2015 Gary Mills
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28/* All Rights Reserved */
29
30/*
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
33 * All Rights Reserved
34 *
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
37 * contributors.
38 */
39
24 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
26 */
27
28/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
29/* All Rights Reserved */
30
31/*
32 * University Copyright- Copyright (c) 1982, 1986, 1988
33 * The Regents of the University of California
34 * All Rights Reserved
35 *
36 * University Acknowledgment- Portions of this document are derived from
37 * software developed by the University of California, Berkeley, and its
38 * contributors.
39 */
40
40#pragma ident "%Z%%M% %I% %E% SMI"
41
42/*
43 * Send query to name server and wait for reply.
44 */
45
46#include <sys/param.h>
47#include <sys/time.h>
48#include <sys/socket.h>
49#include <sys/uio.h>
50#include <sys/stat.h>
51#include <netinet/in.h>
52#include <stdio.h>
41/*
42 * Send query to name server and wait for reply.
43 */
44
45#include <sys/param.h>
46#include <sys/time.h>
47#include <sys/socket.h>
48#include <sys/uio.h>
49#include <sys/stat.h>
50#include <netinet/in.h>
51#include <stdio.h>
52#include <string.h>
53#include <unistd.h>
53#include <errno.h>
54#include <arpa/nameser.h>
54#include <errno.h>
55#include <arpa/nameser.h>
56#include <arpa/inet.h>
55#include <resolv.h>
57#include <resolv.h>
58#include "crossl.h"
56
59
60/*
61 * Undocumented external function in libsocket
62 */
63extern int
64_socket(int, int, int);
57
58static int s = -1; /* socket used for communications */
65
66static int s = -1; /* socket used for communications */
67#if BSD >= 43
59static struct sockaddr no_addr;
68static struct sockaddr no_addr;
69#endif /* BSD */
60
61
62#ifndef FD_SET
63#define NFDBITS 32
64#define FD_SETSIZE 32
65#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
66#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
67#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
68#ifdef SYSV
70
71
72#ifndef FD_SET
73#define NFDBITS 32
74#define FD_SETSIZE 32
75#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
76#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
77#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
78#ifdef SYSV
69#define FD_ZERO(p) memset((void *)(p), 0, sizeof (*(p)))
79#define FD_ZERO(p) (void) memset((void *)(p), 0, sizeof (*(p)))
70#else
71#define FD_ZERO(p) bzero((char *)(p), sizeof (*(p)))
72#endif
73#endif
74
75/*
76 * 1247019: Kludge to time out quickly if there is no /etc/resolv.conf
77 * and a TCP connection to the local DNS server fails.

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

124res_send(buf, buflen, answer, anslen)
125 char *buf;
126 int buflen;
127 char *answer;
128 int anslen;
129{
130 register int n;
131 int try, v_circuit, resplen, ns;
80#else
81#define FD_ZERO(p) bzero((char *)(p), sizeof (*(p)))
82#endif
83#endif
84
85/*
86 * 1247019: Kludge to time out quickly if there is no /etc/resolv.conf
87 * and a TCP connection to the local DNS server fails.

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

134res_send(buf, buflen, answer, anslen)
135 char *buf;
136 int buflen;
137 char *answer;
138 int anslen;
139{
140 register int n;
141 int try, v_circuit, resplen, ns;
132 int gotsomewhere = 0, connected = 0;
142 int gotsomewhere = 0;
143#if BSD >= 43
144 int connected = 0;
145#endif /* BSD */
133 int connreset = 0;
134 u_short id, len;
135 char *cp;
136 fd_set dsmask;
137 struct timeval timeout;
138 HEADER *hp = (HEADER *) buf;
139 HEADER *anhp = (HEADER *) answer;
140 struct iovec iov[2];

--- 376 unchanged lines hidden ---
146 int connreset = 0;
147 u_short id, len;
148 char *cp;
149 fd_set dsmask;
150 struct timeval timeout;
151 HEADER *hp = (HEADER *) buf;
152 HEADER *anhp = (HEADER *) answer;
153 struct iovec iov[2];

--- 376 unchanged lines hidden ---