summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Altman <jaltman@secure-endpoints.com>2009-10-12 16:06:50 -0700
committerRuss Allbery <rra@stanford.edu>2009-10-12 16:06:50 -0700
commit9f5acab7df461621ce1b5191a3668e154aed2d41 (patch)
tree51a8a4500000ab29447f6f62c4874f0ff3c7de35
parent051e86b86fcb76088a878520f2f6886b4476a12f (diff)
Windows portability and build improvements
Get the current version number from configure.ac rather than configure so that the Windows build scripts work from a Git checkout, and rename configure.bat to configure.cmd. Choose the correct GSS-API library for 64-bit Windows. Quote the path to the Kerberos SDK on Windows. Use SOCKET for the type of sockets rather than int, for correct handling of 64-bit Windows. Use INVALID_SOCKET rather than -1 for an invalid socket value. Disable warnings about unknown pragmata and POSIX strdup on Windows. Cast the flag argument to setsockopt to avoid warnings on Windows. Restructure the boundary logic in the xread function in util/tokens.c to be more obvious for both humans and the compiler. Cast the priority value passed into ReportEvent() appropriately.
-rw-r--r--Makefile.w3212
-rw-r--r--client/api.c2
-rw-r--r--client/client-v1.c4
-rw-r--r--client/client-v2.c2
-rw-r--r--client/internal.h2
-rw-r--r--client/open.c21
-rw-r--r--config.h.w324
-rw-r--r--configure.cmd (renamed from configure.bat)2
-rw-r--r--portable/socket.h2
-rw-r--r--util/gss-tokens.c4
-rw-r--r--util/messages.c2
-rw-r--r--util/network.c75
-rw-r--r--util/tokens.c11
-rw-r--r--util/util.h33
14 files changed, 95 insertions, 81 deletions
diff --git a/Makefile.w32 b/Makefile.w32
index 638ae36..05e0216 100644
--- a/Makefile.w32
+++ b/Makefile.w32
@@ -1,16 +1,22 @@
!INCLUDE <Win32.mak>
-cflags=$(cflags) /I $(KRB5SDK)\inc\krb5 /I $(KRB5SDK)\inc\krb5\gssapi /I . /D_CRT_SECURE_NO_DEPRECATE /DWIN32_LEAN_AND_MEAN
+!if "$(CPU)" == "i386"
+GSSAPI_LIB = gssapi32.lib
+!elseif "$(CPU)" == "AMD64"
+GSSAPI_LIB = gssapi64.lib
+!endif
+
+cflags=$(cflags) /I "$(KRB5SDK)"\inc\krb5 /I "$(KRB5SDK)"\inc\krb5\gssapi /I . /D_CRT_SECURE_NO_DEPRECATE /DWIN32_LEAN_AND_MEAN
rcflags=$(rcflags) /I .
remctl.exe: remctl.obj getopt.obj messages.obj messages-die.obj asprintf.obj winsock.obj xmalloc.obj remctl.lib remctl.res
- link $(ldebug) $(lflags) /LIBPATH:$(KRB5SDK)\lib\$(CPU) /out:$@ $** ws2_32.lib advapi32.lib
+ link $(ldebug) $(lflags) /LIBPATH:"$(KRB5SDK)"\lib\$(CPU) /out:$@ $** ws2_32.lib advapi32.lib
remctl.lib: remctl.dll
remctl.dll: api.obj client-v1.obj client-v2.obj error.obj open.obj network.obj asprintf.obj concat.obj gss-tokens.obj gss-errors.obj inet_aton.obj inet_ntop.obj strlcpy.obj strlcat.obj tokens.obj messages.obj messages-die.obj winsock.obj xmalloc.obj libremctl.res
- link $(ldebug) $(lflags) /LIBPATH:$(KRB5SDK)\lib\$(CPU) /dll /out:$@ /export:remctl /export:remctl_new /export:remctl_open /export:remctl_close /export:remctl_command /export:remctl_commandv /export:remctl_error /export:remctl_output $** gssapi32.lib ws2_32.lib advapi32.lib
+ link $(ldebug) $(lflags) /LIBPATH:"$(KRB5SDK)"\lib\$(CPU) /dll /out:$@ /export:remctl /export:remctl_new /export:remctl_open /export:remctl_close /export:remctl_command /export:remctl_commandv /export:remctl_error /export:remctl_output $** $(GSSAPI_LIB) ws2_32.lib advapi32.lib
{client\}.c{}.obj::
$(cc) $(cdebug) $(cflags) $(cvars) /c $<
diff --git a/client/api.c b/client/api.c
index b2d70f3..5d6f168 100644
--- a/client/api.c
+++ b/client/api.c
@@ -213,7 +213,7 @@ remctl_new(void)
r = calloc(1, sizeof(struct remctl));
if (r == NULL)
return NULL;
- r->fd = -1;
+ r->fd = INVALID_SOCKET;
r->host = NULL;
r->principal = NULL;
r->context = NULL;
diff --git a/client/client-v1.c b/client/client-v1.c
index 38f0077..ecd332a 100644
--- a/client/client-v1.c
+++ b/client/client-v1.c
@@ -117,7 +117,7 @@ internal_v1_output(struct remctl *r)
internal_token_error(r, "receiving token", status, major, minor);
if (status == TOKEN_FAIL_EOF) {
socket_close(r->fd);
- r->fd = -1;
+ r->fd = INVALID_SOCKET;
}
return NULL;
}
@@ -179,7 +179,7 @@ internal_v1_output(struct remctl *r)
* connection now.
*/
socket_close(r->fd);
- r->fd = -1;
+ r->fd = INVALID_SOCKET;
r->ready = false;
return r->output;
}
diff --git a/client/client-v2.c b/client/client-v2.c
index 824ab4e..972deb3 100644
--- a/client/client-v2.c
+++ b/client/client-v2.c
@@ -257,7 +257,7 @@ internal_v2_output(struct remctl *r)
internal_token_error(r, "receiving token", status, major, minor);
if (status == TOKEN_FAIL_EOF) {
socket_close(r->fd);
- r->fd = -1;
+ r->fd = INVALID_SOCKET;
}
return NULL;
}
diff --git a/client/internal.h b/client/internal.h
index 7404a7d..d4c16f6 100644
--- a/client/internal.h
+++ b/client/internal.h
@@ -28,7 +28,7 @@ struct remctl {
unsigned short port; /* remctl v1 requires opening a new */
const char *principal; /* connection for each command. */
int protocol; /* Protocol version. */
- int fd;
+ SOCKET fd;
gss_ctx_id_t context;
char *error;
struct remctl_output *output;
diff --git a/client/open.c b/client/open.c
index d58a5e8..f379453 100644
--- a/client/open.c
+++ b/client/open.c
@@ -31,12 +31,13 @@
* network connection. Returns the file descriptor if successful or -1 on
* failure.
*/
-static int
+static SOCKET
internal_connect(struct remctl *r, const char *host, unsigned short port)
{
struct addrinfo hints, *ai;
char portbuf[16];
- int status, fd;
+ int status;
+ SOCKET fd;
/*
* Look up the remote host and open a TCP connection. Call getaddrinfo
@@ -51,14 +52,14 @@ internal_connect(struct remctl *r, const char *host, unsigned short port)
if (status != 0) {
internal_set_error(r, "unknown host %s: %s", host,
gai_strerror(status));
- return -1;
+ return INVALID_SOCKET;
}
fd = network_connect(ai, NULL);
freeaddrinfo(ai);
- if (fd < 0) {
+ if (fd == INVALID_SOCKET) {
internal_set_error(r, "cannot connect to %s (port %hu): %s", host,
port, socket_strerror(socket_errno));
- return -1;
+ return INVALID_SOCKET;
}
return fd;
}
@@ -133,7 +134,7 @@ internal_open(struct remctl *r, const char *host, unsigned short port,
{
int status, flags;
bool port_fallback = false;
- int fd = -1;
+ SOCKET fd = INVALID_SOCKET;
gss_buffer_desc send_tok, recv_tok, *token_ptr;
gss_buffer_desc empty_token = { 0, (void *) "" };
gss_name_t name = GSS_C_NO_NAME;
@@ -156,9 +157,9 @@ internal_open(struct remctl *r, const char *host, unsigned short port,
/* Make the network connection. */
fd = internal_connect(r, host, port);
- if (fd < 0 && port_fallback)
+ if (fd == INVALID_SOCKET && port_fallback)
fd = internal_connect(r, host, REMCTL_PORT_OLD);
- if (fd < 0)
+ if (fd == INVALID_SOCKET)
goto fail;
r->fd = fd;
@@ -259,9 +260,9 @@ internal_open(struct remctl *r, const char *host, unsigned short port,
return true;
fail:
- if (fd >= 0)
+ if (fd != INVALID_SOCKET)
socket_close(fd);
- r->fd = -1;
+ r->fd = INVALID_SOCKET;
if (name != GSS_C_NO_NAME)
gss_release_name(&minor, &name);
if (gss_context != GSS_C_NO_CONTEXT)
diff --git a/config.h.w32 b/config.h.w32
index 376efca..9fabc79 100644
--- a/config.h.w32
+++ b/config.h.w32
@@ -64,3 +64,7 @@
/* Define to 1 if you have the declaration of `gss_mech_krb5', and to 0 if you
don't. */
#define HAVE_DECL_GSS_MECH_KRB5 1
+
+#pragma warning( disable: 4068 ) /* unknown pragma */
+#pragma warning( disable: 4996 ) /* POSIX strdup */
+
diff --git a/configure.bat b/configure.cmd
index 0c33c20..6d80610 100644
--- a/configure.bat
+++ b/configure.cmd
@@ -9,7 +9,7 @@ copy /y config.h.w32 config.h > nul
copy /y Makefile.w32 Makefile > nul
setlocal
-FOR /F "usebackq tokens=2 delims='=" %%i in (`findstr /R "^PACKAGE_VERSION=" configure`) DO SET VERSION=%%i
+FOR /F "usebackq tokens=4 delims=[]" %%i in (`findstr /R "^AC_INIT" configure.ac`) DO SET VERSION=%%i
FOR /F "usebackq tokens=1 delims=." %%i in ('%VERSION%') DO SET MAJOR=%%i
FOR /F "usebackq tokens=2 delims=." %%i in ('%VERSION%') DO SET MINOR=%%i
diff --git a/portable/socket.h b/portable/socket.h
index 07d62cc..c6e90a6 100644
--- a/portable/socket.h
+++ b/portable/socket.h
@@ -108,6 +108,8 @@ const char *socket_strerror(int);
# define socket_errno errno
# define socket_set_errno(e) errno = (e)
# define socket_strerror(e) strerror(e)
+# define SOCKET int
+# define INVALID_SOCKET -1
#endif
/* Some systems don't define INADDR_LOOPBACK. */
diff --git a/util/gss-tokens.c b/util/gss-tokens.c
index 7e2c3fe..b707277 100644
--- a/util/gss-tokens.c
+++ b/util/gss-tokens.c
@@ -46,7 +46,7 @@ enum token_status token_recv(int, int *, gss_buffer_t, size_t);
* side to reply with a MIC, which we then verify.
*/
enum token_status
-token_send_priv(int fd, gss_ctx_id_t ctx, int flags, gss_buffer_t tok,
+token_send_priv(SOCKET fd, gss_ctx_id_t ctx, int flags, gss_buffer_t tok,
OM_uint32 *major, OM_uint32 *minor)
{
gss_buffer_desc out, mic;
@@ -95,7 +95,7 @@ token_send_priv(int fd, gss_ctx_id_t ctx, int flags, gss_buffer_t tok,
* and send it back.
*/
enum token_status
-token_recv_priv(int fd, gss_ctx_id_t ctx, int *flags, gss_buffer_t tok,
+token_recv_priv(SOCKET fd, gss_ctx_id_t ctx, int *flags, gss_buffer_t tok,
size_t max, OM_uint32 *major, OM_uint32 *minor)
{
gss_buffer_desc in, mic;
diff --git a/util/messages.c b/util/messages.c
index 51e8579..5dc4c5a 100644
--- a/util/messages.c
+++ b/util/messages.c
@@ -182,7 +182,7 @@ message_log_syslog(int pri, int len, const char *fmt, va_list args, int err)
eventlog = RegisterEventSource(NULL, message_program_name);
if (eventlog != NULL) {
- ReportEvent(eventlog, pri, 0, 0, NULL, 1, 0, &buffer, NULL);
+ ReportEvent(eventlog, (WORD)pri, 0, 0, NULL, 1, 0, &buffer, NULL);
CloseEventLog(eventlog);
}
}
diff --git a/util/network.c b/util/network.c
index e4e602f..5c79be7 100644
--- a/util/network.c
+++ b/util/network.c
@@ -47,11 +47,11 @@
*/
#ifdef SO_REUSEADDR
static void
-network_set_reuseaddr(int fd)
+network_set_reuseaddr(SOCKET fd)
{
int flag = 1;
- if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag)) < 0)
+ if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char *)&flag, sizeof(flag)) < 0)
syswarn("cannot mark bind address reusable");
}
#endif
@@ -61,18 +61,18 @@ network_set_reuseaddr(int fd)
* Create an IPv4 socket and bind it, returning the resulting file descriptor
* (or -1 on a failure).
*/
-int
+SOCKET
network_bind_ipv4(const char *address, unsigned short port)
{
- int fd;
+ SOCKET fd;
struct sockaddr_in server;
struct in_addr addr;
/* Create the socket. */
fd = socket(PF_INET, SOCK_STREAM, IPPROTO_IP);
- if (fd < 0) {
+ if (fd == INVALID_SOCKET) {
syswarn("cannot create IPv4 socket for %s,%hu", address, port);
- return -1;
+ return INVALID_SOCKET;
}
network_set_reuseaddr(fd);
@@ -85,13 +85,13 @@ network_bind_ipv4(const char *address, unsigned short port)
server.sin_port = htons(port);
if (!inet_aton(address, &addr)) {
warn("invalid IPv4 address %s", address);
- return -1;
+ return INVALID_SOCKET;
}
server.sin_addr = addr;
sin_set_length(&server);
if (bind(fd, (struct sockaddr *) &server, sizeof(server)) < 0) {
syswarn("cannot bind socket for %s,%hu", address, port);
- return -1;
+ return INVALID_SOCKET;
}
return fd;
}
@@ -105,19 +105,19 @@ network_bind_ipv4(const char *address, unsigned short port)
* userland but the kernel doesn't support it.
*/
#if HAVE_INET6
-int
+SOCKET
network_bind_ipv6(const char *address, unsigned short port)
{
- int fd;
+ SOCKET fd;
struct sockaddr_in6 server;
struct in6_addr addr;
/* Create the socket. */
fd = socket(PF_INET6, SOCK_STREAM, IPPROTO_IP);
- if (fd < 0) {
+ if (fd == INVALID_SOCKET) {
if (socket_errno != EAFNOSUPPORT && socket_errno != EPROTONOSUPPORT)
syswarn("cannot create IPv6 socket for %s,%hu", address, port);
- return -1;
+ return INVALID_SOCKET;
}
network_set_reuseaddr(fd);
@@ -131,23 +131,23 @@ network_bind_ipv6(const char *address, unsigned short port)
if (inet_pton(AF_INET6, address, &addr) < 1) {
warn("invalid IPv6 address %s", address);
socket_close(fd);
- return -1;
+ return INVALID_SOCKET;
}
server.sin6_addr = addr;
sin6_set_length(&server);
if (bind(fd, (struct sockaddr *) &server, sizeof(server)) < 0) {
syswarn("cannot bind socket for %s,%hu", address, port);
socket_close(fd);
- return -1;
+ return INVALID_SOCKET;
}
return fd;
}
#else /* HAVE_INET6 */
-int
+SOCKET
network_bind_ipv6(const char *address, unsigned short port)
{
warn("cannot bind %s,%hu: not built with IPv6 support", address, port);
- return -1;
+ return INVALID_SOCKET;
}
#endif /* HAVE_INET6 */
@@ -164,7 +164,8 @@ void
network_bind_all(unsigned short port, int **fds, int *count)
{
struct addrinfo hints, *addrs, *addr;
- int error, fd, size;
+ int error, size;
+ SOCKET fd;
char service[16], name[INET6_ADDRSTRLEN];
*count = 0;
@@ -195,10 +196,10 @@ network_bind_all(unsigned short port, int **fds, int *count)
fd = network_bind_ipv6(name, port);
else
continue;
- if (fd >= 0) {
+ if (fd != INVALID_SOCKET) {
if (*count >= size) {
size += 2;
- *fds = xrealloc(*fds, size * sizeof(int));
+ *fds = xrealloc(*fds, size * sizeof(SOCKET));
}
(*fds)[*count] = fd;
(*count)++;
@@ -208,13 +209,13 @@ network_bind_all(unsigned short port, int **fds, int *count)
}
#else /* HAVE_INET6 */
void
-network_bind_all(unsigned short port, int **fds, int *count)
+network_bind_all(unsigned short port, SOCKET **fds, int *count)
{
- int fd;
+ SOCKET fd;
fd = network_bind_ipv4("0.0.0.0", port);
if (fd >= 0) {
- *fds = xmalloc(sizeof(int));
+ *fds = xmalloc(sizeof(SOCKET));
*fds[0] = fd;
*count = 1;
} else {
@@ -231,7 +232,7 @@ network_bind_all(unsigned short port, int **fds, int *count)
* success and false on failure.
*/
static int
-network_source(int fd, int family, const char *source)
+network_source(SOCKET fd, int family, const char *source)
{
if (source == NULL)
return 1;
@@ -271,18 +272,18 @@ network_source(int fd, int family, const char *source)
* connects. Returns the file descriptor of the open socket on success, or -1
* on failure. Tries to leave the reason for the failure in errno.
*/
-int
+SOCKET
network_connect(struct addrinfo *ai, const char *source)
{
- int fd = -1;
+ SOCKET fd = INVALID_SOCKET;
int oerrno;
int success;
for (success = 0; ai != NULL; ai = ai->ai_next) {
- if (fd >= 0)
+ if (fd != INVALID_SOCKET)
socket_close(fd);
fd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
- if (fd < 0)
+ if (fd == INVALID_SOCKET)
continue;
if (!network_source(fd, ai->ai_family, source))
continue;
@@ -299,7 +300,7 @@ network_connect(struct addrinfo *ai, const char *source)
socket_close(fd);
socket_set_errno(oerrno);
}
- return -1;
+ return INVALID_SOCKET;
}
}
@@ -310,20 +311,21 @@ network_connect(struct addrinfo *ai, const char *source)
* -1 on failure. If getaddrinfo fails, errno may not be set to anything
* useful.
*/
-int
+SOCKET
network_connect_host(const char *host, unsigned short port,
const char *source)
{
struct addrinfo hints, *ai;
char portbuf[16];
- int fd, oerrno;
+ SOCKET fd;
+ int oerrno;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
snprintf(portbuf, sizeof(portbuf), "%d", port);
if (getaddrinfo(host, portbuf, &hints, &ai) != 0)
- return -1;
+ return INVALID_SOCKET;
fd = network_connect(ai, source);
oerrno = socket_errno;
freeaddrinfo(ai);
@@ -339,19 +341,20 @@ network_connect_host(const char *host, unsigned short port,
* failure. Intended primarily for the use of clients that will then go on to
* do a non-blocking connect.
*/
-int
+SOCKET
network_client_create(int domain, int type, const char *source)
{
- int fd, oerrno;
+ SOCKET fd;
+ int oerrno;
fd = socket(domain, type, 0);
- if (fd < 0)
- return -1;
+ if (fd == INVALID_SOCKET)
+ return INVALID_SOCKET;
if (!network_source(fd, domain, source)) {
oerrno = socket_errno;
socket_close(fd);
socket_set_errno(oerrno);
- return -1;
+ return INVALID_SOCKET;
}
return fd;
}
diff --git a/util/tokens.c b/util/tokens.c
index f357984..2d10030 100644
--- a/util/tokens.c
+++ b/util/tokens.c
@@ -38,17 +38,14 @@
* length, using multiple reads if needed and handling EINTR and EAGAIN.
*/
static ssize_t
-xread(int fd, void *buffer, size_t size)
+xread(SOCKET fd, void *buffer, size_t size)
{
size_t total;
ssize_t status;
int count = 0;
- if (size == 0)
- return 0;
-
/* Abort the read if we try 100 times with no forward progress. */
- for (total = 0; total < size; total += status) {
+ for (total = 0, status = 0; total < size; total += status) {
if (++count > 100)
break;
status = socket_read(fd, (char *) buffer + total, size - total);
@@ -72,7 +69,7 @@ xread(int fd, void *buffer, size_t size)
* writes).
*/
enum token_status
-token_send(int fd, int flags, gss_buffer_t tok)
+token_send(SOCKET fd, int flags, gss_buffer_t tok)
{
ssize_t status;
size_t buflen;
@@ -120,7 +117,7 @@ token_send(int fd, int flags, gss_buffer_t tok)
* free().
*/
enum token_status
-token_recv(int fd, int *flags, gss_buffer_t tok, size_t max)
+token_recv(SOCKET fd, int *flags, gss_buffer_t tok, size_t max)
{
ssize_t status;
OM_uint32 len;
diff --git a/util/util.h b/util/util.h
index 16cdb39..ff8a57b 100644
--- a/util/util.h
+++ b/util/util.h
@@ -23,6 +23,7 @@
#include <portable/gssapi.h>
#include <portable/macros.h>
#include <portable/stdbool.h>
+#include <portable/socket.h>
#include <stdarg.h>
#include <sys/types.h>
@@ -98,17 +99,17 @@ enum error_codes {
* token returned by token_recv; this will cause crashes on Windows. Call
* free on the value member instead.
*/
-enum token_status token_send(int fd, int flags, gss_buffer_t);
-enum token_status token_recv(int fd, int *flags, gss_buffer_t, size_t max);
+enum token_status token_send(SOCKET fd, int flags, gss_buffer_t);
+enum token_status token_recv(SOCKET fd, int *flags, gss_buffer_t, size_t max);
/*
* The same, but with a GSS-API protection layer applied. On a GSS-API
* failure, the major and minor status are returned in the final two
* arguments.
*/
-enum token_status token_send_priv(int fd, gss_ctx_id_t, int flags,
+enum token_status token_send_priv(SOCKET fd, gss_ctx_id_t, int flags,
gss_buffer_t, OM_uint32 *, OM_uint32 *);
-enum token_status token_recv_priv(int fd, gss_ctx_id_t, int *flags,
+enum token_status token_recv_priv(SOCKET fd, gss_ctx_id_t, int *flags,
gss_buffer_t, size_t max, OM_uint32 *,
OM_uint32 *);
@@ -133,9 +134,9 @@ char *concatpath(const char *base, const char *name);
* the write is not making progress or there's a real error. Handle partial
* writes and EINTR/EAGAIN errors.
*/
-ssize_t xpwrite(int fd, const void *buffer, size_t size, off_t offset);
-ssize_t xwrite(int fd, const void *buffer, size_t size);
-ssize_t xwritev(int fd, const struct iovec *iov, int iovcnt);
+ssize_t xpwrite(SOCKET fd, const void *buffer, size_t size, off_t offset);
+ssize_t xwrite(SOCKET fd, const void *buffer, size_t size);
+ssize_t xwritev(SOCKET fd, const struct iovec *iov, int iovcnt);
/*
* Create a socket and bind it to the specified address and port (either IPv4
@@ -143,8 +144,8 @@ ssize_t xwritev(int fd, const struct iovec *iov, int iovcnt);
* are reported using warn/syswarn. To bind to all interfaces, use "any" or
* "all" for address.
*/
-int network_bind_ipv4(const char *address, unsigned short port);
-int network_bind_ipv6(const char *address, unsigned short port);
+SOCKET network_bind_ipv4(const char *address, unsigned short port);
+SOCKET network_bind_ipv6(const char *address, unsigned short port);
/*
* Create and bind sockets for every local address (normally two, one for IPv4
@@ -153,7 +154,7 @@ int network_bind_ipv6(const char *address, unsigned short port);
* fds will be set to an array containing the resulting file descriptors, with
* count holding the count returned.
*/
-void network_bind_all(unsigned short port, int **fds, int *count);
+void network_bind_all(unsigned short port, SOCKET **fds, int *count);
/*
* Create a socket and connect it to the remote service given by the linked
@@ -161,14 +162,14 @@ void network_bind_all(unsigned short port, int **fds, int *count);
* -1 on failure, with the error left in errno. Takes an optional source
* address.
*/
-int network_connect(struct addrinfo *, const char *source);
+SOCKET network_connect(struct addrinfo *, const char *source);
/*
* Like network_connect but takes a host and port instead. If host lookup
* fails, errno may not be set to anything useful.
*/
-int network_connect_host(const char *host, unsigned short port,
- const char *source);
+SOCKET network_connect_host(const char *host, unsigned short port,
+ const char *source);
/*
* Creates a socket of the specified domain and type and binds it to the
@@ -180,7 +181,7 @@ int network_connect_host(const char *host, unsigned short port,
* This is a lower-level function intended primarily for the use of clients
* that will then go on to do a non-blocking connect.
*/
-int network_client_create(int domain, int type, const char *source);
+SOCKET network_client_create(int domain, int type, const char *source);
/*
* Put an ASCII representation of the address in a sockaddr into the provided
@@ -205,8 +206,8 @@ unsigned short network_sockaddr_port(const struct sockaddr *);
bool network_addr_match(const char *, const char *, const char *mask);
/* Set a file descriptor close-on-exec or nonblocking. */
-bool fdflag_close_exec(int fd, bool flag);
-bool fdflag_nonblocking(int fd, bool flag);
+bool fdflag_close_exec(SOCKET fd, bool flag);
+bool fdflag_nonblocking(SOCKET fd, bool flag);
/*
* The reporting functions. The ones prefaced by "sys" add a colon, a space,