open intervals and type derivation
[sbcl.git] / contrib / sb-bsd-sockets / win32-constants.lisp
1 ;;; -*- Lisp -*-
2
3 ;;; This isn't really lisp, but it's definitely a source file.  we
4 ;;; name it thus to avoid having to mess with the clc lpn translations
5
6 ;;; first, the headers necessary to find definitions of everything
7 ("winsock2.h")
8
9 ;;; then the stuff we're looking for
10 ((:integer af-inet "AF_INET" "IP Protocol family")
11  (:integer af-unspec "AF_UNSPEC" "Unspecified")
12  (:integer sock-stream "SOCK_STREAM"
13            "Sequenced, reliable, connection-based byte streams.")
14  (:integer sock-dgram "SOCK_DGRAM"
15            "Connectionless, unreliable datagrams of fixed maximum length.")
16  (:integer sock-raw "SOCK_RAW"
17            "Raw protocol interface.")
18  (:integer sock-rdm "SOCK_RDM"
19            "Reliably-delivered messages.")
20  (:integer sock-seqpacket "SOCK_SEQPACKET"
21            "Sequenced, reliable, connection-based, datagrams of fixed maximum length.")
22
23  (:integer sol-socket "SOL_SOCKET")
24
25  ;; some of these may be linux-specific
26  (:integer so-debug "SO_DEBUG"
27    "Enable debugging in underlying protocol modules")
28  (:integer so-reuseaddr "SO_REUSEADDR" "Enable local address reuse")
29  (:integer so-type "SO_TYPE")                  ;get only
30  (:integer so-error "SO_ERROR")                 ;get only (also clears)
31  (:integer so-dontroute "SO_DONTROUTE"
32            "Bypass routing facilities: instead send direct to appropriate network interface for the network portion of the destination address")
33  (:integer so-broadcast "SO_BROADCAST" "Request permission to send broadcast datagrams")
34  (:integer so-sndbuf "SO_SNDBUF")
35  (:integer so-rcvbuf "SO_RCVBUF")
36  (:integer so-keepalive "SO_KEEPALIVE"
37            "Send periodic keepalives: if peer does not respond, we get SIGPIPE")
38  (:integer so-oobinline "SO_OOBINLINE"
39            "Put out-of-band data into the normal input queue when received")
40  (:integer so-linger "SO_LINGER"
41            "For reliable streams, pause a while on closing when unsent messages are queued")
42  (:integer so-sndlowat "SO_SNDLOWAT")
43  (:integer so-rcvlowat "SO_RCVLOWAT")
44  (:integer so-sndtimeo "SO_SNDTIMEO")
45  (:integer so-rcvtimeo "SO_RCVTIMEO")
46
47  (:integer tcp-nodelay "TCP_NODELAY")
48
49  (:integer HOST-NOT-FOUND "HOST_NOT_FOUND" "Authoritative Answer Host not found.")
50  (:integer TRY-AGAIN "TRY_AGAIN" "Non-Authoritative Host not found, or SERVERFAIL.")
51  (:integer NO-RECOVERY "NO_RECOVERY" "Non recoverable errors, FORMERR, REFUSED, NOTIMP.")
52  (:integer NO-DATA "NO_DATA" "Valid name, no data record of requested type.")
53  (:integer NO-ADDRESS "NO_ADDRESS" "No address, look for MX record.")
54
55  (:integer msg-oob "MSG_OOB")
56  (:integer msg-peek "MSG_PEEK")
57  (:integer msg-dontroute "MSG_DONTROUTE")
58
59
60  (:integer EADDRINUSE "WSAEADDRINUSE")
61  (:integer EAGAIN "WSAEWOULDBLOCK")
62  (:integer EBADF "WSAEBADF")
63  (:integer ECONNREFUSED "WSAECONNREFUSED")
64  (:integer ETIMEDOUT "WSAETIMEDOUT")
65  (:integer EINTR "WSAEINTR")
66  (:integer EINVAL "WSAEINVAL")
67  (:integer ENOBUFS "WSAENOBUFS")
68  (:integer ENOMEM "WSAENOBUFS")
69  (:integer EOPNOTSUPP "WSAEOPNOTSUPP")
70  (:integer EPERM "WSAENETDOWN")
71  (:integer EPROTONOSUPPORT "WSAEPROTONOSUPPORT")
72  (:integer ESOCKTNOSUPPORT "WSAESOCKTNOSUPPORT")
73  (:integer ENETUNREACH "WSAENETUNREACH")
74  (:integer ENOTCONN "WSAENOTCONN")
75  (:integer inaddr-any "INADDR_ANY")
76
77
78  ;; for socket-receive
79  (:type socklen-t "int")
80  (:type size-t "size_t")
81  (:type ssize-t "ssize_t")
82
83  (:structure in-addr ("struct in_addr"
84                       ((array (unsigned 8)) addr "u_int32_t" "s_addr")))
85
86  (:structure sockaddr-in ("struct sockaddr_in"
87                           (integer family "sa_family_t" "sin_family")
88                           ;; These two could be in-port-t and
89                           ;; in-addr-t, but then we'd throw away the
90                           ;; convenience (and byte-order agnosticism)
91                           ;; of the old sb-grovel scheme.
92                           ((array (unsigned 8)) port "u_int16_t" "sin_port")
93                           ((array (unsigned 8)) addr "struct in_addr" "sin_addr")))
94
95  (:structure hostent ("struct hostent"
96                       (c-string-pointer name "char *" "h_name")
97                       ((* c-string) aliases "char **" "h_aliases")
98                       (integer type "int" "h_addrtype")
99                       (integer length "int" "h_length")
100                       ((* (* (unsigned 8))) addresses "char **" "h_addr_list")))
101
102  (:structure protoent ("struct protoent"
103                        (c-string-pointer name "char *" "p_name")
104                        ((* (* t)) aliases "char **" "p_aliases")
105                        (integer proto "int" "p_proto")))
106
107  (:function getprotobyname ("getprotobyname" (* protoent)
108                                              (name c-string)))
109
110  (:function getprotobynumber ("getprotobynumber" (* protoent)
111                                                  (proto int)))
112
113  (:function win32-bind
114             ("bind" int
115              (sockfd int)
116              (my-addr (* t))  ; KLUDGE: sockaddr-in or sockaddr-un?
117              (addrlen socklen-t)))
118
119  (:function win32-listen ("listen" int
120                     (socket int)
121                     (backlog int)))
122
123  (:function win32-accept ("accept" int
124                     (socket int)
125                     (my-addr (* t)) ; KLUDGE: sockaddr-in or sockaddr-un?
126                     (addrlen int :in-out)))
127
128  (:function win32-getpeername ("getpeername" int
129                          (socket int)
130                          (her-addr (* t)) ; KLUDGE: sockaddr-in or sockaddr-un?
131                          (addrlen socklen-t :in-out)))
132
133  (:function win32-getsockname ("getsockname" int
134                          (socket int)
135                          (my-addr (* t)) ; KLUDGE: sockaddr-in or sockaddr-un?
136                          (addrlen socklen-t :in-out)))
137
138  (:function win32-connect ("connect" int
139                            (socket int)
140                            (his-addr (* t)) ; KLUDGE: sockaddr-in or sockaddr-un?
141                            (addrlen socklen-t)))
142
143  (:function win32-close ("closesocket" int
144                          (fd int)))
145
146  (:function win32-recvfrom ("recvfrom" ssize-t
147                             (socket int)
148                             (buf (* t))
149                             (len integer)
150                             (flags int)
151                             (sockaddr (* t)) ; KLUDGE: sockaddr-in or sockaddr-un?
152                             (socklen (* socklen-t))))
153
154  (:function win32-recv ("recv" int
155                         (socket int)
156                         (buf (* t))
157                         (len integer)
158                         (flags integer)))
159
160  (:function win32-send ("send" ssize-t
161                         (socket int)
162                         (buf (* t))
163                         (len size-t)
164                         (flags int)))
165
166  (:function win32-sendto ("sendto" int
167                           (socket int)
168                           (buf (* t))
169                           (len size-t)
170                           (flags int)
171                           (sockaddr (* t)) ; KLUDGE: sockaddr-in or sockaddr-un?
172                           (socklen socklen-t)))
173
174  (:function gethostbyname ("gethostbyname" (* hostent) (name c-string)))
175
176  (:function gethostbyaddr ("gethostbyaddr" (* hostent)
177                                            (addr (* t))
178                                            (len int)
179                                            (af int)))
180
181 ;;; should be using getaddrinfo instead?
182
183  (:function win32-setsockopt ("setsockopt" int
184                         (socket int)
185                         (level int)
186                         (optname int)
187                         (optval (* t))
188                         (optlen int))) ;;; should be socklen-t!
189
190  (:function win32-getsockopt ("getsockopt" int
191                         (socket int)
192                         (level int)
193                         (optname int)
194                         (optval (* t))
195                         (optlen int :in-out))) ;;; should be socklen-t!
196
197  (:function win32-ioctl ("ioctlsocket"  int
198                          (socket int)
199                          (cmd int)
200                          (argp (unsigned 32) :in-out)))
201
202
203 ;;; Win32 specific cruft
204  (:function wsa-socket ("WSASocketA" int
205                         (af int)
206                         (type int)
207                         (protocol int)
208                         (lpProtocolInfo (* t))
209                         (g int)
210                         (flags int)))
211
212  (:function fd->handle ("_get_osfhandle" int
213                         (fd int)))
214
215  (:function handle->fd ("_open_osfhandle" int
216                         (osfhandle int)
217                         (flags int)))
218
219  (:structure wsa-data ("struct WSAData"
220                        (integer version "u_int16_t" "wVersion")
221                        (integer high-version "u_int16_t" "wHighVersion")
222                        (c-string description "char" "szDescription")
223                        (c-string system-status "char" "szSystemStatus")
224                        (integer max-sockets "unsigned short" "iMaxSockets")
225                        (integer max-udp-dg "unsigned short" "iMaxUdpDg")
226                        (c-string-pointer vendor-info "char *" "lpVendorInfo")))
227
228  (:function wsa-startup ("WSAStartup" int
229                         (wVersionRequested (unsigned 16))
230                         (lpWSAData wsa-data :out)))
231
232  (:function wsa-get-last-error ("WSAGetLastError" int))
233
234 )