]> git.sur5r.net Git - openldap/blob - libraries/libldap/os-ip.c
Fix month field
[openldap] / libraries / libldap / os-ip.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6 /*  Portions
7  *  Copyright (c) 1995 Regents of the University of Michigan.
8  *  All rights reserved.
9  *
10  *  os-ip.c -- platform-specific TCP & UDP related code
11  */
12
13 #include "portable.h"
14
15 #include <stdio.h>
16
17 #include <ac/stdlib.h>
18
19 #include <ac/errno.h>
20 #include <ac/socket.h>
21 #include <ac/string.h>
22 #include <ac/time.h>
23 #include <ac/unistd.h>
24
25 #ifdef HAVE_IO_H
26 #include <io.h>
27 #endif /* HAVE_IO_H */
28
29 #include "ldap-int.h"
30
31 int ldap_int_tblsize = 0;
32
33 #if defined( HAVE_GETADDRINFO ) && defined( HAVE_INET_NTOP )
34 #  ifdef LDAP_PF_INET6
35 int ldap_int_inet4or6 = AF_UNSPEC;
36 #  else
37 int ldap_int_inet4or6 = AF_INET;
38 #  endif
39 #endif
40
41 /*
42  * nonblock connect code
43  * written by Lars Uffmann, <lars.uffmann@mediaway.net>.
44  *
45  * Copyright 1999, Lars Uffmann, All rights reserved.
46  * This software is not subject to any license of my employer
47  * mediaWays GmbH.
48  *
49  * OpenLDAP COPYING RESTRICTIONS APPLY, see COPYRIGHT file
50  *
51  * Read about the rationale in ldap_connect_timeout: 
52  * ftp://koobera.math.uic.edu/www/docs/connect.html.
53  */
54
55 #define osip_debug(ld,fmt,arg1,arg2,arg3) \
56 do { \
57         ldap_log_printf(NULL, LDAP_DEBUG_TRACE, fmt, arg1, arg2, arg3); \
58 } while(0)
59
60 static void
61 ldap_pvt_set_errno(int err)
62 {
63         errno = err;
64 }
65
66 int
67 ldap_int_timeval_dup( struct timeval **dest, const struct timeval *src )
68 {
69         struct timeval *new;
70
71         assert( dest != NULL );
72
73         if (src == NULL) {
74                 *dest = NULL;
75                 return 0;
76         }
77
78         new = (struct timeval *) LDAP_MALLOC(sizeof(struct timeval));
79
80         if( new == NULL ) {
81                 *dest = NULL;
82                 return 1;
83         }
84
85         AC_MEMCPY( (char *) new, (const char *) src, sizeof(struct timeval));
86
87         *dest = new;
88         return 0;
89 }
90
91 static int
92 ldap_pvt_ndelay_on(LDAP *ld, int fd)
93 {
94         osip_debug(ld, "ldap_ndelay_on: %d\n",fd,0,0);
95         return ber_pvt_socket_set_nonblock( fd, 1 );
96 }
97    
98 static int
99 ldap_pvt_ndelay_off(LDAP *ld, int fd)
100 {
101         osip_debug(ld, "ldap_ndelay_off: %d\n",fd,0,0);
102         return ber_pvt_socket_set_nonblock( fd, 0 );
103 }
104
105 static ber_socket_t
106 ldap_int_socket(LDAP *ld, int family, int type )
107 {
108         ber_socket_t s = socket(family, type, 0);
109         osip_debug(ld, "ldap_new_socket: %d\n",s,0,0);
110         return ( s );
111 }
112
113 static int
114 ldap_pvt_close_socket(LDAP *ld, int s)
115 {
116         osip_debug(ld, "ldap_close_socket: %d\n",s,0,0);
117         return tcp_close(s);
118 }
119
120 static int
121 ldap_int_prepare_socket(LDAP *ld, int s, int proto )
122 {
123         osip_debug(ld, "ldap_prepare_socket: %d\n", s,0,0);
124
125 #ifdef TCP_NODELAY
126         if( proto == LDAP_PROTO_TCP ) {
127                 int dummy = 1;
128                 if ( setsockopt( s, IPPROTO_TCP, TCP_NODELAY,
129                         (char*) &dummy, sizeof(dummy) ) == AC_SOCKET_ERROR )
130                 {
131                         osip_debug(ld, "ldap_prepare_socket: "
132                                 "setsockopt(%d, TCP_NODELAY) failed (ignored).\n",
133                                 s, 0, 0);
134                 }
135         }
136 #endif
137
138         return 0;
139 }
140
141 #ifndef HAVE_WINSOCK
142
143 #undef TRACE
144 #define TRACE do { \
145         osip_debug(ld, \
146                 "ldap_is_socket_ready: error on socket %d: errno: %d (%s)\n", \
147                 s, \
148                 errno, \
149                 sock_errstr(errno) ); \
150 } while( 0 )
151
152 /*
153  * check the socket for errors after select returned.
154  */
155 static int
156 ldap_pvt_is_socket_ready(LDAP *ld, int s)
157 {
158         osip_debug(ld, "ldap_is_sock_ready: %d\n",s,0,0);
159
160 #if defined( notyet ) /* && defined( SO_ERROR ) */
161 {
162         int so_errno;
163         socklen_t dummy = sizeof(so_errno);
164         if ( getsockopt( s, SOL_SOCKET, SO_ERROR, &so_errno, &dummy )
165                 == AC_SOCKET_ERROR )
166         {
167                 return -1;
168         }
169         if ( so_errno ) {
170                 ldap_pvt_set_errno(so_errno);
171                 TRACE;
172                 return -1;
173         }
174         return 0;
175 }
176 #else
177 {
178         /* error slippery */
179 #ifdef LDAP_PF_INET6
180         struct sockaddr_storage sin;
181 #else
182         struct sockaddr_in sin;
183 #endif
184         char ch;
185         socklen_t dummy = sizeof(sin);
186         if ( getpeername( s, (struct sockaddr *) &sin, &dummy )
187                 == AC_SOCKET_ERROR )
188         {
189                 /* XXX: needs to be replace with ber_stream_read() */
190                 read(s, &ch, 1);
191                 TRACE;
192                 return -1;
193         }
194         return 0;
195 }
196 #endif
197         return -1;
198 }
199 #undef TRACE
200
201 #endif /* HAVE_WINSOCK */
202
203 static int
204 ldap_pvt_connect(LDAP *ld, ber_socket_t s,
205         struct sockaddr *sin, socklen_t addrlen,
206         int async)
207 {
208         int rc;
209         struct timeval  tv, *opt_tv=NULL;
210         fd_set          wfds, *z=NULL;
211 #ifdef HAVE_WINSOCK
212         fd_set          efds;
213 #endif
214
215 #ifdef LDAP_CONNECTIONLESS
216         /* We could do a connect() but that would interfere with
217          * attempts to poll a broadcast address
218          */
219         if (LDAP_IS_UDP(ld)) {
220                 if (ld->ld_options.ldo_peer)
221                         ldap_memfree(ld->ld_options.ldo_peer);
222                 ld->ld_options.ldo_peer=ldap_memalloc(sizeof(struct sockaddr));
223                 AC_MEMCPY(ld->ld_options.ldo_peer,sin,sizeof(struct sockaddr));
224                 return ( 0 );
225         }
226 #endif
227         if ( (opt_tv = ld->ld_options.ldo_tm_net) != NULL ) {
228                 tv.tv_usec = opt_tv->tv_usec;
229                 tv.tv_sec = opt_tv->tv_sec;
230         }
231
232         osip_debug(ld, "ldap_connect_timeout: fd: %d tm: %ld async: %d\n",
233                         s, opt_tv ? tv.tv_sec : -1L, async);
234
235         if ( ldap_pvt_ndelay_on(ld, s) == -1 )
236                 return ( -1 );
237
238         if ( connect(s, sin, addrlen) != AC_SOCKET_ERROR ) {
239                 if ( ldap_pvt_ndelay_off(ld, s) == -1 )
240                         return ( -1 );
241                 return ( 0 );
242         }
243
244 #ifdef HAVE_WINSOCK
245         ldap_pvt_set_errno( WSAGetLastError() );
246 #endif
247
248         if ( errno != EINPROGRESS && errno != EWOULDBLOCK ) {
249                 return ( -1 );
250         }
251         
252 #ifdef notyet
253         if ( async ) return ( -2 );
254 #endif
255
256         FD_ZERO(&wfds);
257         FD_SET(s, &wfds );
258
259 #ifdef HAVE_WINSOCK
260         FD_ZERO(&efds);
261         FD_SET(s, &efds );
262 #endif
263
264         do {
265                 rc = select(ldap_int_tblsize, z, &wfds,
266 #ifdef HAVE_WINSOCK
267                         &efds,
268 #else
269                         z,
270 #endif
271                         opt_tv ? &tv : NULL);
272         } while( rc == AC_SOCKET_ERROR && errno == EINTR &&
273                 LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_RESTART ));
274
275         if( rc == AC_SOCKET_ERROR ) return rc;
276
277 #ifdef HAVE_WINSOCK
278         /* This means the connection failed */
279         if ( FD_ISSET(s, &efds) ) {
280             int so_errno;
281             int dummy = sizeof(so_errno);
282             if ( getsockopt( s, SOL_SOCKET, SO_ERROR,
283                         (char *) &so_errno, &dummy ) == AC_SOCKET_ERROR || !so_errno )
284             {
285                 /* impossible */
286                 so_errno = WSAGetLastError();
287             }
288             ldap_pvt_set_errno(so_errno);
289             osip_debug(ld, "ldap_pvt_connect: error on socket %d: "
290                        "errno: %d (%s)\n", s, errno, sock_errstr(errno));
291             return -1;
292         }
293 #endif
294         if ( FD_ISSET(s, &wfds) ) {
295 #ifndef HAVE_WINSOCK
296                 if ( ldap_pvt_is_socket_ready(ld, s) == -1 )
297                         return ( -1 );
298 #endif
299                 if ( ldap_pvt_ndelay_off(ld, s) == -1 )
300                         return ( -1 );
301                 return ( 0 );
302         }
303         osip_debug(ld, "ldap_connect_timeout: timed out\n",0,0,0);
304         ldap_pvt_set_errno( ETIMEDOUT );
305         return ( -1 );
306 }
307
308 #ifndef HAVE_INET_ATON
309 int
310 ldap_pvt_inet_aton( const char *host, struct in_addr *in)
311 {
312         unsigned long u = inet_addr( host );
313         if ( u != 0xffffffff || u != (unsigned long) -1 ) {
314                 in->s_addr = u;
315                 return 1;
316         }
317         return 0;
318 }
319 #endif
320
321
322 int
323 ldap_connect_to_host(LDAP *ld, Sockbuf *sb,
324         int proto,
325         const char *host,
326         unsigned long address, int port, int async )
327 {
328         ber_socket_t            s = AC_SOCKET_INVALID;
329         int                     rc, i, use_hp = 0;
330         struct hostent          *hp = NULL;
331         char                    *ha_buf=NULL, *p, *q;
332         int                     socktype;
333
334         
335         switch(proto) {
336         case LDAP_PROTO_TCP: socktype = SOCK_STREAM;
337                 osip_debug(ld, "ldap_connect_to_host: TCP %s:%d\n",host,port,0);
338                 break;
339         case LDAP_PROTO_UDP: socktype = SOCK_DGRAM;
340                 osip_debug(ld, "ldap_connect_to_host: TCP %s:%d\n",host,port,0);
341                 break;
342
343         default:
344                 osip_debug(ld, "ldap_connect_to_host: unknown proto: %d\n",
345                         proto, 0, 0);
346                 return -1;
347         }
348
349         if (host != NULL) {
350 #if defined( HAVE_GETADDRINFO ) && defined( HAVE_INET_NTOP )
351                 char serv[7];
352                 int err;
353                 struct addrinfo hints, *res, *sai;
354
355                 memset( &hints, '\0', sizeof(hints) );
356                 hints.ai_family = ldap_int_inet4or6;
357                 hints.ai_socktype = socktype;
358
359                 snprintf(serv, sizeof serv, "%d", port );
360                 if ( ( err = getaddrinfo(host, serv, &hints, &res) ) ) {
361                         osip_debug(ld, "ldap_connect_to_host: getaddrinfo failed: %s\n",
362                                 AC_GAI_STRERROR(err), 0, 0);
363                         return -1;
364                 }
365                 rc = -1;
366
367                 for( sai=res; sai != NULL; sai=sai->ai_next) {
368                         if( sai->ai_addr == NULL ) {
369                                 osip_debug(ld, "ldap_connect_to_host: getaddrinfo "
370                                         "ai_addr is NULL?\n", 0, 0, 0);
371                                 continue;
372                         }
373
374                         /* we assume AF_x and PF_x are equal for all x */
375                         s = ldap_int_socket( ld, sai->ai_family, socktype );
376                         if ( s == AC_SOCKET_INVALID ) {
377                                 continue;
378                         }
379
380                         if ( ldap_int_prepare_socket(ld, s, proto ) == -1 ) {
381                                 ldap_pvt_close_socket(ld, s);
382                                 break;
383                         }
384
385                         switch (sai->ai_family) {
386 #ifdef LDAP_PF_INET6
387                         case AF_INET6: {
388                                 char addr[INET6_ADDRSTRLEN];
389                                 inet_ntop( AF_INET6,
390                                         &((struct sockaddr_in6 *)sai->ai_addr)->sin6_addr,
391                                         addr, sizeof addr);
392                                 osip_debug(ld, "ldap_connect_to_host: Trying %s %s\n", 
393                                         addr, serv, 0);
394                         } break;
395 #endif
396                         case AF_INET: {
397                                 char addr[INET_ADDRSTRLEN];
398                                 inet_ntop( AF_INET,
399                                         &((struct sockaddr_in *)sai->ai_addr)->sin_addr,
400                                         addr, sizeof addr);
401                                 osip_debug(ld, "ldap_connect_to_host: Trying %s:%s\n", 
402                                         addr, serv, 0);
403                         } break;
404                         }
405
406                         rc = ldap_pvt_connect(ld, s, sai->ai_addr, sai->ai_addrlen, async);
407                         if ( (rc == 0) || (rc == -2) ) {
408                                 ber_sockbuf_ctrl( sb, LBER_SB_OPT_SET_FD, &s );
409                                 break;
410                         }
411                         ldap_pvt_close_socket(ld, s);
412                 }
413                 freeaddrinfo(res);
414                 return rc;
415
416 #else
417                 struct in_addr in;
418                 if (! inet_aton( host, &in) ) {
419                         int local_h_errno;
420                         struct hostent he_buf;
421                         rc = ldap_pvt_gethostbyname_a(host, &he_buf, &ha_buf,
422                                         &hp, &local_h_errno);
423
424                         if ( (rc < 0) || (hp == NULL) ) {
425 #ifdef HAVE_WINSOCK
426                                 ldap_pvt_set_errno( WSAGetLastError() );
427 #else
428                                 /* not exactly right, but... */
429                                 ldap_pvt_set_errno( EHOSTUNREACH );
430 #endif
431                                 if (ha_buf) LDAP_FREE(ha_buf);
432                                 return -1;
433                         }
434                         use_hp = 1;
435                 }
436                 address = in.s_addr;
437 #endif
438         }
439
440         rc = s = -1;
441         for ( i = 0; !use_hp || (hp->h_addr_list[i] != 0); ++i, rc = -1 ) {
442                 struct sockaddr_in      sin;
443
444                 s = ldap_int_socket( ld, PF_INET, socktype );
445                 if ( s == AC_SOCKET_INVALID ) {
446                         /* use_hp ? continue : break; */
447                         break;
448                 }
449            
450                 if ( ldap_int_prepare_socket( ld, s, proto ) == -1 ) {
451                         ldap_pvt_close_socket(ld, s);
452                         break;
453                 }
454
455                 (void)memset((char *)&sin, '\0', sizeof sin);
456                 sin.sin_family = AF_INET;
457                 sin.sin_port = htons((short) port);
458                 p = (char *)&sin.sin_addr;
459                 q = use_hp ? (char *)hp->h_addr_list[i] : (char *)&address;
460                 AC_MEMCPY(p, q, sizeof(sin.sin_addr) );
461
462                 osip_debug(ld, "ldap_connect_to_host: Trying %s:%d\n", 
463                         inet_ntoa(sin.sin_addr),port,0);
464
465                 rc = ldap_pvt_connect(ld, s,
466                         (struct sockaddr *)&sin, sizeof(struct sockaddr_in),
467                         async);
468    
469                 if ( (rc == 0) || (rc == -2) ) {
470                         ber_sockbuf_ctrl( sb, LBER_SB_OPT_SET_FD, &s );
471                         break;
472                 }
473
474                 ldap_pvt_close_socket(ld, s);
475
476                 if (!use_hp)
477                         break;
478         }
479         if (ha_buf) LDAP_FREE(ha_buf);
480         return rc;
481 }
482
483 #if defined( LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND ) || \
484         defined( HAVE_CYRUS_SASL )
485 char *
486 ldap_host_connected_to( Sockbuf *sb )
487 {
488         struct hostent  *hp;
489         socklen_t               len;
490 #ifdef LDAP_PF_INET6
491         struct sockaddr_storage sabuf;
492 #else
493         struct sockaddr sabuf;
494 #endif
495         struct sockaddr *sa = (struct sockaddr *) &sabuf;
496         char                    *addr;
497         char                    *host;
498
499         /* buffers for gethostbyaddr_r */
500         struct hostent  he_buf;
501         int                             local_h_errno;
502         char                    *ha_buf=NULL;
503         ber_socket_t    sd;
504
505         (void)memset( (char *)sa, '\0', sizeof sabuf );
506         len = sizeof sabuf;
507
508         ber_sockbuf_ctrl( sb, LBER_SB_OPT_GET_FD, &sd );
509         if ( getpeername( sd, sa, &len ) == -1 ) {
510                 return( NULL );
511         }
512
513         /*
514          * do a reverse lookup on the addr to get the official hostname.
515          * this is necessary for kerberos to work right, since the official
516          * hostname is used as the kerberos instance.
517          */
518
519         switch (sa->sa_family) {
520 #ifdef LDAP_PF_LOCAL
521         case AF_LOCAL:
522                 return LDAP_STRDUP( ldap_int_hostname );
523 #endif
524 #ifdef LDAP_PF_INET6
525         case AF_INET6:
526                 addr = (char *) &((struct sockaddr_in6 *)sa)->sin6_addr;
527                 len = sizeof( struct in6_addr );
528                 break;
529 #endif
530         case AF_INET:
531                 addr = (char *) &((struct sockaddr_in *)sa)->sin_addr;
532                 len = sizeof( struct in_addr );
533
534                 {
535                         struct sockaddr_in localhost;
536                         localhost.sin_addr.s_addr = htonl( INADDR_ANY );
537
538                         if( memcmp ( &localhost.sin_addr,
539                                 &((struct sockaddr_in *)sa)->sin_addr,
540                                 sizeof(localhost.sin_addr) ) == 0 )
541                         {
542                                 return LDAP_STRDUP( ldap_int_hostname );
543                         }
544
545 #ifdef INADDR_LOOPBACK
546                         localhost.sin_addr.s_addr = htonl( INADDR_LOOPBACK );
547
548                         if( memcmp ( &localhost.sin_addr,
549                                 &((struct sockaddr_in *)sa)->sin_addr,
550                                 sizeof(localhost.sin_addr) ) == 0 )
551                         {
552                                 return LDAP_STRDUP( ldap_int_hostname );
553                         }
554 #endif
555                 }
556                 break;
557
558         default:
559                 return( NULL );
560                 break;
561         }
562
563         host = NULL;
564         if ((ldap_pvt_gethostbyaddr_a( addr, len, sa->sa_family,
565                 &he_buf, &ha_buf, &hp, &local_h_errno ) == 0 ) &&
566                 (hp != NULL) && ( hp->h_name != NULL ) )
567         {
568                 host = LDAP_STRDUP( hp->h_name );   
569         }
570
571         LDAP_FREE( ha_buf );
572         return host;
573 }
574 #endif
575
576
577 /* for UNIX */
578 struct selectinfo {
579         fd_set  si_readfds;
580         fd_set  si_writefds;
581         fd_set  si_use_readfds;
582         fd_set  si_use_writefds;
583 };
584
585
586 void
587 ldap_mark_select_write( LDAP *ld, Sockbuf *sb )
588 {
589         struct selectinfo       *sip;
590         ber_socket_t            sd;
591
592         sip = (struct selectinfo *)ld->ld_selectinfo;
593         
594         ber_sockbuf_ctrl( sb, LBER_SB_OPT_GET_FD, &sd );
595         if ( !FD_ISSET( sd, &sip->si_writefds )) {
596                 FD_SET( sd, &sip->si_writefds );
597         }
598 }
599
600
601 void
602 ldap_mark_select_read( LDAP *ld, Sockbuf *sb )
603 {
604         struct selectinfo       *sip;
605         ber_socket_t            sd;
606
607         sip = (struct selectinfo *)ld->ld_selectinfo;
608
609         ber_sockbuf_ctrl( sb, LBER_SB_OPT_GET_FD, &sd );
610         if ( !FD_ISSET( sd, &sip->si_readfds )) {
611                 FD_SET( sd, &sip->si_readfds );
612         }
613 }
614
615
616 void
617 ldap_mark_select_clear( LDAP *ld, Sockbuf *sb )
618 {
619         struct selectinfo       *sip;
620         ber_socket_t            sd;
621
622         sip = (struct selectinfo *)ld->ld_selectinfo;
623
624         ber_sockbuf_ctrl( sb, LBER_SB_OPT_GET_FD, &sd );
625         FD_CLR( sd, &sip->si_writefds );
626         FD_CLR( sd, &sip->si_readfds );
627 }
628
629
630 int
631 ldap_is_write_ready( LDAP *ld, Sockbuf *sb )
632 {
633         struct selectinfo       *sip;
634         ber_socket_t            sd;
635
636         sip = (struct selectinfo *)ld->ld_selectinfo;
637
638         ber_sockbuf_ctrl( sb, LBER_SB_OPT_GET_FD, &sd );
639         return( FD_ISSET( sd, &sip->si_use_writefds ));
640 }
641
642
643 int
644 ldap_is_read_ready( LDAP *ld, Sockbuf *sb )
645 {
646         struct selectinfo       *sip;
647         ber_socket_t            sd;
648
649         sip = (struct selectinfo *)ld->ld_selectinfo;
650
651         ber_sockbuf_ctrl( sb, LBER_SB_OPT_GET_FD, &sd );
652         return( FD_ISSET( sd, &sip->si_use_readfds ));
653 }
654
655
656 void *
657 ldap_new_select_info( void )
658 {
659         struct selectinfo       *sip;
660
661         if (( sip = (struct selectinfo *)LDAP_CALLOC( 1,
662             sizeof( struct selectinfo ))) != NULL ) {
663                 FD_ZERO( &sip->si_readfds );
664                 FD_ZERO( &sip->si_writefds );
665         }
666
667         return( (void *)sip );
668 }
669
670
671 void
672 ldap_free_select_info( void *sip )
673 {
674         LDAP_FREE( sip );
675 }
676
677
678 void
679 ldap_int_ip_init( void )
680 {
681         int tblsize;
682 #if defined( HAVE_SYSCONF )
683         tblsize = sysconf( _SC_OPEN_MAX );
684 #elif defined( HAVE_GETDTABLESIZE )
685         tblsize = getdtablesize();
686 #else
687         tblsize = FD_SETSIZE;
688 #endif /* !USE_SYSCONF */
689
690 #ifdef FD_SETSIZE
691         if( tblsize > FD_SETSIZE )
692                 tblsize = FD_SETSIZE;
693 #endif  /* FD_SETSIZE*/
694         ldap_int_tblsize = tblsize;
695 }
696
697
698 int
699 ldap_int_select( LDAP *ld, struct timeval *timeout )
700 {
701         struct selectinfo       *sip;
702
703 #ifdef NEW_LOGGING
704         LDAP_LOG ( CONNECTION, ENTRY, "ldap_int_select\n", 0, 0, 0 );
705 #else
706         Debug( LDAP_DEBUG_TRACE, "ldap_int_select\n", 0, 0, 0 );
707 #endif
708
709         if ( ldap_int_tblsize == 0 )
710                 ldap_int_ip_init();
711
712         sip = (struct selectinfo *)ld->ld_selectinfo;
713         sip->si_use_readfds = sip->si_readfds;
714         sip->si_use_writefds = sip->si_writefds;
715         
716         return( select( ldap_int_tblsize,
717                         &sip->si_use_readfds, &sip->si_use_writefds,
718                         NULL, timeout ));
719 }