25 #define DEBUG_LOG(...) clib_warning(__VA_ARGS__) 27 #define DEBUG_LOG(...) 30 #define _(error,errorCode,msg) \ 31 if (errorCode == code) \ 35 #define get_error_message(errno) \ 37 foreach_vnet_api_error \ 38 message = "Reason unknown"; 44 jclass callbackClass, jobject callbackObject,
45 jclass callbackExceptionClass) {
46 DEBUG_LOG(
"\nCallOnError : callback=%s, retval=%d, context=%d\n", callName,
47 clib_net_to_host_u32(retval), clib_net_to_host_u32(context));
50 DEBUG_LOG(
"CallOnError : jm->callbackClass is null!\n");
53 jmethodID excConstructor = (*env)->GetMethodID(env, callbackExceptionClass,
54 "<init>",
"(Ljava/lang/String;Ljava/lang/String;II)V");
55 if (!excConstructor) {
56 DEBUG_LOG(
"CallOnError : excConstructor is null!\n");
59 jmethodID callbackExcMethod = (*env)->GetMethodID(env, callbackClass,
60 "onError",
"(Lio/fd/vpp/jvpp/VppCallbackException;)V");
61 if (!callbackExcMethod) {
62 DEBUG_LOG(
"CallOnError : callbackExcMethod is null!\n");
68 jobject excObject = (*env)->NewObject(env, callbackExceptionClass,
69 excConstructor, (*env)->NewStringUTF(env, callName),
70 (*env)->NewStringUTF(env, message),
71 clib_net_to_host_u32(contextId), clib_net_to_host_u32(retval));
73 DEBUG_LOG(
"CallOnError : excObject is null!\n");
77 (*env)->CallVoidMethod(env, callbackObject, callbackExcMethod, excObject);
78 DEBUG_LOG(
"CallOnError : Response sent\n");
85 jclass exClass = (*env)->FindClass(env,
"java/lang/IllegalStateException");
87 strcpy(msgBuf,
"API mismatch detected: ");
89 strcat(msgBuf,
" is missing");
90 DEBUG_LOG(
"get_message_id : %s\n", msgBuf);
91 (*env)->ThrowNew(env, exClass, msgBuf);
#define get_error_message(errno)
u32 get_message_id(JNIEnv *env, const char *key)
Retrieves message id based on message name and crc (key format: name_crc).
static void clib_mem_free(void *p)
static void * clib_mem_alloc(uword size)
void call_on_error(const char *callName, int contextId, int retval, jclass callbackClass, jobject callbackObject, jclass callbackExceptionClass)
Calls onError callback on callbackObject reference.