. pci driver now returns devices, even when they have been pci_reserve()d
[minix3.git] / lib / ip / shutdown.c
blob128ded5275466cda63529209973dd19776f6b3c1
1 #include <errno.h>
2 #include <stdio.h>
3 #include <sys/ioctl.h>
4 #include <sys/socket.h>
6 #include <net/gen/in.h>
7 #include <net/gen/tcp.h>
8 #include <net/gen/tcp_io.h>
10 #define DEBUG 1
12 static int _tcp_shutdown(int socket, int how);
14 int shutdown(int socket, int how)
16 int r;
17 nwio_tcpconf_t tcpconf;
19 r= ioctl(socket, NWIOGTCPCONF, &tcpconf);
20 if (r != -1 || errno != ENOTTY)
22 if (r == -1)
24 /* Bad file descriptor */
25 return -1;
27 return _tcp_shutdown(socket, how);
29 #if DEBUG
30 fprintf(stderr, "shutdown: not implemented for fd %d\n", socket);
31 #endif
32 errno= ENOSYS;
33 return -1;
36 static int _tcp_shutdown(int socket, int how)
38 int r;
40 if (how == SHUT_WR || how == SHUT_RDWR)
42 r= ioctl(socket, NWIOTCPSHUTDOWN, NULL);
43 if (r == -1)
44 return -1;
45 if (how == SHUT_WR)
46 return 0;
49 /* We can't shutdown the read side of the socket. */
50 errno= ENOSYS;
51 return -1;