2 * Copyright (c) 1985, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
37 * Permission to use, copy, modify, and distribute this software for any
38 * purpose with or without fee is hereby granted, provided that the above
39 * copyright notice and this permission notice appear in all copies, and that
40 * the name of Digital Equipment Corporation not be used in advertising or
41 * publicity pertaining to distribution of the document or software without
42 * specific, written prior permission.
44 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
45 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
46 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
47 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
48 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
49 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
50 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
55 * Portions Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
56 * Portions Copyright (c) 1996-2003 by Internet Software Consortium
58 * Permission to use, copy, modify, and distribute this software for any
59 * purpose with or without fee is hereby granted, provided that the above
60 * copyright notice and this permission notice appear in all copies.
62 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
63 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
64 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
65 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
66 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
67 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
68 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
70 * Internet Systems Consortium, Inc.
72 * Redwood City, CA 94063
77 #if defined(LIBC_SCCS) && !defined(lint) && !defined(__AROS__)
78 static const char sccsid
[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93";
79 static const char rcsid
[] = "$Id$";
80 #endif /* LIBC_SCCS and not lint */
83 * Send query to name server and wait for reply.
86 #include <sys/types.h>
87 #include <sys/param.h>
89 #include <sys/socket.h>
92 #include <netinet/in.h>
93 #include <arpa/inet.h>
103 #include "minires/minires.h"
104 #include "arpa/nameser.h"
107 #include <aros/debug.h>
111 int trace_mr_socket (int, int, int);
112 int trace_mr_connect (int s
, struct sockaddr
*, SOCKLEN_T
);
113 ssize_t
trace_mr_read (int, void *, size_t);
114 ssize_t
trace_mr_send (int, const void *, size_t, int);
115 int trace_mr_close (int);
116 int trace_mr_bind (int, struct sockaddr
*, SOCKLEN_T
);
117 int trace_mr_select (int, fd_set
*, fd_set
*, fd_set
*, struct timeval
*);
118 ssize_t
trace_mr_recvfrom (int s
, void *, size_t, int,
119 struct sockaddr
*, SOCKLEN_T
*);
121 /* Rename the I/O functions in case we're tracing. */
131 #define send trace_mr_send
132 #define recvfrom trace_mr_recvfrom
133 #define read trace_mr_read
134 #define connect trace_mr_connect
135 #define socket trace_mr_socket
136 #define bind trace_mr_bind
137 #define close trace_mr_close
138 #define select trace_mr_select
139 #define time trace_mr_time
141 #define CHECK_SRVR_ADDR
143 static int cmpsock(struct sockaddr_in
*a1
, struct sockaddr_in
*a2
);
144 void res_pquery(const res_state
, const u_char
*, int, FILE *);
147 * res_isourserver(ina)
148 * looks up "ina" in _res.ns_addr_list[]
153 * paul vixie, 29may94
156 res_ourserver_p(const res_state statp
, const struct sockaddr_in
*inp
) {
157 struct sockaddr_in ina
;
161 for (ns
= 0; ns
< statp
->nscount
; ns
++) {
162 const struct sockaddr_in
*srv
= &statp
->nsaddr_list
[ns
];
164 if (srv
->sin_family
== ina
.sin_family
&&
165 srv
->sin_port
== ina
.sin_port
&&
166 (srv
->sin_addr
.s_addr
== INADDR_ANY
||
167 srv
->sin_addr
.s_addr
== ina
.sin_addr
.s_addr
))
174 * res_nameinquery(name, type, class, buf, eom)
175 * look for (name,type,class) in the query section of packet (buf,eom)
177 * buf + HFIXEDSZ <= eom
183 * paul vixie, 29may94
186 res_nameinquery(const char *name
, int type
, int class,
187 const u_char
*buf
, const u_char
*eom
)
189 const u_char
*cp
= buf
+ HFIXEDSZ
;
190 int qdcount
= ntohs(((const HEADER
*)buf
)->qdcount
);
192 while (qdcount
-- > 0) {
193 char tname
[MAXDNAME
+1];
194 int n
, ttype
, tclass
;
196 n
= dn_expand(buf
, eom
, cp
, tname
, sizeof tname
);
200 if (cp
+ 2 * INT16SZ
> eom
)
202 ttype
= getUShort(cp
); cp
+= INT16SZ
;
203 tclass
= getUShort(cp
); cp
+= INT16SZ
;
204 if (ttype
== type
&& tclass
== class &&
205 ns_samename(tname
, name
) == 1)
212 * res_queriesmatch(buf1, eom1, buf2, eom2)
213 * is there a 1:1 mapping of (name,type,class)
214 * in (buf1,eom1) and (buf2,eom2)?
217 * 0 : not a 1:1 mapping
218 * >0 : is a 1:1 mapping
220 * paul vixie, 29may94
223 res_queriesmatch(const u_char
*buf1
, const u_char
*eom1
,
224 const u_char
*buf2
, const u_char
*eom2
)
226 const u_char
*cp
= buf1
+ HFIXEDSZ
;
227 int qdcount
= ntohs(((const HEADER
*)buf1
)->qdcount
);
229 if (buf1
+ HFIXEDSZ
> eom1
|| buf2
+ HFIXEDSZ
> eom2
)
233 * Only header section present in replies to
234 * dynamic update packets.
236 if ( (((const HEADER
*)buf1
)->opcode
== ns_o_update
) &&
237 (((const HEADER
*)buf2
)->opcode
== ns_o_update
) )
240 if (qdcount
!= ntohs(((const HEADER
*)buf2
)->qdcount
))
242 while (qdcount
-- > 0) {
243 char tname
[MAXDNAME
+1];
244 int n
, ttype
, tclass
;
246 n
= dn_expand(buf1
, eom1
, cp
, tname
, sizeof tname
);
250 if (cp
+ 2 * INT16SZ
> eom1
)
252 ttype
= getUShort(cp
); cp
+= INT16SZ
;
253 tclass
= getUShort(cp
); cp
+= INT16SZ
;
254 if (!res_nameinquery(tname
, ttype
, tclass
, buf2
, eom2
))
261 res_nsend(res_state statp
,
262 double *buf
, unsigned buflen
,
263 double *ans
, unsigned anssiz
, unsigned *ansret
)
265 HEADER
*hp
= (HEADER
*) buf
;
266 HEADER
*anhp
= (HEADER
*) ans
;
267 int gotsomewhere
, connreset
, terrno
, try, v_circuit
, resplen
, ns
, n
;
268 u_int badns
; /* XXX NSMAX can't exceed #/bits in this variable */
269 static int highestFD
= FD_SETSIZE
- 1;
271 if (anssiz
< HFIXEDSZ
) {
272 return ISC_R_INVALIDARG
;
274 DprintQ((statp
->options
& RES_DEBUG
) ||
275 (statp
->pfcode
& RES_PRF_QUERY
),
276 (stdout
, ";; res_send()\n"), buf
, buflen
);
277 v_circuit
= (statp
->options
& RES_USEVC
) || buflen
> PACKETSZ
;
280 terrno
= ISC_R_TIMEDOUT
;
284 * Some callers want to even out the load on their resolver list.
286 if (statp
->nscount
> 0 && (statp
->options
& RES_ROTATE
) != 0) {
287 struct sockaddr_in ina
;
288 int lastns
= statp
->nscount
- 1;
290 ina
= statp
->nsaddr_list
[0];
291 for (ns
= 0; ns
< lastns
; ns
++)
292 statp
->nsaddr_list
[ns
] = statp
->nsaddr_list
[ns
+ 1];
293 statp
->nsaddr_list
[lastns
] = ina
;
296 #if defined (TRACING)
297 trace_mr_statp_setup (statp
);
301 * Send request, RETRY times, or until successful
303 for (try = 0; try < statp
->retry
; try++) {
304 for (ns
= 0; ns
< statp
->nscount
; ns
++) {
305 struct sockaddr_in
*nsap
= &statp
->nsaddr_list
[ns
];
307 if (badns
& (1 << ns
)) {
313 int done
= 0, loops
= 0;
318 act
= (*statp
->qhook
)(&nsap
, &buf
, &buflen
,
319 ans
, anssiz
, &resplen
);
330 /* give the hook another try */
331 if (++loops
< 42) /*doug adams*/
337 return ISC_R_UNEXPECTED
;
342 Dprint(statp
->options
& RES_DEBUG
,
343 (stdout
, ";; Querying server (# %d) address = %s\n",
344 ns
+ 1, inet_ntoa(nsap
->sin_addr
)));
352 /* Use VC; at most one attempt per server. */
356 /* Are we still talking to whom we want to talk to? */
357 if (statp
->_sock
>= 0 &&
358 (statp
->_flags
& RES_F_VC
) != 0) {
359 struct sockaddr_in peer
;
360 SOCKLEN_T size
= sizeof(peer
);
362 if (getpeername(statp
->_sock
,
363 (struct sockaddr
*)&peer
,
366 statp
->_flags
&= ~RES_F_VC
;
367 } else if (!cmpsock(&peer
, nsap
)) {
369 statp
->_flags
&= ~RES_F_VC
;
373 if (statp
->_sock
< 0 ||
374 (statp
->_flags
& RES_F_VC
) == 0) {
375 if (statp
->_sock
>= 0)
378 statp
->_sock
= socket(PF_INET
,
380 if (statp
->_sock
< 0 ||
381 statp
->_sock
> highestFD
) {
382 terrno
= uerr2isc (errno
);
383 Perror(statp
, stderr
,
384 "socket(vc)", errno
);
388 if (connect(statp
->_sock
,
389 (struct sockaddr
*)nsap
,
391 terrno
= uerr2isc (errno
);
392 Aerror(statp
, stderr
, "connect/vc",
398 statp
->_flags
|= RES_F_VC
;
401 * Send length & message
403 putUShort((u_char
*)&len
, buflen
);
404 iov
[0].iov_base
= (caddr_t
)&len
;
405 iov
[0].iov_len
= INT16SZ
;
406 iov
[1].iov_base
= (const caddr_t
)buf
;
407 iov
[1].iov_len
= buflen
;
409 bug("DONT HAVE writev\n");
412 if (writev(statp
->_sock
, iov
, 2) !=
413 (INT16SZ
+ buflen
)) {
414 terrno
= uerr2isc (errno
);
415 Perror(statp
, stderr
, "write failed", errno
);
422 * Receive length & response
427 while ((n
= read(statp
->_sock
,
428 (char *)cp
, (unsigned)len
)) > 0) {
434 terrno
= uerr2isc (errno
);
435 Perror(statp
, stderr
, "read failed", errno
);
438 * A long running process might get its TCP
439 * connection reset if the remote server was
440 * restarted. Requery the server instead of
441 * trying a new one. When there is only one
442 * server, this means that a query might work
443 * instead of failing. We only allow one reset
444 * per query to prevent looping.
446 if (terrno
== ISC_R_CONNREFUSED
&&
455 resplen
= getUShort ((unsigned char *)ans
);
456 if (resplen
> anssiz
) {
457 Dprint(statp
->options
& RES_DEBUG
,
458 (stdout
, ";; response truncated\n")
464 if (len
< HFIXEDSZ
) {
466 * Undersized message.
468 Dprint(statp
->options
& RES_DEBUG
,
469 (stdout
, ";; undersized: %d\n", len
));
470 terrno
= ISC_R_NOSPACE
;
477 (n
= read(statp
->_sock
,
478 (char *)cp
, (unsigned)len
))
484 terrno
= uerr2isc (errno
);
485 Perror(statp
, stderr
, "read(vc)", errno
);
491 * Flush rest of answer
492 * so connection stays in synch.
495 len
= resplen
- anssiz
;
499 n
= (len
> sizeof(junk
)
502 n
= read(statp
->_sock
,
511 * The calling applicating has bailed out of
512 * a previous call and failed to arrange to have
513 * the circuit closed or the server has got
514 * itself confused. Anyway drop the packet and
515 * wait for the correct one.
517 if (hp
->id
!= anhp
->id
) {
518 DprintQ((statp
->options
& RES_DEBUG
) ||
519 (statp
->pfcode
& RES_PRF_REPLY
),
521 ";; old answer (unexpected):\n"),
522 ans
, (resplen
>anssiz
)?anssiz
:resplen
);
529 int start
, timeout
, finish
;
531 struct sockaddr_in from
;
535 if (statp
->_sock
< 0 ||
536 (statp
->_flags
& RES_F_VC
) != 0) {
537 if ((statp
->_flags
& RES_F_VC
) != 0)
539 statp
->_sock
= socket(PF_INET
, SOCK_DGRAM
, 0);
540 if (statp
->_sock
< 0 ||
541 statp
->_sock
> highestFD
) {
542 #ifndef CAN_RECONNECT
545 terrno
= uerr2isc (errno
);
546 Perror(statp
, stderr
,
547 "socket(dg)", errno
);
550 statp
->_flags
&= ~RES_F_CONN
;
552 #ifndef CANNOT_CONNECT_DGRAM
554 * On a 4.3BSD+ machine (client and server,
555 * actually), sending to a nameserver datagram
556 * port with no nameserver will cause an
557 * ICMP port unreachable message to be returned.
558 * If our datagram socket is "connected" to the
559 * server, we get an ECONNREFUSED error on the next
560 * socket operation, and select returns if the
561 * error message is received. We can thus detect
562 * the absence of a nameserver without timing out.
563 * If we have sent queries to at least two servers,
564 * however, we don't want to remain connected,
565 * as we wish to receive answers from the first
568 if (statp
->nscount
== 1 || (try == 0 && ns
== 0)) {
570 * Connect only if we are sure we won't
571 * receive a response from another server.
573 if ((statp
->_flags
& RES_F_CONN
) == 0) {
574 if (connect(statp
->_sock
,
575 (struct sockaddr
*)nsap
,
577 Aerror(statp
, stderr
,
584 statp
->_flags
|= RES_F_CONN
;
586 if (send(statp
->_sock
,
587 buf
, (unsigned)buflen
, 0)
589 Perror(statp
, stderr
, "send", errno
);
596 * Disconnect if we want to listen
597 * for responses from more than one server.
599 if ((statp
->_flags
& RES_F_CONN
) != 0) {
601 struct sockaddr_in no_addr
;
603 no_addr
.sin_family
= AF_INET
;
604 no_addr
.sin_addr
.s_addr
= INADDR_ANY
;
605 no_addr
.sin_port
= 0;
606 (void) connect(statp
->_sock
,
611 struct sockaddr_in local_addr
;
615 len
= sizeof(local_addr
);
616 s1
= socket(PF_INET
, SOCK_DGRAM
, 0);
617 result
= getsockname(statp
->_sock
,
618 (struct sockaddr
*)&local_addr
,
622 #ifdef SOCKET_IS_NOT_A_FILE
623 Dup2Socket(s1
, statp
->_sock
);
625 (void) dup2(s1
, statp
->_sock
);
630 * Attempt to rebind to old
631 * port. Note connected socket
632 * has an sin_addr set.
634 local_addr
.sin_addr
.s_addr
=
636 (void)bind(statp
->_sock
,
641 Dprint(statp
->options
& RES_DEBUG
,
642 (stdout
, ";; new DG socket\n"));
643 #endif /* CAN_RECONNECT */
644 statp
->_flags
&= ~RES_F_CONN
;
647 #endif /* !CANNOT_CONNECT_DGRAM */
648 if (sendto(statp
->_sock
,
649 (const char *)buf
, buflen
, 0,
650 (struct sockaddr
*)nsap
,
653 Aerror(statp
, stderr
, "sendto", errno
, *nsap
);
658 #ifndef CANNOT_CONNECT_DGRAM
660 #endif /* !CANNOT_CONNECT_DGRAM */
662 if (statp
->_sock
< 0 || statp
->_sock
> highestFD
) {
663 Perror(statp
, stderr
,
664 "fd out-of-bounds", EMFILE
);
672 seconds
= (statp
->retrans
<< try);
674 seconds
/= statp
->nscount
;
679 finish
= start
+ timeout
;
682 FD_SET(statp
->_sock
, &dsmask
);
687 n
= select(statp
->_sock
+ 1,
688 &dsmask
, NULL
, NULL
, &t
);
691 Dprint(statp
->options
& RES_DEBUG
,
692 (stdout
, ";; timeout\n"));
697 if (errno
== EINTR
) {
698 if (finish
>= cur_time
) {
699 timeout
= finish
- cur_time
;
703 Perror(statp
, stderr
, "select", errno
);
708 fromlen
= sizeof(struct sockaddr_in
);
709 resplen
= recvfrom(statp
->_sock
,
710 (char *)ans
, anssiz
, 0,
711 (struct sockaddr
*)&from
, &fromlen
);
713 Perror(statp
, stderr
, "recvfrom", errno
);
718 if (resplen
< HFIXEDSZ
) {
720 * Undersized message.
722 Dprint(statp
->options
& RES_DEBUG
,
723 (stdout
, ";; undersized: %d\n",
725 terrno
= ISC_R_NOSPACE
;
730 if (hp
->id
!= anhp
->id
) {
732 * response from old query, ignore it.
733 * XXX - potential security hazard could
736 DprintQ((statp
->options
& RES_DEBUG
) ||
737 (statp
->pfcode
& RES_PRF_REPLY
),
738 (stdout
, ";; old answer:\n"),
739 ans
, (resplen
>anssiz
)?anssiz
:resplen
);
742 #ifdef CHECK_SRVR_ADDR
743 if (!(statp
->options
& RES_INSECURE1
) &&
744 !res_ourserver_p(statp
, &from
)) {
746 * response from wrong server? ignore it.
747 * XXX - potential security hazard could
750 DprintQ((statp
->options
& RES_DEBUG
) ||
751 (statp
->pfcode
& RES_PRF_REPLY
),
752 (stdout
, ";; not our server:\n"),
753 ans
, (resplen
>anssiz
)?anssiz
:resplen
);
757 if (!(statp
->options
& RES_INSECURE2
) &&
758 !res_queriesmatch((u_char
*)buf
,
759 ((u_char
*)buf
) + buflen
,
761 ((u_char
*)ans
) + anssiz
)) {
763 * response contains wrong query? ignore it.
764 * XXX - potential security hazard could
767 DprintQ((statp
->options
& RES_DEBUG
) ||
768 (statp
->pfcode
& RES_PRF_REPLY
),
769 (stdout
, ";; wrong query name:\n"),
770 ans
, (resplen
>anssiz
)?anssiz
:resplen
);
773 if (anhp
->rcode
== SERVFAIL
||
774 anhp
->rcode
== NOTIMP
||
775 anhp
->rcode
== REFUSED
) {
776 DprintQ(statp
->options
& RES_DEBUG
,
777 (stdout
, "server rejected query:\n"),
778 ans
, (resplen
>anssiz
)?anssiz
:resplen
);
781 /* don't retry if called from dig */
785 if (!(statp
->options
& RES_IGNTC
) && anhp
->tc
) {
787 * get rest of answer;
788 * use TCP with same server.
790 Dprint(statp
->options
& RES_DEBUG
,
791 (stdout
, ";; truncated answer\n"));
797 Dprint((statp
->options
& RES_DEBUG
) ||
798 ((statp
->pfcode
& RES_PRF_REPLY
) &&
799 (statp
->pfcode
& RES_PRF_HEAD1
)),
800 (stdout
, ";; got answer:\n"));
801 DprintQ((statp
->options
& RES_DEBUG
) ||
802 (statp
->pfcode
& RES_PRF_REPLY
),
804 ans
, (resplen
>anssiz
)?anssiz
:resplen
);
806 * If using virtual circuits, we assume that the first server
807 * is preferred over the rest (i.e. it is on the local
808 * machine) and only keep that one open.
809 * If we have temporarily opened a virtual circuit,
810 * or if we haven't been asked to keep a socket open,
813 if ((v_circuit
&& (!(statp
->options
& RES_USEVC
) || ns
!= 0)) ||
814 !(statp
->options
& RES_STAYOPEN
)) {
818 int done
= 0, loops
= 0;
823 act
= (*statp
->rhook
)(nsap
, buf
, buflen
,
824 ans
, anssiz
, &resplen
);
834 /* give the hook another try */
835 if (++loops
< 42) /*doug adams*/
841 return ISC_R_UNEXPECTED
;
847 return ISC_R_SUCCESS
;
854 terrno
= ISC_R_CONNREFUSED
; /* no nameservers found */
856 errno
= ISC_R_TIMEDOUT
; /* no answer obtained */
862 * This routine is for closing the socket if a virtual circuit is used and
863 * the program wants to close it. This provides support for endhostent()
864 * which expects to close the socket.
866 * This routine is not expected to be user visible.
869 res_nclose(res_state statp
) {
870 if (statp
->_sock
>= 0) {
871 (void) close(statp
->_sock
);
873 statp
->_flags
&= ~(RES_F_VC
| RES_F_CONN
);
879 cmpsock(struct sockaddr_in
*a1
, struct sockaddr_in
*a2
) {
880 return ((a1
->sin_family
== a2
->sin_family
) &&
881 (a1
->sin_port
== a2
->sin_port
) &&
882 (a1
->sin_addr
.s_addr
== a2
->sin_addr
.s_addr
));
886 /* XXX needs to move to the porting library. */
888 pselect(int nfds
, void *rfds
, void *wfds
, void *efds
,
889 struct timespec
*tsp
,
890 const sigset_t
*sigmask
)
892 struct timeval tv
, *tvp
;
898 tv
= evTimeVal(*tsp
);
902 sigprocmask(SIG_SETMASK
, sigmask
, &sigs
);
903 n
= select(nfds
, rfds
, wfds
, efds
, tvp
);
905 sigprocmask(SIG_SETMASK
, &sigs
, NULL
);
907 *tsp
= evTimeSpec(tv
);