On Mon, 28 Aug 2017 20:05:24 +0100 David Lebrun <david.leb...@uclouvain.be> 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.