-from vpp_serializer import VPPType, VPPEnumType, VPPUnionType, BaseTypes
+from . vpp_serializer import VPPType, VPPEnumType, VPPUnionType, BaseTypes
+from . vpp_serializer import VPPMessage
def vpp_atexit(vpp_weakref):
"""Clean up VPP connection on shutdown."""
vpp_instance = vpp_weakref()
def vpp_atexit(vpp_weakref):
"""Clean up VPP connection on shutdown."""
vpp_instance = vpp_weakref()
- def make_function(self, msg, i, multipart, async):
- if (async):
+ def make_function(self, msg, i, multipart, do_async):
+ if (do_async):
f.__name__ = str(msg.name)
f.__doc__ = ", ".join(["%s %s" %
f.__name__ = str(msg.name)
f.__doc__ = ", ".join(["%s %s" %
self.id_names = [None] * (self.vpp_dictionary_maxid + 1)
self.id_msgdef = [None] * (self.vpp_dictionary_maxid + 1)
self.id_names = [None] * (self.vpp_dictionary_maxid + 1)
self.id_msgdef = [None] * (self.vpp_dictionary_maxid + 1)
for name, msg in vpp_iterator(self.messages):
n = name + '_' + msg.crc[2:]
i = vpp_api.vac_get_msg_index(n.encode())
for name, msg in vpp_iterator(self.messages):
n = name + '_' + msg.crc[2:]
i = vpp_api.vac_get_msg_index(n.encode())
- f = self.make_function(msg, i, multipart, async)
+ f = self.make_function(msg, i, multipart, do_async)
return msg
def connect_internal(self, name, msg_handler, chroot_prefix, rx_qlen,
return msg
def connect_internal(self, name, msg_handler, chroot_prefix, rx_qlen,
pfx = chroot_prefix.encode() if chroot_prefix else ffi.NULL
rv = vpp_api.vac_connect(name.encode(), pfx, msg_handler, rx_qlen)
if rv != 0:
raise IOError(2, 'Connect failed')
self.connected = True
self.vpp_dictionary_maxid = vpp_api.vac_msg_table_max_index()
pfx = chroot_prefix.encode() if chroot_prefix else ffi.NULL
rv = vpp_api.vac_connect(name.encode(), pfx, msg_handler, rx_qlen)
if rv != 0:
raise IOError(2, 'Connect failed')
self.connected = True
self.vpp_dictionary_maxid = vpp_api.vac_msg_table_max_index()
- def connect(self, name, chroot_prefix=None, async=False, rx_qlen=32):
+ def connect(self, name, chroot_prefix=None, do_async=False, rx_qlen=32):
"""Attach to VPP.
name - the name of the client.
chroot_prefix - if VPP is chroot'ed, the prefix of the jail
"""Attach to VPP.
name - the name of the client.
chroot_prefix - if VPP is chroot'ed, the prefix of the jail
return self.connect_internal(name, msg_handler, chroot_prefix, rx_qlen,
return self.connect_internal(name, msg_handler, chroot_prefix, rx_qlen,
def connect_sync(self, name, chroot_prefix=None, rx_qlen=32):
"""Attach to VPP in synchronous mode. Application must poll for events.
def connect_sync(self, name, chroot_prefix=None, rx_qlen=32):
"""Attach to VPP in synchronous mode. Application must poll for events.
"""
return self.connect_internal(name, ffi.NULL, chroot_prefix, rx_qlen,
"""
return self.connect_internal(name, ffi.NULL, chroot_prefix, rx_qlen,
def validate_args(self, msg, kwargs):
d = set(kwargs.keys()) - set(msg.field_by_name.keys())
if d:
def validate_args(self, msg, kwargs):
d = set(kwargs.keys()) - set(msg.field_by_name.keys())
if d:
def _call_vpp(self, i, msg, multipart, **kwargs):
"""Given a message, send the message and await a reply.
def _call_vpp(self, i, msg, multipart, **kwargs):
"""Given a message, send the message and await a reply.