X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=contrib%2Fsb-bsd-sockets%2Fconstants.lisp;h=de0e2e8f8733165854e621c3e34d5edd17c619f4;hb=HEAD;hp=0b80a64ab4dda0a0c128b0a7239993cbea1f63d2;hpb=8ac04a07bef481085c338f34e458ee7f04defc47;p=sbcl.git diff --git a/contrib/sb-bsd-sockets/constants.lisp b/contrib/sb-bsd-sockets/constants.lisp index 0b80a64..de0e2e8 100644 --- a/contrib/sb-bsd-sockets/constants.lisp +++ b/contrib/sb-bsd-sockets/constants.lisp @@ -12,8 +12,8 @@ ((:integer af-inet "AF_INET" "IP Protocol family") (:integer af-unspec "AF_UNSPEC" "Unspecified") (:integer af-local - #+(or sunos solaris) "AF_UNIX" - #-(or sunos solaris) "AF_LOCAL" + #+(or sunos solaris hpux) "AF_UNIX" + #-(or sunos solaris hpux) "AF_LOCAL" "Local to host (pipes and file-domain).") #+linux (:integer af-inet6 "AF_INET6" "IP version 6") #+linux (:integer af-route "AF_NETLINK" "Alias to emulate 4.4BSD ") @@ -33,25 +33,31 @@ ;; some of these may be linux-specific (:integer so-debug "SO_DEBUG" - "Enable debugging in underlying protocol modules") + "Enable debugging in underlying protocol modules") (:integer so-reuseaddr "SO_REUSEADDR" "Enable local address reuse") - (:integer so-type "SO_TYPE") ;get only - (:integer so-error "SO_ERROR") ;get only (also clears) + (:integer so-type "SO_TYPE") ;get only + (:integer so-error "SO_ERROR") ;get only (also clears) (:integer so-dontroute "SO_DONTROUTE" "Bypass routing facilities: instead send direct to appropriate network interface for the network portion of the destination address") (:integer so-broadcast "SO_BROADCAST" "Request permission to send broadcast datagrams") (:integer so-sndbuf "SO_SNDBUF") -#+linux (:integer so-passcred "SO_PASSCRED") + #+linux (:integer so-passcred "SO_PASSCRED") (:integer so-rcvbuf "SO_RCVBUF") (:integer so-keepalive "SO_KEEPALIVE" - "Send periodic keepalives: if peer does not respond, we get SIGPIPE") + "Send periodic keepalives. If peer does not respond, we get SIGPIPE.") + #+linux (:integer tcp-keepcnt "TCP_KEEPCNT" + "Number of unacknowledged probes before the connection is considered dead.") + #+linux (:integer tcp-keepidle "TCP_KEEPIDLE" + "Seconds between the last data packet sent and the first keepalive probe.") + #+linux (:integer tcp-keepintvl "TCP_KEEPINTVL" "Seconds between keepalive probes.") (:integer so-oobinline "SO_OOBINLINE" "Put out-of-band data into the normal input queue when received") + #+linux (:integer so-no-check "SO_NO_CHECK") -#+linux (:integer so-priority "SO_PRIORITY") + #+linux (:integer so-priority "SO_PRIORITY") (:integer so-linger "SO_LINGER" "For reliable streams, pause a while on closing when unsent messages are queued") -#+linux (:integer so-bsdcompat "SO_BSDCOMPAT") + #+linux (:integer so-bsdcompat "SO_BSDCOMPAT") (:integer so-sndlowat "SO_SNDLOWAT") (:integer so-rcvlowat "SO_RCVLOWAT") (:integer so-sndtimeo "SO_SNDTIMEO") @@ -61,6 +67,12 @@ #+linux (:integer so-bindtodevice "SO_BINDTODEVICE") (:integer ifnamsiz "IFNAMSIZ") +;; socket shutdown flags +(:integer SHUT_RD "SHUT_RD") +(:integer SHUT_WR "SHUT_WR") +(:integer SHUT_RDWR "SHUT_RDWR") + +;; errors (:integer EADDRINUSE "EADDRINUSE") (:integer EAGAIN "EAGAIN") (:integer EBADF "EBADF") @@ -73,23 +85,24 @@ (:integer EOPNOTSUPP "EOPNOTSUPP") (:integer EPERM "EPERM") (:integer EPROTONOSUPPORT "EPROTONOSUPPORT") + (:integer ERANGE "ERANGE") (:integer ESOCKTNOSUPPORT "ESOCKTNOSUPPORT") (:integer ENETUNREACH "ENETUNREACH") (:integer ENOTCONN "ENOTCONN") - (:integer NETDB-INTERNAL "NETDB_INTERNAL" "See errno.") - (:integer NETDB-SUCCESS "NETDB_SUCCESS" "No problem.") + (:integer NETDB-INTERNAL #+hpux "h_NETDB_INTERNAL" #-hpux "NETDB_INTERNAL" "See errno.") + (:integer NETDB-SUCCESS #+hpux "h_NETDB_SUCCESS" #-hpux "NETDB_SUCCESS" "No problem.") (:integer HOST-NOT-FOUND "HOST_NOT_FOUND" "Authoritative Answer Host not found.") (:integer TRY-AGAIN "TRY_AGAIN" "Non-Authoritative Host not found, or SERVERFAIL.") (:integer NO-RECOVERY "NO_RECOVERY" "Non recoverable errors, FORMERR, REFUSED, NOTIMP.") (:integer NO-DATA "NO_DATA" "Valid name, no data record of requested type.") (:integer NO-ADDRESS "NO_ADDRESS" "No address, look for MX record.") + #-(or hpux sunos) (:function h-strerror ("hstrerror" c-string (errno int))) (:integer O-NONBLOCK "O_NONBLOCK") (:integer f-getfl "F_GETFL") (:integer f-setfl "F_SETFL") - #+linux (:integer msg-nosignal "MSG_NOSIGNAL") (:integer msg-oob "MSG_OOB") (:integer msg-peek "MSG_PEEK") (:integer msg-trunc "MSG_TRUNC") @@ -97,23 +110,23 @@ (:integer msg-eor "MSG_EOR") (:integer msg-dontroute "MSG_DONTROUTE") (:integer msg-dontwait "MSG_DONTWAIT") - (:integer msg-nosignal "MSG_NOSIGNAL") -#+linux (:integer msg-confirm "MSG_CONFIRM") -#+linux (:integer msg-more "MSG_MORE") + #+linux (:integer msg-nosignal "MSG_NOSIGNAL") + #+linux (:integer msg-confirm "MSG_CONFIRM") + #+linux (:integer msg-more "MSG_MORE") ;; for socket-receive (:type socklen-t "socklen_t") (:type size-t "size_t") (:type ssize-t "ssize_t") - #| + #| ;;; stat is nothing to do with sockets, but I keep it around for testing ;;; the ffi glue (:structure stat ("struct stat" - (t dev "dev_t" "st_dev") - ((alien:integer 32) atime "time_t" "st_atime"))) + (t dev "dev_t" "st_dev") + ((alien:integer 32) atime "time_t" "st_atime"))) (:function stat ("stat" (integer 32) - (file-name (* t)) + (file-name (* t)) (buf (* t)))) |# (:structure protoent ("struct protoent" @@ -122,12 +135,35 @@ (integer proto "int" "p_proto"))) (:function getprotobyname ("getprotobyname" (* protoent) (name c-string))) + +;; getprotobyname_r is a thread-safe reentrant version of getprotobyname + #+os-provides-getprotoby-r + (:function getprotobyname-r ("getprotobyname_r" int + (name c-string) + (result_buf (* protoent)) + (buffer (* char)) + (buffer-len size-t) + #-solaris + (result (* (* protoent))))) + + (:function getprotobynumber ("getprotobynumber" (* protoent) (proto int))) + ;;ditto, save for the getprotobynumber part + #+os-provides-getprotoby-r + (:function getprotobynumber-r ("getprotobynumber_r" int + (proto int) + (result_buf (* protoent)) + (buffer (* char)) + (buffer-len size-t) + #-solaris + (result (* (* protoent))))) + (:integer inaddr-any "INADDR_ANY") (:structure in-addr ("struct in_addr" ((array (unsigned 8)) addr "u_int32_t" "s_addr"))) (:structure sockaddr-in ("struct sockaddr_in" + #+darwin ((unsigned 8) len "__uint8_t" "sin_len") (integer family "sa_family_t" "sin_family") ;; These two could be in-port-t and ;; in-addr-t, but then we'd throw away the @@ -138,6 +174,9 @@ (:structure sockaddr-un ("struct sockaddr_un" (integer family "sa_family_t" "sun_family") (c-string path "char" "sun_path"))) + (:structure sockaddr-un-abstract ("struct sockaddr_un" + (integer family "sa_family_t" "sun_family") + ((array (unsigned 8)) path "char" "sun_path"))) (:structure hostent ("struct hostent" (c-string-pointer name "char *" "h_name") ((* c-string) aliases "char **" "h_aliases") @@ -181,6 +220,8 @@ (addrlen socklen-t))) (:function close ("close" int (fd int))) + (:function shutdown ("shutdown" int + (fd int) (how int))) (:function recvfrom ("recvfrom" ssize-t (socket int) (buf (* t)) @@ -209,11 +250,91 @@ (msg (* msghdr)) (flags int))) (:function gethostbyname ("gethostbyname" (* hostent) (name c-string))) + #+darwin + (:function gethostbyname2 ("gethostbyname2" (* hostent) + (name c-string) + (af int))) (:function gethostbyaddr ("gethostbyaddr" (* hostent) (addr (* t)) (len int) (af int))) -;;; should be using getaddrinfo instead? + + ;; Re-entrant gethostbyname + + #+linux + (:function gethostbyname-r ("gethostbyname_r" + int + (name c-string) + (ret (* hostent)) + (buf (* char)) + (buflen long) + (result (* (* hostent))) + (h-errnop (* int)))) + ;; getaddrinfo / getnameinfo + + #+sb-bsd-sockets-addrinfo + (:structure addrinfo ("struct addrinfo" + (integer flags "int" "ai_flags") + (integer family "int" "ai_family") + (integer socktype "int" "ai_socktype") + (integer protocol "int" "ai_protocol") + ;; CLH 20070306 FIXME: ai_addrlen should really + ;; be a socklen_t, but I'm not sure if this the + ;; case on other platforms. I'm setting this to + ;; socklen_t on darwin and hoping that other + ;; platform maintainers will do the right thing + ;; here. + #+darwin (integer addrlen "socklen_t" "ai_addrlen") + #-darwin (integer addrlen "size_t" "ai_addrlen") + ((* sockaddr-in) addr "struct sockaddr*" "ai_addr") + (c-string-pointer canonname "char *" "ai_canonname") + ((* (struct addrinfo)) next "struct addrinfo*" "ai_next"))) + + #+sb-bsd-sockets-addrinfo + (:function getaddrinfo ("getaddrinfo" + int + (node c-string) + (service c-string) + (hints (* addrinfo)) + (res (* (* addrinfo))))) + + #+sb-bsd-sockets-addrinfo + (:function freeaddrinfo ("freeaddrinfo" + void + (res (* addrinfo)))) + + #+sb-bsd-sockets-addrinfo + (:function gai-strerror ("gai_strerror" + c-string + (error-code int))) + + #+sb-bsd-sockets-addrinfo + (:function getnameinfo ("getnameinfo" + int + (address (* sockaddr-in)) + (address-length size-t) + (host (* char)) + (host-len size-t) + (service (* char)) + (service-len size-t) + (flags int))) + + (:integer EAI-FAMILY "EAI_FAMILY") + (:integer EAI-SOCKTYPE "EAI_SOCKTYPE") + (:integer EAI-BADFLAGS "EAI_BADFLAGS") + (:integer EAI-NONAME "EAI_NONAME") + (:integer EAI-SERVICE "EAI_SERVICE") + #-freebsd + (:integer EAI-ADDRFAMILY "EAI_ADDRFAMILY") + (:integer EAI-MEMORY "EAI_MEMORY") + (:integer EAI-FAIL "EAI_FAIL") + (:integer EAI-AGAIN "EAI_AGAIN") + (:integer EAI-SYSTEM "EAI_SYSTEM") + + (:integer NI-NAMEREQD "NI_NAMEREQD") + + ;; Socket options + (:function setsockopt ("setsockopt" int (socket int) (level int) @@ -229,5 +350,5 @@ (level int) (optname int) (optval (* t)) - (optlen (* int))))) ;;; should be socklen-t! -) + (optlen (* int)))) ;;; should be socklen-t! + )