VPP-353: Fully support LISP negative mappings in API
[vpp.git] / vppapigen / node.c
index ef81278..420a128 100644 (file)
@@ -172,7 +172,7 @@ void node_u8_generate (node_t *this, enum passid which, FILE *ofp)
 node_vft_t node_u8_vft = {
     node_u8_print,
     node_u8_generate,
-    ""
+    NULL
 };
 
 void node_u16_print (node_t *this)
@@ -527,7 +527,7 @@ void node_scalar_generate (node_t *this, enum passid which, FILE *fp)
                         CDATA0, current_endianfun, 
                         union_prefix, CDATA0);
             } else {
-                fprintf(fp, "/* a->%s%s = a->%s%s */\n",
+                fprintf(fp, "/* a->%s%s = a->%s%s (no-op) */\n",
                         union_prefix, CDATA0, 
                         union_prefix, CDATA0);
             }
@@ -611,6 +611,16 @@ void node_vector_generate (node_t *this, enum passid which, FILE *fp)
         /* Don't bother about "u8 data [0];" et al. */
         if (IDATA1 == 0)
             break;
+        /* If this is a simple endian swap, but the endian swap method is a no-op,
+         * then indicate this is a no-op in a comment.
+         */
+       if (!current_is_complex && current_endianfun == NULL) {
+            indent_me(fp);
+            fprintf(fp, "/* a->%s%s[0..%d] = a->%s%s[0..%d] (no-op) */\n",
+                    union_prefix, CDATA0, IDATA1 - 1,
+                    union_prefix, CDATA0, IDATA1 - 1);
+            break;
+        }
 
         indent_me(fp);
         fprintf(fp, "{\n");
@@ -1024,7 +1034,7 @@ char *fixup_input_filename(void)
     if (*cp == '/')
         cp++;
 
-    strcpy (tmpbuf, cp);
+    strncpy (tmpbuf, cp, sizeof(tmpbuf)-1);
 
     cp = tmpbuf;
 
@@ -1329,6 +1339,11 @@ void generate_python (YYSTYPE a1, FILE *fp)
     np = np->peer;
   }
   fprintf (fp, "\n]\n");
+
+  /*
+   * API CRC signature
+   */
+  fprintf (fp, "vl_api_version = 0x%08x\n\n", (unsigned int)input_crc);
 }
 
 void generate(YYSTYPE a1)