diff --git a/proto/ptf/base_test.py b/proto/ptf/base_test.py index 99934c8c..d6a52f5d 100644 --- a/proto/ptf/base_test.py +++ b/proto/ptf/base_test.py @@ -79,6 +79,12 @@ def ipv4_to_binary(addr): # check for that here. return "".join(chr(b) for b in bytes_) +def ipv6_to_binary(addr): + """ Accepts IPv6 address in colon format. + e.g., 2001:dead:beef::2 + """ + return socket.inet_pton(socket.AF_INET6, addr) + def mac_to_binary(addr): """Take an argument 'addr' containing an Ethernet MAC address written as a string in hexadecimal notation, with each byte separated by a