diff options
Diffstat (limited to 'plugins/snat-plugin/snat/jvpp_snat.c')
-rw-r--r-- | plugins/snat-plugin/snat/jvpp_snat.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/plugins/snat-plugin/snat/jvpp_snat.c b/plugins/snat-plugin/snat/jvpp_snat.c index 537299ae..fd72ddb1 100644 --- a/plugins/snat-plugin/snat/jvpp_snat.c +++ b/plugins/snat-plugin/snat/jvpp_snat.c @@ -64,11 +64,15 @@ JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_snat_JVppSnatImpl_init0 plugin_main->my_client_index = my_client_index; plugin_main->vl_input_queue = (unix_shared_memory_queue_t *)queue_address; - name = format (0, "snat_%08x%c", api_version, 0); - plugin_main->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name); + name = format (0, "snat_%08x%c", api_version, 0); + plugin_main->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name); - plugin_main->callbackObject = (*env)->NewGlobalRef(env, callback); - plugin_main->callbackClass = (jclass)(*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, callback)); + if (plugin_main->msg_id_base == (u16) ~0) { + jclass exClass = (*env)->FindClass(env, "java/lang/IllegalStateException"); + (*env)->ThrowNew(env, exClass, "snat plugin is not loaded in VPP"); + } else { + plugin_main->callbackObject = (*env)->NewGlobalRef(env, callback); + plugin_main->callbackClass = (jclass)(*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, callback)); #define _(N,n) \ vl_msg_api_set_handlers(VL_API_##N + plugin_main->msg_id_base, #n, \ @@ -79,6 +83,7 @@ JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_snat_JVppSnatImpl_init0 sizeof(vl_api_##n##_t), 1); foreach_api_reply_handler; #undef _ + } } JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_snat_JVppSnatImpl_close0 |