Author: Isomer <isomer@coders.net>
authorPerry Lorier <isomer@undernet.org>
Sat, 16 Dec 2000 12:38:09 +0000 (12:38 +0000)
committerPerry Lorier <isomer@undernet.org>
Sat, 16 Dec 2000 12:38:09 +0000 (12:38 +0000)
Log message:

Beginning of support for setting the Type Of Service bits - by default
ircu traffic is now set to 'low delay' (no lag! no lag!) which may help.
Network admins can then adjust their network to let traffic with various
ToS's do various things.  If I could figure out how Kev's "feature" subsystem
worked then I'd make it configurable via that.

git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@345 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
include/ircd_osdep.h
include/s_bsd.h
ircd/listener.c
ircd/os_linux.c
ircd/s_bsd.c

index 674ba51a3ef820f66895ccdd7c0747f725c615bb..0521a22604fa84e791dabc79df2652e57e9e85e7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2000-12-17  Isomer <Isomer@coders.net>
+       * ircd/os_linux.c: add TOS stuffs
+
+       * ircd/listener.c: add TOS stuffs
+
 2000-12-16  Kevin L. Mitchell  <klmitch@mit.edu>
 
        * ircd/whocmds.c (do_who): use HasPriv to determine whether or not
index f991a41ee66566c03ab53862bf2c82cdf39f6ba5..981b902ceb533dbd172d48677c061f4dbc7911d9 100644 (file)
@@ -43,6 +43,7 @@ extern int os_set_listen(int fd, int backlog);
 extern int os_set_nonblocking(int fd);
 extern int os_set_reuseaddr(int fd);
 extern int os_set_sockbufs(int fd, unsigned int size);
+extern int os_set_tos(int fd,int tos);
 
 #endif /* INCLUDED_ircd_osdep_h */
 
index 91bf9fa12dc13fffd9c855938914a40e6a95e7e2..b9a88564dbb59b1000f26aa8fe2cd8fa333a5792 100644 (file)
@@ -48,6 +48,7 @@ extern const char* const POLL_ERROR_MSG;
 extern const char* const SELECT_ERROR_MSG;
 extern const char* const CONNECT_ERROR_MSG;
 extern const char* const SETBUFS_ERROR_MSG;
+extern const char* const TOS_ERROR_MSG;
 
 
 extern int            HighestFd;
index a36d755fead990b8c6d201395bd5af401a935e15..fab23846c82ec68d7143fbfe812ac9329b54247e 100644 (file)
@@ -47,6 +47,9 @@
 #define INADDR_NONE ((unsigned int) 0xffffffff)
 #endif
 
+int tos_server = 0x08; // Low delay
+int tos_client = 0x08; // Low delay
+
 struct Listener* ListenerPollList = 0;
 
 static struct Listener* make_listener(int port, struct in_addr addr)
@@ -213,6 +216,12 @@ static int inetport(struct Listener* listener)
     close(fd);
     return 0;
   }
+  /*
+   * Set the TOS bits - this is nonfatal if it doesn't stick.
+   */
+  if (!os_set_tos(fd,(listener->server) ? tos_server : tos_client)) {
+    report_error(TOS_ERROR_MSG, get_listener_name(listener), errno);
+  }
   listener->fd = fd;
 
   return 1;
index f48e552ce1b9be5b2f53207d8c3bc97008b6b533..b17dbe43fac0a87db439b6ef572b0104dcedbc8e 100644 (file)
@@ -157,6 +157,12 @@ int os_set_sockbufs(int fd, unsigned int size)
           0 == setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &opt, sizeof(opt)));
 }
 
+int os_set_tos(int fd,int tos)
+{
+  unsigned int opt = tos;
+  return (0 == setsockopt(fd, SOL_IP, IP_TOS, &opt, sizeof(opt)));
+}
+
 int os_disable_options(int fd)
 {
   return (0 == setsockopt(fd, IPPROTO_IP, IP_OPTIONS, NULL, 0));
index 7e56cf0c8164bc189da8e1aae860a2857e758266..c9d6f76a4361f1496093867e9b83b07065ad68f7 100644 (file)
@@ -97,6 +97,7 @@ const char* const REUSEADDR_ERROR_MSG = "error setting SO_REUSEADDR for %s: %s";
 const char* const SELECT_ERROR_MSG    = "select error for %s: %s";
 const char* const SETBUFS_ERROR_MSG   = "error setting buffer size for %s: %s";
 const char* const SOCKET_ERROR_MSG    = "error creating socket for %s: %s";
+const char* const TOS_ERROR_MSG              = "error setting TOS for %s: %s";
 
 
 #ifdef GODMODE