X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvlibapi%2Fapi_shared.c;h=4d11b519cf2b87407de7e6114f9472d9c1a9b694;hb=6545716c073c88ad86458620c6dbc59ba1cd00bb;hp=59dc2375cf6747196f47af20020c77b2591d3493;hpb=eb1ac1732f15f9a99edbeffeb94c525b9ff25c1d;p=vpp.git diff --git a/src/vlibapi/api_shared.c b/src/vlibapi/api_shared.c index 59dc2375cf6..4d11b519cf2 100644 --- a/src/vlibapi/api_shared.c +++ b/src/vlibapi/api_shared.c @@ -665,15 +665,32 @@ vl_msg_api_config (vl_msg_api_msg_config_t * c) { api_main_t *am = &api_main; - ASSERT (c->id > 0); + /* + * This happens during the java core tests if the message + * dictionary is missing newly added xxx_reply_t messages. + * Should never happen, but since I shot myself in the foot once + * this way, I thought I'd make it easy to debug if I ever do + * it again... (;-)... + */ + if (c->id == 0) + { + if (c->name) + clib_warning ("Trying to register %s with a NULL msg id!", c->name); + else + clib_warning ("Trying to register a NULL msg with a NULL msg id!"); + clib_warning ("Did you forget to call setup_message_id_table?"); + return; + } #define _(a) vec_validate (am->a, c->id); foreach_msg_api_vector; #undef _ - if (am->msg_names[c->id]) - clib_warning ("BUG: multiple registrations of 'vl_api_%s_t_handler'", - c->name); + if (am->msg_handlers[c->id] && am->msg_handlers[c->id] != c->handler) + clib_warning + ("BUG: re-registering 'vl_api_%s_t_handler'." + "Handler was %llx, replaced by %llx", + c->name, am->msg_handlers[c->id], c->handler); am->msg_names[c->id] = c->name; am->msg_handlers[c->id] = c->handler; @@ -714,6 +731,18 @@ vl_msg_api_set_handlers (int id, char *name, void *handler, void *cleanup, vl_msg_api_config (c); } +void +vl_msg_api_clean_handlers (int msg_id) +{ + vl_msg_api_msg_config_t cfg; + vl_msg_api_msg_config_t *c = &cfg; + + memset (c, 0, sizeof (*c)); + + c->id = msg_id; + vl_msg_api_config (c); +} + void vl_msg_api_set_cleanup_handler (int msg_id, void *fp) { @@ -901,6 +930,15 @@ vl_msg_api_add_msg_name_crc (api_main_t * am, const char *string, u32 id) hash_set_mem (am->msg_index_by_name_and_crc, string, id); } +void +vl_msg_api_add_version (api_main_t * am, const char *string, + u32 major, u32 minor, u32 patch) +{ + api_version_t version = {.major = major,.minor = minor,.patch = patch }; + ASSERT (strlen (string) < 64); + strncpy (version.name, string, 64 - 1); + vec_add1 (am->api_version_list, version); +} /* * fd.io coding-style-patch-verification: ON