summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2002-06-18 23:46:32 +0000
committerKen Raeburn <raeburn@mit.edu>2002-06-18 23:46:32 +0000
commit96fa6cea53c9cfe3c0d835f4a8f01260d8544267 (patch)
tree3e5035deee1dfee868c02cd22952b7686c934f17 /src/include
parentbd8fd6f6256fc69455dbd53977fd7819de9103bb (diff)
downloadkrb5-96fa6cea53c9cfe3c0d835f4a8f01260d8544267.tar.gz
krb5-96fa6cea53c9cfe3c0d835f4a8f01260d8544267.tar.xz
krb5-96fa6cea53c9cfe3c0d835f4a8f01260d8544267.zip
Client-side TCP support update for Windows.
Some support for scatter/gather socket i/o added via macros in port-sockets.h. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@14538 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/include')
-rw-r--r--src/include/ChangeLog13
-rw-r--r--src/include/port-sockets.h64
2 files changed, 77 insertions, 0 deletions
diff --git a/src/include/ChangeLog b/src/include/ChangeLog
index c69a621f3..fbb8704b5 100644
--- a/src/include/ChangeLog
+++ b/src/include/ChangeLog
@@ -1,3 +1,16 @@
+2002-06-18 Ken Raeburn <raeburn@mit.edu>
+
+ * port-sockets.h (sg_buf): New typedef name for OS-specific
+ scatter-gather buffer handle type.
+ (SG_ADVANCE, SG_LEN, SG_SET): New macros to manipulate sg_buf.
+ (SOCKET_WRITEV, SOCKET_WRITEV_TEMP): New macros for sending on
+ socket with gathered input.
+ (SHUTDOWN_READ, SHUTDOWN_WRITE, SHUTDOWN_BOTH): New macros, to be
+ passed to shutdown() to indicate direction.
+ (EINPROGRESS, EWOULDBLOCK, ECONNRESET, ECONNABORTED,
+ ECONNREFUSED, EHOSTUNREACH, ETIMEDOUT) [_WIN32]: Define as WSA
+ equivalents if not already defined.
+
2002-06-15 Ken Raeburn <raeburn@mit.edu>
* krb5.hin: Delete inclusion of profile.h again.
diff --git a/src/include/port-sockets.h b/src/include/port-sockets.h
index 052b40270..0681ddb0b 100644
--- a/src/include/port-sockets.h
+++ b/src/include/port-sockets.h
@@ -8,6 +8,16 @@
/* Some of our own infrastructure where the WinSock stuff was too hairy
to dump into a clean Unix program... */
+typedef WSABUF sg_buf;
+
+#define SG_ADVANCE(SG, N) \
+ ((SG)->len < (N) \
+ ? (abort(), 0) \
+ : ((SG)->buf += (N), (SG)->len -= (N), 0))
+
+#define SG_LEN(SG) ((SG)->len + 0)
+#define SG_SET(SG, B, N) ((SG)->buf = (char *)(B),(SG)->len = (N))
+
#define SOCKET_INITIALIZE() 0
#define SOCKET_CLEANUP()
#define SOCKET_ERRNO (WSAGetLastError())
@@ -17,6 +27,40 @@
#define SOCKET_WRITE(fd, b, l) (send(fd, b, l, 0))
#define SOCKET_EINTR WSAEINTR
+/* Return -1 for error or number of bytes written.
+ TMP is a temporary variable; must be declared by the caller, and
+ must be used by this macro (to avoid compiler warnings). */
+/* WSASend returns 0 or SOCKET_ERROR. */
+#define SOCKET_WRITEV_TEMP DWORD
+#define SOCKET_WRITEV(FD, SG, LEN, TMP) \
+ (WSASend((FD), (SG), (LEN), &(TMP), 0, 0, 0) ? -1 : (TMP))
+
+#define SHUTDOWN_READ SD_RECEIVE
+#define SHUTDOWN_WRITE SD_SEND
+#define SHUTDOWN_BOTH SD_BOTH
+
+#ifndef EINPROGRESS
+#define EINPROGRESS WSAEINPROGRESS
+#endif
+#ifndef EWOULDBLOCK
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#endif
+#ifndef ECONNRESET
+#define ECONNRESET WSAECONNRESET
+#endif
+#ifndef ECONNABORTED
+#define ECONNABORTED WSAECONNABORTED
+#endif
+#ifndef ECONNREFUSED
+#define ECONNREFUSED WSAECONNREFUSED
+#endif
+#ifndef EHOSTUNREACH
+#define EHOSTUNREACH WSAEHOSTUNREACH
+#endif
+#ifndef ETIMEDOUT
+#define ETIMEDOUT WSAETIMEDOUT
+#endif
+
int win_socket_initialize();
#else /* not _WIN32 */
@@ -46,6 +90,17 @@ int win_socket_initialize();
#define ioctlsocket ioctl
#define SOCKET_ERROR (-1)
+typedef struct iovec sg_buf;
+
+#define SG_ADVANCE(SG, N) \
+ ((SG)->iov_len < (N) \
+ ? (abort(), 0) \
+ : ((SG)->iov_base = (char *) (SG)->iov_base + (N), \
+ (SG)->iov_len -= (N), 0))
+
+#define SG_LEN(SG) ((SG)->iov_len + 0)
+#define SG_SET(SG, B, L) ((SG)->iov_base = (char*)(B), (SG)->iov_len = (L))
+
/* Some of our own infrastructure where the WinSock stuff was too hairy
to dump into a clean Unix program... */
@@ -57,6 +112,15 @@ int win_socket_initialize();
#define SOCKET_READ read
#define SOCKET_WRITE write
#define SOCKET_EINTR EINTR
+#define SOCKET_WRITEV_TEMP int
+/* Use TMP to avoid compiler warnings and keep things consistent with
+ Windoze version. */
+#define SOCKET_WRITEV(FD, SG, LEN, TMP) \
+ ((TMP) = writev((FD), (SG), (LEN)))
+
+#define SHUTDOWN_READ 0
+#define SHUTDOWN_WRITE 1
+#define SHUTDOWN_BOTH 2
#endif /* HAVE_MACSOCK_H */