0b80a64ab4dda0a0c128b0a7239993cbea1f63d2
[sbcl.git] / contrib / sb-bsd-sockets / 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 ("sys/types.h" "sys/socket.h" "sys/stat.h" "unistd.h" "sys/un.h"
8  "netinet/in.h" "netinet/in_systm.h" "netinet/ip.h" "net/if.h"
9  "netdb.h" "errno.h" "netinet/tcp.h" "fcntl.h" )
10
11 ;;; then the stuff we're looking for
12 ((:integer af-inet "AF_INET" "IP Protocol family")
13  (:integer af-unspec "AF_UNSPEC" "Unspecified")
14  (:integer af-local
15            #+(or sunos solaris) "AF_UNIX"
16            #-(or sunos solaris) "AF_LOCAL"
17            "Local to host (pipes and file-domain).")
18  #+linux (:integer af-inet6 "AF_INET6"   "IP version 6")
19  #+linux (:integer af-route "AF_NETLINK" "Alias to emulate 4.4BSD ")
20
21  (:integer sock-stream "SOCK_STREAM"
22            "Sequenced, reliable, connection-based byte streams.")
23  (:integer sock-dgram "SOCK_DGRAM"
24            "Connectionless, unreliable datagrams of fixed maximum length.")
25  (:integer sock-raw "SOCK_RAW"
26            "Raw protocol interface.")
27  (:integer sock-rdm "SOCK_RDM"
28            "Reliably-delivered messages.")
29  (:integer sock-seqpacket "SOCK_SEQPACKET"
30            "Sequenced, reliable, connection-based, datagrams of fixed maximum length.")
31
32  (:integer sol-socket "SOL_SOCKET")
33
34  ;; some of these may be linux-specific
35  (:integer so-debug "SO_DEBUG"
36    "Enable debugging in underlying protocol modules")
37  (:integer so-reuseaddr "SO_REUSEADDR" "Enable local address reuse")
38  (:integer so-type "SO_TYPE")                  ;get only
39  (:integer so-error "SO_ERROR")                 ;get only (also clears)
40  (:integer so-dontroute "SO_DONTROUTE"
41            "Bypass routing facilities: instead send direct to appropriate network interface for the network portion of the destination address")
42  (:integer so-broadcast "SO_BROADCAST" "Request permission to send broadcast datagrams")
43  (:integer so-sndbuf "SO_SNDBUF")
44 #+linux (:integer so-passcred "SO_PASSCRED")
45  (:integer so-rcvbuf "SO_RCVBUF")
46  (:integer so-keepalive "SO_KEEPALIVE"
47            "Send periodic keepalives: if peer does not respond, we get SIGPIPE")
48  (:integer so-oobinline "SO_OOBINLINE"
49            "Put out-of-band data into the normal input queue when received")
50  (:integer so-no-check "SO_NO_CHECK")
51 #+linux (:integer so-priority "SO_PRIORITY")
52  (:integer so-linger "SO_LINGER"
53            "For reliable streams, pause a while on closing when unsent messages are queued")
54 #+linux (:integer so-bsdcompat "SO_BSDCOMPAT")
55  (:integer so-sndlowat "SO_SNDLOWAT")
56  (:integer so-rcvlowat "SO_RCVLOWAT")
57  (:integer so-sndtimeo "SO_SNDTIMEO")
58  (:integer so-rcvtimeo "SO_RCVTIMEO")
59
60  (:integer tcp-nodelay "TCP_NODELAY")
61  #+linux (:integer so-bindtodevice "SO_BINDTODEVICE")
62  (:integer ifnamsiz "IFNAMSIZ")
63
64  (:integer EADDRINUSE "EADDRINUSE")
65  (:integer EAGAIN "EAGAIN")
66  (:integer EBADF "EBADF")
67  (:integer ECONNREFUSED "ECONNREFUSED")
68  (:integer ETIMEDOUT "ETIMEDOUT")
69  (:integer EINTR "EINTR")
70  (:integer EINVAL "EINVAL")
71  (:integer ENOBUFS "ENOBUFS")
72  (:integer ENOMEM "ENOMEM")
73  (:integer EOPNOTSUPP "EOPNOTSUPP")
74  (:integer EPERM "EPERM")
75  (:integer EPROTONOSUPPORT "EPROTONOSUPPORT")
76  (:integer ESOCKTNOSUPPORT "ESOCKTNOSUPPORT")
77  (:integer ENETUNREACH "ENETUNREACH")
78  (:integer ENOTCONN "ENOTCONN")
79
80  (:integer NETDB-INTERNAL "NETDB_INTERNAL" "See errno.")
81  (:integer NETDB-SUCCESS "NETDB_SUCCESS" "No problem.")
82  (:integer HOST-NOT-FOUND "HOST_NOT_FOUND" "Authoritative Answer Host not found.")
83  (:integer TRY-AGAIN "TRY_AGAIN" "Non-Authoritative Host not found, or SERVERFAIL.")
84  (:integer NO-RECOVERY "NO_RECOVERY" "Non recoverable errors, FORMERR, REFUSED, NOTIMP.")
85  (:integer NO-DATA "NO_DATA" "Valid name, no data record of requested type.")
86  (:integer NO-ADDRESS "NO_ADDRESS" "No address, look for MX record.")
87
88  (:integer O-NONBLOCK "O_NONBLOCK")
89  (:integer f-getfl "F_GETFL")
90  (:integer f-setfl "F_SETFL")
91
92  #+linux (:integer msg-nosignal "MSG_NOSIGNAL")
93  (:integer msg-oob "MSG_OOB")
94  (:integer msg-peek "MSG_PEEK")
95  (:integer msg-trunc "MSG_TRUNC")
96  (:integer msg-waitall "MSG_WAITALL")
97  (:integer msg-eor "MSG_EOR")
98  (:integer msg-dontroute "MSG_DONTROUTE")
99  (:integer msg-dontwait "MSG_DONTWAIT")
100  (:integer msg-nosignal "MSG_NOSIGNAL")
101 #+linux (:integer msg-confirm "MSG_CONFIRM")
102 #+linux (:integer msg-more "MSG_MORE")
103
104  ;; for socket-receive
105  (:type socklen-t "socklen_t")
106  (:type size-t "size_t")
107  (:type ssize-t "ssize_t")
108
109  #|
110  ;;; stat is nothing to do with sockets, but I keep it around for testing
111  ;;; the ffi glue
112  (:structure stat ("struct stat"
113                    (t dev "dev_t" "st_dev")
114                    ((alien:integer 32) atime "time_t" "st_atime")))
115  (:function stat ("stat" (integer 32)
116                   (file-name (* t))
117  (buf (* t))))
118  |#
119  (:structure protoent ("struct protoent"
120                        (c-string-pointer name "char *" "p_name")
121                        ((* (* t)) aliases "char **" "p_aliases")
122                        (integer proto "int" "p_proto")))
123  (:function getprotobyname ("getprotobyname" (* protoent)
124                                              (name c-string)))
125  (:function getprotobynumber ("getprotobynumber" (* protoent)
126                                                  (proto int)))
127  (:integer inaddr-any "INADDR_ANY")
128  (:structure in-addr ("struct in_addr"
129                       ((array (unsigned 8)) addr "u_int32_t" "s_addr")))
130  (:structure sockaddr-in ("struct sockaddr_in"
131                           (integer family "sa_family_t" "sin_family")
132                           ;; These two could be in-port-t and
133                           ;; in-addr-t, but then we'd throw away the
134                           ;; convenience (and byte-order agnosticism)
135                           ;; of the old sb-grovel scheme.
136                           ((array (unsigned 8)) port "u_int16_t" "sin_port")
137                           ((array (unsigned 8)) addr "struct in_addr" "sin_addr")))
138  (:structure sockaddr-un ("struct sockaddr_un"
139                           (integer family "sa_family_t" "sun_family")
140                           (c-string path "char" "sun_path")))
141  (:structure hostent ("struct hostent"
142                       (c-string-pointer name "char *" "h_name")
143                       ((* c-string) aliases "char **" "h_aliases")
144                       (integer type "int" "h_addrtype")
145                       (integer length "int" "h_length")
146                       ((* (* (unsigned 8))) addresses "char **" "h_addr_list")))
147  (:structure msghdr ("struct msghdr"
148                       (c-string-pointer name "void *" "msg_name")
149                       (integer namelen "socklen_t" "msg_namelen")
150                       ((* t) iov "struct iovec" "msg_iov")
151                       (integer iovlen "size_t" "msg_iovlen")
152                       ((* t) control "void *" "msg_control")
153                       (integer controllen "socklen_t" "msg_controllen")
154                       (integer flags "int" "msg_flags")))
155  (:function socket (#-netbsd "socket" #+netbsd "_socket" int
156                     (domain int)
157                     (type int)
158                     (protocol int)))
159  (:function bind ("bind" int
160                   (sockfd int)
161                   (my-addr (* t))  ; KLUDGE: sockaddr-in or sockaddr-un?
162                   (addrlen socklen-t)))
163  (:function listen ("listen" int
164                     (socket int)
165                     (backlog int)))
166  (:function accept ("accept" int
167                     (socket int)
168                     (my-addr (* t)) ; KLUDGE: sockaddr-in or sockaddr-un?
169                     (addrlen socklen-t :in-out)))
170  (:function getpeername ("getpeername" int
171                          (socket int)
172                          (her-addr (* t)) ; KLUDGE: sockaddr-in or sockaddr-un?
173                          (addrlen socklen-t :in-out)))
174  (:function getsockname ("getsockname" int
175                          (socket int)
176                          (my-addr (* t)) ; KLUDGE: sockaddr-in or sockaddr-un?
177                          (addrlen socklen-t :in-out)))
178  (:function connect ("connect" int
179                     (socket int)
180                     (his-addr (* t)) ; KLUDGE: sockaddr-in or sockaddr-un?
181                     (addrlen socklen-t)))
182  (:function close ("close" int
183                    (fd int)))
184  (:function recvfrom ("recvfrom" ssize-t
185                                  (socket int)
186                                  (buf (* t))
187                                  (len integer)
188                                  (flags int)
189                                  (sockaddr (* t)) ; KLUDGE: sockaddr-in or sockaddr-un?
190                                  (socklen (* socklen-t))))
191  (:function recvmsg ("recvmsg" ssize-t
192                                (socket int)
193                                (msg (* msghdr))
194                                (flags int)))
195  (:function send ("send" ssize-t
196                          (socket int)
197                          (buf (* t))
198                          (len size-t)
199                          (flags int)))
200  (:function sendto ("sendto" int
201                              (socket int)
202                              (buf (* t))
203                              (len size-t)
204                              (flags int)
205                              (sockaddr (* t)) ; KLUDGE: sockaddr-in or sockaddr-un?
206                              (socklen socklen-t)))
207  (:function sendmsg ("sendmsg" int
208                                (socket int)
209                                (msg (* msghdr))
210                                (flags int)))
211  (:function gethostbyname ("gethostbyname" (* hostent) (name c-string)))
212  (:function gethostbyaddr ("gethostbyaddr" (* hostent)
213                                            (addr (* t))
214                                            (len int)
215                                            (af int)))
216 ;;; should be using getaddrinfo instead?
217  (:function setsockopt ("setsockopt" int
218                         (socket int)
219                         (level int)
220                         (optname int)
221                         (optval (* t))
222                         (optlen int))) ;;; should be socklen-t!
223  (:function fcntl ("fcntl" int
224                    (fd int)
225                    (cmd int)
226                    (arg long)))
227  (:function getsockopt ("getsockopt" int
228                         (socket int)
229                         (level int)
230                         (optname int)
231                         (optval (* t))
232                         (optlen (* int))))) ;;; should be socklen-t!
233 )