static int lhnet_active;
static lhnetsocket_t lhnet_socketlist;
static lhnetpacket_t lhnet_packetlist;
+static int lhnet_default_dscp = 0;
#ifdef WIN32
static int lhnet_didWSAStartup = 0;
static WSADATA lhnet_winsockdata;
#endif
}
+int LHNET_DefaultDSCP(int dscp)
+{
+#ifdef IP_TOS
+ int prev = lhnet_default_dscp;
+ if(dscp >= 0)
+ lhnet_default_dscp = dscp;
+ return prev;
+#else
+ return -1;
+#endif
+}
+
void LHNET_Shutdown(void)
{
lhnetpacket_t *p;
int i = 1;
// enable broadcast on this socket
setsockopt(lhnetsocket->inetsocket, SOL_SOCKET, SO_BROADCAST, (char *)&i, sizeof(i));
+#ifdef IP_TOS
+ {
+ // enable DSCP for ToS support
+ int tos = lhnet_default_dscp << 2;
+ setsockopt(lhnetsocket->inetsocket, IPPROTO_IP, IP_TOS, (char *) &tos, sizeof(tos));
+ }
+#endif
lhnetsocket->next = &lhnet_socketlist;
lhnetsocket->prev = lhnetsocket->next->prev;
lhnetsocket->next->prev = lhnetsocket;
void LHNET_Init(void);
void LHNET_Shutdown(void);
+int LHNET_DefaultDSCP(int dscp); // < 0: query; >= 0: set (returns previous value)
void LHNET_SleepUntilPacket_Microseconds(int microseconds);
lhnetsocket_t *LHNET_OpenSocket_Connectionless(lhnetaddress_t *address);
void LHNET_CloseSocket(lhnetsocket_t *lhnetsocket);
static cvar_t net_slist_pause = {0, "net_slist_pause", "0", "when set to 1, the server list won't update until it is set back to 0"};
static cvar_t net_slist_maxtries = {0, "net_slist_maxtries", "3", "how many times to ask the same server for information (more times gives better ping reports but takes longer)"};
static cvar_t net_slist_favorites = {CVAR_SAVE | CVAR_NQUSERINFOHACK, "net_slist_favorites", "", "contains a list of IP addresses and ports to always query explicitly"};
+static cvar_t net_tos_dscp = {CVAR_SAVE, "net_tos_dscp", "32", "DiffServ Codepoint for network sockets (may need game restart to apply)"};
static cvar_t gameversion = {0, "gameversion", "0", "version of game data (mod-specific) to be sent to querying clients"};
static cvar_t gameversion_min = {0, "gameversion_min", "-1", "minimum version of game data (mod-specific), when client and server gameversion mismatch in the server browser the server is shown as incompatible; if -1, gameversion is used alone"};
static cvar_t gameversion_max = {0, "gameversion_max", "-1", "maximum version of game data (mod-specific), when client and server gameversion mismatch in the server browser the server is shown as incompatible; if -1, gameversion is used alone"};
{
int i, j;
+ // TODO add logic to automatically close sockets if needed
+ LHNET_DefaultDSCP(net_tos_dscp.integer);
+
if (cls.state != ca_dedicated)
{
if (clientport2 != cl_netport.integer)
Cvar_RegisterVariable(&net_slist_maxtries);
Cvar_RegisterVariable(&net_slist_favorites);
Cvar_RegisterVariable(&net_slist_pause);
+ if(LHNET_DefaultDSCP(-1) >= 0) // register cvar only if supported
+ Cvar_RegisterVariable(&net_tos_dscp);
Cvar_RegisterVariable(&net_messagetimeout);
Cvar_RegisterVariable(&net_connecttimeout);
Cvar_RegisterVariable(&net_connectfloodblockingtimeout);