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 ("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" )
11 ;;; then the stuff we're looking for
12 ((:integer af-inet
"AF_INET" "IP Protocol family")
13 (:integer af-unspec
"AF_UNSPEC" "Unspecified")
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 ")
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.")
32 (:integer sol-socket
"SOL_SOCKET")
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")
60 (:integer tcp-nodelay
"TCP_NODELAY")
61 #+linux
(:integer so-bindtodevice
"SO_BINDTODEVICE")
62 (:integer ifnamsiz
"IFNAMSIZ")
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")
79 (:integer NETDB-INTERNAL
"NETDB_INTERNAL" "See errno.")
80 (:integer NETDB-SUCCESS
"NETDB_SUCCESS" "No problem.")
81 (:integer HOST-NOT-FOUND
"HOST_NOT_FOUND" "Authoritative Answer Host not found.")
82 (:integer TRY-AGAIN
"TRY_AGAIN" "Non-Authoritative Host not found, or SERVERFAIL.")
83 (:integer NO-RECOVERY
"NO_RECOVERY" "Non recoverable errors, FORMERR, REFUSED, NOTIMP.")
84 (:integer NO-DATA
"NO_DATA" "Valid name, no data record of requested type.")
85 (:integer NO-ADDRESS
"NO_ADDRESS" "No address, look for MX record.")
87 (:integer O-NONBLOCK
"O_NONBLOCK")
88 (:integer f-getfl
"F_GETFL")
89 (:integer f-setfl
"F_SETFL")
91 #+linux
(:integer msg-nosignal
"MSG_NOSIGNAL")
92 (:integer msg-oob
"MSG_OOB")
93 (:integer msg-peek
"MSG_PEEK")
94 (:integer msg-trunc
"MSG_TRUNC")
95 (:integer msg-waitall
"MSG_WAITALL")
98 (:type socklen-t
"socklen_t")
101 ;;; stat is nothing to do with sockets, but I keep it around for testing
103 (:structure stat
("struct stat"
104 (t dev
"dev_t" "st_dev")
105 ((alien:integer
32) atime
"time_t" "st_atime")))
106 (:function stat
("stat" (integer 32)
110 (:structure protoent
("struct protoent"
111 (c-string-pointer name
"char *" "p_name")
112 ((* (* t
)) aliases
"char **" "p_aliases")
113 (integer proto
"int" "p_proto")))
114 (:function getprotobyname
("getprotobyname" (* protoent
)
116 (:integer inaddr-any
"INADDR_ANY")
117 (:structure in-addr
("struct in_addr"
118 ((array (unsigned 8)) addr
"u_int32_t" "s_addr")))
119 (:structure sockaddr-in
("struct sockaddr_in"
120 (integer family
"sa_family_t" "sin_family")
121 ;; These two could be in-port-t and
122 ;; in-addr-t, but then we'd throw away the
123 ;; convenience (and byte-order agnosticism)
124 ;; of the old sb-grovel scheme.
125 ((array (unsigned 8)) port
"u_int16_t" "sin_port")
126 ((array (unsigned 8)) addr
"struct in_addr" "sin_addr")))
127 (:structure sockaddr-un
("struct sockaddr_un"
128 (integer family
"sa_family_t" "sun_family")
129 (c-string path
"char" "sun_path")))
130 (:structure hostent
("struct hostent"
131 (c-string-pointer name
"char *" "h_name")
132 ((* c-string
) aliases
"char **" "h_aliases")
133 (integer type
"int" "h_addrtype")
134 (integer length
"int" "h_length")
135 ((* (* (unsigned 8))) addresses
"char **" "h_addr_list")))
136 (:function socket
("socket" integer
140 (:function bind
("bind" integer
142 (my-addr (* t
)) ; KLUDGE: sockaddr-in or sockaddr-un?
144 (:function listen
("listen" integer
147 (:function accept
("accept" integer
149 (my-addr (* t
)) ; KLUDGE: sockaddr-in or sockaddr-un?
150 (addrlen integer
:in-out
)))
151 (:function getpeername
("getpeername" integer
153 (her-addr (* t
)) ; KLUDGE: sockaddr-in or sockaddr-un?
154 (addrlen integer
:in-out
)))
155 (:function getsockname
("getsockname" integer
157 (my-addr (* t
)) ; KLUDGE: sockaddr-in or sockaddr-un?
158 (addrlen integer
:in-out
)))
159 (:function connect
("connect" integer
161 (his-addr (* t
)) ; KLUDGE: sockaddr-in or sockaddr-un?
164 (:function close
("close" integer
166 (:function recvfrom
("recvfrom" integer
171 (sockaddr (* t
)) ; KLUDGE: sockaddr-in or sockaddr-un?
172 (socklen (* socklen-t
))))
173 (:function gethostbyname
("gethostbyname" (* hostent
) (name c-string
)))
174 (:function gethostbyaddr
("gethostbyaddr" (* hostent
)
178 (:function setsockopt
("setsockopt" integer
184 (:function fcntl
("fcntl" integer
188 (:function getsockopt
("getsockopt" integer
193 (optlen (* integer
)))))