vapi: write enumflag types to vapi headers 08/37608/2
authorMatthew Smith <mgsmith@netgate.com>
Wed, 9 Nov 2022 17:45:19 +0000 (17:45 +0000)
committerMatthew Smith <mgsmith@netgate.com>
Mon, 28 Nov 2022 21:34:00 +0000 (21:34 +0000)
Type: fix
Fixes: a51f9b3747

Some IPsec message type definitions were not being written to
ipsec.api.vapi.h. These include ipsec_sad_entry_add_del_v3 and
ipsec_sad_entry_add.

The cause appears to be that tunnel_flags, which is defined in
tunnel_types.api is a special case of enum called an enumflag. These do
not appear to have been handled in the code that generates the vapi
header files.

This patch adds processing of enumflag objects for vapi.

Change-Id: Ie506c4fcb5a07fe97a330ba11c252d1df98adfd9
Signed-off-by: Matthew Smith <mgsmith@netgate.com>
src/vpp-api/vapi/fake.api.json
src/vpp-api/vapi/vapi_json_parser.py

index 24c9f4d..f7238c4 100644 (file)
@@ -10,6 +10,8 @@
     },
     "enums" : [
     ],
+    "enumflags" : [
+    ],
     "unions" : [
     ],
     "types" : [
index a323f15..4f29f95 100644 (file)
@@ -324,6 +324,7 @@ class JsonParser(object):
         self.services = {}
         self.messages = {}
         self.enums = {}
+        self.enumflags = {}
         self.unions = {}
         self.aliases = {}
         self.types = {
@@ -391,6 +392,14 @@ class JsonParser(object):
                 self.enums[enum.name] = enum
                 self.logger.debug("Parsed enum: %s" % enum)
                 self.enums_by_json[path].append(enum)
+            for e in j["enumflags"]:
+                name = e[0]
+                value_pairs = e[1:-1]
+                enumtype = self.types[e[-1]["enumtype"]]
+                enum = self.enum_class(name, value_pairs, enumtype)
+                self.enums[enum.name] = enum
+                self.logger.debug("Parsed enumflag: %s" % enum)
+                self.enums_by_json[path].append(enum)
             exceptions = []
             progress = 0
             last_progress = 0
@@ -485,6 +494,8 @@ class JsonParser(object):
             return self.types[name]
         elif name in self.enums:
             return self.enums[name]
+        elif name in self.enumflags:
+            return self.enumflags[name]
         elif name in self.unions:
             return self.unions[name]
         elif name in self.aliases:
@@ -493,6 +504,8 @@ class JsonParser(object):
             return self.types[mundane_name]
         elif mundane_name in self.enums:
             return self.enums[mundane_name]
+        elif mundane_name in self.enumflags:
+            return self.enumflags[mundane_name]
         elif mundane_name in self.unions:
             return self.unions[mundane_name]
         elif mundane_name in self.aliases: