From: Perry Lorier Date: Sat, 16 Dec 2000 12:38:09 +0000 (+0000) Subject: Author: Isomer X-Git-Url: http://git.pk910.de/?p=ircu2.10.12-pk.git;a=commitdiff_plain;h=f4858b15c06391be73006c63b42aa1d31fd4c87e Author: Isomer 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 --- diff --git a/ChangeLog b/ChangeLog index 674ba51..0521a22 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2000-12-17 Isomer + * ircd/os_linux.c: add TOS stuffs + + * ircd/listener.c: add TOS stuffs + 2000-12-16 Kevin L. Mitchell * ircd/whocmds.c (do_who): use HasPriv to determine whether or not diff --git a/include/ircd_osdep.h b/include/ircd_osdep.h index f991a41..981b902 100644 --- a/include/ircd_osdep.h +++ b/include/ircd_osdep.h @@ -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 */ diff --git a/include/s_bsd.h b/include/s_bsd.h index 91bf9fa..b9a8856 100644 --- a/include/s_bsd.h +++ b/include/s_bsd.h @@ -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; diff --git a/ircd/listener.c b/ircd/listener.c index a36d755..fab2384 100644 --- a/ircd/listener.c +++ b/ircd/listener.c @@ -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; diff --git a/ircd/os_linux.c b/ircd/os_linux.c index f48e552..b17dbe4 100644 --- a/ircd/os_linux.c +++ b/ircd/os_linux.c @@ -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)); diff --git a/ircd/s_bsd.c b/ircd/s_bsd.c index 7e56cf0..c9d6f76 100644 --- a/ircd/s_bsd.c +++ b/ircd/s_bsd.c @@ -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