PAPI: Unpack embedded types with variable length arrays.
[vpp.git] / src / vpp-api / python / vpp_papi / vpp_papi.py
index 4afb616..4f765ec 100644 (file)
@@ -63,7 +63,7 @@ vpp_api = ffi.dlopen('libvppapiclient.so')
 def vpp_atexit(vpp_weakref):
     """Clean up VPP connection on shutdown."""
     vpp_instance = vpp_weakref()
-    if vpp_instance.connected:
+    if vpp_instance and vpp_instance.connected:
         vpp_instance.logger.debug('Cleaning up VPP on exit')
         vpp_instance.disconnect()
 
@@ -523,8 +523,7 @@ class VPP():
         if not msg:
             self.logger.warning('vpp_api.read failed')
             return
-
-        i, ci = self.header.unpack(msg, 0)
+        (i, ci), size = self.header.unpack(msg, 0)
         if self.id_names[i] == 'rx_thread_exit':
             return
 
@@ -535,8 +534,7 @@ class VPP():
         if not msgobj:
             raise IOError(2, 'Reply message undefined')
 
-        r = msgobj.unpack(msg)
-
+        r, size = msgobj.unpack(msg)
         return r
 
     def msg_handler_async(self, msg):