Ver código fonte

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

Andrei Pelinescu-Onciul 20 anos atrás
pai
commit
fe09f3158f
8 arquivos alterados com 17 adições e 4 exclusões
  1. 1 0
      CREDITS
  2. 1 0
      NEWS
  3. 4 1
      cfg.lex
  4. 3 0
      cfg.y
  5. 2 0
      globals.h
  6. 3 0
      main.c
  7. 2 2
      tcp_main.c
  8. 1 1
      udp_server.c

+ 1 - 0
CREDITS

@@ -10,6 +10,7 @@ Jiri Kuthan
 Contributors:
 
 Adrian Georgescu
+Andreas Granig
 Dan Pascu
 Greg Fausak
 Jamey Hicks

+ 1 - 0
NEWS

@@ -35,6 +35,7 @@ core:
     onreply route that will be executed for any reply (usefull to catch
     replies without using tm)
 new config variables:
+   tos = number  - ip type of service (TOS) value
    dns_try_ipv6 = yes/no - if yes and a dns lookup fails, it will retry it
       for ipv6 (AAAA record). Default: yes
    dns_retr_time = time - time in s before retrying a dns request.

+ 4 - 1
cfg.lex

@@ -238,7 +238,8 @@ ADVERTISED_PORT		"advertised_port"
 DISABLE_CORE		"disable_core_dump"
 OPEN_FD_LIMIT		"open_files_limit"
 MCAST_LOOPBACK		"mcast_loopback"
-MCAST_TTL			"mcast_ttl"
+MCAST_TTL		"mcast_ttl"
+TOS			"tos"
 
 LOADMODULE	loadmodule
 MODPARAM        modparam
@@ -442,6 +443,8 @@ EAT_ABLE	[\ \t\b\r]
 									return MCAST_LOOPBACK; }
 <INITIAL>{MCAST_TTL}		{	count(); yylval.strval=yytext;
 									return MCAST_TTL; }
+<INITIAL>{TOS}			{	count(); yylval.strval=yytext;
+									return TOS; }
 <INITIAL>{LOADMODULE}	{ count(); yylval.strval=yytext; return LOADMODULE; }
 <INITIAL>{MODPARAM}     { count(); yylval.strval=yytext; return MODPARAM; }
 

+ 3 - 0
cfg.y

@@ -260,6 +260,7 @@ static struct socket_id* mk_listen_id(char*, int, int);
 %token OPEN_FD_LIMIT
 %token MCAST_LOOPBACK
 %token MCAST_TTL
+%token TOS
 
 
 
@@ -749,6 +750,8 @@ assign_stm:	DEBUG EQUAL NUMBER { debug=$3; }
 								#endif
 		  }
 		| MCAST_TTL EQUAL error { yyerror("number expected"); }
+		| TOS EQUAL NUMBER { tos=$3; }
+		| TOS EQUAL error { yyerror("number expected"); }
 		| error EQUAL { yyerror("unknown config variable"); }
 	;
 

+ 2 - 0
globals.h

@@ -112,6 +112,8 @@ extern int mcast_loopback;
 extern int mcast_ttl;
 #endif /* USE_MCAST */
 
+extern int tos;
+
 /*
  * debug & log_stderr moved to dprint.h*/
 

+ 3 - 0
main.c

@@ -73,6 +73,7 @@
 #include <unistd.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#include <netinet/ip.h>
 #include <arpa/inet.h>
 #include <sys/utsname.h>
 #include <sys/types.h>
@@ -291,6 +292,8 @@ int mcast_loopback = 0;
 int mcast_ttl = -1; /* if -1, don't touch it, use the default (usually 1) */
 #endif /* USE_MCAST */
 
+int tos = IPTOS_LOWDELAY;
+
 #if 0
 char* names[MAX_LISTEN];              /* our names */
 int names_len[MAX_LISTEN];            /* lengths of the names*/

+ 2 - 2
tcp_main.c

@@ -179,7 +179,7 @@ static int init_sock_opt(int s)
 	}
 #endif
 	/* tos*/
-	optval=IPTOS_LOWDELAY;
+	optval = tos;
 	if (setsockopt(s, IPPROTO_IP, IP_TOS, (void*)&optval,sizeof(optval)) ==-1){
 		LOG(L_WARN, "WARNING: init_sock_opt: setsockopt tos: %s\n",
 				strerror(errno));
@@ -898,7 +898,7 @@ int tcp_init(struct socket_info* sock_info)
 	}
 #endif
 	/* tos */
-	optval=IPTOS_LOWDELAY;
+	optval = tos;
 	if (setsockopt(sock_info->socket, IPPROTO_IP, IP_TOS, (void*)&optval, 
 				sizeof(optval)) ==-1){
 		LOG(L_WARN, "WARNING: tcp_init: setsockopt tos: %s\n", strerror(errno));

+ 1 - 1
udp_server.c

@@ -298,7 +298,7 @@ int udp_init(struct socket_info* sock_info)
 		goto error;
 	}
 	/* tos */
-	optval=IPTOS_LOWDELAY;
+	optval = tos;
 	if (setsockopt(sock_info->socket, IPPROTO_IP, IP_TOS, (void*)&optval, 
 			sizeof(optval)) ==-1){
 		LOG(L_WARN, "WARNING: udp_init: setsockopt tos: %s\n", strerror(errno));