e1a06e39 | 18-Oct-2024 |
Robin Jarry <rjarry@redhat.com> |
lpm6: use IPv6 address structure and utils
Replace ad-hoc uint8_t[16] array types in the API of rte_lpm6 with rte_ipv6_addr structures. Replace duplicate functions and macros with common ones from r
lpm6: use IPv6 address structure and utils
Replace ad-hoc uint8_t[16] array types in the API of rte_lpm6 with rte_ipv6_addr structures. Replace duplicate functions and macros with common ones from rte_ip6.h. Update all code accordingly.
NB: the conversion between 16 bytes arrays and RTE_IPV6() literals was done automatically with the following python script and adjusted manually afterwards:
import argparse import re import struct
ip = re.compile( r""" \{ [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*, [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*, [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*, [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*, [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*, [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*, [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*, [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*, [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*, [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*, [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*, [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*, [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*, [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*, [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*, [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]* \} """, re.VERBOSE, )
def repl(match): u8 = bytes(int(g, 0) for g in match.groups("0")) nums = [] for u16 in struct.unpack("!HHHHHHHH", u8): if u16: nums.append(f"0x{u16:04x}") else: nums.append("0") return f"RTE_IPV6({', '.join(nums)})"
p = argparse.ArgumentParser() p.add_argument("args", nargs="+") args = p.parse_args()
for a in args.args:
with open(a) as f: buf = f.read()
buf = ip.sub(repl, buf) with open(a, "w") as f: f.write(buf)
Signed-off-by: Robin Jarry <rjarry@redhat.com>
show more ...
|