]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - lhnet.c
miscellaneous fixes from graphitemaster
[xonotic/darkplaces.git] / lhnet.c
diff --git a/lhnet.c b/lhnet.c
index fc1acf2b056724cc983cc8bbbb4be46bd332fd1c..e3bc6b712186f54dd511fd4165ddfc2f54fa3c88 100644 (file)
--- a/lhnet.c
+++ b/lhnet.c
@@ -723,6 +723,7 @@ lhnetpacket_t;
 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;
@@ -742,6 +743,18 @@ void LHNET_Init(void)
 #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;
@@ -980,6 +993,13 @@ lhnetsocket_t *LHNET_OpenSocket_Connectionless(lhnetaddress_t *address)
                                                                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;