Added a decode function to convert.py for MAC, IPs, and numeric values.
- Added
decodefunction can decode various types of encoded values.
I withdraw (and deleted) my previous comment. If you happen to see it in email, you can ignore it.
Is there a example use case you expect where this new decode function would be used?
I withdraw (and deleted) my previous comment. If you happen to see it in email, you can ignore it.
Is there a example use case you expect where this new
decodefunction would be used?
@jafingerhut
The main reason for including this decode function is as follows:
- It may be challenging to decode the values in the match fields of an already-running device as we won't be aware of the kind of entries it currently has in its table.
- Adding a more general decode function to convert.py that determines whether the value is a numeric, MAC, or IP value and then interprets the decode result appropriately.
So the thing that seems strange to me about this new function is that you give it a byte string, with presumably no knowledge whatsoever of what that byte string is intended to represent. This new decode function assumes it is either an IPv6 address, an IPv4 address, or a MAC address, and opportunistically tries to decode it to a human-readable string representing that address, even if the byte string is just some other 128-, 32-, or 48-bit value that has nothing to do with one of those address types. It seems difficult for me to imagine when one would find that useful. At least with the existing decodeIPv4, decodeIPv6, and decodeMac, the caller knows that the byte string is supposed to represent an address of the given kind, and tries to decode it with that assumption.
Thank you for pointing that out! I'll revisit my implementation for this decode function to ensure it aligns with the intended use case.