2005-11-29 13:12:45 +00:00
2013-07-31 00:20:16 +00:00
# if !defined(NACL) && !defined(FTE_TARGET_WEB)
2013-07-15 09:55:27 +00:00
# define HAVE_IPV4 //says we can send and receive AF_INET ipv4 udp packets.
2012-04-09 19:12:12 +00:00
# define HAVE_TCP //says we can use tcp too (either ipv4 or ipv6)
# define HAVE_PACKET //if we have the socket api at all...
# endif
2005-11-29 13:12:45 +00:00
2013-07-31 00:20:16 +00:00
# if defined(NACL) || defined(FTE_TARGET_WEB)
2012-04-09 19:12:12 +00:00
struct sockaddr
{
short sa_family ;
} ;
/* struct sockaddr_in
{
short sin_family ;
unsigned short sin_port ;
in_addr sin_addr ;
} ; */
# define AF_UNSPEC 0
// #define AF_INET 1
/*NaCl engines cannot host servers. Regular FTE servers can use the same listening tcpconnect socket to host a websocket connection*/
# define AF_WEBSOCK 342
struct sockaddr_websocket
{
short sws_family ;
char url [ 64 ] ;
} ;
# elif defined(_WIN32)
2005-11-30 01:20:53 +00:00
# ifdef _MSC_VER
# define USEIPX
# endif
2013-06-23 02:17:02 +00:00
# define WIN32_LEAN_AND_MEAN
# define byte winbyte
# include <windows.h>
# include <winsock2.h>
// #include "winquake.h"
2005-11-30 01:20:53 +00:00
# ifdef USEIPX
# include "wsipx.h"
# endif
2010-11-10 02:02:56 +00:00
# include <ws2tcpip.h>
2010-12-18 21:30:16 +00:00
# include <errno.h>
2010-11-10 02:02:56 +00:00
# ifndef IPPROTO_IPV6
/*for msvc6*/
2012-09-30 05:52:03 +00:00
# define IPPROTO_IPV6 41
2010-11-11 09:06:36 +00:00
# ifndef EAI_NONAME
# define EAI_NONAME 8
# endif
2008-05-25 01:11:20 +00:00
struct ip6_scope_id
{
union
{
struct
{
u_long Zone : 28 ;
u_long Level : 4 ;
} ;
u_long Value ;
} ;
} ;
2010-11-11 09:06:36 +00:00
# if !(_MSC_VER >= 1500)
2008-05-25 01:11:20 +00:00
struct in6_addr
{
u_char s6_addr [ 16 ] ; /* IPv6 address */
} ;
2011-01-04 02:56:16 +00:00
# define sockaddr_in6 sockaddr_in6_fixed /*earlier versions of msvc have a sockaddr_in6 which does _not_ match windows, so this *must* be redefined for any non-final msvc releases or it won't work at all*/
2008-05-25 01:11:20 +00:00
typedef struct sockaddr_in6
{
short sin6_family ;
u_short sin6_port ;
u_long sin6_flowinfo ;
struct in6_addr sin6_addr ;
union
{
u_long sin6_scope_id ;
struct ip6_scope_id sin6_scope_struct ;
} ;
} ;
struct addrinfo
{
int ai_flags ;
int ai_family ;
int ai_socktype ;
int ai_protocol ;
size_t ai_addrlen ;
char * ai_canonname ;
struct sockaddr * ai_addr ;
struct addrinfo * ai_next ;
} ;
2010-11-11 09:06:36 +00:00
# endif
2005-11-30 01:20:53 +00:00
# endif
2011-12-05 15:23:40 +00:00
# ifndef IPV6_V6ONLY
# define IPV6_V6ONLY 27
# endif
2008-05-25 01:11:20 +00:00
2013-05-07 19:37:37 +00:00
# ifdef EADDRNOTAVAIL
2010-12-18 21:30:16 +00:00
# undef EADDRNOTAVAIL
2013-05-07 19:37:37 +00:00
# endif
# ifdef EAFNOSUPPORT
2010-12-18 21:30:16 +00:00
# undef EAFNOSUPPORT
2013-05-07 19:37:37 +00:00
# endif
# ifdef ECONNABORTED
2010-12-18 21:30:16 +00:00
# undef ECONNABORTED
2013-05-07 19:37:37 +00:00
# endif
# ifdef ECONNREFUSED
2010-12-18 21:30:16 +00:00
# undef ECONNREFUSED
2013-05-07 19:37:37 +00:00
# endif
# ifdef ECONNREFUSED
2013-05-03 04:28:08 +00:00
# undef ECONNREFUSED
2013-05-07 19:37:37 +00:00
# endif
# ifdef EMSGSIZE
2010-12-18 21:30:16 +00:00
# undef EMSGSIZE
2013-05-07 19:37:37 +00:00
# endif
# ifdef EWOULDBLOCK
2010-12-18 21:30:16 +00:00
# undef EWOULDBLOCK
# endif
2013-05-07 19:37:37 +00:00
# ifdef EACCES
# undef EACCES
# endif
2010-12-18 21:30:16 +00:00
2013-05-03 04:28:08 +00:00
# define EWOULDBLOCK WSAEWOULDBLOCK
2013-06-29 16:01:07 +00:00
# define EINPROGRESS WSAEINPROGRESS
2013-05-03 04:28:08 +00:00
# define EMSGSIZE WSAEMSGSIZE
# define ECONNRESET WSAECONNRESET
2010-12-18 21:30:16 +00:00
# define ECONNABORTED WSAECONNABORTED
# define ECONNREFUSED WSAECONNREFUSED
2013-06-29 16:01:07 +00:00
# define ENOTCONN WSAENOTCONN
2013-05-03 04:28:08 +00:00
# define EACCES WSAEACCES
2010-12-18 21:30:16 +00:00
# define EADDRNOTAVAIL WSAEADDRNOTAVAIL
# define EAFNOSUPPORT WSAEAFNOSUPPORT
2005-11-29 13:12:45 +00:00
# else
2013-07-15 09:55:27 +00:00
# include <sys/time.h>
2005-11-30 01:20:53 +00:00
# include <sys/types.h>
# include <sys/socket.h>
# include <netinet/in.h>
2005-12-02 01:14:20 +00:00
# include <netinet/tcp.h>
2005-11-30 01:20:53 +00:00
# include <netdb.h>
# include <sys/ioctl.h>
# include <sys/uio.h>
# include <arpa/inet.h>
# include <errno.h>
2005-11-29 13:12:45 +00:00
2005-11-30 01:20:53 +00:00
# include <unistd.h>
2005-11-29 13:12:45 +00:00
2005-11-30 01:20:53 +00:00
# ifdef sun
# include <sys/filio.h>
# endif
# ifdef NeXT
# include <libc.h>
# endif
# if defined(__MORPHOS__) && !defined(ixemul)
# define closesocket CloseSocket
# define ioctlsocket IoctlSocket
# else
# define closesocket close
# define ioctlsocket ioctl
# endif
2005-11-29 13:12:45 +00:00
2012-02-29 20:54:22 +00:00
# if defined(AF_INET6) && !defined(IPPROTO_IPV6)
# define IPPROTO_IPV6 IPPROTO_IPV6
# endif
2010-03-19 03:45:11 +00:00
# define SOCKET int
2005-11-29 13:12:45 +00:00
# endif
# if defined(_WIN32)
2005-11-30 01:20:53 +00:00
# define qerrno WSAGetLastError()
2005-11-29 13:12:45 +00:00
# elif defined(__MORPHOS__) && !defined(ixemul)
2005-11-30 01:20:53 +00:00
# define qerrno Errno()
2005-11-29 13:12:45 +00:00
# else
2005-11-30 01:20:53 +00:00
# define qerrno errno
2005-11-29 13:12:45 +00:00
# endif
# ifndef INVALID_SOCKET
2005-11-30 01:20:53 +00:00
# define INVALID_SOCKET -1
2005-11-29 13:12:45 +00:00
# endif
2005-12-31 13:33:10 +00:00
# ifndef INADDR_LOOPBACK
# define INADDR_LOOPBACK 0x7f000001
# endif
2013-04-02 05:18:17 +00:00
# if defined(FTE_TARGET_WEB)
# undef IPPROTO_IPV6
# endif
2013-06-23 02:17:02 +00:00
# if 1 //def SUPPORT_ICE
2013-06-29 16:01:07 +00:00
struct icecandinfo_s
2013-06-23 02:17:02 +00:00
{
2013-06-29 16:01:07 +00:00
char candidateid [ 64 ] ;
char addr [ 64 ] ; //v4/v6/fqdn. fqdn should prefer ipv6
2013-06-23 02:17:02 +00:00
int port ;
int transport ; //0=udp. other values not supported
int foundation ; //to figure out...
int component ; //1-based. allows rtp+rtcp in a single ICE... we only support one.
int priority ; //some random value...
enum
{
ICE_HOST = 0 ,
ICE_SRFLX = 1 ,
ICE_PRFLX = 2 ,
ICE_RELAY = 3 ,
} type ; //says what sort of proxy is used.
2013-06-29 16:01:07 +00:00
char reladdr [ 64 ] ; //when proxied, this is our local info
2013-06-23 02:17:02 +00:00
int relport ;
int generation ; //for ice restarts. starts at 0.
int network ; //which network device this comes from.
} ;
2013-06-29 16:01:07 +00:00
enum iceproto_e
2013-06-23 02:17:02 +00:00
{
2013-06-29 16:01:07 +00:00
ICEP_INVALID , //not allowed..
ICEP_QWSERVER , //we're server side
ICEP_QWCLIENT , //we're client side
ICEP_VOICE //speex. requires client.
} ;
enum icemode_e
{
ICEM_RAW , //not actually interactive beyond a simple handshake.
ICEM_ICE //rfc5245. meant to be able to holepunch, but not implemented properly yet.
} ;
enum icestate_e
{
ICE_INACTIVE , //idle.
ICE_FAILED ,
ICE_CONNECTING , //exchanging pings.
ICE_CONNECTED //media is flowing, supposedly. sending keepalives.
2013-06-23 02:17:02 +00:00
} ;
2013-06-29 16:01:07 +00:00
struct icestate_s ;
# define ICE_API_CURRENT "Internet Connectivity Establishment 0.0"
typedef struct
{
struct icestate_s * ( QDECL * ICE_Create ) ( void * module , char * conname , char * peername , enum icemode_e mode , enum iceproto_e proto ) ; //doesn't start pinging anything.
qboolean ( QDECL * ICE_Set ) ( struct icestate_s * con , char * prop , char * value ) ;
qboolean ( QDECL * ICE_Get ) ( struct icestate_s * con , char * prop , char * value , int valuesize ) ;
struct icecandinfo_s * ( QDECL * ICE_GetLCandidateInfo ) ( struct icestate_s * con ) ; //retrieves candidates that need reporting to the peer.
void ( QDECL * ICE_AddRCandidateInfo ) ( struct icestate_s * con , struct icecandinfo_s * cand ) ; //stuff that came from the peer.
void ( QDECL * ICE_Close ) ( struct icestate_s * con ) ; //bye then.
void ( QDECL * ICE_CloseModule ) ( void * module ) ; //closes all unclosed connections, with warning.
} icefuncs_t ;
extern icefuncs_t iceapi ;
2013-07-31 00:20:16 +00:00
# endif