PAPI: Allow ipaddress object as argument and return values from API calls

The API calls that use any of vl_api_address_t, vl_api_ip4_address,
vl_api_ip6_address_t, vl_api_prefix_t, vl_api_ip4_prefix_t,
vl_api_ip6_prefix_t now accepts either the old style dictionary,
a text string (2001:db8::/32) or an ipaddress ojbect.

Unless it is called with '_no_type_conversion':True, it will
also return an appropriate ipaddress object.

Change-Id: I84e4a1577bd57f6b5ae725f316a523988b6a955b
Signed-off-by: Ole Troan <ot@cisco.com>
This commit is contained in:
Ole Troan
2018-12-11 13:04:01 +01:00
committed by Damjan Marion
parent 41b25cf638
commit 0bcad32b38
13 changed files with 290 additions and 259 deletions

View File

@ -192,20 +192,6 @@ class VppIpPrefix():
return False
class VppIp6Prefix():
def __init__(self, prefix, prefixlen):
self.ip_prefix = ip_address(unicode(prefix))
self.prefixlen = prefixlen
def encode(self):
return {'prefix': self.ip_prefix.packed,
'len': self.prefixlen}
class VppIp4Prefix(VppIp6Prefix):
pass
class VppIpMPrefix():
def __init__(self, saddr, gaddr, len):
self.saddr = saddr