- u32 index, thread_index;
- stream_session_t *s;
-
- session_parse_handle (a->handle, &index, &thread_index);
- s = session_get_if_valid (index, thread_index);
-
- if (!s || s->app_index != a->app_index)
- return VNET_API_ERROR_INVALID_VALUE;
+ if (session_handle_is_local (a->handle))
+ {
+ local_session_t *ls;
+ ls = application_get_local_session_from_handle (a->handle);
+ if (ls->app_index != a->app_index && ls->client_index != a->app_index)
+ {
+ clib_warning ("app %u is neither client nor server for session %u",
+ a->app_index, a->app_index);
+ return VNET_API_ERROR_INVALID_VALUE;
+ }
+ return application_local_session_disconnect (a->app_index, ls);
+ }
+ else
+ {
+ stream_session_t *s;
+ s = session_get_from_handle_if_valid (a->handle);
+ if (!s || s->app_index != a->app_index)
+ return VNET_API_ERROR_INVALID_VALUE;