VPP-362 Implement dumping of LISP adjacencies
[vpp.git] / vpp-api / python / pneum / api-gen.py
index b9a9ee3..fcf293e 100755 (executable)
@@ -35,6 +35,7 @@ format_struct = {'u8': 'B',
                  'f64' : 'd',
                  'vl_api_ip4_fib_counter_t' : 'IBQQ',
                  'vl_api_ip6_fib_counter_t' : 'QQBQQ',
+                 'vl_api_lisp_adjacency_t' : 'B' * 35,
                  };
 #
 # NB: If new types are introduced in vpe.api, these must be updated.
@@ -47,12 +48,17 @@ type_size = {'u8':   1,
              'f64' : 8,
              'vl_api_ip4_fib_counter_t' : 21,
              'vl_api_ip6_fib_counter_t' : 33,
+             'vl_api_lisp_adjacency_t' : 35,
 };
 
 def get_args(t):
     argslist = []
     for i in t:
-        argslist.append(i[1].replace('_',''))
+        if i[1][0] == '_':
+            argslist.append(i[1][1:])
+        else:
+            argslist.append(i[1])
+
     return argslist
 
 def get_pack(t):
@@ -63,7 +69,7 @@ def get_pack(t):
     j = -1
     for i in t:
         j += 1
-        if len(i) is 3:
+        if len(i) is 3 or len(i) is 4:  # TODO: add support for variable length arrays (VPP-162)
             size = type_size[i[0]]
             bytecount += size * int(i[2])
             # Check if we have a zero length array
@@ -115,7 +121,7 @@ def get_definitions():
     func_list = []
     func_name = {}
     i = 1
-    for a in cfg.vppapidef:
+    for a in cfg.messages:
         pack, packlen, tup, zeroarray = get_pack(a[1:])
         func_name[a[0]] = dict([('name', a[0]), ('pack', pack), ('packlen', packlen), ('tup', tup), ('args', get_args(a[1:])),
                                 ('zeroarray', zeroarray)])