Browse code

- ip TOS can now be set from ser cfg (thanks to Andreas Granig)

Andrei Pelinescu-Onciul authored on 02/11/2005 18:14:12
Showing 8 changed files
... ...
@@ -10,6 +10,7 @@ Jiri Kuthan
10 10
 Contributors:
11 11
 
12 12
 Adrian Georgescu
13
+Andreas Granig
13 14
 Dan Pascu
14 15
 Greg Fausak
15 16
 Jamey Hicks
... ...
@@ -35,6 +35,7 @@ core:
35 35
     onreply route that will be executed for any reply (usefull to catch
36 36
     replies without using tm)
37 37
 new config variables:
38
+   tos = number  - ip type of service (TOS) value
38 39
    dns_try_ipv6 = yes/no - if yes and a dns lookup fails, it will retry it
39 40
       for ipv6 (AAAA record). Default: yes
40 41
    dns_retr_time = time - time in s before retrying a dns request.
... ...
@@ -238,7 +238,8 @@ ADVERTISED_PORT		"advertised_port"
238 238
 DISABLE_CORE		"disable_core_dump"
239 239
 OPEN_FD_LIMIT		"open_files_limit"
240 240
 MCAST_LOOPBACK		"mcast_loopback"
241
-MCAST_TTL			"mcast_ttl"
241
+MCAST_TTL		"mcast_ttl"
242
+TOS			"tos"
242 243
 
243 244
 LOADMODULE	loadmodule
244 245
 MODPARAM        modparam
... ...
@@ -442,6 +443,8 @@ EAT_ABLE	[\ \t\b\r]
442 442
 									return MCAST_LOOPBACK; }
443 443
 <INITIAL>{MCAST_TTL}		{	count(); yylval.strval=yytext;
444 444
 									return MCAST_TTL; }
445
+<INITIAL>{TOS}			{	count(); yylval.strval=yytext;
446
+									return TOS; }
445 447
 <INITIAL>{LOADMODULE}	{ count(); yylval.strval=yytext; return LOADMODULE; }
446 448
 <INITIAL>{MODPARAM}     { count(); yylval.strval=yytext; return MODPARAM; }
447 449
 
... ...
@@ -260,6 +260,7 @@ static struct socket_id* mk_listen_id(char*, int, int);
260 260
 %token OPEN_FD_LIMIT
261 261
 %token MCAST_LOOPBACK
262 262
 %token MCAST_TTL
263
+%token TOS
263 264
 
264 265
 
265 266
 
... ...
@@ -749,6 +750,8 @@ assign_stm:	DEBUG EQUAL NUMBER { debug=$3; }
749 749
 								#endif
750 750
 		  }
751 751
 		| MCAST_TTL EQUAL error { yyerror("number expected"); }
752
+		| TOS EQUAL NUMBER { tos=$3; }
753
+		| TOS EQUAL error { yyerror("number expected"); }
752 754
 		| error EQUAL { yyerror("unknown config variable"); }
753 755
 	;
754 756
 
... ...
@@ -112,6 +112,8 @@ extern int mcast_loopback;
112 112
 extern int mcast_ttl;
113 113
 #endif /* USE_MCAST */
114 114
 
115
+extern int tos;
116
+
115 117
 /*
116 118
  * debug & log_stderr moved to dprint.h*/
117 119
 
... ...
@@ -73,6 +73,7 @@
73 73
 #include <unistd.h>
74 74
 #include <sys/socket.h>
75 75
 #include <netinet/in.h>
76
+#include <netinet/ip.h>
76 77
 #include <arpa/inet.h>
77 78
 #include <sys/utsname.h>
78 79
 #include <sys/types.h>
... ...
@@ -291,6 +292,8 @@ int mcast_loopback = 0;
291 291
 int mcast_ttl = -1; /* if -1, don't touch it, use the default (usually 1) */
292 292
 #endif /* USE_MCAST */
293 293
 
294
+int tos = IPTOS_LOWDELAY;
295
+
294 296
 #if 0
295 297
 char* names[MAX_LISTEN];              /* our names */
296 298
 int names_len[MAX_LISTEN];            /* lengths of the names*/
... ...
@@ -179,7 +179,7 @@ static int init_sock_opt(int s)
179 179
 	}
180 180
 #endif
181 181
 	/* tos*/
182
-	optval=IPTOS_LOWDELAY;
182
+	optval = tos;
183 183
 	if (setsockopt(s, IPPROTO_IP, IP_TOS, (void*)&optval,sizeof(optval)) ==-1){
184 184
 		LOG(L_WARN, "WARNING: init_sock_opt: setsockopt tos: %s\n",
185 185
 				strerror(errno));
... ...
@@ -898,7 +898,7 @@ int tcp_init(struct socket_info* sock_info)
898 898
 	}
899 899
 #endif
900 900
 	/* tos */
901
-	optval=IPTOS_LOWDELAY;
901
+	optval = tos;
902 902
 	if (setsockopt(sock_info->socket, IPPROTO_IP, IP_TOS, (void*)&optval, 
903 903
 				sizeof(optval)) ==-1){
904 904
 		LOG(L_WARN, "WARNING: tcp_init: setsockopt tos: %s\n", strerror(errno));
... ...
@@ -298,7 +298,7 @@ int udp_init(struct socket_info* sock_info)
298 298
 		goto error;
299 299
 	}
300 300
 	/* tos */
301
-	optval=IPTOS_LOWDELAY;
301
+	optval = tos;
302 302
 	if (setsockopt(sock_info->socket, IPPROTO_IP, IP_TOS, (void*)&optval, 
303 303
 			sizeof(optval)) ==-1){
304 304
 		LOG(L_WARN, "WARNING: udp_init: setsockopt tos: %s\n", strerror(errno));