2004-08-21 01:25:48 +00:00
/*
Copyright ( C ) 1996 - 1997 Id Software , Inc .
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation ; either version 2
of the License , or ( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
See the GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*/
// net.h -- quake's interface to the networking layer
# define PORT_ANY -1
2013-07-31 00:20:16 +00:00
# if defined(NACL) || defined(FTE_TARGET_WEB)
2012-04-09 19:12:12 +00:00
# define HAVE_WEBSOCKCL
# endif
2018-09-23 19:35:24 +00:00
# ifdef __linux__
//#define UNIXSOCKETS
# endif
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
//FIXME: should split this into loopback/dgram/stream/dtls/tls/irc
2013-03-31 04:21:08 +00:00
//with the ipv4/v6/x as a separate parameter
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
typedef enum {
NA_INVALID ,
NA_LOOPBACK ,
/*NA_HYBRID,*/ //ipv6 hybrid socket that might accept ipv4 packets too.
NA_IP ,
NA_IPV6 ,
NA_IPX ,
2018-09-23 19:35:24 +00:00
# ifdef UNIXSOCKETS
NA_UNIX ,
# endif
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
# ifdef IRCCONNECT
NA_IRC /*remove!*/ ,
# endif
# ifdef HAVE_WEBSOCKCL
NA_WEBSOCKET ,
# endif
2022-01-28 10:48:01 +00:00
# ifdef SUPPORT_ICE
NA_ICE
# endif
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
} netadrtype_t ;
typedef enum {
NP_DGRAM ,
NP_DTLS , //connected via ICE/WebRTC
NP_STREAM ,
NP_TLS ,
NP_WS ,
NP_WSS ,
2018-09-23 19:35:24 +00:00
NP_NATPMP , //server-only scheme for registering public ports.
2020-02-11 18:06:10 +00:00
NP_RTC_TCP ,
NP_RTC_TLS , //really need a better way to do this than two copies of every protocol...
2018-09-23 19:35:24 +00:00
NP_INVALID
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
} netproto_t ;
2004-08-21 01:25:48 +00:00
typedef enum { NS_CLIENT , NS_SERVER } netsrc_t ;
2019-09-04 07:59:40 +00:00
typedef struct netadr_s
2004-08-21 01:25:48 +00:00
{
netadrtype_t type ;
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
netproto_t prot ;
2004-08-21 01:25:48 +00:00
2022-03-08 05:31:34 +00:00
unsigned short port ;
unsigned short connum ; //which quake connection/socket the address is talking about. 1-based. 0 is unspecified. this is NOT used for address equivelency.
unsigned int scopeid ; //ipv6 interface id thing.
2004-08-21 01:25:48 +00:00
union {
2005-08-03 23:14:59 +00:00
qbyte ip [ 4 ] ;
qbyte ip6 [ 16 ] ;
qbyte ipx [ 10 ] ;
2008-11-09 22:29:28 +00:00
# ifdef IRCCONNECT
struct {
2013-05-03 04:28:08 +00:00
char host [ 32 ] ;
2008-11-09 22:29:28 +00:00
char user [ 32 ] ;
char channel [ 12 ] ;
} irc ;
# endif
2022-01-28 10:48:01 +00:00
# ifdef SUPPORT_ICE
char icename [ 16 ] ;
# endif
2012-04-09 19:12:12 +00:00
# ifdef HAVE_WEBSOCKCL
char websocketurl [ 64 ] ;
2018-09-23 19:35:24 +00:00
# endif
# ifdef UNIXSOCKETS
struct
{
int len ; //abstract addresses contain nulls, so this is needed.
char path [ 108 ] ;
} un ;
2012-04-09 19:12:12 +00:00
# endif
2006-02-17 02:51:59 +00:00
} address ;
2004-08-21 01:25:48 +00:00
} netadr_t ;
struct sockaddr_qstorage
{
2005-01-29 02:26:42 +00:00
short dontusesa_family ;
unsigned char dontusesa_pad [ 6 ] ;
2016-02-15 06:01:17 +00:00
qint64_t sa_align ;
2004-08-21 01:25:48 +00:00
unsigned char sa_pad2 [ 112 ] ;
} ;
2005-05-26 12:55:34 +00:00
extern netadr_t net_local_cl_ipadr ;
2004-08-21 01:25:48 +00:00
extern netadr_t net_from ; // address of who sent the packet
2022-07-28 02:16:31 +00:00
extern struct ftenet_generic_connection_s * net_from_connection ;
2004-08-21 01:25:48 +00:00
extern sizebuf_t net_message ;
//#define MAX_UDP_PACKET (MAX_MSGLEN*2) // one more than msg + header
# define MAX_UDP_PACKET 8192 // one more than msg + header
2016-07-12 00:40:13 +00:00
extern FTE_ALIGN ( 4 ) qbyte net_message_buffer [ MAX_OVERALLMSGLEN ] ;
typedef enum
{
NETERR_SENT = 0 , //all is well
NETERR_NOROUTE = 1 , //destination isn't valid for this socket/etc. try a different one if possible
NETERR_DISCONNECTED = 2 , //socket can no longer send anything
NETERR_MTU = 3 , //packet wasn't sent due to MTU
NETERR_CLOGGED = 4 //socket is suffering from conjestion
} neterr_t ;
2004-08-21 01:25:48 +00:00
extern cvar_t hostname ;
2022-06-19 15:18:30 +00:00
int TCP_OpenStream ( netadr_t * remoteaddr , const char * remotename ) ; //makes things easier. remotename is printable-only
2006-02-11 14:51:36 +00:00
2008-11-09 22:29:28 +00:00
struct ftenet_connections_s ;
2004-08-21 01:25:48 +00:00
void NET_Init ( void ) ;
2013-06-29 16:01:07 +00:00
void NET_Tick ( void ) ;
2013-03-31 04:21:08 +00:00
void SVNET_RegisterCvars ( void ) ;
2015-06-05 03:45:01 +00:00
void NET_InitClient ( qboolean loopbackonly ) ;
2017-05-18 10:24:09 +00:00
void NET_CloseClient ( void ) ;
2004-08-21 01:25:48 +00:00
void NET_InitServer ( void ) ;
2018-12-28 00:04:36 +00:00
qboolean NET_WasSpecialPacket ( struct ftenet_connections_s * col ) ;
2004-08-21 01:25:48 +00:00
void NET_CloseServer ( void ) ;
2013-03-31 04:21:08 +00:00
void UDP_CloseSocket ( int socket ) ;
2004-08-21 01:25:48 +00:00
void NET_Shutdown ( void ) ;
2014-07-02 03:20:40 +00:00
qboolean NET_GetRates ( struct ftenet_connections_s * collection , float * pi , float * po , float * bi , float * bo ) ;
2016-07-12 00:40:13 +00:00
qboolean NET_UpdateRates ( struct ftenet_connections_s * collection , qboolean inbound , size_t size ) ; //for demos to not be weird
2020-02-26 00:37:52 +00:00
void NET_ReadPackets ( struct ftenet_connections_s * collection ) ;
2018-12-28 00:04:36 +00:00
neterr_t NET_SendPacket ( struct ftenet_connections_s * col , int length , const void * data , netadr_t * to ) ;
2008-11-09 22:29:28 +00:00
int NET_LocalAddressForRemote ( struct ftenet_connections_s * collection , netadr_t * remote , netadr_t * local , int idx ) ;
void NET_PrintAddresses ( struct ftenet_connections_s * collection ) ;
2013-05-03 04:28:08 +00:00
qboolean NET_AddressSmellsFunny ( netadr_t * a ) ;
2018-09-23 19:35:24 +00:00
qboolean NET_EnsureRoute ( struct ftenet_connections_s * collection , char * routename , char * host , netadr_t * adr ) ;
2022-07-28 02:18:05 +00:00
void NET_TerminateRoute ( struct ftenet_connections_s * collection , netadr_t * adr ) ;
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
void NET_PrintConnectionsStatus ( struct ftenet_connections_s * collection ) ;
2004-08-21 01:25:48 +00:00
2015-07-07 02:33:00 +00:00
enum addressscope_e
{
ASCOPE_PROCESS = 0 ,
ASCOPE_HOST = 1 ,
2019-02-16 19:09:07 +00:00
ASCOPE_LINK = 2 ,
ASCOPE_LAN = 3 ,
ASCOPE_NET = 4
2015-07-07 02:33:00 +00:00
} ;
2020-05-14 15:50:26 +00:00
enum addressscope_e NET_ClassifyAddress ( netadr_t * adr , const char * * outdesc ) ;
2015-07-07 02:33:00 +00:00
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
qboolean NET_AddrIsReliable ( netadr_t * adr ) ; //hints that the protocol is reliable. if so, we don't need to wait for acks
2022-07-28 02:16:31 +00:00
qboolean NET_IsEncrypted ( netadr_t * adr ) ;
2013-05-03 04:28:08 +00:00
qboolean NET_CompareAdr ( netadr_t * a , netadr_t * b ) ;
qboolean NET_CompareBaseAdr ( netadr_t * a , netadr_t * b ) ;
2015-06-15 20:11:27 +00:00
void NET_AdrToStringResolve ( netadr_t * adr , void ( * resolved ) ( void * ctx , void * data , size_t a , size_t b ) , void * ctx , size_t a , size_t b ) ;
2013-05-03 04:28:08 +00:00
char * NET_AdrToString ( char * s , int len , netadr_t * a ) ;
2018-09-23 19:35:24 +00:00
char * NET_SockadrToString ( char * s , int len , struct sockaddr_qstorage * a , size_t sizeofa ) ;
2013-05-03 04:28:08 +00:00
char * NET_BaseAdrToString ( char * s , int len , netadr_t * a ) ;
2018-09-23 19:35:24 +00:00
size_t NET_StringToSockaddr2 ( const char * s , int defaultport , netadrtype_t afhint , struct sockaddr_qstorage * sadr , int * addrfamily , int * addrsize , size_t addrcount ) ;
# define NET_StringToSockaddr(s,p,a,f,z) (NET_StringToSockaddr2(s,p,NA_INVALID,a,f,z,1)>0)
2020-02-11 18:06:10 +00:00
size_t NET_StringToAdr2 ( const char * s , int defaultport , netadr_t * a , size_t addrcount , const char * * pathstart ) ;
# define NET_StringToAdr(s,p,a) NET_StringToAdr2(s,p,a,1,NULL)
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
qboolean NET_PortToAdr ( netadrtype_t adrfamily , netproto_t adrprot , const char * s , netadr_t * a ) ;
2004-08-21 01:25:48 +00:00
qboolean NET_IsClientLegal ( netadr_t * adr ) ;
2013-05-03 04:28:08 +00:00
qboolean NET_IsLoopBackAddress ( netadr_t * adr ) ;
2004-08-21 01:25:48 +00:00
2017-02-11 16:14:06 +00:00
qboolean NET_StringToAdrMasked ( const char * s , qboolean allowdns , netadr_t * a , netadr_t * amask ) ;
2013-05-03 04:28:08 +00:00
char * NET_AdrToStringMasked ( char * s , int len , netadr_t * a , netadr_t * amask ) ;
2006-05-22 22:51:14 +00:00
void NET_IntegerToMask ( netadr_t * a , netadr_t * amask , int bits ) ;
2013-05-03 04:28:08 +00:00
qboolean NET_CompareAdrMasked ( netadr_t * a , netadr_t * b , netadr_t * mask ) ;
2006-05-22 22:51:14 +00:00
2017-06-21 01:24:25 +00:00
qboolean FTENET_AddToCollection ( struct ftenet_connections_s * col , const char * name , const char * address , netadrtype_t addrtype , netproto_t addrprot ) ;
2009-11-04 21:16:50 +00:00
2018-11-19 06:37:25 +00:00
enum certprops_e
{
QCERT_PEERFINGERPRINT
} ;
size_t NET_GetConnectionCertificate ( struct ftenet_connections_s * col , netadr_t * a , enum certprops_e prop , char * out , size_t outsize ) ;
2017-05-18 10:24:09 +00:00
# ifdef HAVE_DTLS
2022-01-28 10:48:01 +00:00
struct dtlscred_s ;
struct dtlsfuncs_s ;
qboolean NET_DTLS_Create ( struct ftenet_connections_s * col , netadr_t * to , const struct dtlscred_s * cred ) ;
2017-05-18 10:24:09 +00:00
qboolean NET_DTLS_Decode ( struct ftenet_connections_s * col ) ;
qboolean NET_DTLS_Disconnect ( struct ftenet_connections_s * col , netadr_t * to ) ;
void NET_DTLS_Timeouts ( struct ftenet_connections_s * col ) ;
2022-01-16 18:41:34 +00:00
extern cvar_t dtls_psk_hint , dtls_psk_user , dtls_psk_key ;
2017-05-18 10:24:09 +00:00
# endif
2022-01-28 10:48:01 +00:00
# ifdef SUPPORT_ICE
2022-07-28 02:18:05 +00:00
neterr_t ICE_SendPacket ( size_t length , const void * data , netadr_t * to ) ;
void ICE_Terminate ( netadr_t * to ) ; //if we kicked the client/etc, kill their ICE too.
2022-07-28 02:16:31 +00:00
qboolean ICE_IsEncrypted ( netadr_t * to ) ;
void ICE_Init ( void ) ;
2022-01-28 10:48:01 +00:00
# endif
2018-10-23 07:09:06 +00:00
extern cvar_t timeout ;
2019-06-05 20:48:06 +00:00
extern cvar_t tls_ignorecertificateerrors ; //evil evil evil.
2021-06-21 13:43:57 +00:00
struct ftecrypto_s ;
qboolean NET_RegisterCrypto ( void * module , struct ftecrypto_s * driver ) ;
2017-05-18 10:24:09 +00:00
2004-08-21 01:25:48 +00:00
//============================================================================
# define OLD_AVG 0.99 // total = oldtotal*OLD_AVG + new*(1-OLD_AVG)
# define MAX_LATENT 32
2008-06-08 14:37:57 +00:00
# define MAX_ADR_SIZE 64
2004-08-21 01:25:48 +00:00
typedef struct
{
qboolean fatal_error ;
# ifdef NQPROT
2011-06-16 02:03:57 +00:00
int isnqprotocol ;
2013-03-12 22:35:33 +00:00
qboolean nqreliable_allowed ; //says the peer has acked the last reliable (or timed out and needs resending).
float nqreliable_resendtime ; //force nqreliable_allowed, thereby forcing a resend of anything n
2018-03-05 11:06:12 +00:00
qbyte nqunreliableonly ; //nq can't cope with certain reliables some times. if 2, we have a reliable that result in a block (that should be sent). if 1, we are blocking. if 0, we can send reliables freely. if 3, then we just want to ignore clc_moves
2004-08-21 01:25:48 +00:00
# endif
2019-05-23 15:11:32 +00:00
qboolean pext_fragmentation ; //fte's packet fragmentation extension, to avoid issues with low mtus.
2020-02-11 18:06:10 +00:00
qboolean pext_stunaware ; //prevent the two lead-bits of packets from being either 0(stun), so stray stun packets cannot mess things up for us.
2010-08-11 09:31:24 +00:00
struct netprim_s netprim ;
2019-05-23 15:11:32 +00:00
int mtu ; //the path mtu, if known
int dupe ; //how many times to dupe packets
2004-08-21 01:25:48 +00:00
float last_received ; // for timeouts
// the statistics are cleared at each client begin, because
// the server connecting process gives a bogus picture of the data
float frame_latency ; // rolling average
float frame_rate ;
int drop_count ; // dropped packets, cleared each level
int good_count ; // cleared each level
2012-02-27 12:23:15 +00:00
int bytesin ;
int bytesout ;
2004-08-21 01:25:48 +00:00
netadr_t remote_address ;
netsrc_t sock ;
int qport ;
2015-12-28 17:41:39 +00:00
int qportsize ;
2004-08-21 01:25:48 +00:00
// bandwidth estimator
double cleartime ; // if realtime > nc->cleartime, free to go
2004-10-19 16:10:14 +00:00
// double rate; // seconds / qbyte
2004-08-21 01:25:48 +00:00
// sequencing variables
2005-05-26 12:55:34 +00:00
int incoming_unreliable ; //dictated by the other end.
2004-08-21 01:25:48 +00:00
int incoming_sequence ;
int incoming_acknowledged ;
int incoming_reliable_acknowledged ; // single bit
int incoming_reliable_sequence ; // single bit, maintained local
2005-05-26 12:55:34 +00:00
int outgoing_unreliable ;
2004-08-21 01:25:48 +00:00
int outgoing_sequence ;
int reliable_sequence ; // single bit
int last_reliable_sequence ; // sequence number of last send
// reliable staging and holding areas
sizebuf_t message ; // writing buffer to send to server
qbyte message_buf [ MAX_OVERALLMSGLEN ] ;
2005-05-26 12:55:34 +00:00
//nq has message truncation.
2004-08-21 01:25:48 +00:00
int reliable_length ;
2005-05-26 12:55:34 +00:00
int reliable_start ;
2004-08-21 01:25:48 +00:00
qbyte reliable_buf [ MAX_OVERALLMSGLEN ] ; // unacked reliable message
// time and size data to calculate bandwidth
int outgoing_size [ MAX_LATENT ] ;
double outgoing_time [ MAX_LATENT ] ;
2014-05-10 13:42:13 +00:00
struct huffman_s * compresstable ;
2004-12-24 08:45:56 +00:00
2005-05-26 12:55:34 +00:00
//nq servers must recieve truncated packets.
2005-06-04 04:20:20 +00:00
int in_fragment_length ;
char in_fragment_buf [ MAX_OVERALLMSGLEN ] ;
int in_fragment_start ;
2004-08-21 01:25:48 +00:00
} netchan_t ;
extern int net_drop ; // packets dropped before this one
2014-12-23 15:26:42 +00:00
void Net_Master_Init ( void ) ;
2004-08-21 01:25:48 +00:00
void Netchan_Init ( void ) ;
2009-06-23 21:49:44 +00:00
int Netchan_Transmit ( netchan_t * chan , int length , qbyte * data , int rate ) ;
2022-07-28 02:17:27 +00:00
void Netchan_OutOfBand ( netsrc_t sock , netadr_t * adr , int length , const qbyte * data ) ;
2013-05-03 04:28:08 +00:00
void VARGS Netchan_OutOfBandPrint ( netsrc_t sock , netadr_t * adr , char * format , . . . ) LIKEPRINTF ( 3 ) ;
void VARGS Netchan_OutOfBandTPrintf ( netsrc_t sock , netadr_t * adr , int language , translation_t text , . . . ) ;
2004-08-21 01:25:48 +00:00
qboolean Netchan_Process ( netchan_t * chan ) ;
2013-05-03 04:28:08 +00:00
void Netchan_Setup ( netsrc_t sock , netchan_t * chan , netadr_t * adr , int qport ) ;
2019-05-10 09:31:21 +00:00
unsigned int Net_PextMask ( unsigned int protover , qboolean fornq ) ;
2012-02-12 05:18:31 +00:00
extern cvar_t net_mtu ;
2004-08-21 01:25:48 +00:00
2004-10-19 16:10:14 +00:00
qboolean Netchan_CanPacket ( netchan_t * chan , int rate ) ;
2009-11-04 21:16:50 +00:00
void Netchan_Block ( netchan_t * chan , int bytes , int rate ) ;
2004-10-19 16:10:14 +00:00
qboolean Netchan_CanReliable ( netchan_t * chan , int rate ) ;
2005-06-14 04:52:10 +00:00
# ifdef NQPROT
2021-04-14 05:21:04 +00:00
enum nqnc_packettype_e
{
NQNC_IGNORED ,
NQNC_ACK ,
NQNC_RELIABLE ,
NQNC_UNRELIABLE ,
} ;
enum nqnc_packettype_e NQNetChan_Process ( netchan_t * chan ) ;
2005-06-14 04:52:10 +00:00
# endif
2004-08-21 01:25:48 +00:00
# ifdef HUFFNETWORK
2014-05-10 13:42:13 +00:00
# define HUFFCRC_QUAKE3 0x286f2e8d
typedef struct huffman_s huffman_t ;
2004-08-21 01:25:48 +00:00
int Huff_PreferedCompressionCRC ( void ) ;
2006-02-11 14:51:36 +00:00
void Huff_EncryptPacket ( sizebuf_t * msg , int offset ) ;
void Huff_DecryptPacket ( sizebuf_t * msg , int offset ) ;
2014-05-10 13:42:13 +00:00
huffman_t * Huff_CompressionCRC ( int crc ) ;
void Huff_CompressPacket ( huffman_t * huff , sizebuf_t * msg , int offset ) ;
void Huff_DecompressPacket ( huffman_t * huff , sizebuf_t * msg , int offset ) ;
2005-01-04 07:54:24 +00:00
int Huff_GetByte ( qbyte * buffer , int * count ) ;
2005-10-07 16:27:20 +00:00
void Huff_EmitByte ( int ch , qbyte * buffer , int * count ) ;
2004-08-21 01:25:48 +00:00
# endif
# ifdef NQPROT
2005-05-26 12:55:34 +00:00
//taken from nq's net.h
//refer to that for usage info. :)
# define NETFLAG_LENGTH_MASK 0x0000ffff
# define NETFLAG_DATA 0x00010000
# define NETFLAG_ACK 0x00020000
# define NETFLAG_NAK 0x00040000
# define NETFLAG_EOM 0x00080000
# define NETFLAG_UNRELIABLE 0x00100000
2022-01-16 18:41:44 +00:00
# define NETFLAG_ZLIB 0x00200000 //QEx - payload contains the real (full) packet
2005-05-26 12:55:34 +00:00
# define NETFLAG_CTL 0x80000000
2014-12-23 15:26:42 +00:00
# define NQ_NETCHAN_GAMENAME "QUAKE"
# define NQ_NETCHAN_VERSION 3
2022-01-08 10:01:15 +00:00
# define NQ_NETCHAN_VERSION_QEX 4 //the rerelease's id, used for nqish-over dtls.
2005-05-26 12:55:34 +00:00
# define CCREQ_CONNECT 0x01
# define CCREQ_SERVER_INFO 0x02
# define CCREQ_PLAYER_INFO 0x03
# define CCREQ_RULE_INFO 0x04
2021-08-19 06:02:18 +00:00
# define CCREQ_PROQUAKE_RCON 0x05
2005-05-26 12:55:34 +00:00
# define CCREP_ACCEPT 0x81
# define CCREP_REJECT 0x82
# define CCREP_SERVER_INFO 0x83
# define CCREP_PLAYER_INFO 0x84
# define CCREP_RULE_INFO 0x85
2005-05-27 05:41:07 +00:00
//server->client protocol info
2016-02-15 06:01:17 +00:00
# define PROTOCOL_VERSION_NQ 15
# define PROTOCOL_VERSION_H2 19
# define PROTOCOL_VERSION_NEHD 250
# define PROTOCOL_VERSION_FITZ 666
# define PROTOCOL_VERSION_RMQ 999
# define PROTOCOL_VERSION_DP5 3502
# define PROTOCOL_VERSION_DP6 3503
# define PROTOCOL_VERSION_DP7 3504
# define PROTOCOL_VERSION_BJP1 10000
# define PROTOCOL_VERSION_BJP2 10001
# define PROTOCOL_VERSION_BJP3 10002
2011-10-27 16:16:29 +00:00
2018-01-03 04:40:06 +00:00
# define MOD_PROQUAKE 1
//#define MOD_PROQUAKE_VERSION (10*3.1) //password feature added
//#define MOD_PROQUAKE_VERSION (10*3.2) //first 'cheatfree'
# define MOD_PROQUAKE_VERSION (10*3.3) //no real changes, but w/e, this is the highest we can claim without having serverside issues.
//#define MOD_PROQUAKE_VERSION (10*3.4) //added nat wait weirdness that's redundant and breaks the whole single-port thing by using two ports on the client too. *sigh*.
//#define MOD_PROQUAKE_VERSION (10*3.5) //optional cheatfree encryption
//#define MOD_PROQUAKE_VERSION (10*4.51) //current version
2011-10-27 16:16:29 +00:00
/*RMQ protocol flags*/
# define RMQFL_SHORTANGLE (1 << 1)
# define RMQFL_FLOATANGLE (1 << 2)
# define RMQFL_24BITCOORD (1 << 3)
# define RMQFL_FLOATCOORD (1 << 4)
# define RMQFL_EDICTSCALE (1 << 5)
# define RMQFL_ALPHASANITY (1 << 6)
2012-09-30 05:52:03 +00:00
# define RMQFL_INT32COORD (1 << 7)
2011-10-27 16:16:29 +00:00
# define RMQFL_MOREFLAGS (1 << 31)
2004-08-21 01:25:48 +00:00
# endif
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
int UDP_OpenSocket ( int port ) ;
int UDP6_OpenSocket ( int port ) ;
int IPX_OpenSocket ( int port ) ;
2007-08-17 23:24:05 +00:00
int NetadrToSockadr ( netadr_t * a , struct sockaddr_qstorage * s ) ;
2018-09-23 19:35:24 +00:00
void SockadrToNetadr ( struct sockaddr_qstorage * s , int sizeofsockaddr , netadr_t * a ) ;
2014-07-02 03:20:40 +00:00
qboolean NET_Sleep ( float seconds , qboolean stdinissocket ) ;