Initial commit
This commit is contained in:
47
libsst-net/Makefile
Normal file
47
libsst-net/Makefile
Normal file
@@ -0,0 +1,47 @@
|
||||
# libsst-net/Makefile
|
||||
# Author: Patrick Baggett <ptbaggett@762studios.com>
|
||||
# Created: 12/03/2012
|
||||
#
|
||||
# Purpose:
|
||||
#
|
||||
# Makefile for libsst-net
|
||||
#
|
||||
# License:
|
||||
#
|
||||
# This program is free software. It comes without any warranty, to
|
||||
# the extent permitted by applicable law. You can redistribute it
|
||||
# and/or modify it under the terms of the Do What The Fuck You Want
|
||||
# To Public License, Version 2, as published by Sam Hocevar. See
|
||||
# http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
BINNAME := $(DIST)/libsst-net.a
|
||||
ifeq ($(TARGET),debug)
|
||||
BINNAME := $(subst .a,_d.a, $(BINNAME))
|
||||
endif
|
||||
|
||||
SRC := SST_NetAddress.c \
|
||||
SST_NetSocket.c \
|
||||
|
||||
ifeq ($(SUBSYSTEM),Solaris)
|
||||
include sources-POSIX.mk
|
||||
else
|
||||
# Add platform specific code
|
||||
include sources-$(SUBSYSTEM).mk
|
||||
endif
|
||||
|
||||
OBJ := $(addprefix obj/$(ARCH)/$(TARGET)/,$(subst .c,.o,$(SRC)))
|
||||
|
||||
$(shell mkdir -p obj/$(ARCH)/$(TARGET))
|
||||
|
||||
$(BINNAME): $(OBJ)
|
||||
$(AR) cru $@ $+
|
||||
$(RANLIB) $@
|
||||
|
||||
# CLEAN
|
||||
clean:
|
||||
@-rm -r -f obj $(DIST)/libsst-net*.a
|
||||
|
||||
# *.c files to *.o files
|
||||
obj/$(ARCH)/$(TARGET)/%.o: %.c
|
||||
@echo CC $@
|
||||
@$(CC) $(CFLAGS) -c $*.c -o obj/$(ARCH)/$(TARGET)/$*.o
|
||||
44
libsst-net/POSIXPrivate.h
Normal file
44
libsst-net/POSIXPrivate.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
POSIXPrivate.h
|
||||
Author: Patrick Baggett <ptbaggett@762studios.com>
|
||||
Created: 12/3/2012
|
||||
|
||||
Purpose:
|
||||
|
||||
Private data structures for POSIX implementation of libsst-net. Not to be distributed
|
||||
as part of public SDK headers.
|
||||
|
||||
License:
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _POSIXPRIVATE_H
|
||||
#define _POSIXPRIVATE_H
|
||||
|
||||
/* Solaris needs this for FIONBIO */
|
||||
#define BSD_COMP
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
typedef int NativeSocketType;
|
||||
typedef socklen_t NativeSocketLen;
|
||||
#define SST_NATIVE_INVALIDSOCKET (-1)
|
||||
#define SST_NATIVE_NETERROR (-1)
|
||||
#define NativeCloseSocket(s) close(s)
|
||||
#define NativeIoctl(s, cmd, arg) ioctl(s, cmd, arg)
|
||||
|
||||
|
||||
#endif
|
||||
98
libsst-net/PlatformPrivate.h
Normal file
98
libsst-net/PlatformPrivate.h
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
PlatformPrivate.h
|
||||
Author: Patrick Baggett <ptbaggett@762studios.com>
|
||||
Created: 8/7/2012
|
||||
|
||||
Purpose:
|
||||
|
||||
Crossplatform include that defers to platform-specific headers. Not to be
|
||||
distributed as part of public SDK headers.
|
||||
|
||||
License:
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _SST_PLATFORMPRIVATE_H
|
||||
#define _SST_PLATFORMPRIVATE_H
|
||||
|
||||
#include <pstdint.h>
|
||||
#include <limits.h>
|
||||
#include <SST/SST_Build.h>
|
||||
#ifdef _WIN32
|
||||
#include "Win32Private.h"
|
||||
#else
|
||||
#include "POSIXPrivate.h"
|
||||
#endif
|
||||
|
||||
#include <SST/SST_NetResult.h>
|
||||
#include <SST/SST_NetTypes.h>
|
||||
|
||||
SST_NetResult NativeDecodeError(void);
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
static INLINE NativeSocketLen sockLenForNetAddr(const SST_NetAddress* addr)
|
||||
{
|
||||
NativeSocketLen socklen = 0;
|
||||
const struct sockaddr* saddr = (const struct sockaddr*)addr;
|
||||
|
||||
switch(saddr->sa_family)
|
||||
{
|
||||
case AF_INET: socklen = sizeof(struct sockaddr_in); break;
|
||||
case AF_INET6: socklen = sizeof(struct sockaddr_in6); break;
|
||||
}
|
||||
|
||||
return socklen;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
static INLINE int convertSockOpt(SST_NetSocketOption option)
|
||||
{
|
||||
int ret;
|
||||
|
||||
switch(option)
|
||||
{
|
||||
case SSTNETSOCKOPT_DEBUG: ret = SO_DEBUG; break;
|
||||
case SSTNETSOCKOPT_ACCEPTCONN: ret = SO_ACCEPTCONN; break;
|
||||
case SSTNETSOCKOPT_BROADCAST: ret = SO_BROADCAST; break;
|
||||
case SSTNETSOCKOPT_REUSEADDR: ret = SO_REUSEADDR; break;
|
||||
case SSTNETSOCKOPT_KEEPALIVE: ret = SO_KEEPALIVE; break;
|
||||
case SSTNETSOCKOPT_LINGER: ret = SO_LINGER; break;
|
||||
case SSTNETSOCKOPT_OOBINLINE: ret = SO_OOBINLINE; break;
|
||||
case SSTNETSOCKOPT_SENDBUFFERSIZE: ret = SO_SNDBUF; break;
|
||||
case SSTNETSOCKOPT_RECVBUFFERSIZE: ret = SO_RCVBUF; break;
|
||||
case SSTNETSOCKOPT_ERRORSTATUS: ret = SO_ERROR; break;
|
||||
case SSTNETSOCKOPT_SOCKETTYPE: ret = SO_TYPE; break;
|
||||
case SSTNETSOCKOPT_DONTROUTE: ret = SO_DONTROUTE; break;
|
||||
default: ret = -1; break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
static INLINE int convertSockLevel(SST_NetProtocolLevel level)
|
||||
{
|
||||
int ret;
|
||||
|
||||
switch(level)
|
||||
{
|
||||
case SSTNETPROTOLEVEL_SOCKET: ret = SO_DEBUG; break;
|
||||
default: ret = -1; break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
292
libsst-net/SST_NetAddress.c
Normal file
292
libsst-net/SST_NetAddress.c
Normal file
@@ -0,0 +1,292 @@
|
||||
/*
|
||||
SST_NetAddress.h
|
||||
Author: Patrick Baggett <ptbaggett@762studios.com>
|
||||
Created: 8/7/2012
|
||||
|
||||
Purpose:
|
||||
|
||||
Address storage manipulation
|
||||
|
||||
License:
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
*/
|
||||
|
||||
#include "PlatformPrivate.h"
|
||||
#include <SST/SST_NetAddress.h>
|
||||
#include <string.h>
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
SST_NetResult SST_Net_InitAddress(SST_NetAddress* addr, SST_NetAddressFamily family, unsigned short port)
|
||||
{
|
||||
unsigned short nboPort; /* Port in network byte order */
|
||||
size_t addrSize;
|
||||
uint8_t* asBytes = (uint8_t*)addr;
|
||||
|
||||
nboPort = htons(port);
|
||||
|
||||
/* Avoid strict aliasing violations by setting up a temporary structure and memcpy()ing. */
|
||||
|
||||
switch(family)
|
||||
{
|
||||
case SSTNETADDRFAM_IPV4:
|
||||
{
|
||||
struct sockaddr_in addr4;
|
||||
|
||||
addr4.sin_family = AF_INET;
|
||||
addr4.sin_port = nboPort;
|
||||
addr4.sin_addr.s_addr = INADDR_ANY;
|
||||
memset(&addr4.sin_zero, 0, sizeof(addr4.sin_zero));
|
||||
|
||||
addrSize = sizeof(struct sockaddr_in);
|
||||
memcpy(addr, &addr4, addrSize);
|
||||
break;
|
||||
}
|
||||
|
||||
case SSTNETADDRFAM_IPV6:
|
||||
{
|
||||
struct sockaddr_in6 addr6;
|
||||
|
||||
addr6.sin6_family = AF_INET;
|
||||
addr6.sin6_port = nboPort;
|
||||
addr6.sin6_flowinfo = 0;
|
||||
addr6.sin6_addr = in6addr_any;
|
||||
addr6.sin6_scope_id = 0;
|
||||
|
||||
addrSize = sizeof(struct sockaddr_in6);
|
||||
memcpy(addr, &addr6, addrSize);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Default: return error */
|
||||
default:
|
||||
return SSTNETRESULT_ADDRFAMNOTSUPPORTED;
|
||||
}
|
||||
|
||||
/* memset() the rest of the address storage to all-bits-zero. */
|
||||
memset(asBytes + addrSize, 0, sizeof(SST_NetAddress) - addrSize);
|
||||
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
SST_NetAddressFamily SST_Net_GetAddressFamily(const SST_NetAddress* addr)
|
||||
{
|
||||
switch(addr->ss_family)
|
||||
{
|
||||
case AF_INET: return SSTNETADDRFAM_IPV4;
|
||||
case AF_INET6: return SSTNETADDRFAM_IPV6;
|
||||
default: return SSTNETADDRFAM_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
unsigned short SST_Net_GetAddressPort(const SST_NetAddress* addr)
|
||||
{
|
||||
|
||||
switch(addr->ss_family)
|
||||
{
|
||||
case AF_INET:
|
||||
{
|
||||
const struct sockaddr_in* addr4 = (const struct sockaddr_in*)addr;
|
||||
|
||||
return ntohs(addr4->sin_port);
|
||||
}
|
||||
|
||||
case AF_INET6:
|
||||
{
|
||||
const struct sockaddr_in6* addr6 = (const struct sockaddr_in6*)addr;
|
||||
|
||||
return ntohs(addr6->sin6_port);
|
||||
}
|
||||
|
||||
default: return UINT16_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
int SST_Net_AddressCompare(const SST_NetAddress* addr1, const SST_NetAddress* addr2)
|
||||
{
|
||||
|
||||
if(addr1->ss_family != addr2->ss_family)
|
||||
return (addr1->ss_family < addr2->ss_family ? -1 : 1);
|
||||
|
||||
switch(addr1->ss_family)
|
||||
{
|
||||
case AF_INET:
|
||||
{
|
||||
const struct sockaddr_in* A = (const struct sockaddr_in*)addr1;
|
||||
const struct sockaddr_in* B = (const struct sockaddr_in*)addr2;
|
||||
|
||||
/* Are the addresses different? */
|
||||
if(A->sin_addr.s_addr != B->sin_addr.s_addr)
|
||||
return (A->sin_addr.s_addr < B->sin_addr.s_addr ? -1 : 1);
|
||||
|
||||
/* Are the ports different? */
|
||||
if(A->sin_port != B->sin_port)
|
||||
return (A->sin_port < B->sin_port ? -1 : 1);
|
||||
|
||||
/* Address/port are the same, so OK */
|
||||
return 0;
|
||||
}
|
||||
|
||||
case AF_INET6:
|
||||
{
|
||||
const struct sockaddr_in6* A = (const struct sockaddr_in6*)addr1;
|
||||
const struct sockaddr_in6* B = (const struct sockaddr_in6*)addr2;
|
||||
int result;
|
||||
|
||||
result = memcmp(&A->sin6_addr, &B->sin6_addr, sizeof(struct in6_addr));
|
||||
|
||||
/* Are the addresses different? */
|
||||
if(result != 0)
|
||||
return result;
|
||||
|
||||
/* Are the ports different? */
|
||||
if(A->sin6_port != B->sin6_port)
|
||||
return (A->sin6_port < B->sin6_port ? -1 : 1);
|
||||
|
||||
/* Address/port are the same, so OK */
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Undefined structure -> useless result */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
int SST_Net_AddressIsLocalhost(const SST_NetAddress* addr)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
switch(addr->ss_family)
|
||||
{
|
||||
case AF_INET:
|
||||
{
|
||||
struct sockaddr_in* addr4 = (struct sockaddr_in*)addr;
|
||||
|
||||
uint32_t localhost = (uint32_t)inet_addr("127.0.0.1");
|
||||
uint32_t myaddr = (uint32_t)addr4->sin_addr.s_addr;
|
||||
|
||||
/* Compare address to loopback */
|
||||
retval = (myaddr == localhost);
|
||||
}
|
||||
|
||||
case AF_INET6:
|
||||
{
|
||||
struct sockaddr_in6* addr6 = (struct sockaddr_in6*)addr;
|
||||
|
||||
/* Compare address to loopback */
|
||||
retval = (memcmp(&addr6->sin6_addr, &in6addr_loopback, sizeof(in6addr_loopback)) == 0);
|
||||
}
|
||||
|
||||
default: retval = -1; /* Error code*/
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
void SST_Net_AddressSetToLocalhost(SST_NetAddress* addr)
|
||||
{
|
||||
switch(addr->ss_family)
|
||||
{
|
||||
case AF_INET:
|
||||
{
|
||||
struct sockaddr_in* addr4 = (struct sockaddr_in*)addr;
|
||||
|
||||
addr4->sin_addr.s_addr = inet_addr("127.0.0.1");
|
||||
}
|
||||
|
||||
case AF_INET6:
|
||||
{
|
||||
struct sockaddr_in6* addr6 = (struct sockaddr_in6*)addr;
|
||||
|
||||
addr6->sin6_addr = in6addr_loopback;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
SST_NetResult SST_Net_SetAddressFromAddress(SST_NetAddress* dst, const SST_NetAddress* src)
|
||||
{
|
||||
switch(src->ss_family)
|
||||
{
|
||||
case AF_INET:
|
||||
{
|
||||
struct sockaddr_in* dstAddr = (struct sockaddr_in*)dst;
|
||||
const struct sockaddr_in* srcAddr = (const struct sockaddr_in*)src;
|
||||
|
||||
memcpy(&dstAddr->sin_addr, &srcAddr->sin_addr, sizeof(struct in_addr));
|
||||
break;
|
||||
}
|
||||
|
||||
case AF_INET6:
|
||||
{
|
||||
struct sockaddr_in6* dstAddr = (struct sockaddr_in6*)dst;
|
||||
const struct sockaddr_in6* srcAddr = (const struct sockaddr_in6*)src;
|
||||
|
||||
memcpy(&dstAddr->sin6_addr, &srcAddr->sin6_addr, sizeof(struct in6_addr));
|
||||
break;
|
||||
}
|
||||
/* Default: return error */
|
||||
default:
|
||||
return SSTNETRESULT_ADDRFAMNOTSUPPORTED;
|
||||
}
|
||||
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
SST_NetResult SST_Net_SetAddressFromString(SST_NetAddress* addr, const char* addrString)
|
||||
{
|
||||
int result;
|
||||
char buf[sizeof(SST_NetAddress)];
|
||||
result = inet_pton(addr->ss_family, addrString, buf);
|
||||
|
||||
if(result > 0)
|
||||
{
|
||||
switch(addr->ss_family)
|
||||
{
|
||||
case AF_INET:
|
||||
{
|
||||
struct sockaddr_in* dst = (struct sockaddr_in*)addr;
|
||||
|
||||
memcpy(&dst->sin_addr, buf, sizeof(dst->sin_addr));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case AF_INET6:
|
||||
{
|
||||
struct sockaddr_in6* dst = (struct sockaddr_in6*)addr;
|
||||
|
||||
memcpy(&dst->sin6_addr, buf, sizeof(dst->sin6_addr));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
}
|
||||
else if(result == 0)
|
||||
return SSTNETRESULT_BADADDRESSSTRING;
|
||||
|
||||
//Other error
|
||||
return NativeDecodeError();
|
||||
}
|
||||
29
libsst-net/SST_NetInit_Generic.c
Normal file
29
libsst-net/SST_NetInit_Generic.c
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
SST_NetInit_Generic.c
|
||||
Author: Patrick Baggett <ptbaggett@762studios.com>
|
||||
Created: 8/7/2012
|
||||
|
||||
Purpose:
|
||||
|
||||
libsst-net initialization functions for platforms that do not need them.
|
||||
|
||||
License:
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
*/
|
||||
|
||||
int SST_Net_Init(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void SST_Net_Shutdown(void)
|
||||
{
|
||||
/* Intentionally blank */
|
||||
}
|
||||
|
||||
36
libsst-net/SST_NetInit_Win32.c
Normal file
36
libsst-net/SST_NetInit_Win32.c
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
SST_NetInit_Win32.c
|
||||
Author: Patrick Baggett <ptbaggett@762studios.com>
|
||||
Created: 8/7/2012
|
||||
|
||||
Purpose:
|
||||
|
||||
libsst-net initialization functions for Win32
|
||||
|
||||
License:
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
*/
|
||||
|
||||
#include "PlatformPrivate.h"
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
int SST_Net_Init(void)
|
||||
{
|
||||
WSADATA wsainfo;
|
||||
|
||||
return (WSAStartup(MAKEWORD(2,2), &wsainfo) == 0);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
void SST_Net_Shutdown(void)
|
||||
{
|
||||
WSACleanup();
|
||||
}
|
||||
64
libsst-net/SST_NetResult_POSIX.c
Normal file
64
libsst-net/SST_NetResult_POSIX.c
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
SST_NetResult_POSIX.c
|
||||
Authors: Patrick Baggett <ptbaggett@762studios.com>
|
||||
Created: 12/03/2012
|
||||
|
||||
Purpose:
|
||||
|
||||
errno to libsst-net error codes
|
||||
|
||||
License:
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
*/
|
||||
|
||||
#include <SST/SST_NetResult.h>
|
||||
#include "PlatformPrivate.h"
|
||||
#include <errno.h>
|
||||
|
||||
SST_NetResult NativeDecodeError(void)
|
||||
{
|
||||
SST_NetResult e;
|
||||
switch(errno)
|
||||
{
|
||||
case EAFNOSUPPORT: e = SSTNETRESULT_ADDRFAMNOTSUPPORTED; break;
|
||||
case EINPROGRESS: e = SSTNETRESULT_INPROGRESS; break;
|
||||
case EMFILE: e = SSTNETRESULT_NOFILESAVAILABLE; break;
|
||||
case EINVAL: e = SSTNETRESULT_INVALIDARGS; break;
|
||||
case ENOBUFS: return SSTNETRESULT_NOSPACE; break;
|
||||
case EPROTONOSUPPORT: e = SSTNETRESULT_PROTOCOLNOTSUPPORTED; break;
|
||||
case EPROTOTYPE: e = SSTNETRESULT_WRONGPROTOCOLFORSOCK; break;
|
||||
case ESOCKTNOSUPPORT: e = SSTNETRESULT_SOCKETNOTSUPPORTED; break;
|
||||
case EFAULT: return SSTNETRESULT_BADPOINTER; break;
|
||||
case ENOTSOCK: return SSTNETRESULT_NOTASOCKET; break;
|
||||
case EADDRINUSE: return SSTNETRESULT_ADDRINUSE; break;
|
||||
case EISCONN: return SSTNETRESULT_ALREADYCONNECTED; break;
|
||||
case EOPNOTSUPP: return SSTNETRESULT_OPNOTSUPPORTED; break;
|
||||
case EINTR: return SSTNETRESULT_INTERRUPTED; break;
|
||||
case EALREADY: return SSTNETRESULT_ALREADYCONNECTING; break;
|
||||
case EADDRNOTAVAIL: return SSTNETRESULT_ADDRNOTAVAILABLE; break;
|
||||
case ECONNREFUSED: return SSTNETRESULT_CONNECTIONREFUSED; break;
|
||||
case ENETUNREACH: return SSTNETRESULT_NETUNREACHABLE; break;
|
||||
case EHOSTUNREACH: return SSTNETRESULT_HOSTUNREACHABLE; break;
|
||||
case ETIMEDOUT: return SSTNETRESULT_TIMEDOUT; break;
|
||||
case EWOULDBLOCK: return SSTNETRESULT_WOULDBLOCK; break;
|
||||
case EACCES: return SSTNETRESULT_ACCESSDENIED; break;
|
||||
case ECONNRESET: return SSTNETRESULT_CONNECTIONRESET; break;
|
||||
case ENOTCONN: return SSTNETRESULT_NOTCONNECTED; break;
|
||||
case ENETRESET: return SSTNETRESULT_NETRESET; break;
|
||||
case ESHUTDOWN: return SSTNETRESULT_SOCKETSHUTDOWN; break;
|
||||
case EMSGSIZE: return SSTNETRESULT_MESSAGESIZE; break;
|
||||
case ECONNABORTED: return SSTNETRESULT_CONNECTIONABORTED; break;
|
||||
case EDESTADDRREQ: return SSTNETRESULT_NODESTADDRESSGIVEN; break;
|
||||
|
||||
|
||||
default: e = SSTNETRESULT_UNKNOWN; break;
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
67
libsst-net/SST_NetResult_Win32.c
Normal file
67
libsst-net/SST_NetResult_Win32.c
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
SST_NetResult_Win32.c
|
||||
Authors: Chris Ertel <crertel@762studios.com, Patrick Baggett <ptbaggett@762studios.com>
|
||||
Created: 8/7/2012
|
||||
|
||||
Purpose:
|
||||
|
||||
Winsock2 to libsst-net error codes
|
||||
|
||||
License:
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
*/
|
||||
#include <SST/SST_NetResult.h>
|
||||
#include "PlatformPrivate.h"
|
||||
|
||||
SST_NetResult NativeDecodeError(void)
|
||||
{
|
||||
SST_NetResult e;
|
||||
switch(WSAGetLastError())
|
||||
{
|
||||
case WSANOTINITIALISED: e = SSTNETRESULT_NETNOTINIT; break;
|
||||
case WSAENETDOWN: e = SSTNETRESULT_NETDOWN; break;
|
||||
case WSAEAFNOSUPPORT: e = SSTNETRESULT_ADDRFAMNOTSUPPORTED; break;
|
||||
case WSAEINPROGRESS: e = SSTNETRESULT_INPROGRESS; break;
|
||||
case WSAEMFILE: e = SSTNETRESULT_NOFILESAVAILABLE; break;
|
||||
case WSAEINVAL: e = SSTNETRESULT_INVALIDARGS; break;
|
||||
case WSAENOBUFS: return SSTNETRESULT_NOSPACE; break;
|
||||
case WSAEPROTONOSUPPORT: e = SSTNETRESULT_PROTOCOLNOTSUPPORTED; break;
|
||||
case WSAEPROTOTYPE: e = SSTNETRESULT_WRONGPROTOCOLFORSOCK; break;
|
||||
case WSAEPROVIDERFAILEDINIT: e = SSTNETRESULT_NETNOTINIT; break;
|
||||
case WSAESOCKTNOSUPPORT: e = SSTNETRESULT_SOCKETNOTSUPPORTED; break;
|
||||
case WSAEINVALIDPROVIDER: e = SSTNETRESULT_NETNOTINIT; break;
|
||||
case WSAEINVALIDPROCTABLE: e = SSTNETRESULT_NETNOTINIT; break;
|
||||
case WSAEFAULT: return SSTNETRESULT_BADPOINTER; break;
|
||||
case WSAENOTSOCK: return SSTNETRESULT_NOTASOCKET; break;
|
||||
case WSAEADDRINUSE: return SSTNETRESULT_ADDRINUSE; break;
|
||||
case WSAEISCONN: return SSTNETRESULT_ALREADYCONNECTED; break;
|
||||
case WSAEOPNOTSUPP: return SSTNETRESULT_OPNOTSUPPORTED; break;
|
||||
case WSAEINTR: return SSTNETRESULT_INTERRUPTED; break;
|
||||
case WSAEALREADY: return SSTNETRESULT_ALREADYCONNECTING; break;
|
||||
case WSAEADDRNOTAVAIL: return SSTNETRESULT_ADDRNOTAVAILABLE; break;
|
||||
case WSAECONNREFUSED: return SSTNETRESULT_CONNECTIONREFUSED; break;
|
||||
case WSAENETUNREACH: return SSTNETRESULT_NETUNREACHABLE; break;
|
||||
case WSAEHOSTUNREACH: return SSTNETRESULT_HOSTUNREACHABLE; break;
|
||||
case WSAETIMEDOUT: return SSTNETRESULT_TIMEDOUT; break;
|
||||
case WSAEWOULDBLOCK: return SSTNETRESULT_WOULDBLOCK; break;
|
||||
case WSAEACCES: return SSTNETRESULT_ACCESSDENIED; break;
|
||||
case WSAECONNRESET: return SSTNETRESULT_CONNECTIONRESET; break;
|
||||
case WSAENOTCONN: return SSTNETRESULT_NOTCONNECTED; break;
|
||||
case WSAENETRESET: return SSTNETRESULT_NETRESET; break;
|
||||
case WSAESHUTDOWN: return SSTNETRESULT_SOCKETSHUTDOWN; break;
|
||||
case WSAEMSGSIZE: return SSTNETRESULT_MESSAGESIZE; break;
|
||||
case WSAECONNABORTED: return SSTNETRESULT_CONNECTIONABORTED; break;
|
||||
case WSAEDESTADDRREQ: return SSTNETRESULT_NODESTADDRESSGIVEN; break;
|
||||
|
||||
|
||||
default: e = SSTNETRESULT_UNKNOWN; break;
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
309
libsst-net/SST_NetSocket.c
Normal file
309
libsst-net/SST_NetSocket.c
Normal file
@@ -0,0 +1,309 @@
|
||||
/*
|
||||
SST_NetSocket.c
|
||||
Author: Patrick Baggett <ptbaggett@762studios.com>
|
||||
Created: 8/7/2012
|
||||
|
||||
Purpose:
|
||||
|
||||
Socket functions
|
||||
|
||||
License:
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
*/
|
||||
#include <SST/SST_NetSocket.h>
|
||||
#include "PlatformPrivate.h"
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
SST_NetResult SST_Net_Socket( SST_NetAddressFamily _addressFamily, SST_NetSocketType _socketType, SST_NetProtocol _protocol, SST_Socket* _createdSocket)
|
||||
{
|
||||
NativeSocketType sock;
|
||||
int af;
|
||||
int socktype;
|
||||
int proto;
|
||||
|
||||
/* Configure socket options */
|
||||
switch (_addressFamily)
|
||||
{
|
||||
case SSTNETADDRFAM_IPV4: af = AF_INET; break;
|
||||
case SSTNETADDRFAM_IPV6: af = AF_INET6; break;
|
||||
default: return SSTNETRESULT_ADDRFAMNOTSUPPORTED; break;
|
||||
}
|
||||
|
||||
switch (_socketType)
|
||||
{
|
||||
case SSTNETSOCKTYPE_STREAM: socktype = SOCK_STREAM; break;
|
||||
case SSTNETSOCKTYPE_DATAGRAM: socktype = SOCK_DGRAM; break;
|
||||
default: return SSTNETRESULT_SOCKETNOTSUPPORTED; break;
|
||||
}
|
||||
|
||||
switch (_protocol)
|
||||
{
|
||||
case SSTNETPROTOCOL_TCP: proto = IPPROTO_TCP; break;
|
||||
case SSTNETPROTOCOL_UDP: proto = IPPROTO_UDP; break;
|
||||
default: return SSTNETRESULT_PROTOCOLNOTSUPPORTED; break;
|
||||
}
|
||||
|
||||
/* Create socket */
|
||||
sock = socket(af, socktype, proto);
|
||||
if(sock == SST_NATIVE_INVALIDSOCKET)
|
||||
return NativeDecodeError();
|
||||
|
||||
*_createdSocket = (SST_Socket)sock;
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
SST_NetResult SST_Net_Bind(SST_Socket sock, const SST_NetAddress* addr)
|
||||
{
|
||||
NativeSocketLen socklen;
|
||||
NativeSocketType s = (NativeSocketType)sock;
|
||||
|
||||
socklen = sockLenForNetAddr(addr);
|
||||
|
||||
if(bind(s, (struct sockaddr*) addr, socklen) == 0)
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
|
||||
return NativeDecodeError();
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
SST_NetResult SST_Net_Listen( SST_Socket sock, int backlog)
|
||||
{
|
||||
NativeSocketType s = (NativeSocketType)sock;
|
||||
|
||||
if(listen(s, backlog) == 0)
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
|
||||
return NativeDecodeError();
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
SST_NetResult SST_Net_Connect( SST_Socket sock, const SST_NetAddress* addr)
|
||||
{
|
||||
int socklen;
|
||||
NativeSocketType s = (NativeSocketType)sock;
|
||||
|
||||
socklen = sockLenForNetAddr(addr);
|
||||
|
||||
if(connect(s, (struct sockaddr*)addr, socklen) == 0)
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
|
||||
return NativeDecodeError();
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
SST_NetResult SST_Net_Accept(SST_Socket sock, SST_NetAddress* addr, SST_Socket* newSockReturn)
|
||||
{
|
||||
NativeSocketType s = (NativeSocketType)sock;
|
||||
NativeSocketType newSock;
|
||||
|
||||
NativeSocketLen addrlen = (int) sizeof(SST_NetAddress);
|
||||
|
||||
newSock = accept(s, (struct sockaddr*)addr, &addrlen);
|
||||
if(newSock != SST_NATIVE_INVALIDSOCKET)
|
||||
{
|
||||
*newSockReturn = newSock;
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
}
|
||||
|
||||
return NativeDecodeError();
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
SST_NetResult SST_Net_Send(SST_Socket sock, const void* data, size_t length, uint32_t sendFlags, size_t* bytesSentReturn)
|
||||
{
|
||||
NativeSocketType s = (NativeSocketType)sock;
|
||||
int bytesSent;
|
||||
int flags = 0;
|
||||
int sendAmount;
|
||||
|
||||
flags |= (sendFlags & SSTNET_DONTROUTE ? MSG_DONTROUTE : 0);
|
||||
flags |= (sendFlags & SSTNET_OOB ? MSG_OOB : 0);
|
||||
|
||||
/* Ensure send() with huge values doesn't result in negative numbers when typecasted to an int */
|
||||
if(length > INT_MAX)
|
||||
sendAmount = INT_MAX;
|
||||
else
|
||||
sendAmount = (int)length;
|
||||
|
||||
bytesSent = send(s, data, sendAmount,flags);
|
||||
if(bytesSent != SST_NATIVE_NETERROR)
|
||||
{
|
||||
*bytesSentReturn = (size_t)bytesSent;
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
}
|
||||
|
||||
return NativeDecodeError();
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
SST_NetResult SST_Net_Recv(SST_Socket sock, void* data, size_t length, uint32_t recvFlags, size_t* bytesRecvReturn)
|
||||
{
|
||||
NativeSocketType s = (NativeSocketType)sock;
|
||||
int bytesReceived;
|
||||
int flags = 0;
|
||||
int recvSize;
|
||||
|
||||
flags |= (recvFlags & SSTNET_PEEK)? MSG_PEEK : 0;
|
||||
flags |= (recvFlags & SSTNET_OOB)? MSG_OOB : 0;
|
||||
flags |= (recvFlags & SSTNET_WAITALL)? MSG_WAITALL : 0;
|
||||
|
||||
/* Ensure recv() with huge values doesn't result in negative numbers when typecasted to an int */
|
||||
if(length > INT_MAX)
|
||||
recvSize = INT_MAX;
|
||||
else
|
||||
recvSize = (int)length;
|
||||
|
||||
bytesReceived = recv(s, data, recvSize, flags);
|
||||
if(bytesReceived != SST_NATIVE_NETERROR)
|
||||
{
|
||||
*bytesRecvReturn = (size_t)bytesReceived;
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
}
|
||||
|
||||
return NativeDecodeError();
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
SST_NetResult SST_Net_SendTo(SST_Socket sock, const void* data, size_t length, uint32_t sendFlags, const SST_NetAddress* dest, size_t* bytesSentReturn)
|
||||
{
|
||||
NativeSocketType s = (NativeSocketType)sock;
|
||||
int bytesSent;
|
||||
int flags = 0;
|
||||
int sendAmount;
|
||||
NativeSocketLen addrLen = sockLenForNetAddr(dest);
|
||||
|
||||
flags |= (sendFlags & SSTNET_DONTROUTE)? MSG_DONTROUTE : 0;
|
||||
flags |= (sendFlags & SSTNET_OOB)? MSG_OOB : 0;
|
||||
|
||||
/* Ensure send() with huge values doesn't result in negative numbers when typecasted to an int */
|
||||
if(length > INT_MAX)
|
||||
sendAmount = INT_MAX;
|
||||
else
|
||||
sendAmount = (int)length;
|
||||
|
||||
|
||||
bytesSent = sendto(s, data, sendAmount, flags, (struct sockaddr*)dest, addrLen);
|
||||
if(bytesSent != SST_NATIVE_NETERROR)
|
||||
{
|
||||
*bytesSentReturn = (size_t)bytesSent;
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
}
|
||||
|
||||
return NativeDecodeError();
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
SST_NetResult SST_Net_RecvFrom(SST_Socket sock, void* data, size_t length, uint32_t recvFlags, SST_NetAddress* senderReturn, size_t* bytesRecvReturn)
|
||||
{
|
||||
NativeSocketType s = (NativeSocketType)sock;
|
||||
int bytesReceived;
|
||||
int flags = 0;
|
||||
NativeSocketLen addrsize = sizeof(SST_NetAddress);
|
||||
int recvSize;
|
||||
|
||||
flags |= (recvFlags & SSTNET_DONTROUTE)? MSG_DONTROUTE : 0;
|
||||
flags |= (recvFlags & SSTNET_OOB)? MSG_OOB : 0;
|
||||
|
||||
/* Ensure recv() with huge values doesn't result in negative numbers when typecasted to an int */
|
||||
if(length > INT_MAX)
|
||||
recvSize = INT_MAX;
|
||||
else
|
||||
recvSize = (int)length;
|
||||
|
||||
bytesReceived = recvfrom(s, data, recvSize, flags, (struct sockaddr*)senderReturn, &addrsize);
|
||||
|
||||
if(bytesReceived != SST_NATIVE_NETERROR)
|
||||
{
|
||||
*bytesRecvReturn = (size_t)bytesReceived;
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
}
|
||||
|
||||
return NativeDecodeError();
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
void SST_Net_Close(SST_Socket sock)
|
||||
{
|
||||
NativeSocketType s = (NativeSocketType)sock;
|
||||
|
||||
NativeCloseSocket(s);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
SST_NetResult SST_Net_GetSockOpt(SST_Socket sock, SST_NetProtocolLevel level, SST_NetSocketOption option, void* optionStorage, size_t* optionStorageSize)
|
||||
{
|
||||
NativeSocketType s = (NativeSocketType)sock;
|
||||
int opt;
|
||||
int lvl;
|
||||
NativeSocketLen optlen;
|
||||
|
||||
lvl = convertSockLevel(level);
|
||||
if(lvl == -1)
|
||||
return SSTNETRESULT_BADPROTOCOLLEVEL;
|
||||
|
||||
opt = convertSockOpt(option);
|
||||
if(opt == -1)
|
||||
return SSTNETRESULT_BADSOCKETOP;
|
||||
|
||||
optlen = (NativeSocketLen)*optionStorageSize;
|
||||
if(getsockopt(s, lvl, opt, optionStorage, &optlen) == SST_NATIVE_NETERROR)
|
||||
return NativeDecodeError();
|
||||
|
||||
*optionStorageSize = (size_t)optlen;
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
SST_NetResult SST_Net_SetSockOpt(SST_Socket sock, SST_NetProtocolLevel level, SST_NetSocketOption option, const void* optionData, size_t optionDataSize)
|
||||
{
|
||||
NativeSocketType s = (NativeSocketType)sock;
|
||||
int opt;
|
||||
int lvl;
|
||||
int optlen;
|
||||
|
||||
lvl = convertSockLevel(level);
|
||||
if(lvl == -1)
|
||||
return SSTNETRESULT_BADPROTOCOLLEVEL;
|
||||
|
||||
opt = convertSockOpt(option);
|
||||
if(opt == -1)
|
||||
return SSTNETRESULT_BADSOCKETOP;
|
||||
|
||||
optlen = (int)optionDataSize;
|
||||
if(setsockopt(s, lvl, opt, (const void*)optionData, optlen) == SST_NATIVE_NETERROR)
|
||||
return NativeDecodeError();
|
||||
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
SST_NetResult SST_Net_SetNonblock(SST_Socket sock, int nonblock)
|
||||
{
|
||||
NativeSocketType s = (NativeSocketType)sock;
|
||||
int nb = (nonblock != 0);
|
||||
|
||||
if(NativeIoctl(s, FIONBIO, (void*)&nb) != SST_NATIVE_NETERROR)
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
|
||||
return NativeDecodeError();
|
||||
}
|
||||
772
libsst-net/SST_Sockets_Win32.c
Normal file
772
libsst-net/SST_Sockets_Win32.c
Normal file
@@ -0,0 +1,772 @@
|
||||
/*
|
||||
SST_Sockets_Win32.c
|
||||
Author: Chris Ertel <crertel@762studios.com>
|
||||
Created: 07/15/2012
|
||||
|
||||
Purpose:
|
||||
|
||||
libsst-net BSD sockets wrapper, Win32 implementation.
|
||||
|
||||
License:
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
*/
|
||||
|
||||
#include <SST/SST_Sockets.h>
|
||||
#include <SST/SST_NetTypes.h>
|
||||
#include <SST/SST_NetResult.h>
|
||||
#include "Win32Private.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct SST_NetPollDescriptorSet_Win32
|
||||
{
|
||||
size_t Count;
|
||||
WSAPOLLFD* Descriptors;
|
||||
} SST_NetPollDescriptorSet_Win32;
|
||||
|
||||
|
||||
typedef struct SST_NetAddrInfo_Win32
|
||||
{
|
||||
SST_NetAddrInfoFlags flags;
|
||||
SST_NetAddressFamily family;
|
||||
SST_NetSocketType socketType;
|
||||
SST_NetProtocol protocol;
|
||||
char* canonicalName;
|
||||
SOCKADDR_STORAGE addr;
|
||||
struct SST_NetAddrInfo_Win32* next;
|
||||
} SST_NetAddrInfo_Win32;
|
||||
SST_NetResult SST_Net_CreateSocketSet( SST_NetSocketSet* _out )
|
||||
{
|
||||
fd_set* ret;
|
||||
|
||||
ret = (fd_set*) calloc( 1, sizeof(fd_set) );
|
||||
if (ret == NULL)
|
||||
{
|
||||
return SSTNETRESULT_NOSPACE;
|
||||
}
|
||||
else
|
||||
{
|
||||
*_out = (SST_NetSocketSet) ret;
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
void SST_Net_DestroySocketSet( SST_NetSocketSet _set )
|
||||
{
|
||||
free( (void*) _set );
|
||||
}
|
||||
|
||||
void SST_Net_ClearSocketFromSocketSet( SST_NetSocketSet _set, SST_Socket _sock)
|
||||
{
|
||||
FD_CLR( ( *(SOCKET*)_sock), (fd_set*) _set );
|
||||
}
|
||||
|
||||
void SST_Net_AddSocketToSocketSet( SST_NetSocketSet _set, SST_Socket _sock)
|
||||
{
|
||||
FD_SET( ( *(SOCKET*)_sock), (fd_set*) _set );
|
||||
}
|
||||
|
||||
int SST_Net_IsSocketInSocketSet( SST_NetSocketSet _set, SST_Socket _sock)
|
||||
{
|
||||
return FD_ISSET( ( *(SOCKET*)_sock), (fd_set*) _set );
|
||||
}
|
||||
|
||||
void SST_Net_ZeroSocketSet( SST_NetSocketSet _set)
|
||||
{
|
||||
FD_ZERO( (fd_set*) _set );
|
||||
}
|
||||
|
||||
static SST_NetResult decodeerror_select(int _errcode)
|
||||
{
|
||||
switch( _errcode )
|
||||
{
|
||||
case WSANOTINITIALISED: return SSTNETRESULT_NETNOTINIT; break;
|
||||
case WSAEFAULT: return SSTNETRESULT_BADPOINTER; break;
|
||||
case WSAENETDOWN: return SSTNETRESULT_NETDOWN; break;
|
||||
case WSAEINVAL: return SSTNETRESULT_INVALIDARGS; break;
|
||||
case WSAEINTR: return SSTNETRESULT_INTERRUPTED; break;
|
||||
case WSAEINPROGRESS: return SSTNETRESULT_INPROGRESS; break;
|
||||
case WSAENOTSOCK: return SSTNETRESULT_NOTASOCKET; break;
|
||||
|
||||
default: return SSTNETRESULT_UNKNOWN; break;
|
||||
}
|
||||
}
|
||||
|
||||
SST_NetResult SST_Net_Select( size_t _numSockets, SST_NetSocketSet _readSockets, SST_NetSocketSet _writeSockets, SST_NetSocketSet _errorSockets, SST_NetTimeval* _timeout, size_t* _numEvented)
|
||||
{
|
||||
int numEvented;
|
||||
struct timeval timeVal; /* really, Winsock? You couldn't typedef this? */
|
||||
|
||||
if (_timeout != NULL)
|
||||
{
|
||||
timeVal.tv_sec = _timeout->seconds;
|
||||
timeVal.tv_usec = _timeout->microseconds;
|
||||
}
|
||||
else
|
||||
{
|
||||
timeVal.tv_sec = 0;
|
||||
timeVal.tv_usec = 0;
|
||||
}
|
||||
|
||||
numEvented = select((int) _numSockets,
|
||||
(fd_set*) _readSockets,
|
||||
(fd_set*) _writeSockets,
|
||||
(fd_set*) _errorSockets,
|
||||
(_timeout != NULL)? &timeVal : NULL );
|
||||
|
||||
if (numEvented == SOCKET_ERROR)
|
||||
{
|
||||
return decodeerror_select(WSAGetLastError());
|
||||
}
|
||||
else
|
||||
{
|
||||
*_numEvented = numEvented;
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
static SST_NetResult decodeerror_poll(int _errcode)
|
||||
{
|
||||
switch( _errcode )
|
||||
{
|
||||
case WSAENETDOWN: return SSTNETRESULT_NETDOWN; break;
|
||||
case WSAEFAULT: return SSTNETRESULT_BADPOINTER; break;
|
||||
case WSAEINVAL: return SSTNETRESULT_INVALIDARGS; break;
|
||||
case WSAENOBUFS: return SSTNETRESULT_NOSPACE; break;
|
||||
|
||||
default: return SSTNETRESULT_UNKNOWN; break;
|
||||
}
|
||||
}
|
||||
|
||||
SST_NetResult SST_Net_CreatePollDescriptorSet(size_t _numDescriptors, SST_NetPollDescriptorSet* _out)
|
||||
{
|
||||
WSAPOLLFD* fds;
|
||||
SST_NetPollDescriptorSet_Win32* ret;
|
||||
|
||||
fds = (WSAPOLLFD*) calloc(_numDescriptors, sizeof(WSAPOLLFD));
|
||||
if (fds == NULL)
|
||||
return SSTNETRESULT_NOSPACE;
|
||||
|
||||
ret = (SST_NetPollDescriptorSet_Win32*) malloc( sizeof(SST_NetPollDescriptorSet_Win32) );
|
||||
if (ret == NULL)
|
||||
{
|
||||
free(fds);
|
||||
return SSTNETRESULT_NOSPACE;
|
||||
}
|
||||
|
||||
ret->Count = _numDescriptors;
|
||||
ret->Descriptors = fds;
|
||||
*_out = ret;
|
||||
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
}
|
||||
|
||||
void SST_Net_DestroyPollDescriptorSet(SST_NetPollDescriptorSet _toDestroy)
|
||||
{
|
||||
SST_NetPollDescriptorSet_Win32* desc = (SST_NetPollDescriptorSet_Win32*) _toDestroy;
|
||||
|
||||
free(desc->Descriptors);
|
||||
desc->Descriptors = NULL;
|
||||
desc->Count = 0;
|
||||
}
|
||||
|
||||
void SST_Net_SetPollDescriptorSocket(SST_NetPollDescriptorSet _descriptors, size_t _which, SST_Socket _socket)
|
||||
{
|
||||
SST_NetPollDescriptorSet_Win32* desc = (SST_NetPollDescriptorSet_Win32*) _descriptors;
|
||||
desc->Descriptors[_which].fd = *((SOCKET*) _socket);
|
||||
}
|
||||
|
||||
SST_Socket SST_Net_GetPollDescriptorSocket(SST_NetPollDescriptorSet _descriptors, size_t _which )
|
||||
{
|
||||
SST_Socket ret;
|
||||
SST_NetPollDescriptorSet_Win32* desc = (SST_NetPollDescriptorSet_Win32*) _descriptors;
|
||||
|
||||
if (convertWinSocketToSSTSocket(&(desc->Descriptors[_which].fd), &ret) != SSTNETRESULT_SUCCESS)
|
||||
{
|
||||
return SSTNET_INVALIDSOCKET;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
static short convertSSTPollFlagsToWinPollFlags(SST_NetPollFlag _flags)
|
||||
{
|
||||
short ret = 0;
|
||||
|
||||
ret |= (_flags & SSTNETPOLLFLAG_POLLPRI)? POLLPRI : 0;
|
||||
ret |= (_flags & SSTNETPOLLFLAG_POLLRDBAND)? POLLRDBAND : 0;
|
||||
ret |= (_flags & SSTNETPOLLFLAG_POLLRDNORM)? POLLRDNORM : 0;
|
||||
ret |= (_flags & SSTNETPOLLFLAG_POLLWRNORM)? POLLWRNORM : 0;
|
||||
ret |= (_flags & SSTNETPOLLFLAG_POLLERR)? POLLERR : 0;
|
||||
ret |= (_flags & SSTNETPOLLFLAG_POLLHUP)? POLLHUP : 0;
|
||||
ret |= (_flags & SSTNETPOLLFLAG_POLLNVAL)? POLLNVAL : 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void SST_Net_SetPollDescriptorFlag(SST_NetPollDescriptorSet _descriptors, size_t _which, SST_NetPollFlag _flags)
|
||||
{
|
||||
SST_NetPollDescriptorSet_Win32* desc = (SST_NetPollDescriptorSet_Win32*) _descriptors;
|
||||
desc->Descriptors[_which].events = convertSSTPollFlagsToWinPollFlags(_flags);
|
||||
}
|
||||
|
||||
static short convertWinPollFlagsToSSTPollFlags(short _flags)
|
||||
{
|
||||
SST_NetPollFlag ret = 0;
|
||||
|
||||
ret |= (_flags & POLLPRI)? SSTNETPOLLFLAG_POLLPRI : 0;
|
||||
ret |= (_flags & POLLRDBAND )? SSTNETPOLLFLAG_POLLRDBAND : 0;
|
||||
ret |= (_flags & POLLRDNORM )? SSTNETPOLLFLAG_POLLRDNORM : 0;
|
||||
ret |= (_flags & POLLWRNORM )? SSTNETPOLLFLAG_POLLWRNORM : 0;
|
||||
ret |= (_flags & POLLERR )? SSTNETPOLLFLAG_POLLERR : 0;
|
||||
ret |= (_flags & POLLHUP )? SSTNETPOLLFLAG_POLLHUP : 0;
|
||||
ret |= (_flags & POLLNVAL )? SSTNETPOLLFLAG_POLLNVAL : 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
SST_NetPollFlag SST_Net_GetPollDescriptorFlags(SST_NetPollDescriptorSet _descriptors, size_t _which)
|
||||
{
|
||||
SST_NetPollDescriptorSet_Win32* desc = (SST_NetPollDescriptorSet_Win32*) _descriptors;
|
||||
return convertWinPollFlagsToSSTPollFlags(desc->Descriptors[_which].events);
|
||||
}
|
||||
|
||||
void SST_Net_ClearPollDescriptorFlags(SST_NetPollDescriptorSet _descriptors, size_t _which)
|
||||
{
|
||||
SST_NetPollDescriptorSet_Win32* desc = (SST_NetPollDescriptorSet_Win32*) _descriptors;
|
||||
desc->Descriptors[_which].events = 0;
|
||||
}
|
||||
|
||||
SST_NetPollFlag SST_Net_GetPollDescriptorEvents(SST_NetPollDescriptorSet _descriptors, size_t _which)
|
||||
{
|
||||
SST_NetPollDescriptorSet_Win32* desc = (SST_NetPollDescriptorSet_Win32*) _descriptors;
|
||||
return convertWinPollFlagsToSSTPollFlags(desc->Descriptors[_which].revents);
|
||||
}
|
||||
|
||||
SST_NetResult SST_Net_Poll( SST_NetPollDescriptorSet _toPoll, int _timeout, size_t* _numEvented)
|
||||
{
|
||||
int polled = 0;
|
||||
SST_NetPollDescriptorSet_Win32* set = (SST_NetPollDescriptorSet_Win32*) _toPoll;
|
||||
|
||||
polled = WSAPoll( (WSAPOLLFD*)set->Descriptors,
|
||||
(ULONG) set->Count,
|
||||
_timeout);
|
||||
|
||||
if (polled == SOCKET_ERROR)
|
||||
{
|
||||
return decodeerror_poll(WSAGetLastError());
|
||||
}
|
||||
else
|
||||
{
|
||||
*_numEvented = polled;
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
static SST_NetResult decodeerror_getsockopt(int _errcode)
|
||||
{
|
||||
switch( _errcode )
|
||||
{
|
||||
case WSANOTINITIALISED: return SSTNETRESULT_NETNOTINIT; break;
|
||||
case WSAENETDOWN: return SSTNETRESULT_NETDOWN; break;
|
||||
case WSAEFAULT: return SSTNETRESULT_BADPOINTER; break;
|
||||
case WSAEINPROGRESS: return SSTNETRESULT_INPROGRESS; break;
|
||||
case WSAEINVAL: return SSTNETRESULT_INVALIDARGS; break;
|
||||
case WSAENOPROTOOPT: return SSTNETRESULT_PROTOCOLOPNOTSUPPORED; break;
|
||||
case WSAENOTSOCK: return SSTNETRESULT_NOTASOCKET; break;
|
||||
|
||||
default: return SSTNETRESULT_UNKNOWN; break;
|
||||
}
|
||||
}
|
||||
|
||||
static int convertSSTSockOptToWinSockOpt( SST_NetSocketOption _in, int* _out)
|
||||
{
|
||||
int ret = 0;
|
||||
switch(_in)
|
||||
{
|
||||
case SSTNETSOCKOPT_DEBUG: ret = SO_DEBUG; break;
|
||||
case SSTNETSOCKOPT_ACCEPTCONN: ret = SO_ACCEPTCONN; break;
|
||||
case SSTNETSOCKOPT_BROADCAST: ret = SO_BROADCAST; break;
|
||||
case SSTNETSOCKOPT_REUSEADDR: ret = SO_REUSEADDR; break;
|
||||
case SSTNETSOCKOPT_KEEPALIVE: ret = SO_KEEPALIVE; break;
|
||||
case SSTNETSOCKOPT_LINGER: ret = SO_LINGER; break;
|
||||
case SSTNETSOCKOPT_OOBINLINE: ret = SO_OOBINLINE; break;
|
||||
case SSTNETSOCKOPT_SENDBUFFERSIZE: ret = SO_SNDBUF; break;
|
||||
case SSTNETSOCKOPT_RECVBUFFERSIZE: ret = SO_RCVBUF; break;
|
||||
case SSTNETSOCKOPT_ERRORSTATUS: ret = SO_ERROR; break;
|
||||
case SSTNETSOCKOPT_SOCKETTYPE: ret = SO_TYPE; break;
|
||||
case SSTNETSOCKOPT_DONTROUTE: ret = SO_DONTROUTE; break;
|
||||
|
||||
default: return -1; break;
|
||||
}
|
||||
|
||||
*_out = ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int convertSSTSockLevelToWinSockLevel( SST_NetProtocolLevel _in, int* _out)
|
||||
{
|
||||
int ret = 0;
|
||||
switch(_in)
|
||||
{
|
||||
case SSTNETPROTOLEVEL_SOCKET: ret = SO_DEBUG; break;
|
||||
default: return -1; break;
|
||||
}
|
||||
|
||||
*_out = ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
SST_NetResult SST_Net_GetSockOpt( SST_Socket _socket, SST_NetProtocolLevel _level, SST_NetSocketOption _option, void* _optionStorage, size_t* _optionStorageSize)
|
||||
{
|
||||
int winsockopt;
|
||||
int winsocklevel;
|
||||
int errcode;
|
||||
int optlen;
|
||||
|
||||
if (convertSSTSockLevelToWinSockLevel(_level, &winsocklevel) != 0)
|
||||
return SSTNETRESULT_BADPROTOCOLLEVEL;
|
||||
|
||||
if (convertSSTSockOptToWinSockOpt(_option, &winsockopt) != 0)
|
||||
return SSTNETRESULT_BADSOCKETOP;
|
||||
|
||||
optlen = (int) _optionStorageSize;
|
||||
errcode = getsockopt( *((SOCKET*)_socket),
|
||||
winsocklevel,
|
||||
winsockopt,
|
||||
(char*) _optionStorage,
|
||||
&optlen);
|
||||
if (errcode == SOCKET_ERROR)
|
||||
{
|
||||
return decodeerror_getsockopt(WSAGetLastError());
|
||||
}
|
||||
else
|
||||
{
|
||||
*_optionStorageSize = (size_t) optlen;
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
static SST_NetResult decodeerror_setsockopt(int _errcode)
|
||||
{
|
||||
switch( _errcode )
|
||||
{
|
||||
case WSANOTINITIALISED: return SSTNETRESULT_NETNOTINIT; break;
|
||||
case WSAENETDOWN: return SSTNETRESULT_NETDOWN; break;
|
||||
case WSAEFAULT: return SSTNETRESULT_BADPOINTER; break;
|
||||
case WSAEINPROGRESS: return SSTNETRESULT_INPROGRESS; break;
|
||||
case WSAEINVAL: return SSTNETRESULT_INVALIDARGS; break;
|
||||
case WSAENETRESET: return SSTNETRESULT_NETRESET; break;
|
||||
case WSAENOPROTOOPT: return SSTNETRESULT_PROTOCOLOPNOTSUPPORED; break;
|
||||
case WSAENOTCONN: return SSTNETRESULT_NOTCONNECTED; break;
|
||||
case WSAENOTSOCK: return SSTNETRESULT_NOTASOCKET; break;
|
||||
|
||||
default: return SSTNETRESULT_UNKNOWN; break;
|
||||
}
|
||||
}
|
||||
SST_NetResult SST_Net_SetSockOpt( SST_Socket _socket, SST_NetProtocolLevel _level, SST_NetSocketOption _option, const void* _optionData, size_t* _optionDataSize)
|
||||
{
|
||||
int winsockopt;
|
||||
int winsocklevel;
|
||||
int errcode;
|
||||
int optlen;
|
||||
|
||||
if (convertSSTSockLevelToWinSockLevel(_level, &winsocklevel) != 0)
|
||||
return SSTNETRESULT_BADPROTOCOLLEVEL;
|
||||
|
||||
if (convertSSTSockOptToWinSockOpt(_option, &winsockopt) != 0)
|
||||
return SSTNETRESULT_BADSOCKETOP;
|
||||
|
||||
optlen = (int) *_optionDataSize;
|
||||
errcode = getsockopt( *((SOCKET*)_socket),
|
||||
winsocklevel,
|
||||
winsockopt,
|
||||
(char*) _optionData,
|
||||
&optlen);
|
||||
if (errcode == SOCKET_ERROR)
|
||||
{
|
||||
return decodeerror_setsockopt(WSAGetLastError());
|
||||
}
|
||||
else
|
||||
{
|
||||
*_optionDataSize = (size_t) optlen;
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
static SST_NetResult decodeerror_pton(int _errcode)
|
||||
{
|
||||
switch( _errcode )
|
||||
{
|
||||
case WSAEAFNOSUPPORT: return SSTNETRESULT_ADDRFAMNOTSUPPORTED; break;
|
||||
case WSAEFAULT: return SSTNETRESULT_BADPOINTER; break;
|
||||
|
||||
default: return SSTNETRESULT_UNKNOWN; break;
|
||||
}
|
||||
}
|
||||
|
||||
SST_NetResult SST_Net_PToN( SST_NetAddressFamily _family, const char* _addressText, SST_NetAddress _storage)
|
||||
{
|
||||
int af = 0;
|
||||
int errcode = 0;
|
||||
void* addr = NULL;
|
||||
|
||||
struct in_addr* v4addr = &( ((struct sockaddr_in*)_storage)->sin_addr );
|
||||
struct in6_addr* v6addr = &( ((struct sockaddr_in6*)_storage)->sin6_addr );
|
||||
|
||||
switch (_family)
|
||||
{
|
||||
case SSTNETADDRFAM_IPV4: af = AF_INET;
|
||||
addr = (void*) v4addr;
|
||||
((struct sockaddr_in*)_storage)->sin_family = AF_INET;
|
||||
break;
|
||||
case SSTNETADDRFAM_IPV6: af = AF_INET6;
|
||||
addr = (void*) v6addr;
|
||||
((struct sockaddr_in6*)_storage)->sin6_family = AF_INET6;
|
||||
break;
|
||||
default: return SSTNETRESULT_ADDRFAMNOTSUPPORTED; break;
|
||||
}
|
||||
|
||||
errcode = InetPton( af,
|
||||
_addressText,
|
||||
addr );
|
||||
if (errcode == 1)
|
||||
{
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (errcode == 0)
|
||||
{
|
||||
return SSTNETRESULT_BADADDRESSSTRING;
|
||||
}
|
||||
else
|
||||
{
|
||||
return decodeerror_pton(WSAGetLastError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static SST_NetResult decodeerror_ntop(int _errcode)
|
||||
{
|
||||
switch( _errcode )
|
||||
{
|
||||
case WSAEAFNOSUPPORT: return SSTNETRESULT_ADDRFAMNOTSUPPORTED; break;
|
||||
case ERROR_INVALID_PARAMETER: return SSTNETRESULT_INVALIDARGS; break;
|
||||
|
||||
default: return SSTNETRESULT_UNKNOWN; break;
|
||||
}
|
||||
}
|
||||
|
||||
SST_NetResult SST_Net_NToP( SST_NetAddressFamily _family, SST_NetAddress _data, char* _addressTextStorage, size_t _addressTextStorageLength)
|
||||
{
|
||||
char* retval = NULL;
|
||||
struct sockaddr_storage* ss = (struct sockaddr_storage*) _data;
|
||||
|
||||
switch (_family)
|
||||
{
|
||||
case SSTNETADDRFAM_IPV4: retval = (char*) InetNtop(AF_INET, &(((struct sockaddr_in*)ss)->sin_addr), _addressTextStorage, _addressTextStorageLength); break;
|
||||
case SSTNETADDRFAM_IPV6: retval = (char*) InetNtop(AF_INET6, &(((struct sockaddr_in6*)ss)->sin6_addr), _addressTextStorage, _addressTextStorageLength); break;
|
||||
default: return SSTNETRESULT_ADDRFAMNOTSUPPORTED; break;
|
||||
}
|
||||
|
||||
if (retval == NULL)
|
||||
{
|
||||
return decodeerror_ntop(WSAGetLastError());
|
||||
}
|
||||
else
|
||||
{
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
static SST_NetResult decodeerror_getaddrinfo( int _errcode )
|
||||
{
|
||||
switch( _errcode )
|
||||
{
|
||||
case WSATRY_AGAIN: return SSTNETRESULT_TRYAGAIN; break;
|
||||
case WSAEINVAL: return SSTNETRESULT_INVALIDARGS; break;
|
||||
case WSANO_RECOVERY: return SSTNETRESULT_HOSTUNREACHABLE; break;
|
||||
case WSAEAFNOSUPPORT: return SSTNETRESULT_ADDRFAMNOTSUPPORTED; break;
|
||||
case WSA_NOT_ENOUGH_MEMORY: return SSTNETRESULT_NOSPACE; break;
|
||||
case WSAHOST_NOT_FOUND: return SSTNETRESULT_HOSTUNREACHABLE; break;
|
||||
case WSATYPE_NOT_FOUND: return SSTNETRESULT_SERVICENOTSUPPORTED; break;
|
||||
case WSAESOCKTNOSUPPORT: return SSTNETRESULT_SOCKETNOTSUPPORTED; break;
|
||||
|
||||
default: return SSTNETRESULT_UNKNOWN; break;
|
||||
}
|
||||
}
|
||||
|
||||
static SST_NetResult convertSSTAddrHintsToWinAddrHints( const SST_NetAddrHints* _hints, struct addrinfo* _winHints )
|
||||
{
|
||||
int tempflags = 0;
|
||||
|
||||
/* handle address family */
|
||||
switch (_hints->addressFamily)
|
||||
{
|
||||
case SSTNETADDRFAM_IPV4: _winHints->ai_family = AF_INET; break;
|
||||
case SSTNETADDRFAM_IPV6: _winHints->ai_family = AF_INET6; break;
|
||||
default: return SSTNETRESULT_ADDRFAMNOTSUPPORTED; break;
|
||||
}
|
||||
|
||||
/* handle socket type */
|
||||
switch (_hints->socketType)
|
||||
{
|
||||
case SSTNETSOCKTYPE_STREAM: _winHints->ai_socktype = SOCK_STREAM; break;
|
||||
case SSTNETSOCKTYPE_DATAGRAM: _winHints->ai_socktype = SOCK_DGRAM; break;
|
||||
default: return SSTNETRESULT_SOCKETNOTSUPPORTED; break;
|
||||
}
|
||||
|
||||
/* handle protocol */
|
||||
switch (_hints->protocolType)
|
||||
{
|
||||
case SSTNETPROTOCOL_TCP: _winHints->ai_protocol = IPPROTO_TCP; break;
|
||||
case SSTNETPROTOCOL_UDP: _winHints->ai_protocol = IPPROTO_UDP; break;
|
||||
default: return SSTNETRESULT_PROTOCOLNOTSUPPORTED; break;
|
||||
}
|
||||
|
||||
/* handle flags */
|
||||
tempflags |= (_hints->flags & SSTNETAINFOFLAG_PASSIVE) ? AI_PASSIVE : 0;
|
||||
tempflags |= (_hints->flags & SSTNETAINFOFLAG_CANONICALNAME) ? AI_CANONNAME : 0;
|
||||
tempflags |= (_hints->flags & SSTNETAINFOFLAG_NUMERICHOST) ? AI_NUMERICHOST : 0;
|
||||
tempflags |= (_hints->flags & SSTNETAINFOFLAG_ADDRESSCONFIG) ? AI_ADDRCONFIG : 0;
|
||||
tempflags |= (_hints->flags & SSTNETAINFOFLAG_NONAUTHORATATIVE) ? AI_NON_AUTHORITATIVE : 0;
|
||||
tempflags |= (_hints->flags & SSTNETAINFOFLAG_SECURE) ? AI_SECURE : 0;
|
||||
tempflags |= (_hints->flags & SSTNETAINFOFLAG_RETURNPREFERREDNAME) ? AI_RETURN_PREFERRED_NAMES : 0;
|
||||
tempflags |= (_hints->flags & SSTNETAINFOFLAG_FILESERVER) ? AI_FILESERVER : 0;
|
||||
_winHints->ai_flags = tempflags;
|
||||
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
}
|
||||
|
||||
static SST_NetResult copySingleWinAddrInfoToSSTAddrInfo( const ADDRINFO* _winInfo, SST_NetAddrInfo_Win32* _sstInfo )
|
||||
{
|
||||
SST_NetAddrInfoFlags tempflags = 0;
|
||||
int winFlags = 0;
|
||||
|
||||
/* handle address family */
|
||||
switch (_winInfo->ai_family)
|
||||
{
|
||||
case AF_INET: _sstInfo->family = SSTNETADDRFAM_IPV4; break;
|
||||
case AF_INET6: _sstInfo->family = SSTNETADDRFAM_IPV6; break;
|
||||
default: _sstInfo->family = SSTNETADDRFAM_UNKNOWN; break;
|
||||
}
|
||||
|
||||
/* handle socket type */
|
||||
switch (_winInfo->ai_socktype)
|
||||
{
|
||||
case SOCK_STREAM: _sstInfo->socketType = SSTNETSOCKTYPE_STREAM; break;
|
||||
case SOCK_DGRAM: _sstInfo->socketType = SSTNETSOCKTYPE_DATAGRAM; break;
|
||||
default: _sstInfo->socketType = SSTNETSOCKTYPE_UNKNOWN; break;
|
||||
}
|
||||
|
||||
/* handle protocol */
|
||||
switch (_winInfo->ai_protocol)
|
||||
{
|
||||
case IPPROTO_TCP: _sstInfo->protocol = SSTNETPROTOCOL_TCP; break;
|
||||
case IPPROTO_UDP: _sstInfo->protocol = SSTNETPROTOCOL_UDP; break;
|
||||
default: _sstInfo->protocol = SSTNETPROTOCOL_UNKNOWN; break;
|
||||
}
|
||||
|
||||
/* handle flags */
|
||||
winFlags = _winInfo->ai_flags;
|
||||
tempflags |= (winFlags & AI_PASSIVE) ? SSTNETAINFOFLAG_PASSIVE : 0;
|
||||
tempflags |= (winFlags & AI_CANONNAME) ? SSTNETAINFOFLAG_CANONICALNAME : 0;
|
||||
tempflags |= (winFlags & AI_NUMERICHOST) ? SSTNETAINFOFLAG_NUMERICHOST : 0;
|
||||
tempflags |= (winFlags & AI_ADDRCONFIG) ? SSTNETAINFOFLAG_ADDRESSCONFIG : 0;
|
||||
tempflags |= (winFlags & AI_NON_AUTHORITATIVE) ? SSTNETAINFOFLAG_NONAUTHORATATIVE : 0;
|
||||
tempflags |= (winFlags & AI_SECURE) ? SSTNETAINFOFLAG_SECURE : 0;
|
||||
tempflags |= (winFlags & AI_RETURN_PREFERRED_NAMES) ? SSTNETAINFOFLAG_RETURNPREFERREDNAME : 0;
|
||||
tempflags |= (winFlags & AI_FILESERVER) ? SSTNETAINFOFLAG_FILESERVER : 0;
|
||||
_sstInfo->flags = tempflags;
|
||||
|
||||
/* handle canonical name */
|
||||
_sstInfo->canonicalName = _strdup(_winInfo->ai_canonname);
|
||||
if (_sstInfo->canonicalName == NULL)
|
||||
return SSTNETRESULT_NOSPACE;
|
||||
|
||||
/* handle sockaddr info */
|
||||
memcpy( &(_sstInfo->addr),
|
||||
&(_winInfo->ai_addr),
|
||||
_winInfo->ai_addrlen);
|
||||
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
}
|
||||
|
||||
static SST_NetResult convertWinAddrInfoToSSTAddrInfo( ADDRINFO* _winai, SST_NetAddrInfo_Win32** _out )
|
||||
{
|
||||
SST_NetAddrInfo_Win32* root = NULL;
|
||||
SST_NetAddrInfo_Win32* prev = NULL;
|
||||
SST_NetAddrInfo_Win32* temp = NULL;
|
||||
ADDRINFO* currWinInfo = _winai;
|
||||
|
||||
while (currWinInfo != NULL)
|
||||
{
|
||||
/* allocate our temp node space */
|
||||
temp = calloc( 1, sizeof(SST_NetAddrInfo_Win32) );
|
||||
if (temp == NULL)
|
||||
{
|
||||
/* handle out of memory... */
|
||||
if (root != NULL)
|
||||
{
|
||||
SST_Net_FreeAddrInfo(root);
|
||||
}
|
||||
*_out = NULL;
|
||||
return SSTNETRESULT_NOSPACE;
|
||||
}
|
||||
|
||||
/* if we haven't had a root node yet, set that */
|
||||
if (root == NULL)
|
||||
{
|
||||
root = temp;
|
||||
}
|
||||
|
||||
/* if we have a previous node, attach us as the next node */
|
||||
if (prev != NULL)
|
||||
{
|
||||
prev->next = temp;
|
||||
}
|
||||
|
||||
/* copy over attributes, bail if we can't */
|
||||
temp->next = NULL;
|
||||
if ( copySingleWinAddrInfoToSSTAddrInfo(currWinInfo, temp) != SSTNETRESULT_SUCCESS )
|
||||
{
|
||||
/* handle out of memory... */
|
||||
if (root != NULL)
|
||||
{
|
||||
SST_Net_FreeAddrInfo(root);
|
||||
}
|
||||
*_out = NULL;
|
||||
return SSTNETRESULT_NOSPACE;
|
||||
}
|
||||
|
||||
/* set us to be the previous node */
|
||||
prev = temp;
|
||||
|
||||
/* go to next record */
|
||||
currWinInfo = currWinInfo->ai_next;
|
||||
}
|
||||
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
};
|
||||
|
||||
SST_NetResult SST_Net_GetAddrInfo( const char* _node, const char* _service, const SST_NetAddrHints* _hints, SST_NetAddrInfo* _results)
|
||||
{
|
||||
int errcode = 0;
|
||||
ADDRINFO hints;
|
||||
ADDRINFO* results;
|
||||
ADDRINFO* currResult;
|
||||
SST_NetAddrInfo_Win32* ret;
|
||||
SST_NetResult convret;
|
||||
size_t recordCount = 0;
|
||||
|
||||
/* convert the hints */
|
||||
memset(&hints, 0, sizeof(struct addrinfo));
|
||||
convret = convertSSTAddrHintsToWinAddrHints(_hints, &hints);
|
||||
if ( convret != SSTNETRESULT_SUCCESS )
|
||||
{
|
||||
return convret;
|
||||
}
|
||||
|
||||
/* do the lookup */
|
||||
errcode = getaddrinfo(_node, _service, (struct addrinfo*) _hints, &results);
|
||||
if ( errcode != 0 )
|
||||
{
|
||||
return decodeerror_getaddrinfo(errcode);
|
||||
}
|
||||
|
||||
/* count the number of records */
|
||||
currResult = results;
|
||||
while (currResult != NULL)
|
||||
{
|
||||
currResult = currResult->ai_next;
|
||||
recordCount++;
|
||||
}
|
||||
|
||||
/* convert results */
|
||||
*_results = NULL;
|
||||
convret = convertWinAddrInfoToSSTAddrInfo(results, &ret);
|
||||
if (convret == SSTNETRESULT_SUCCESS)
|
||||
{
|
||||
*_results = ret;
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
freeaddrinfo(results);
|
||||
|
||||
return convret;
|
||||
}
|
||||
|
||||
void SST_Net_FreeAddrInfo( SST_NetAddrInfo _toFree )
|
||||
{
|
||||
SST_NetAddrInfo_Win32* root = (SST_NetAddrInfo_Win32*) _toFree;
|
||||
SST_NetAddrInfo_Win32* curr;
|
||||
SST_NetAddrInfo_Win32* temp;
|
||||
|
||||
|
||||
curr = root;
|
||||
while (curr != NULL)
|
||||
{
|
||||
/* free strings */
|
||||
free(curr->canonicalName);
|
||||
curr->canonicalName = NULL;
|
||||
|
||||
/* save where we are and free it */
|
||||
temp = curr;
|
||||
curr = curr->next;
|
||||
free(temp);
|
||||
}
|
||||
}
|
||||
|
||||
static SST_NetResult decodeerror_getnameinfo( int _errcode )
|
||||
{
|
||||
switch( _errcode )
|
||||
{
|
||||
case WSATRY_AGAIN: return SSTNETRESULT_TRYAGAIN; break;
|
||||
case WSAEINVAL: return SSTNETRESULT_INVALIDARGS; break;
|
||||
case WSANO_RECOVERY: return SSTNETRESULT_HOSTUNREACHABLE; break;
|
||||
case WSAEAFNOSUPPORT: return SSTNETRESULT_ADDRFAMNOTSUPPORTED; break;
|
||||
case WSA_NOT_ENOUGH_MEMORY: return SSTNETRESULT_NOSPACE; break;
|
||||
case WSAHOST_NOT_FOUND: return SSTNETRESULT_HOSTUNREACHABLE; break;
|
||||
case WSAEFAULT: return SSTNETRESULT_BADPOINTER; break;
|
||||
|
||||
default: return SSTNETRESULT_UNKNOWN; break;
|
||||
}
|
||||
}
|
||||
|
||||
SST_NetResult SST_Net_GetNameInfo(SST_NetAddress _address, char* _hostName, size_t _hostNameLength, char* _serviceName, size_t _serviceNameLength, SST_NetNameInfoFlags _flags)
|
||||
{
|
||||
int flags = 0;
|
||||
int errcode = 0;
|
||||
|
||||
flags |= ( _flags &SSTNETNINFOFLAGS_NOFQDN) ? NI_NOFQDN : 0;
|
||||
flags |= ( _flags &SSTNETNINFOFLAGS_NUMBERICHOST) ? NI_NUMERICHOST : 0;
|
||||
flags |= ( _flags &SSTNETNINFOFLAGS_NAMEREQD) ? NI_NAMEREQD : 0;
|
||||
flags |= ( _flags &SSTNETNINFOFLAGS_NUMERICSERVICE) ? NI_NUMERICSERV : 0;
|
||||
flags |= ( _flags &SSTNETNINFOFLAGS_DATAGRAM) ? NI_DGRAM : 0;
|
||||
|
||||
errcode = getnameinfo( (const struct sockaddr*) _address,
|
||||
sizeof(SOCKADDR_STORAGE),
|
||||
_hostName,
|
||||
(DWORD) _hostNameLength,
|
||||
_serviceName,
|
||||
(DWORD) _serviceNameLength,
|
||||
flags );
|
||||
|
||||
if (errcode != 0)
|
||||
{
|
||||
return decodeerror_getnameinfo(WSAGetLastError());
|
||||
}
|
||||
else
|
||||
{
|
||||
return SSTNETRESULT_SUCCESS;
|
||||
}
|
||||
}
|
||||
40
libsst-net/Win32Private.h
Normal file
40
libsst-net/Win32Private.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
Win32Private.h
|
||||
Author: Chris Ertel <crertel@762studios.com>
|
||||
Created: 07/15/2012
|
||||
|
||||
Purpose:
|
||||
|
||||
Private data structures for Win32 implementation of libsst-net. Not to be distributed
|
||||
as part of public SDK headers.
|
||||
|
||||
License:
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _WIN32PRIVATE_H
|
||||
#define _WIN32PRIVATE_H
|
||||
|
||||
#define _WIN32_WINNT 0x0601 /* Windows 7 or later */
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <ws2ipdef.h>
|
||||
|
||||
typedef SOCKET NativeSocketType;
|
||||
typedef int NativeSocketLen;
|
||||
#define SST_NATIVE_INVALIDSOCKET INVALID_SOCKET
|
||||
#define SST_NATIVE_NETERROR SOCKET_ERROR
|
||||
#define NativeCloseSocket(s) closesocket(s)
|
||||
#define NativeIoctl(s, cmd, arg) ioctlsocket(s, cmd, arg)
|
||||
#endif
|
||||
163
libsst-net/libsst-net.vcxproj
Normal file
163
libsst-net/libsst-net.vcxproj
Normal file
@@ -0,0 +1,163 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{E6679A2F-6C8E-4555-9228-6929C734CEF4}</ProjectGuid>
|
||||
<RootNamespace>libsstnet</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>11.0.50727.1</_ProjectFileVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(SolutionDir)\Lib\x86\</OutDir>
|
||||
<IntDir>$(SolutionDir)Intermediate\$(Configuration)\$(Platform)\$(ProjectName)\</IntDir>
|
||||
<TargetName>$(ProjectName)-debug</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>$(SolutionDir)\Lib\x64\</OutDir>
|
||||
<IntDir>$(SolutionDir)Intermediate\$(Configuration)\$(Platform)\$(ProjectName)\</IntDir>
|
||||
<TargetName>$(ProjectName)-debug</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)\Lib\x86\</OutDir>
|
||||
<IntDir>$(SolutionDir)Intermediate\$(Configuration)\$(Platform)\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>$(SolutionDir)\Lib\x64\</OutDir>
|
||||
<IntDir>$(SolutionDir)Intermediate\$(Configuration)\$(Platform)\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)Lib\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<StringPooling>true</StringPooling>
|
||||
</ClCompile>
|
||||
<Lib />
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)Lib\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<StringPooling>true</StringPooling>
|
||||
</ClCompile>
|
||||
<Lib />
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)Lib\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<StringPooling>true</StringPooling>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)Lib\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<StringPooling>true</StringPooling>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="SST_NetAddress.c" />
|
||||
<ClCompile Include="SST_NetSocket.c" />
|
||||
<ClCompile Include="SST_NetInit_Win32.c" />
|
||||
<ClCompile Include="SST_NetResult_Win32.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="PlatformPrivate.h" />
|
||||
<ClInclude Include="Win32Private.h" />
|
||||
<ClInclude Include="..\Lib\Include\SST\SST_Net.h" />
|
||||
<ClInclude Include="..\Lib\Include\SST\SST_NetAddress.h" />
|
||||
<ClInclude Include="..\Lib\Include\SST\SST_NetResult.h" />
|
||||
<ClInclude Include="..\Lib\Include\SST\SST_NetSocket.h" />
|
||||
<ClInclude Include="..\Lib\Include\SST\SST_NetTypes.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
63
libsst-net/libsst-net.vcxproj.filters
Normal file
63
libsst-net/libsst-net.vcxproj.filters
Normal file
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\Crossplatform">
|
||||
<UniqueIdentifier>{e3f3c5ec-e302-4820-ae8b-c035c895fd62}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\Private">
|
||||
<UniqueIdentifier>{d95db6dc-a57d-48c0-b644-d334e7e9e051}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\Win32">
|
||||
<UniqueIdentifier>{7009320b-8cf4-4dd4-9fc5-3cac9de62341}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="SST_NetAddress.c">
|
||||
<Filter>Source Files\Crossplatform</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SST_NetSocket.c">
|
||||
<Filter>Source Files\Crossplatform</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SST_NetInit_Win32.c">
|
||||
<Filter>Source Files\Win32</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SST_NetResult_Win32.c">
|
||||
<Filter>Source Files\Win32</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="PlatformPrivate.h">
|
||||
<Filter>Source Files\Private</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Win32Private.h">
|
||||
<Filter>Source Files\Private</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Lib\Include\SST\SST_Net.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Lib\Include\SST\SST_NetAddress.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Lib\Include\SST\SST_NetResult.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Lib\Include\SST\SST_NetSocket.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Lib\Include\SST\SST_NetTypes.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
BIN
libsst-net/obj/x86-64/release/SST_NetAddress.o
Normal file
BIN
libsst-net/obj/x86-64/release/SST_NetAddress.o
Normal file
Binary file not shown.
BIN
libsst-net/obj/x86-64/release/SST_NetInit_Generic.o
Normal file
BIN
libsst-net/obj/x86-64/release/SST_NetInit_Generic.o
Normal file
Binary file not shown.
BIN
libsst-net/obj/x86-64/release/SST_NetResult_POSIX.o
Normal file
BIN
libsst-net/obj/x86-64/release/SST_NetResult_POSIX.o
Normal file
Binary file not shown.
BIN
libsst-net/obj/x86-64/release/SST_NetSocket.o
Normal file
BIN
libsst-net/obj/x86-64/release/SST_NetSocket.o
Normal file
Binary file not shown.
19
libsst-net/sources-POSIX.mk
Normal file
19
libsst-net/sources-POSIX.mk
Normal file
@@ -0,0 +1,19 @@
|
||||
# libsst-net/sources-POSIX.mk
|
||||
# Author: Patrick Baggett <ptbaggett@762studios.com>
|
||||
# Created: 12/03/2012
|
||||
#
|
||||
# Purpose:
|
||||
#
|
||||
# List of source files for POSIX-compliant systems. This reduces the amount
|
||||
# of copy/pasting for different UNIX configurations.
|
||||
#
|
||||
# License:
|
||||
#
|
||||
# This program is free software. It comes without any warranty, to
|
||||
# the extent permitted by applicable law. You can redistribute it
|
||||
# and/or modify it under the terms of the Do What The Fuck You Want
|
||||
# To Public License, Version 2, as published by Sam Hocevar. See
|
||||
# http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
SRC += SST_NetInit_Generic.c \
|
||||
SST_NetResult_POSIX.c
|
||||
Reference in New Issue
Block a user