Browse code

raw sockets: config file support

Raw socket usage for udp ipv4 send, can now be turned on/off/auto
from the config file, via udp4_raw.
The mtu used can be set via udp4_raw_mtu.

Andrei Pelinescu-Onciul authored on 15/06/2010 14:46:04
Showing 2 changed files
... ...
@@ -213,6 +213,8 @@ ADD_LOCAL_RPORT		"add_local_rport"
213 213
 FORCE_TCP_ALIAS		"force_tcp_alias"|"add_tcp_alias"
214 214
 UDP_MTU		"udp_mtu"
215 215
 UDP_MTU_TRY_PROTO	"udp_mtu_try_proto"
216
+UDP4_RAW		"udp4_raw"
217
+UDP4_RAW_MTU	"udp4_raw_mtu"
216 218
 SETFLAG		setflag
217 219
 RESETFLAG	resetflag
218 220
 ISFLAGSET	isflagset
... ...
@@ -607,6 +609,8 @@ SUBST       subst
607 609
 <INITIAL>{UDP_MTU}	{ count(); yylval.strval=yytext; return UDP_MTU; }
608 610
 <INITIAL>{UDP_MTU_TRY_PROTO}	{ count(); yylval.strval=yytext;
609 611
 									return UDP_MTU_TRY_PROTO; }
612
+<INITIAL>{UDP4_RAW}	{ count(); yylval.strval=yytext; return UDP4_RAW; }
613
+<INITIAL>{UDP4_RAW_MTU}	{ count(); yylval.strval=yytext; return UDP4_RAW_MTU; }
610 614
 <INITIAL>{IF}	{ count(); yylval.strval=yytext; return IF; }
611 615
 <INITIAL>{ELSE}	{ count(); yylval.strval=yytext; return ELSE; }
612 616
 
... ...
@@ -200,6 +200,12 @@
200 200
 	#define IF_SCTP(x) warn("sctp support not compiled in")
201 201
 #endif
202 202
 
203
+#ifdef USE_RAW_SOCKS
204
+	#define IF_RAW_SOCKS(x) x
205
+#else
206
+	#define IF_RAW_SOCKS(x) warn("raw socket support not compiled in")
207
+#endif
208
+
203 209
 
204 210
 extern int yylex();
205 211
 /* safer then using yytext which can be array or pointer */
... ...
@@ -323,6 +329,8 @@ extern char *finame;
323 329
 %token FORCE_TCP_ALIAS
324 330
 %token UDP_MTU
325 331
 %token UDP_MTU_TRY_PROTO
332
+%token UDP4_RAW
333
+%token UDP4_RAW_MTU
326 334
 %token IF
327 335
 %token ELSE
328 336
 %token SET_ADV_ADDRESS
... ...
@@ -1579,6 +1587,12 @@ assign_stm:
1579 1587
 		{ default_core_cfg.udp_mtu_try_proto=$3; fix_global_req_flags(0, 0); }
1580 1588
 	| UDP_MTU_TRY_PROTO EQUAL error
1581 1589
 		{ yyerror("TCP, TLS, SCTP or UDP expected"); }
1590
+	| UDP4_RAW EQUAL intno { IF_RAW_SOCKS(default_core_cfg.udp4_raw=$3); }
1591
+	| UDP4_RAW EQUAL error { yyerror("number expected"); }
1592
+	| UDP4_RAW_MTU EQUAL NUMBER {
1593
+		IF_RAW_SOCKS(default_core_cfg.udp4_raw_mtu=$3);
1594
+	}
1595
+	| UDP4_RAW_MTU EQUAL error { yyerror("number expected"); }
1582 1596
 	| cfg_var
1583 1597
 	| error EQUAL { yyerror("unknown config variable"); }
1584 1598
 	;