2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 /* selsubs.c - common code for client and server. */
11 #include <afsconfig.h>
12 #include <afs/param.h>
20 #include <sys/select.h>
21 #include <sys/types.h>
22 #include <sys/socket.h>
25 #include <netinet/in.h>
28 #include <sys/ioctl.h>
36 #ifdef NEEDS_ALLOCFDSET
37 /* Include these if testing against 32 bit fd_set IOMGR. */
39 IOMGR_AllocFDSet(void)
41 fd_set
*tmp
= calloc(1, sizeof(fd_set
));
46 IOMGR_FreeFDSet(fd_set
* fds
)
52 /* The TCP spec calls for writing at least one byte of OOB data which is
53 * read by the receiver using recv with the MSG_OOB flag set.
60 Log("Sending OOB.\n");
61 if (send(fd
, &c
, 1, MSG_OOB
) < 0) {
71 Log("Received OOB\n");
72 if (recv(fd
, &c
, 1, MSG_OOB
) < 0) {
79 assertNullFDSet(int fd
, fd_set
* fds
)
82 int n
= sizeof(*fds
) / sizeof(int);
88 for (i
= 0; i
< n
; i
++)
94 * Open file descriptors until file descriptor n or higher is returned.
106 for (i
= 0; i
< n
; i
++) {
107 if (fstat(i
, &sbuf
) == 0)
109 if ((fd
= open("/dev/null", 0, 0)) < 0) {
125 /* If flag is set, abort. */
127 Die(int flag
, char *msg
)
130 extern char *program
;
132 (void)sprintf(tmp
, "%s: %s: ", program
? program
: "", msg
);
152 extern char *program
;
154 code
= gettimeofday(&now
, NULL
);
158 ltime
= localtime(&tt
);
160 LWP_CurrentProcess(&pid
);
161 fprintf(stderr
, "%s 0x%x %02d:%02d:%02d.%d: ", program
? program
: "",
162 pid
, ltime
->tm_hour
, ltime
->tm_min
, ltime
->tm_sec
, now
.tv_usec
);
166 vfprintf(stderr
, fmt
, args
);