[syslog-ng] [PATCH] afsocket: Add an ip-protocol() option for the network driver

Balazs Scheidler bazsi77 at gmail.com
Sat Dec 8 08:43:56 CET 2012


Hi,

I haven't forgotten about this, I just wanted to refactor the transport selection logic out of the source/destination driver.

The patch otherwise looks ok, and I'll either fold it into the refactor stuff or merge on its own if I can't do the refactor.

Thanks.

----- Original message -----
> To make it easy to set up IPv6 sources or destinations, the network()
> driver should have an option to select the IP protocol. This patch
> does just that, in the form of an ip-protocol() option, which allows
> one to select either IPv4 or IPv6.
> 
> In the end, this allows us to have a source as follows:
> 
> source s_v6_syslog {
>     network(port(12345)
>                     transport(framed)
>                     ip-protocol(6));
> };
> 
> The option is available for both the source and destination version of
> network().
> 
> Signed-off-by: Gergely Nagy <algernon at balabit.hu>
> ---
>   modules/afsocket/afsocket-grammar.ym |     29
> ++++++++++++++++++++++++++++- modules/afsocket/afsocket-parser.c     |     
> 1 + 2 files changed, 29 insertions(+), 1 deletion(-)
> 
> diff --git a/modules/afsocket/afsocket-grammar.ym
> b/modules/afsocket/afsocket-grammar.ym index 7beb6e8..464d5d8 100644
> --- a/modules/afsocket/afsocket-grammar.ym
> +++ b/modules/afsocket/afsocket-grammar.ym
> @@ -79,6 +79,7 @@ TLSContext *last_tls_context;
>   %token KW_UDP6
>   %token KW_NETWORK
>   %token KW_TRANSPORT
> +%token KW_IP_PROTOCOL
>   
>   %token KW_IP_TTL
>   %token KW_SO_BROADCAST
> @@ -136,6 +137,8 @@ TLSContext *last_tls_context;
>   %type     <ptr> dest_afnetwork
>   %type     <ptr> dest_afnetwork_params
>   
> +%type     <num> afinet_ip_protocol_option
> +
>   %%
>   
>   start
> @@ -149,6 +152,25 @@ start
>                   | LL_CONTEXT_DESTINATION dest_afnetwork                             {
> YYACCEPT; }                 ;
>   
> +afinet_ip_protocol_option
> +               : LL_NUMBER
> +               {
> +                   CHECK_ERROR($1 == 4 || $1 == 6, @1, "ip-protocol option can
> only be 4 or 6!"); +                   if ($1 == 4)
> +                       {
> +                           $$ = AF_INET;
> +                       }
> +                   else
> +                       {
> +                           $$ = AF_INET6;
> +                       }
> +               }
> +               ;
> +
> +source_afinet_ip_protocol
> +               : KW_IP_PROTOCOL '(' afinet_ip_protocol_option ')' {
> ((AFSocketSourceDriver *)last_driver)->address_family = $3; } +               ;
> +               
>   source_afunix
>                   : KW_UNIX_DGRAM '(' source_afunix_dgram_params ')'                           
>                                       { $$ = $3; }     | KW_UNIX_STREAM '('
> source_afunix_stream_params ')'                                                                    { $$ =
> $3; } @@ -314,6 +336,7 @@ source_afnetwork_option                 :
> source_afinet_option                 | source_afsocket_transport
>       | source_afsocket_stream_params        {}
> +               | source_afinet_ip_protocol
>       ;
>   
>   source_afsocket_transport
> @@ -335,7 +358,10 @@ source_afsocket_transport
>                       }
>                   ;
>   
> -
> +dest_afinet_ip_protocol
> +               : KW_IP_PROTOCOL '(' afinet_ip_protocol_option ')' {
> ((AFSocketDestDriver *)last_driver)->address_family = $3; } +               ;
> +               
>   dest_afunix
>       : KW_UNIX_DGRAM '(' dest_afunix_dgram_params ')'    { $$ = $3; }
>       | KW_UNIX_STREAM '(' dest_afunix_stream_params ')'    { $$ = $3; }
> @@ -500,6 +526,7 @@ dest_afnetwork_options
>   dest_afnetwork_option
>       : dest_afinet_option
>       | dest_afsocket_transport
> +               | dest_afinet_ip_protocol
>       ;
>   
>   dest_afsocket_transport
> diff --git a/modules/afsocket/afsocket-parser.c
> b/modules/afsocket/afsocket-parser.c index 4065d31..f9e14a4 100644
> --- a/modules/afsocket/afsocket-parser.c
> +++ b/modules/afsocket/afsocket-parser.c
> @@ -72,6 +72,7 @@ static CfgLexerKeyword afsocket_keywords[] = {
>       { "tcp_keepalive_intvl", KW_TCP_KEEPALIVE_INTVL, 0x0304 },
>       { "spoof_source",             KW_SPOOF_SOURCE },
>       { "transport",                   KW_TRANSPORT },
> +   { "ip_protocol",               KW_IP_PROTOCOL },
>       { "max_connections",       KW_MAX_CONNECTIONS },
>       { "keep_alive",                 KW_KEEP_ALIVE },
>       { NULL }
> -- 
> 1.7.10.4
> 
> 
> ______________________________________________________________________________
> Member info: https://lists.balabit.hu/mailman/listinfo/syslog-ng
> Documentation:
> http://www.balabit.com/support/documentation/?product=syslog-ng FAQ:
> http://www.balabit.com/wiki/syslog-ng-faq
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.balabit.hu/pipermail/syslog-ng/attachments/20121208/16e0abc2/attachment-0001.htm 


More information about the syslog-ng mailing list