Commit b334f5ed authored by Hangbin Liu's avatar Hangbin Liu Committed by Jakub Kicinski
Browse files

ynl: support hex display_hint for integer



Some times it would be convenient to read the integer as hex, like
mask values.

Suggested-by: default avatarDonald Hunter <donald.hunter@gmail.com>
Reviewed-by: default avatarDonald Hunter <donald.hunter@gmail.com>
Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
Link: https://lore.kernel.org/r/20240327123130.1322921-2-liuhangbin@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 51cf49f6
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -819,6 +819,9 @@ class YnlFamily(SpecFamily):
        if display_hint == 'mac':
            formatted = ':'.join('%02x' % b for b in raw)
        elif display_hint == 'hex':
            if isinstance(raw, int):
                formatted = hex(raw)
            else:
                formatted = bytes.hex(raw, ' ')
        elif display_hint in [ 'ipv4', 'ipv6' ]:
            formatted = format(ipaddress.ip_address(raw))