aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp-api/python/vpp_papi/vpp_serializer.py
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2019-09-11 17:49:08 +0200
committerAndrew Yourtchenko <ayourtch@gmail.com>2019-09-19 14:24:54 +0000
commit75761b933f3e28494bae4b2cf5636a07ffe6ce18 (patch)
treea9663623eba8a5c26c6bcceab1606c946ce29754 /src/vpp-api/python/vpp_papi/vpp_serializer.py
parentfbc388986e3f38aaedff87b843137be81b7d4f91 (diff)
api: split vl_api_prefix into two
One type for address with prefix and one type for prefix. Type: fix Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: Icfec51d9b7d5cde1d69fbecdd97498688ab7b295 Signed-off-by: Ole Troan <ot@cisco.com> Signed-off-by: Klement Sekera <ksekera@cisco.com> Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src/vpp-api/python/vpp_papi/vpp_serializer.py')
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_serializer.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/vpp-api/python/vpp_papi/vpp_serializer.py b/src/vpp-api/python/vpp_papi/vpp_serializer.py
index 443dd83ba68..c01b2d3bd8b 100644
--- a/src/vpp-api/python/vpp_papi/vpp_serializer.py
+++ b/src/vpp-api/python/vpp_papi/vpp_serializer.py
@@ -414,7 +414,7 @@ class VPPTypeAlias(object):
self.name = name
t = vpp_get_type(msgdef['type'])
if not t:
- raise ValueError()
+ raise ValueError('No such type: {}'.format(msgdef['type']))
if 'length' in msgdef:
if msgdef['length'] == 0:
raise ValueError()
@@ -429,6 +429,7 @@ class VPPTypeAlias(object):
self.size = t.size
types[name] = self
+ self.toplevelconversion = False
def __call__(self, args):
self.options = args
@@ -445,8 +446,13 @@ class VPPTypeAlias(object):
return self.packer.pack(data, kwargs)
def unpack(self, data, offset=0, result=None, ntc=False):
+ if ntc == False and self.name in vpp_format.conversion_unpacker_table:
+ # Disable type conversion for dependent types
+ ntc = True
+ self.toplevelconversion = True
t, size = self.packer.unpack(data, offset, result, ntc=ntc)
- if not ntc:
+ if self.toplevelconversion:
+ self.toplevelconversion = False
return conversion_unpacker(t, self.name), size
return t, size
@@ -513,6 +519,7 @@ class VPPType(object):
self.size = size
self.tuple = collections.namedtuple(name, self.fields, rename=True)
types[name] = self
+ self.toplevelconversion = False
def __call__(self, args):
self.options = args
@@ -551,6 +558,11 @@ class VPPType(object):
# Return a list of arguments
result = []
total = 0
+ if ntc == False and self.name in vpp_format.conversion_unpacker_table:
+ # Disable type conversion for dependent types
+ ntc = True
+ self.toplevelconversion = True
+
for p in self.packers:
x, size = p.unpack(data, offset, result, ntc)
if type(x) is tuple and len(x) == 1:
@@ -559,7 +571,9 @@ class VPPType(object):
offset += size
total += size
t = self.tuple._make(result)
- if not ntc:
+
+ if self.toplevelconversion:
+ self.toplevelconversion = False
t = conversion_unpacker(t, self.name)
return t, total