Fix FlagValue dump behavior.
When running the command method on a packet, by default, the __repr__ method of the value is used to dump a field. Although, the __repr__ method of the new FlagValue class is not a valid python syntax: In [2]: IP(flags=0).command() Out[2]: 'IP(flags=<Flag 0 ()>)' In [3]: IP(flags=<Flag 0 ()>) File "<ipython-input-3-1e8a4a1eb25a>", line 1 IP(flags=<Flag 0 ()>) ^ SyntaxError: invalid syntax Also, when print a FlagValue with value of 0, flagrepr returns an empty string which can be confusing: In [1]: IP(flags=0) Out[1]: <IP flags= |> Use int value instead in both cases. Fixes: fc6a4caa ("Introduce FlagValue(int) objects to represent FlagsField() values") Signed-off-by:Thomas Faivre <thomas.faivre@6wind.com>
Loading
Please register or sign in to comment