summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2021-09-29 14:20:49 +0000
committerOle Tr�an <otroan@employees.org>2021-09-30 08:28:55 +0000
commitd6f22aa98638ad78d2de7c56c014c6190b96617a (patch)
treedb61ddf32cea559d0ba33156780f2559994cfc79
parentcdd9a703b14b7ee093764eae14c67f60924ad67b (diff)
vat2: do not require _crc field in API messages
Type: improvement Signed-off-by: Filip Tehlar <ftehlar@cisco.com> Change-Id: Icc2ce594225c3197c9e5be8faa3dc2ee5b0a553e
-rw-r--r--src/vat2/main.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/vat2/main.c b/src/vat2/main.c
index 667f473c635..2d148472d42 100644
--- a/src/vat2/main.c
+++ b/src/vat2/main.c
@@ -133,17 +133,16 @@ vat2_register_function (char *name, cJSON (*f) (cJSON *),
static int
vat2_exec_command_by_name (char *msgname, cJSON *o)
{
+ u32 crc = 0;
if (filter_message (msgname))
return 0;
cJSON *crc_obj = cJSON_GetObjectItem (o, "_crc");
- if (!crc_obj)
+ if (crc_obj)
{
- fprintf (stderr, "Missing '_crc' element!\n");
- return -1;
+ char *crc_str = cJSON_GetStringValue (crc_obj);
+ crc = (u32) strtol (crc_str, NULL, 16);
}
- char *crc_str = cJSON_GetStringValue (crc_obj);
- u32 crc = (u32) strtol (crc_str, NULL, 16);
uword *p = hash_get_mem (function_by_name, msgname);
if (!p)
@@ -151,7 +150,7 @@ vat2_exec_command_by_name (char *msgname, cJSON *o)
fprintf (stderr, "No such command %s\n", msgname);
return -1;
}
- if (crc != apifuncs[p[0]].crc)
+ if (crc && crc != apifuncs[p[0]].crc)
{
fprintf (stderr, "API CRC does not match: %s!\n", msgname);
}