Re: extensions: libxt_multiport: Multiport translations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 03, 2016 at 06:02:41PM +0000, Piyush Pangtey wrote:
> Added multiport translations for ipv4 only .
> It's for review pupose only , it definitely needs changes .
> 
> example :
> iptables-translate -A INPUT -p tcp -m multiport --dports 22,http,ssh -j ACCEPT
> nft add rule ip filter INPUT ip protocol tcp dport  { 22,80,22 } counter accept
> 
> diff --git a/extensions/libxt_multiport.c b/extensions/libxt_multiport.c
> index 03af5a9..6b46f93 100644
> --- a/extensions/libxt_multiport.c
> +++ b/extensions/libxt_multiport.c
> @@ -468,6 +468,67 @@ static void multiport_save6_v1(const void *ip_void,
>      __multiport_save_v1(match, ip->proto);
>  }
> 
> +static int multiport_xlate(const struct xt_entry_match *match, struct
> xt_xlate *xl,
> +             int numeric)
> +{
> +    const struct xt_multiport_v1 *multiinfo
> +        = (const struct xt_multiport_v1 *)match->data;

The = should be on the first line, ie.

        const struct xt_multiport_v1 *multiinfo =
                (const struct xt_multiport_v1 *)match->data;

> +    unsigned int i;
   ^^^^
I see spaces here, there should be an 8-chars tab indentation there.

Please, make sure coding style is correct.

> +    switch (multiinfo->flags) {
> +    case XT_MULTIPORT_SOURCE:
> +        xt_xlate_add(xl,"sport ");
                           ^
                          add space after comma

> +        break;
> +

No need for this extra line break;

> +    case XT_MULTIPORT_DESTINATION:
> +        xt_xlate_add(xl,"dport ");
> +        break;
> +
> +    default:
> +        return 1;
> +    }
> +    xt_xlate_add(xl," { ");
> +    for (i=0; i < multiinfo->count; i++) {
             ^
add space betwen variable and value, ie.

        i = 0

this is preferred.

> +        xt_xlate_add(xl,"%u%s", multiinfo->ports[i],
> +                (i+1) != multiinfo->count ? "," : "");

Align this line with the parens:

        xt_xlate_add(xl,"%u%s", multiinfo->ports[i],
                    i + 1 != multiinfo->count ? "," : "");

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux