Commit dd3a7d58 authored by Michal Michalik's avatar Michal Michalik Committed by David S. Miller

tools: ynl: Add missing types to encode/decode

While testing the tool I noticed we miss the u16 type on payload create.
On the code inspection it turned out we miss also u64 - add them.

We also miss the decoding of u16 despite the fact `NlAttr` class
supports it - add it.
Signed-off-by: default avatarMichal Michalik <michal.michalik@intel.com>
Acked-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fe5b9907
...@@ -336,8 +336,12 @@ class YnlFamily(SpecFamily): ...@@ -336,8 +336,12 @@ class YnlFamily(SpecFamily):
attr_payload = b'' attr_payload = b''
elif attr["type"] == 'u8': elif attr["type"] == 'u8':
attr_payload = struct.pack("B", int(value)) attr_payload = struct.pack("B", int(value))
elif attr["type"] == 'u16':
attr_payload = struct.pack("H", int(value))
elif attr["type"] == 'u32': elif attr["type"] == 'u32':
attr_payload = struct.pack("I", int(value)) attr_payload = struct.pack("I", int(value))
elif attr["type"] == 'u64':
attr_payload = struct.pack("Q", int(value))
elif attr["type"] == 'string': elif attr["type"] == 'string':
attr_payload = str(value).encode('ascii') + b'\x00' attr_payload = str(value).encode('ascii') + b'\x00'
elif attr["type"] == 'binary': elif attr["type"] == 'binary':
...@@ -373,6 +377,8 @@ class YnlFamily(SpecFamily): ...@@ -373,6 +377,8 @@ class YnlFamily(SpecFamily):
decoded = subdict decoded = subdict
elif attr_spec['type'] == 'u8': elif attr_spec['type'] == 'u8':
decoded = attr.as_u8() decoded = attr.as_u8()
elif attr_spec['type'] == 'u16':
decoded = attr.as_u16()
elif attr_spec['type'] == 'u32': elif attr_spec['type'] == 'u32':
decoded = attr.as_u32() decoded = attr.as_u32()
elif attr_spec['type'] == 'u64': elif attr_spec['type'] == 'u64':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment