aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp-api/java/jvpp-common/jvpp_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vpp-api/java/jvpp-common/jvpp_common.c')
-rw-r--r--src/vpp-api/java/jvpp-common/jvpp_common.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/vpp-api/java/jvpp-common/jvpp_common.c b/src/vpp-api/java/jvpp-common/jvpp_common.c
index a161c09c95b..b88c0ea2197 100644
--- a/src/vpp-api/java/jvpp-common/jvpp_common.c
+++ b/src/vpp-api/java/jvpp-common/jvpp_common.c
@@ -63,3 +63,19 @@ void call_on_error(const char* callName, int contextId, int retval,
(*env)->CallVoidMethod(env, callbackObject, callbackExcMethod, excObject);
DEBUG_LOG("CallOnError : Response sent\n");
}
+
+u32 get_message_id(JNIEnv *env, const char *key) {
+ uword *p = hash_get(jvpp_main.messages_hash, key);
+ if (!p) {
+ jclass exClass = (*env)->FindClass(env, "java/lang/IllegalStateException");
+ char *msgBuf = clib_mem_alloc(strlen(key) + 40);
+ strcpy(msgBuf, "API mismatch detected: ");
+ strcat(msgBuf, key);
+ strcat(msgBuf, " is missing");
+ DEBUG_LOG("get_message_id : %s\n", msgBuf);
+ (*env)->ThrowNew(env, exClass, msgBuf);
+ clib_mem_free(msgBuf);
+ return 0;
+ }
+ return (u32) p[0];
+}