From 8628620d1c4b50287e6a0b1375ceb9717cf75493 Mon Sep 17 00:00:00 2001 From: hemant_mnkcg Date: Sat, 3 Apr 2021 13:11:41 -0400 Subject: [PATCH] Add ipv6_to_binary to ptf --- proto/ptf/base_test.py | 6 ++++++ 1 file changed, 6 insertions(+) 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