summaryrefslogtreecommitdiffstats
path: root/test/vpp_ip.py
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2018-10-16 14:42:50 +0200
committerNeale Ranns <nranns@cisco.com>2018-10-18 10:16:49 +0000
commit0685da4a6db8195d1a86f3466fcd3395b0ccb83e (patch)
treec77bf5b08aade685beadc01972f601e795685ba8 /test/vpp_ip.py
parent5fcca2a124ac828b01633a3ad237a6435e8ff603 (diff)
PAPI: Expose API enums to tests / applications
e.g: from vpp_papi import VppEnum VppEnum.vl_api_address_family_t.ADDRESS_IP4 Change-Id: I10c22d57234a1a06e98a889cf80b19085b468ed3 Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'test/vpp_ip.py')
-rw-r--r--test/vpp_ip.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/test/vpp_ip.py b/test/vpp_ip.py
index e44e6b56e30..e92c91943db 100644
--- a/test/vpp_ip.py
+++ b/test/vpp_ip.py
@@ -5,11 +5,7 @@
from ipaddress import ip_address
from socket import AF_INET, AF_INET6
-
-
-class IpAddressFamily:
- ADDRESS_IP4 = 0
- ADDRESS_IP6 = 1
+from vpp_papi import VppEnum
class DpoProto:
@@ -86,12 +82,12 @@ class VppIpAddress():
def encode(self):
if self.addr.version is 6:
return {
- 'af': IpAddressFamily.ADDRESS_IP6,
+ 'af': VppEnum.vl_api_address_family_t.ADDRESS_IP6,
'un': self.addr.encode()
}
else:
return {
- 'af': IpAddressFamily.ADDRESS_IP4,
+ 'af': VppEnum.vl_api_address_family_t.ADDRESS_IP4,
'un': self.addr.encode()
}
@@ -101,10 +97,12 @@ class VppIpAddress():
elif hasattr(other, "af") and hasattr(other, "un"):
# a vp_api_address_t
if 4 is self.version:
- return other.af == IpAddressFamily.ADDRESS_IP4 and \
+ return other.af == \
+ VppEnum.vl_api_address_family_t.ADDRESS_IP4 and \
other.un == self.addr
else:
- return other.af == IpAddressFamily.ADDRESS_IP6 and \
+ return other.af == \
+ VppEnum.vl_api_address_family_t.ADDRESS_IP6 and \
other.un == self.addr
else:
raise Exception("Comparing VppIpAddress:%s with unknown type: %s" %
@@ -202,7 +200,7 @@ class VppIpMPrefix():
if 6 is self.ip_saddr.version:
prefix = {
- 'af': IpAddressFamily.ADDRESS_IP6,
+ 'af': VppEnum.vl_api_address_family_t.ADDRESS_IP6,
'grp_address': {
'ip6': {
'address': self.ip_gaddr.packed
@@ -217,7 +215,7 @@ class VppIpMPrefix():
}
else:
prefix = {
- 'af': IpAddressFamily.ADDRESS_IP4,
+ 'af': VppEnum.vl_api_address_family_t.ADDRESS_IP4,
'grp_address': {
'ip4': {
'address': self.ip_gaddr.packed