Windows port. Lots of rough edges, passes the most important tests.
[iolib.git] / sockets / grovel.lisp
blobe93fd0077c862c6809e9428a329f5af6c0087b1b
1 ;;;; -*- Mode: lisp; indent-tabs-mode: nil -*-
2 ;;;
3 ;;; grovel.lisp --- Grovelling for socket constants and types.
4 ;;;
5 ;;; Copyright (C) 2005-2006, Matthew Backes <lucca@accela.net>
6 ;;; Copyright (C) 2005-2006, Dan Knapp <dankna@accela.net>
7 ;;; Copyright (C) 2007, Stelian Ionescu <stelian.ionescu-zeus@poste.it>
8 ;;; Copyright (C) 2007, Luis Oliveira <loliveira@common-lisp.net>
9 ;;;
10 ;;; Permission is hereby granted, free of charge, to any person
11 ;;; obtaining a copy of this software and associated documentation
12 ;;; files (the "Software"), to deal in the Software without
13 ;;; restriction, including without limitation the rights to use, copy,
14 ;;; modify, merge, publish, distribute, sublicense, and/or sell copies
15 ;;; of the Software, and to permit persons to whom the Software is
16 ;;; furnished to do so, subject to the following conditions:
17 ;;;
18 ;;; The above copyright notice and this permission notice shall be
19 ;;; included in all copies or substantial portions of the Software.
20 ;;;
21 ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 ;;; DEALINGS IN THE SOFTWARE.
30 ;;; This file contains a lot of unused types and constants that should
31 ;;; be cleaned up or at least commented out.
33 #-windows
34 (include "sys/socket.h" "sys/un.h" "netinet/in.h" "netinet/in_systm.h"
35 "netinet/ip.h" "net/if.h" "netinet/tcp.h" "netdb.h" "errno.h"
36 "arpa/inet.h")
38 #+windows (include "Winsock2.h" "Ws2tcpip.h")
40 (in-package #:bsd-sockets)
42 ;;; TODO: check if I didn't miss any from CL-POSIX. --luis
43 (constantenum socket-error-values
44 ((:eprotonosupport "EPROTONOSUPPORT" "WSAEPROTONOSUPPORT"))
45 ((:esocktnosupport "ESOCKTNOSUPPORT" "WSAESOCKTNOSUPPORT"))
46 ((:enotsock "ENOTSOCK" "WSAENOTSOCK"))
47 ((:edestaddrreq "EDESTADDRREQ" "WSAEDESTADDRREQ"))
48 ((:emsgsize "EMSGSIZE" "WSAEMSGSIZE"))
49 ((:eprototype "EPROTOTYPE" "WSAEPROTOTYPE"))
50 ((:enoprotoopt "ENOPROTOOPT" "WSAENOPROTOOPT"))
51 ((:eremote "EREMOTE" "WSAEREMOTE"))
52 #-windows ((:enolink "ENOLINK"))
53 ((:epfnosupport "EPFNOSUPPORT" "WSAEPFNOSUPPORT"))
54 ((:eafnosupport "EAFNOSUPPORT" "WSAEAFNOSUPPORT"))
55 ((:eaddrinuse "EADDRINUSE" "WSAEADDRINUSE"))
56 ((:eaddrnotavail "EADDRNOTAVAIL" "WSAEADDRNOTAVAIL"))
57 ((:enetdown "ENETDOWN" "WSAENETDOWN"))
58 ((:enetunreach "ENETUNREACH" "WSAENETUNREACH"))
59 ((:enetreset "ENETRESET" "WSAENETRESET"))
60 ((:econnaborted "ECONNABORTED" "WSAECONNABORTED"))
61 ((:econnreset "ECONNRESET" "WSAECONNRESET"))
62 ((:eisconn "EISCONN" "WSAEISCONN"))
63 ((:enotconn "ENOTCONN" "WSAENOTCONN"))
64 ((:eshutdown "ESHUTDOWN" "WSAESHUTDOWN"))
65 ((:etoomanyrefs "ETOOMANYREFS" "WSAETOOMANYREFS"))
66 ((:etimedout "ETIMEDOUT" "WSAETIMEDOUT"))
67 ((:econnrefused "ECONNREFUSED" "WSAECONNREFUSED"))
68 ((:ehostdown "EHOSTDOWN" "WSAEHOSTDOWN"))
69 ((:ehostunreach "EHOSTUNREACH" "WSAEHOSTUNREACH"))
70 ((:enonet "ENONET") :optional t)
71 ((:enobufs "ENOBUFS" "WSAENOBUFS"))
72 ((:eopnotsupp "EOPNOTSUPP" "WSAEOPNOTSUPP"))
73 ;; The following are here because of Winsock only and I'm not 100%
74 ;; if they are correct. TODO: check these. So, for portability, we
75 ;; probably really want to define here every possibly error even if
76 ;; they are repeated from CL-POSIX otherwise we'll be generating
77 ;; different conditions (POSIX-ERROR vs. SOCKET-ERROR) on different
78 ;; platforms.
79 ((:eagain "EAGAIN" "WSAEWOULDBLOCK")) ; is this right?
80 ((:ebadf "EBADF" "WSAEBADF"))
81 ((:eintr "EINTR" "WSAEINTR"))
82 ((:einval "EINVAL" "WSAEINVAL"))
83 ((:enomem "ENOMEM" "WSAENOBUFS"))
84 ((:eacces "EACCES" "WSAEACCES"))
85 ((:efault "EFAULT" "WSAEFAULT"))
86 ((:emfile "EMFILE" "WSAEMFILE"))
87 ((:einprogress "EINPROGRESS" "WSAEINPROGRESS"))
88 ((:ealready "EALREADY" "WSAEALREADY"))
89 ((:eloop "ELOOP" "WSAELOOP"))
90 ((:enametoolong "ENAMETOOLONG" "WSAENAMETOOLONG"))
91 ((:enotempty "ENOTEMPTY" "WSAENOTEMPTY"))
92 ((:eusers "EUSERS" "WSAEUSERS"))
93 ((:edquot "EDQUOT" "WSAEDQUOT"))
94 ((:estale "ESTALE" "WSAESTALE"))
95 #+windows ((:eproclim "WSAEPROCLIM"))
96 #+windows ((:ediscon "WSAEDISCON"))
97 #+windows ((:enomre "WSAENOMORE"))
98 #+windows ((:ecancelled "WSAECANCELLED"))
99 #+windows ((:einvalidproctable "WSAEINVALIDPROCTABLE"))
100 #+windows ((:einvalidprovider "WSAEINVALIDPROVIDER"))
101 #+windows ((:eproviderfailedinit "WSAEPROVIDERFAILEDINIT"))
102 #+windows ((:erefused "WSAEREFUSED")))
104 ;;;; sys/socket.h
106 (ctype socklen "socklen_t")
107 (ctype sa-family #-windows "sa_family_t" #+windows "short")
109 ;;; socket() - socket address family
110 (constant (af-unspec "AF_UNSPEC" "PF_UNSPEC"))
111 (constant (af-inet "AF_INET" "PF_INET") :documentation "IPv4 Protocol family")
112 (constant (af-inet6 "AF_INET6" "PF_INET6")
113 :documentation "IPv6 Protocol family")
114 (constant (af-local "AF_UNIX" "AF_LOCAL" "PF_UNIX" "PF_LOCAL")
115 :documentation "File domain sockets")
116 (constant (af-packet "AF_PACKET" "PF_PACKET") :documentation "Raw packet access"
117 :optional t)
118 (constant (af-route "AF_ROUTE" "PF_ROUTE")
119 :documentation "Routing sockets" :optional t)
120 #-windows (constant (af-key "AF_KEY" "PF_KEY"))
121 (constant (af-netlink "AF_NETLINK" "PF_NETLINK")
122 :documentation "Linux Netlink sockets" :optional t)
124 ;;; socket() - socket type
125 (constant (sock-stream "SOCK_STREAM") :documentation "TCP")
126 (constant (sock-dgram "SOCK_DGRAM") :documentation "UDP")
127 (constant (sock-seqpacket "SOCK_SEQPACKET")
128 :documentation "Reliable Sequenced Datagram Protocol" :optional t)
129 (constant (sock-raw "SOCK_RAW") :documentation "Raw protocol access"
130 :optional t)
131 (constant (sock-rdm "SOCK_RDM")
132 :documentation "Reliable Unordered Datagram Protocol" :optional t)
134 ;;; socket() - socket protocol
135 (constant (ipproto-ip "IPPROTO_IP"))
136 (constant (ipproto-ipv6 "IPPROTO_IPV6"))
137 (constant (ipproto-icmp "IPPROTO_ICMP"))
138 (constant (ipproto-icmpv6 "IPPROTO_ICMPV6"))
139 (constant (ipproto-raw "IPPROTO_RAW"))
140 (constant (ipproto-tcp "IPPROTO_TCP"))
141 (constant (ipproto-udp "IPPROTO_UDP"))
142 #-(or windows darwin) (constant (ipproto-sctp "IPPROTO_SCTP"))
144 (cstruct sockaddr "struct sockaddr"
145 (family "sa_family" :type #-windows sa-family #+windows :ushort))
147 (cstruct sockaddr-storage "struct sockaddr_storage"
148 (family "ss_family" :type sa-family))
150 (cstruct hostent "struct hostent"
151 (name "h_name" :type :string)
152 (aliases "h_aliases" :type :pointer)
153 (type "h_addrtype" :type :int)
154 (length "h_length" :type :int)
155 (addresses "h_addr_list" :type :pointer))
157 (cstruct servent "struct servent"
158 (name "s_name" :type :string)
159 (aliases "s_aliases" :type :pointer)
160 (port "s_port" :type :int)
161 (proto "s_proto" :type :string))
163 (constant (somaxconn "SOMAXCONN")
164 :documentation "Maximum listen() queue length")
166 (constant (sol-socket "SOL_SOCKET")
167 :documentation "get/setsockopt socket level constant.")
169 #+linux
170 (progn
171 (constant (sol-tcp "SOL_TCP")
172 :documentation "get/setsockopt TCP level constant.")
173 (constant (sol-ip "SOL_IP")
174 :documentation "get/setsockopt IP level constant.")
175 (constant (sol-raw "SOL_RAW")
176 :documentation "get/setsockopt raw level constant."))
178 ;;; getsockopt/setsockopt()
179 (constant (so-acceptconn "SO_ACCEPTCONN"))
180 (constant (so-acceptfilter "SO_ACCEPTFILTER") :optional t) ; freebsd
181 (constant (so-bindtodevice "SO_BINDTODEVICE") :optional t) ; linux
182 (constant (so-bintime "SO_BINTIME") :optional t) ; freebsd
183 (constant (so-broadcast "SO_BROADCAST"))
184 (constant (so-bsdcompat "SO_BSDCOMPAT") :optional t) ; linux
185 (constant (so-debug "SO_DEBUG"))
186 (constant (so-dontroute "SO_DONTROUTE"))
187 (constant (so-error "SO_ERROR"))
188 (constant (so-keepalive "SO_KEEPALIVE"))
189 (constant (so-label "SO_LABEL") :optional t) ; freebsd
190 (constant (so-linger "SO_LINGER"))
191 (constant (so-listenincqlen "SO_LISTENINCQLEN") :optional t) ; freebsd
192 (constant (so-listenqlen "SO_LISTENQLEN") :optional t) ; freebsd
193 (constant (so-listenqlimit "SO_LISTENQLIMIT") :optional t) ; freebsd
194 (constant (so-nosigpipe "SO_NOSIGPIPE") :optional t) ; freebsd
195 (constant (so-oobinline "SO_OOBINLINE"))
196 (constant (so-passcred "SO_PASSCRED") :optional t) ; linux
197 (constant (so-peercred "SO_PEERCRED") :optional t) ; linux
198 (constant (so-peerlabel "SO_PEERLABEL") :optional t) ; freebsd
199 (constant (so-priority "SO_PRIORITY") :optional t) ; linux
200 (constant (so-rcvbuf "SO_RCVBUF"))
201 (constant (so-rcvlowat "SO_RCVLOWAT"))
202 (constant (so-rcvtimeo "SO_RCVTIMEO"))
203 (constant (so-reuseaddr "SO_REUSEADDR"))
204 (constant (so-reuseport "SO_REUSEPORT") :optional t) ; freebsd
205 (constant (so-sndbuf "SO_SNDBUF"))
206 (constant (so-sndlowat "SO_SNDLOWAT"))
207 (constant (so-sndtimeo "SO_SNDTIMEO"))
208 #-windows (constant (so-timestamp "SO_TIMESTAMP"))
209 (constant (so-type "SO_TYPE"))
210 (constant (so-useloopback "SO_USELOOPBACK") :optional t) ; freebsd
211 (constant (tcp-cork "TCP_CORK") :optional t) ; linux
212 (constant (tcp-defer-accept "TCP_DEFER_ACCEPT") :optional t) ; linux
213 (constant (tcp-info "TCP_INFO") :optional t) ; linux
214 (constant (tcp-keepcnt "TCP_KEEPCNT") :optional t) ; linux
215 (constant (tcp-keepidle "TCP_KEEPIDLE") :optional t) ; linux
216 (constant (tcp-keepintvl "TCP_KEEPINTVL") :optional t) ; linux
217 (constant (tcp-linger2 "TCP_LINGER2") :optional t) ; linux
218 (constant (tcp-maxseg "TCP_MAXSEG") :optional t) ; linux, freebsd
219 (constant (tcp-nodelay "TCP_NODELAY") :optional t) ; linux, freebsd
220 (constant (tcp-noopt "TCP_NOOPT") :optional t) ; freebsd
221 (constant (tcp-nopush "TCP_NOPUSH") :optional t) ; freebsd
222 (constant (tcp-quickack "TCP_QUICKACK") :optional t) ; linux
223 (constant (tcp-syncnt "TCP_SYNCNT") :optional t) ; linux
224 (constant (tcp-window "TCP_WINDOW") :optional t) ; linux
226 ;;; shutdown()
227 (constant (shut-rd "SHUT_RD" "SD_RECEIVE"))
228 (constant (shut-wr "SHUT_WR" "SD_SEND"))
229 (constant (shut-rdwr "SHUT_RDWR" "SD_BOTH"))
231 ;;; recvmsg/sendmsg()
232 (constant (msg-dontroute "MSG_DONTROUTE")) ; sendmsg
233 (constant (msg-oob "MSG_OOB")) ; recvmsg sendmsg
234 (constant (msg-peek "MSG_PEEK")) ; recvmsg
235 (constant (msg-errqueue "MSG_ERRQUEUE") :optional t) ; recvmsg
236 (constant (msg-more "MSG_MORE") :optional t) ; sendmsg
237 (constant (msg-confirm "MSG_CONFIRM") :optional t) ; sendmsg sendmsg
238 (constant (msg-proxy "MSG_PROXY") :optional t) ;
239 (constant (msg-fin "MSG_FIN") :optional t) ;
240 (constant (msg-syn "MSG_SYN") :optional t) ;
241 (constant (msg-eof "MSG_EOF") :optional t) ;
242 (constant (msg-nbio "MSG_NBIO") :optional t) ;
243 (constant (msg-compat "MSG_COMPAT") :optional t) ;
244 #-windows
245 (progn
246 (constant (msg-trunc "MSG_TRUNC")) ; recvmsg
247 (constant (msg-waitall "MSG_WAITALL")) ; recvmsg
248 (constant (msg-dontwait "MSG_DONTWAIT")) ; recvmsg sendmsg
249 #-darwin (constant (msg-nosignal "MSG_NOSIGNAL")) ; sendmsg
250 (constant (msg-eor "MSG_EOR")) ; recvmsg sendmsg
251 (constant (msg-ctrunc "MSG_CTRUNC"))) ; recvmsg
253 #-(and) ; unused
254 (cstruct msghdr "struct msghdr"
255 (name "msg_name" :type :pointer)
256 (namelen "msg_namelen" :type socklen)
257 (iov "msg_iov" :type :pointer)
258 (iovlen "msg_iovlen" :type size)
259 (control "msg_control" :type :pointer)
260 (controllen "msg_controllen" :type socklen)
261 (flags "msg_flags" :type :int))
263 #-(and) ; unused
264 (cstruct cmsghdr "struct cmsghdr"
265 (len "cmsg_len" :type socklen)
266 (level "cmsg_level" :type :int)
267 (type "cmsg_type" :type :int))
269 #-(and) ; unused
270 (constant (cmgroup-max "CMGROUP_MAX") :optional t)
272 #+(or (or) freebsd) ; unused
273 (cstruct cmsgcred "struct cmsgcred"
274 (pid "cmcred_pid" :type pid)
275 (uid "cmcred_uid" :type uid)
276 (euid "cmcred_euid" :type uid)
277 (gid "cmcred_gid" :type gid)
278 (ngroups "cmcred_ngroups" :type :short)
279 (groups "cmcred_groups" :type gid :count :auto))
281 #-(and) ; unused
282 (constant (scm-rights "SCM_RIGHTS"))
283 (constant (scm-credentials "SCM_CREDENTIALS") :optional t)
285 #+linux
286 (cstruct ucred "struct ucred"
287 "Socket credential messages."
288 (pid "pid" :type pid)
289 (uid "uid" :type uid)
290 (gid "gid" :type gid))
292 #+freebsd
293 (cstruct sockcred "struct sockcred"
294 (uid "sc_uid" :type uid)
295 (euid "sc_euid" :type uid)
296 (gid "sc_gid" :type gid)
297 (egid "sc_egid" :type gid)
298 (ngroups "sc_ngroups" :type :int)
299 (groups "sc_groups" :type gid :count :auto))
301 (cstruct linger "struct linger"
302 "SO_LINGER manipulation record."
303 (onoff "l_onoff" :type :int)
304 (linger "l_linger" :type :int))
306 #+freebsd
307 (cstruct accept-filter-arg "struct accept_filter_arg"
308 (name "af_name" :type :uint8 :count :auto)
309 (arg "af_arg" :type :uint8 :count :auto))
311 ;;;; from sys/un.h
313 #-windows
314 (cstruct sockaddr-un "struct sockaddr_un"
315 "A UNIX-domain socket address."
316 (family "sun_family" :type sa-family)
317 (path "sun_path" :type :uint8 :count :auto))
319 #+freebsd
320 (progn
321 (constant (local-peercred "LOCAL_PEERCRED"))
322 (constant (local-creds "LOCAL_CREDS"))
323 (constant (local-connwait "LOCAL_CONNWAIT")))
325 ;;;; from netinet/in.h
327 (ctype in-port #-windows "in_port_t" #+windows "u_short")
328 (ctype in-addr #-windows "in_addr_t" #+windows "u_long")
330 (cstruct sockaddr-in "struct sockaddr_in"
331 "An IPv4 socket address."
332 (family "sin_family" :type sa-family)
333 (port "sin_port" :type in-port)
334 (addr "sin_addr" :type in-addr))
336 (cstruct in-addr-struct "struct in_addr"
337 (addr "s_addr" :type :uint32))
339 (cunion in6-addr "struct in6_addr"
340 "An IPv6 address."
341 (addr8 "s6_addr" :type :uint8 :count :auto)
342 (addr16 "s6_addr16" :type :uint16 :count :auto)
343 (addr32 "s6_addr32" :type :uint32 :count :auto))
345 (cstruct sockaddr-in6 "struct sockaddr_in6"
346 "An IPv6 socket address."
347 (family "sin6_family" :type sa-family)
348 (port "sin6_port" :type in-port)
349 (flowinfo "sin6_flowinfo" :type :uint32)
350 (addr "sin6_addr" :type in6-addr)
351 (scope-id "sin6_scope_id" :type :uint32))
353 #-(and) ; unused
354 (progn
355 (constant (inaddr-any "INADDR_ANY"))
356 (constant (inaddr-broadcast "INADDR_BROADCAST"))
357 (constant (inaddr-none "INADDR_NONE"))
358 (constant (in-loopbacknet "IN_LOOPBACKNET"))
359 (constant (inaddr-loopback "INADDR_LOOPBACK"))
360 (constant (inaddr-unspec-group "INADDR_UNSPEC_GROUP"))
361 (constant (inaddr-allhosts-group "INADDR_ALLHOSTS_GROUP"))
362 (constant (inaddr-allrtrs-group "INADDR_ALLRTRS_GROUP"))
363 (constant (inaddr-max-local-group "INADDR_MAX_LOCAL_GROUP")))
365 (constant (inet-addrstrlen "INET_ADDRSTRLEN"))
366 (constant (inet6-addrstrlen "INET6_ADDRSTRLEN"))
368 (constant (ipv6-join-group "IPV6_JOIN_GROUP"))
369 (constant (ipv6-leave-group "IPV6_LEAVE_GROUP"))
370 (constant (ipv6-multicast-hops "IPV6_MULTICAST_HOPS"))
371 (constant (ipv6-multicast-if "IPV6_MULTICAST_IF"))
372 (constant (ipv6-multicast-loop "IPV6_MULTICAST_LOOP"))
373 (constant (ipv6-unicast-hops "IPV6_UNICAST_HOPS"))
374 #-windows (constant (ipv6-v6only "IPV6_V6ONLY"))
376 ;;;; from netinet/tcp.h
378 (constant (tcp-nodelay "TCP_NODELAY"))
379 #-windows (constant (tcp-maxseg "TCP_MAXSEG"))
380 #+linux
381 (constant (tcp-cork "TCP_CORK"))
382 (constant (tcp-keepidle "TCP_KEEPIDLE") :optional t)
383 (constant (tcp-keepintvl "TCP_KEEPINTVL") :optional t)
384 (constant (tcp-keepcnt "TCP_KEEPCNT") :optional t)
385 (constant (tcp-syncnt "TCP_SYNCNT") :optional t)
386 (constant (tcp-linger2 "TCP_LINGER2") :optional t)
387 (constant (tcp-defer-accept "TCP_DEFER_ACCEPT") :optional t)
388 (constant (tcp-window-clamp "TCP_WINDOW_CLAMP") :optional t)
389 #-(or windows darwin) (constant (tcp-info "TCP_INFO"))
390 (constant (tcp-quickack "TCP_QUICKACK") :optional t)
392 #+linux
393 (cenum connstates
394 ((:tcp-established "TCP_ESTABLISHED"))
395 ((:tcp-syn-sent "TCP_SYN_SENT"))
396 ((:tcp-syn-recv "TCP_SYN_RECV"))
397 ((:tcp-fin-wait1 "TCP_FIN_WAIT1"))
398 ((:tcp-fin-wait2 "TCP_FIN_WAIT2"))
399 ((:tcp-time-wait "TCP_TIME_WAIT"))
400 ((:tcp-close "TCP_CLOSE"))
401 ((:tcp-close-wait "TCP_CLOSE_WAIT"))
402 ((:tcp-last-ack "TCP_LAST_ACK"))
403 ((:tcp-listen "TCP_LISTEN"))
404 ((:tcp-closing "TCP_CLOSING")))
406 ;;;; from netdb.h
408 (constant (ipport-reserved "IPPORT_RESERVED"))
410 (cstruct addrinfo "struct addrinfo"
411 (flags "ai_flags" :type :int)
412 (family "ai_family" :type :int)
413 (socktype "ai_socktype" :type :int)
414 (protocol "ai_protocol" :type :int)
415 (addrlen "ai_addrlen" :type socklen)
416 (addr "ai_addr" :type :pointer)
417 (canonname "ai_canonname" :type :pointer)
418 (next "ai_next" :type :pointer))
420 ;;; addrinfo flags
421 (constant (ai-passive "AI_PASSIVE"))
422 (constant (ai-canonname "AI_CANONNAME"))
423 (constant (ai-numerichost "AI_NUMERICHOST"))
424 #-(or windows darwin) (constant (ai-numericserv "AI_NUMERICSERV"))
425 #-windows (constant (ai-v4mapped "AI_V4MAPPED"))
426 (constant (ai-v4mapped-cfg "AI_V4MAPPED_CFG") :optional t) ; freebsd
427 #-windows (constant (ai-all "AI_ALL"))
428 #-windows (constant (ai-addrconfig "AI_ADDRCONFIG"))
430 (constant (ni-maxhost "NI_MAXHOST"))
431 (constant (ni-maxserv "NI_MAXSERV"))
433 ;;; nameinfo flags
434 (constant (ni-nofqdn "NI_NOFQDN"))
435 (constant (ni-numerichost "NI_NUMERICHOST"))
436 (constant (ni-namereqd "NI_NAMEREQD"))
437 (constant (ni-numericserv "NI_NUMERICSERV"))
438 (constant (ni-numericscope "NI_NUMERICSCOPE") :optional t)
439 (constant (ni-dgram "NI_DGRAM"))
441 ;;; error codes
442 #-windows (constant (netdb-success "NETDB_SUCCESS"))
443 #-windows (constant (netdb-internal "NETDB_INTERNAL"))
445 (constantenum addrinfo-errors
446 #-windows ((:netdb-success "NETDB_SUCCESS"))
447 ((:eai-addrfamily "EAI_ADDRFAMILY") :optional t) ; linux
448 ((:eai-again "EAI_AGAIN"))
449 ((:eai-badflags "EAI_BADFLAGS"))
450 ((:eai-fail "EAI_FAIL"))
451 ((:eai-family "EAI_FAMILY"))
452 ((:eai-memory "EAI_MEMORY"))
453 ((:eai-noname "EAI_NONAME"))
454 ((:eai-nodata "EAI_NODATA") :optional t) ; linux
455 ((:eai-service "EAI_SERVICE"))
456 ((:eai-socktype "EAI_SOCKTYPE"))
457 ((:eai-system "EAI_SYSTEM" #+windows "EAI_FAIL"))
458 ((:eai-badhints "EAI_BADHINTS") :optional t) ; freebsd
459 ((:eai-protocol "EAI_PROTOCOL") :optional t) ; freebsd
460 ((:eai-max "EAI_MAX") :optional t) ; freebsd
461 ((:eai-overflow "EAI_OVERFLOW") :optional t)) ; linux
463 (cstruct protoent "struct protoent"
464 (name "p_name" :type :string)
465 (aliases "p_aliases" :type :pointer)
466 (proto "p_proto" :type :int))
468 ;;;; from net/if.h
470 ;;; On windows platforms, this is only supported on Vista and later.
471 #-windows
472 (progn
473 (cstruct if-nameindex "struct if_nameindex"
474 (index "if_index" :type :unsigned-int)
475 (name "if_name" :type :string))
477 (constant (ifnamesize "IF_NAMESIZE"))
478 (constant (ifnamsiz "IFNAMSIZ")))