Fix sb-bsd-sockets on windows.
[sbcl.git] / contrib / sb-bsd-sockets / win32-constants.lisp
blobc3a63f6230c93b1e77e1ab6059ee4908ad77d8c1
1 ;;; -*- Lisp -*-
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
6 ;;; first, the headers necessary to find definitions of everything
7 ("winsock2.h")
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.")
23 (:integer sol-socket "SOL_SOCKET")
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")
47 (:integer tcp-nodelay "TCP_NODELAY")
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.")
55 (:integer msg-oob "MSG_OOB")
56 (:integer msg-peek "MSG_PEEK")
57 (:integer msg-dontroute "MSG_DONTROUTE")
59 ;; socket shutdown flags
60 (:integer SHUT_RD "SD_RECEIVE")
61 (:integer SHUT_WR "SD_SEND")
62 (:integer SHUT_RDWR "SD_BOTH")
64 ;; errors
65 (:integer EADDRINUSE "WSAEADDRINUSE")
66 (:integer EAGAIN "WSAEWOULDBLOCK")
67 (:integer EBADF "WSAEBADF")
68 (:integer ECONNREFUSED "WSAECONNREFUSED")
69 (:integer ETIMEDOUT "WSAETIMEDOUT")
70 (:integer EINTR "WSAEINTR")
71 (:integer EINVAL "WSAEINVAL")
72 (:integer ENOBUFS "WSAENOBUFS")
73 (:integer ENOMEM "WSAENOBUFS")
74 (:integer EOPNOTSUPP "WSAEOPNOTSUPP")
75 (:integer EPERM "WSAENETDOWN")
76 (:integer EPROTONOSUPPORT "WSAEPROTONOSUPPORT")
77 (:integer ESOCKTNOSUPPORT "WSAESOCKTNOSUPPORT")
78 (:integer ENETUNREACH "WSAENETUNREACH")
79 (:integer ENOTCONN "WSAENOTCONN")
80 (:integer inaddr-any "INADDR_ANY")
81 (:integer FIONBIO "FIONBIO")
84 ;; for socket-receive
85 (:type socklen-t "int")
87 (:structure in-addr ("struct in_addr"
88 ((array (unsigned 8)) addr "u_int32_t" "s_addr")))
90 (:structure sockaddr-in ("struct sockaddr_in"
91 (integer family "sa_family_t" "sin_family")
92 ;; These two could be in-port-t and
93 ;; in-addr-t, but then we'd throw away the
94 ;; convenience (and byte-order agnosticism)
95 ;; of the old sb-grovel scheme.
96 ((array (unsigned 8)) port "u_int16_t" "sin_port")
97 ((array (unsigned 8)) addr "struct in_addr" "sin_addr")))
99 (:structure hostent ("struct hostent"
100 (c-string-pointer name "char *" "h_name")
101 ((* c-string) aliases "char **" "h_aliases")
102 (integer type "int" "h_addrtype")
103 (integer length "int" "h_length")
104 ((* (* (unsigned 8))) addresses "char **" "h_addr_list")))
106 (:structure protoent ("struct protoent"
107 (c-string-pointer name "char *" "p_name")
108 ((* (* t)) aliases "char **" "p_aliases")
109 (integer proto "int" "p_proto")))
111 (:function getprotobyname ("getprotobyname" (* protoent)
112 (name c-string)))
114 (:function getprotobynumber ("getprotobynumber" (* protoent)
115 (proto int)))
117 ;; FIXME: We should probably grovel the windows SOCKET type and use it in
118 ;; these instead of int...
120 ;; KLUDGE: For historical reasons many of these prepend win32- to the symbol
121 ;; names. Life for Windows users of SBCL is already hard enough, so rather
122 ;; than break compatibility for those who directly use these, win32-sockets.lisp
123 ;; wraps them with prefixless wrappers.
124 (:function win32-bind
125 ("bind" int
126 (sockfd int)
127 (my-addr (* t)) ; KLUDGE: sockaddr-in or sockaddr-un?
128 (addrlen socklen-t)))
130 (:function win32-listen ("listen" int
131 (socket int)
132 (backlog int)))
134 (:function win32-accept ("accept" int
135 (socket int)
136 (my-addr (* t)) ; KLUDGE: sockaddr-in or sockaddr-un?
137 (addrlen int :in-out)))
139 (:function win32-getpeername ("getpeername" int
140 (socket int)
141 (her-addr (* t)) ; KLUDGE: sockaddr-in or sockaddr-un?
142 (addrlen socklen-t :in-out)))
144 (:function win32-getsockname ("getsockname" int
145 (socket int)
146 (my-addr (* t)) ; KLUDGE: sockaddr-in or sockaddr-un?
147 (addrlen socklen-t :in-out)))
149 (:function win32-connect ("connect" int
150 (socket int)
151 (his-addr (* t)) ; KLUDGE: sockaddr-in or sockaddr-un?
152 (addrlen socklen-t)))
154 (:function win32-close ("closesocket" int
155 (fd int)))
157 (:function shutdown ("shutdown" int
158 (socket int) ; KLUDGE: should be SOCKET, not int.
159 (how int)))
161 (:function win32-recvfrom ("recvfrom" int
162 (socket int)
163 (buf (* t))
164 (len integer)
165 (flags int)
166 (sockaddr (* t)) ; KLUDGE: sockaddr-in or sockaddr-un?
167 (socklen (* socklen-t))))
169 (:function win32-recv ("recv" int
170 (socket int)
171 (buf (* t))
172 (len integer)
173 (flags integer)))
175 (:function win32-send ("send" int
176 (socket int)
177 (buf (* t))
178 (len int)
179 (flags int)))
181 (:function win32-sendto ("sendto" int
182 (socket int)
183 (buf (* t))
184 (len int)
185 (flags int)
186 (sockaddr (* t)) ; KLUDGE: sockaddr-in or sockaddr-un?
187 (socklen socklen-t)))
189 (:function gethostbyname ("gethostbyname" (* hostent) (name c-string)))
191 (:function gethostbyaddr ("gethostbyaddr" (* hostent)
192 (addr (* t))
193 (len int)
194 (af int)))
196 ;;; should be using getaddrinfo instead?
198 (:function win32-setsockopt ("setsockopt" int
199 (socket int)
200 (level int)
201 (optname int)
202 (optval (* t))
203 (optlen int))) ;;; should be socklen-t!
205 (:function win32-getsockopt ("getsockopt" int
206 (socket int)
207 (level int)
208 (optname int)
209 (optval (* t))
210 (optlen int :in-out))) ;;; should be socklen-t!
212 (:function win32-ioctl ("ioctlsocket" int
213 (socket int)
214 (cmd int)
215 (argp (unsigned 32) :in-out)))
218 ;;; Win32 specific cruft
219 (:function wsa-socket ("WSASocketA" int
220 (af int)
221 (type int)
222 (protocol int)
223 (lpProtocolInfo (* t))
224 (g int)
225 (flags int)))
227 (:function fd->handle ("_get_osfhandle" int
228 (fd int)))
230 (:function handle->fd ("_open_osfhandle" int
231 (osfhandle int)
232 (flags int)))
234 (:structure wsa-data ("struct WSAData"
235 (integer version "u_int16_t" "wVersion")
236 (integer high-version "u_int16_t" "wHighVersion")
237 (c-string description "char" "szDescription")
238 (c-string system-status "char" "szSystemStatus")
239 (integer max-sockets "unsigned short" "iMaxSockets")
240 (integer max-udp-dg "unsigned short" "iMaxUdpDg")
241 (c-string-pointer vendor-info "char *" "lpVendorInfo")))
243 (:function wsa-startup ("WSAStartup" int
244 (wVersionRequested (unsigned 16))
245 (lpWSAData wsa-data :out)))
247 (:function wsa-get-last-error ("WSAGetLastError" int))
248 (:integer IPPROTO_IP "IPPROTO_IP")
249 (:integer IPPROTO_IPV6 "IPPROTO_IPV6")
250 (:integer IPPROTO_ICMP "IPPROTO_ICMP")
251 (:integer IPPROTO_IGMP "IPPROTO_IGMP")
252 (:integer IPPROTO_TCP "IPPROTO_TCP")
253 (:integer IPPROTO_UDP "IPPROTO_UDP")
254 (:integer IPPROTO_RAW "IPPROTO_RAW"))