Re: [PATCH nft] datatype: Display pre-defined inet_service values in host byte order

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

 



On Mon, Dec 05, 2016 at 10:30:38PM -0200, Elise Lennion wrote:
> nft describe displays, to the user, which values are available for a selector,
> then the values should be in host byte order.
> 
> Reported-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
> Fixes: ccc5da470e76 ("datatype: Replace getnameinfo() by internal lookup table")
> Signed-off-by: Elise Lennion <elise.lennion@xxxxxxxxx>
> ---
>  include/datatype.h |  3 ++-
>  src/datatype.c     | 14 +++++++++++---
>  src/expression.c   |  3 ++-
>  3 files changed, 15 insertions(+), 5 deletions(-)
> 
> diff --git a/include/datatype.h b/include/datatype.h
> index d4fe817..a7db1df 100644
> --- a/include/datatype.h
> +++ b/include/datatype.h
> @@ -191,7 +191,8 @@ extern struct error_record *symbolic_constant_parse(const struct expr *sym,
>  extern void symbolic_constant_print(const struct symbol_table *tbl,
>  				    const struct expr *expr, bool quotes);
>  extern void symbol_table_print(const struct symbol_table *tbl,
> -			       const struct datatype *dtype);
> +			       const struct datatype *dtype,
> +			       enum byteorder byteorder);
>  
>  extern struct symbol_table *rt_symbol_table_init(const char *filename);
>  extern void rt_symbol_table_free(struct symbol_table *tbl);
> diff --git a/src/datatype.c b/src/datatype.c
> index b5d73bc..4f98a83 100644
> --- a/src/datatype.c
> +++ b/src/datatype.c
> @@ -181,14 +181,22 @@ void symbolic_constant_print(const struct symbol_table *tbl,
>  }
>  
>  void symbol_table_print(const struct symbol_table *tbl,
> -			const struct datatype *dtype)
> +			const struct datatype *dtype,
> +			enum byteorder byteorder)
>  {
>  	const struct symbolic_constant *s;
>  	unsigned int size = 2 * dtype->size / BITS_PER_BYTE;
> +	long unsigned int value;
> +
> +	for (s = tbl->symbols; s->identifier != NULL; s++) {
> +		if (byteorder == BYTEORDER_BIG_ENDIAN)
> +			value = __constant_ntohs(s->value);

Is this going to work for other cases other than 16-bit?

You can probably add a function that, based on the datatype, performs
the byteswapping based on the integer length.

Thanks.
--
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