Subject: Re: [PATCH iproute2 net-next 1/2] iproute: add support for seg6 l2encap mode

From: Stephen Hemminger <[email-masked]>
Date: Mon, 28 Aug 2017 12:07:24 -0700

On Mon, 28 Aug 2017 20:05:24 +0100
David Lebrun <[email-masked]> wrote:

>  
> +static const char *format_seg6mode_type(int mode)
> +{
> +	if (mode == SEG6_IPTUN_MODE_ENCAP)
> +		return "encap";
> +	else if (mode == SEG6_IPTUN_MODE_INLINE)
> +		return "inline";
> +	else if (mode == SEG6_IPTUN_MODE_L2ENCAP)
> +		return "l2encap";
> +
> +	return "<unknown>";
> +}
> +
> +static int read_seg6mode_type(const char *mode)
> +{
> +	if (strcmp(mode, "encap") == 0)
> +		return SEG6_IPTUN_MODE_ENCAP;
> +	else if (strcmp(mode, "inline") == 0)
> +		return SEG6_IPTUN_MODE_INLINE;
> +	else if (strcmp(mode, "l2encap") == 0)
> +		return SEG6_IPTUN_MODE_L2ENCAP;
> +
> +	return -1;
> +}

Since these values probably will grow over time, it would make
sense to have this a name/value table.