+ x, size = p.unpack(data, offset, ntc=ntc)
+ if size > maxsize:
+ maxsize = size
+ r.append(x)
+ return self.tuple._make(r), maxsize
+
+
+class VPPTypeAlias(object):
+ def __init__(self, name, msgdef):
+ self.name = name
+ t = vpp_get_type(msgdef['type'])
+ if not t:
+ raise ValueError()
+ if 'length' in msgdef:
+ if msgdef['length'] == 0:
+ raise ValueError()
+ if msgdef['type'] == 'u8':
+ self.packer = FixedList_u8(name, msgdef['type'],
+ msgdef['length'])
+ self.size = self.packer.size
+ else:
+ self.packer = FixedList(name, msgdef['type'], msgdef['length'])
+ else:
+ self.packer = t
+ self.size = t.size
+
+ types[name] = self
+
+ def pack(self, data, kwargs=None):
+ if data and conversion_required(data, self.name):
+ try:
+ return conversion_packer(data, self.name)
+ # Python 2 and 3 raises different exceptions from inet_pton
+ except(OSError, socket.error, TypeError):
+ pass
+
+ return self.packer.pack(data, kwargs)
+
+ def unpack(self, data, offset=0, result=None, ntc=False):
+ t, size = self.packer.unpack(data, offset, result, ntc=ntc)
+ if not ntc:
+ return conversion_unpacker(t, self.name), size
+ return t, size