+static int
+session_test_basic (vlib_main_t * vm, unformat_input_t * input)
+{
+ session_endpoint_t server_sep = SESSION_ENDPOINT_NULL;
+ u64 options[SESSION_OPTIONS_N_OPTIONS], bind4_handle, bind6_handle;
+ u8 segment_name[128];
+ clib_error_t *error = 0;
+ u32 server_index;
+
+ memset (options, 0, sizeof (options));
+ options[APP_OPTIONS_FLAGS] = APP_OPTIONS_FLAGS_IS_BUILTIN;
+ options[APP_OPTIONS_FLAGS] |= APP_OPTIONS_FLAGS_ACCEPT_REDIRECT;
+ options[APP_OPTIONS_FLAGS] |= APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE;
+ options[APP_OPTIONS_FLAGS] |= APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE;
+ vnet_app_attach_args_t attach_args = {
+ .api_client_index = ~0,
+ .options = options,
+ .namespace_id = 0,
+ .session_cb_vft = &dummy_session_cbs,
+ .segment_name = segment_name,
+ };
+
+ error = vnet_application_attach (&attach_args);
+ SESSION_TEST ((error == 0), "app attached");
+ server_index = attach_args.app_index;
+
+ server_sep.is_ip4 = 1;
+ vnet_bind_args_t bind_args = {
+ .sep = server_sep,
+ .app_index = 0,
+ };
+
+ bind_args.app_index = server_index;
+ error = vnet_bind (&bind_args);
+ SESSION_TEST ((error == 0), "server bind4 should work");
+ bind4_handle = bind_args.handle;
+
+ error = vnet_bind (&bind_args);
+ SESSION_TEST ((error != 0), "double server bind4 should not work");
+
+ bind_args.sep.is_ip4 = 0;
+ error = vnet_bind (&bind_args);
+ SESSION_TEST ((error == 0), "server bind6 should work");
+ bind6_handle = bind_args.handle;
+
+ error = vnet_bind (&bind_args);
+ SESSION_TEST ((error != 0), "double server bind6 should not work");
+
+ vnet_unbind_args_t unbind_args = {
+ .handle = bind4_handle,
+ .app_index = server_index,
+ };
+ error = vnet_unbind (&unbind_args);
+ SESSION_TEST ((error == 0), "unbind4 should work");
+
+ unbind_args.handle = bind6_handle;
+ error = vnet_unbind (&unbind_args);
+ SESSION_TEST ((error == 0), "unbind6 should work");
+
+ vnet_app_detach_args_t detach_args = {
+ .app_index = server_index,
+ };
+ vnet_application_detach (&detach_args);
+ return 0;
+}
+