浏览代码

raw sockets: ttl can be set from the config file

The ttl used for raw sockets can be set from the config file,
using udp4_raw_ttl.
 -1 can be used for auto-detection.
Andrei Pelinescu-Onciul 15 年之前
父节点
当前提交
2556cd84fa
共有 2 个文件被更改,包括 7 次插入0 次删除
  1. 2 0
      cfg.lex
  2. 5 0
      cfg.y

+ 2 - 0
cfg.lex

@@ -215,6 +215,7 @@ UDP_MTU		"udp_mtu"
 UDP_MTU_TRY_PROTO	"udp_mtu_try_proto"
 UDP4_RAW		"udp4_raw"
 UDP4_RAW_MTU	"udp4_raw_mtu"
+UDP4_RAW_TTL	"udp4_raw_ttl"
 SETFLAG		setflag
 RESETFLAG	resetflag
 ISFLAGSET	isflagset
@@ -611,6 +612,7 @@ SUBST       subst
 									return UDP_MTU_TRY_PROTO; }
 <INITIAL>{UDP4_RAW}	{ count(); yylval.strval=yytext; return UDP4_RAW; }
 <INITIAL>{UDP4_RAW_MTU}	{ count(); yylval.strval=yytext; return UDP4_RAW_MTU; }
+<INITIAL>{UDP4_RAW_TTL}	{ count(); yylval.strval=yytext; return UDP4_RAW_TTL; }
 <INITIAL>{IF}	{ count(); yylval.strval=yytext; return IF; }
 <INITIAL>{ELSE}	{ count(); yylval.strval=yytext; return ELSE; }
 

+ 5 - 0
cfg.y

@@ -331,6 +331,7 @@ extern char *finame;
 %token UDP_MTU_TRY_PROTO
 %token UDP4_RAW
 %token UDP4_RAW_MTU
+%token UDP4_RAW_TTL
 %token IF
 %token ELSE
 %token SET_ADV_ADDRESS
@@ -1593,6 +1594,10 @@ assign_stm:
 		IF_RAW_SOCKS(default_core_cfg.udp4_raw_mtu=$3);
 	}
 	| UDP4_RAW_MTU EQUAL error { yyerror("number expected"); }
+	| UDP4_RAW_TTL EQUAL NUMBER {
+		IF_RAW_SOCKS(default_core_cfg.udp4_raw_ttl=$3);
+	}
+	| UDP4_RAW_TTL EQUAL error { yyerror("number expected"); }
 	| cfg_var
 	| error EQUAL { yyerror("unknown config variable"); }
 	;