Module: sip-router Branch: andrei/raw_sock Commit: e92fe8b41e30abc92b5a8e2b4baff0d4aab95e61 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e92fe8b4...
Author: Andrei Pelinescu-Onciul andrei@iptel.org Committer: Andrei Pelinescu-Onciul andrei@iptel.org Date: Tue Jun 15 16:46:04 2010 +0200
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.
---
cfg.lex | 4 ++++ cfg.y | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/cfg.lex b/cfg.lex index e4b5486..de88891 100644 --- a/cfg.lex +++ b/cfg.lex @@ -213,6 +213,8 @@ ADD_LOCAL_RPORT "add_local_rport" FORCE_TCP_ALIAS "force_tcp_alias"|"add_tcp_alias" UDP_MTU "udp_mtu" UDP_MTU_TRY_PROTO "udp_mtu_try_proto" +UDP4_RAW "udp4_raw" +UDP4_RAW_MTU "udp4_raw_mtu" SETFLAG setflag RESETFLAG resetflag ISFLAGSET isflagset @@ -607,6 +609,8 @@ SUBST subst <INITIAL>{UDP_MTU} { count(); yylval.strval=yytext; return UDP_MTU; } <INITIAL>{UDP_MTU_TRY_PROTO} { count(); yylval.strval=yytext; 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>{IF} { count(); yylval.strval=yytext; return IF; } <INITIAL>{ELSE} { count(); yylval.strval=yytext; return ELSE; }
diff --git a/cfg.y b/cfg.y index 5052078..3c52e69 100644 --- a/cfg.y +++ b/cfg.y @@ -200,6 +200,12 @@ #define IF_SCTP(x) warn("sctp support not compiled in") #endif
+#ifdef USE_RAW_SOCKS + #define IF_RAW_SOCKS(x) x +#else + #define IF_RAW_SOCKS(x) warn("raw socket support not compiled in") +#endif +
extern int yylex(); /* safer then using yytext which can be array or pointer */ @@ -323,6 +329,8 @@ extern char *finame; %token FORCE_TCP_ALIAS %token UDP_MTU %token UDP_MTU_TRY_PROTO +%token UDP4_RAW +%token UDP4_RAW_MTU %token IF %token ELSE %token SET_ADV_ADDRESS @@ -1579,6 +1587,12 @@ assign_stm: { default_core_cfg.udp_mtu_try_proto=$3; fix_global_req_flags(0, 0); } | UDP_MTU_TRY_PROTO EQUAL error { yyerror("TCP, TLS, SCTP or UDP expected"); } + | UDP4_RAW EQUAL intno { IF_RAW_SOCKS(default_core_cfg.udp4_raw=$3); } + | UDP4_RAW EQUAL error { yyerror("number expected"); } + | UDP4_RAW_MTU EQUAL NUMBER { + IF_RAW_SOCKS(default_core_cfg.udp4_raw_mtu=$3); + } + | UDP4_RAW_MTU EQUAL error { yyerror("number expected"); } | cfg_var | error EQUAL { yyerror("unknown config variable"); } ;