From aa609dfe9072323483c8c0a95460b1be4ca05383 Mon Sep 17 00:00:00 2001 From: Hongjun Ni Date: Thu, 16 Mar 2017 00:07:36 +0800 Subject: Hc2vpp failed to load libjvpp_nsh.so Modify code to adapt new API registration mechanism Change-Id: I968199e86278a01ff01267e55468099886689d12 Signed-off-by: Hongjun Ni --- nsh-plugin/java/jvpp/jvpp_nsh.c | 50 +++++++++++++++-------------------------- nsh-plugin/java/jvpp/jvpp_nsh.h | 5 +---- 2 files changed, 19 insertions(+), 36 deletions(-) (limited to 'nsh-plugin/java/jvpp') diff --git a/nsh-plugin/java/jvpp/jvpp_nsh.c b/nsh-plugin/java/jvpp/jvpp_nsh.c index 9dd5bf7..bea330b 100644 --- a/nsh-plugin/java/jvpp/jvpp_nsh.c +++ b/nsh-plugin/java/jvpp/jvpp_nsh.c @@ -29,11 +29,6 @@ #include #undef vl_printfun -/* Get the API version number */ -#define vl_api_version(n,v) static u32 api_version=(v); -#include -#undef vl_api_version - #include #include #include @@ -53,38 +48,29 @@ JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_nsh_JVppNshImpl_init0 (JNIEnv *env, jclass clazz, jobject callback, jlong queue_address, jint my_client_index) { nsh_main_t * plugin_main = &nsh_main; - u8 * name; clib_warning ("Java_io_fd_vpp_jvpp_nsh_JVppNshImpl_init0"); plugin_main->my_client_index = my_client_index; plugin_main->vl_input_queue = (unix_shared_memory_queue_t *)queue_address; - name = format (0, "nsh_%08x%c", api_version, 0); - plugin_main->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name); - - if (plugin_main->msg_id_base == (u16) ~0) { - jclass exClass = (*env)->FindClass(env, "java/lang/IllegalStateException"); - (*env)->ThrowNew(env, exClass, "nsh 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)); - - // verify API has not changed since jar generation - #define _(N) \ - get_message_id(env, #N); - foreach_supported_api_message; - #undef _ - - #define _(N,n) \ - vl_msg_api_set_handlers(get_message_id(env, #N), #n, \ - vl_api_##n##_t_handler, \ - vl_noop_handler, \ - vl_api_##n##_t_endian, \ - vl_api_##n##_t_print, \ - sizeof(vl_api_##n##_t), 1); - foreach_api_reply_handler; - #undef _ - } + plugin_main->callbackObject = (*env)->NewGlobalRef(env, callback); + plugin_main->callbackClass = (jclass)(*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, callback)); + + // verify API has not changed since jar generation + #define _(N) \ + get_message_id(env, #N); + foreach_supported_api_message; + #undef _ + + #define _(N,n) \ + vl_msg_api_set_handlers(get_message_id(env, #N), #n, \ + vl_api_##n##_t_handler, \ + vl_noop_handler, \ + vl_api_##n##_t_endian, \ + vl_api_##n##_t_print, \ + sizeof(vl_api_##n##_t), 1); + foreach_api_reply_handler; + #undef _ } JNIEXPORT void JNICALL Java_io_fd_vpp_jvpp_nsh_JVppNshImpl_close0 diff --git a/nsh-plugin/java/jvpp/jvpp_nsh.h b/nsh-plugin/java/jvpp/jvpp_nsh.h index 1f9ab58..8cd6a44 100644 --- a/nsh-plugin/java/jvpp/jvpp_nsh.h +++ b/nsh-plugin/java/jvpp/jvpp_nsh.h @@ -23,10 +23,7 @@ #include typedef struct { - /* Base message index for the nsh plugin */ - u16 msg_id_base; - - /* Pointer to shared memory queue */ + /* Pointer to shared memory queue */ unix_shared_memory_queue_t * vl_input_queue; /* VPP api client index */ -- cgit 1.2.3-korg