diff --git a/code/exports.lisp b/code/exports.lisp index db753fe0d5a5e78f38cc8e46c29a51936b58c75e..fa77a61304fb68358faf6acb250689c7ee0c8f68 100644 --- a/code/exports.lisp +++ b/code/exports.lisp @@ -5,7 +5,7 @@ ;;; Carnegie Mellon University, and has been placed in the public domain. ;;; (ext:file-comment - "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/exports.lisp,v 1.239 2004/12/24 15:05:27 rtoy Exp $") + "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/exports.lisp,v 1.240 2005/01/27 15:23:32 rtoy Exp $") ;;; ;;; ********************************************************************** ;;; @@ -304,7 +304,9 @@ "VSUSP" "VSTART" "VSTOP" "VDSUSP" "UNIX-TCSENDBREAK" "UNIX-TCDRAIN" "UNIX-TCFLUSH" "UNIX-TCFLOW" #+(or svr4 bsd linux) "O_NDELAY" - "CHECK") + "CHECK" + + "UNIX-RECVFROM" "UNIX-SENDTO" "UNIX-SHUTDOWN") #+(or svr4 linux) (:export "EADDRINUSE" "EADDRNOTAVAIL" "EADV" "EAFNOSUPPORT" "EALREADY" "EBADE" "EBADFD" "EBADMSG" "EBADR" "EBADRQC" @@ -1340,7 +1342,10 @@ ;; PCL declaration identifiers. "SLOTS" "AUTO-COMPILE" "NOT-AUTO-COMPILE" - "*TRUST-DYNAMIC-EXTENT-DECLARATIONS*")) + "*TRUST-DYNAMIC-EXTENT-DECLARATIONS*" + + "INET-RECVFROM" "INET-SENDTO" "INET-SHUTDOWN" + "SHUT-RD" "SHUT-WR" "SHUT-RDWR")) (defpackage "STREAM" (:import-from "SYSTEM" "LISP-STREAM") diff --git a/code/internet.lisp b/code/internet.lisp index bc52cb0e37fac507559e1c78f63033626417556a..4d9312d0a9d6eb78c7647437a49e377e634f899e 100644 --- a/code/internet.lisp +++ b/code/internet.lisp @@ -5,7 +5,7 @@ ;;; Carnegie Mellon University, and has been placed in the public domain. ;;; (ext:file-comment - "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/internet.lisp,v 1.43 2004/12/13 15:19:38 rtoy Exp $") + "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/internet.lisp,v 1.44 2005/01/27 15:23:33 rtoy Exp $") ;;; ;;; ********************************************************************** ;;; @@ -26,7 +26,10 @@ connect-to-inet-socket create-inet-listener accept-tcp-connection close-socket ipproto-tcp ipproto-udp inaddr-any add-oob-handler remove-oob-handler remove-all-oob-handlers - send-character-out-of-band)) + send-character-out-of-band + + inet-recvfrom inet-sendto inet-shutdown + shut-rd shut-wr shut-rdwr)) #-svr4 @@ -684,3 +687,37 @@ struct in_addr { char fd (unix:get-unix-error-msg))))) + +(defun inet-recvfrom (fd buffer size &key (flags 0)) + "A packaging of the unix recvfrom call. Returns three values: +bytecount, source address as integer, and source port. bytecount +can of course be negative, to indicate faults." + #+mp (mp:process-wait-until-fd-usable fd :input) + (with-alien ((sockaddr inet-sockaddr)) + (let* ((bytecount (unix:unix-recvfrom fd buffer size flags + (alien-sap sockaddr) + (alien-size inet-sockaddr :bytes)))) + (values bytecount (ntohl (slot sockaddr 'addr)) (ntohs (slot sockaddr 'port)))))) + +(defun inet-sendto (fd buffer size addr port &key (flags 0)) + "A packaging of the unix sendto call. Return value like sendto" + (with-alien ((sockaddr inet-sockaddr)) + (setf (slot sockaddr 'family) af-inet) + (setf (slot sockaddr 'port) (htons port)) + (setf (slot sockaddr 'addr) (htonl addr)) + (unix:unix-sendto fd + buffer + size + flags + (alien-sap sockaddr) + (alien-size inet-sockaddr :bytes)))) +(defconstant shut-rd 0) +(defconstant shut-wr 1) +(defconstant shut-rdwr 2) + +(defun inet-shutdown (fd level) + (when (minusp (unix:unix-shutdown fd level)) + (error 'socket-error + :format-control "Error on shutdown of socket: ~A" + :format-arguments (list (unix:get-unix-error-msg)) + :errno (unix:unix-errno)))) diff --git a/code/unix-glibc2.lisp b/code/unix-glibc2.lisp index 74ed61db2747955ba0ce9ba171eed331c011bc89..affddd951d96e542b2ed627693ee31a86b88dcf0 100644 --- a/code/unix-glibc2.lisp +++ b/code/unix-glibc2.lisp @@ -5,7 +5,7 @@ ;;; Carnegie Mellon University, and has been placed in the public domain. ;;; (ext:file-comment - "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/unix-glibc2.lisp,v 1.34 2004/09/11 19:18:01 rtoy Exp $") + "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/unix-glibc2.lisp,v 1.35 2005/01/27 15:23:33 rtoy Exp $") ;;; ;;; ********************************************************************** ;;; @@ -187,6 +187,8 @@ unix-recv unix-send unix-getpeername unix-getsockname unix-getsockopt unix-setsockopt + unix-recvfrom unix-sendto unix-shutdown + unix-getpwnam unix-getpwuid unix-getgrnam unix-getgrgid user-info user-info-name user-info-password user-info-uid user-info-gid user-info-gecos user-info-dir user-info-shell @@ -2677,6 +2679,28 @@ in at a time in poll.") (optval (* t)) (optlen unsigned)) +;; Datagram support + +(def-alien-routine ("recvfrom" unix-recvfrom) int + (fd int) + (buffer c-string) + (length int) + (flags int) + (sockaddr (* t)) + (len int :in-out)) + +(def-alien-routine ("sendto" unix-sendto) int + (fd int) + (buffer c-string) + (length int) + (flags int) + (sockaddr (* t)) + (len int)) + +(def-alien-routine ("shutdown" unix-shutdown) int + (socket int) + (level int)) + ;;; sys/select.h ;;; UNIX-FAST-SELECT -- public. diff --git a/code/unix.lisp b/code/unix.lisp index 198e59338ccfe76e1750e2e1160ebd45c030c886..d62fc77112e61154e37a49375e766892e462039c 100644 --- a/code/unix.lisp +++ b/code/unix.lisp @@ -5,7 +5,7 @@ ;;; Carnegie Mellon University, and has been placed in the public domain. ;;; (ext:file-comment - "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/unix.lisp,v 1.99 2004/09/21 11:59:16 emarsden Exp $") + "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/unix.lisp,v 1.100 2005/01/27 15:23:33 rtoy Exp $") ;;; ;;; ********************************************************************** ;;; @@ -169,6 +169,8 @@ unix-recv unix-send unix-getpeername unix-getsockname unix-getsockopt unix-setsockopt + unix-recvfrom unix-sendto unix-shutdown + unix-getpwnam unix-getpwuid unix-getgrnam unix-getgrgid user-info user-info-name user-info-password user-info-uid user-info-gid user-info-gecos user-info-dir user-info-shell @@ -2965,6 +2967,28 @@ (optval (* t)) (optlen unsigned)) +;; Datagram support + +(def-alien-routine ("recvfrom" unix-recvfrom) int + (fd int) + (buffer c-string) + (length int) + (flags int) + (sockaddr (* t)) + (len int :in-out)) + +(def-alien-routine ("sendto" unix-sendto) int + (fd int) + (buffer c-string) + (length int) + (flags int) + (sockaddr (* t)) + (len int)) + +(def-alien-routine ("shutdown" unix-shutdown) int + (socket int) + (level int)) + ;;; ;;; Support for the Interval Timer (experimental)