#include "vat.h"
#include "plugin.h"
#include <signal.h>
+#include <limits.h>
vat_main_t vat_main;
/* do nothing in the standalone version, just return */
}
-void
-fformat_append_cr (FILE * ofp, const char *fmt, ...)
-{
- va_list va;
-
- va_start (va, fmt);
- (void) va_fformat (ofp, (char *) fmt, &va);
- va_end (va);
- fformat (ofp, "\n");
-}
-
int
connect_to_vpe (char *name)
{
vat_main_t *vam = &vat_main;
- api_main_t *am = &api_main;
+ api_main_t *am = vlibapi_get_main ();
if (vl_client_connect_to_vlib ("/vpe-api", name, 32) < 0)
return -1;
vec_free (this_cmd);
this_cmd =
- (u8 *) clib_macro_eval (&vam->macro_main, (char *) vam->inbuf,
+ (u8 *) clib_macro_eval (&vam->macro_main, (i8 *) vam->inbuf,
1 /* complain */ );
if (vam->exec_mode == 0)
if (vam->client_index_invalid)
{
vat_main_t *vam = &vat_main;
- api_main_t *am = &api_main;
+ api_main_t *am = vlibapi_get_main ();
vam->vl_input_queue = am->shmem_hdr->vl_input_queue;
vam->my_client_index = am->my_client_index;
for (i = 1; i < 32; i++)
{
- memset (&sa, 0, sizeof (sa));
+ clib_memset (&sa, 0, sizeof (sa));
sa.sa_sigaction = (void *) signal_handler;
sa.sa_flags = SA_SIGINFO;
/* ignore SIGPIPE, SIGCHLD */
case SIGPIPE:
case SIGCHLD:
+ case SIGWINCH:
sa.sa_sigaction = (void *) SIG_IGN;
break;
}
}
+static void
+vat_find_plugin_path ()
+{
+ char *p, path[PATH_MAX];
+ int rv;
+ u8 *s;
+
+ /* find executable path */
+ if ((rv = readlink ("/proc/self/exe", path, PATH_MAX - 1)) == -1)
+ return;
+
+ /* readlink doesn't provide null termination */
+ path[rv] = 0;
+
+ /* strip filename */
+ if ((p = strrchr (path, '/')) == 0)
+ return;
+ *p = 0;
+
+ /* strip bin/ */
+ if ((p = strrchr (path, '/')) == 0)
+ return;
+ *p = 0;
+
+ s = format (0, "%s/lib/" CLIB_TARGET_TRIPLET "/vpp_api_test_plugins:"
+ "%s/lib/vpp_api_test_plugins", path, path);
+ vec_add1 (s, 0);
+ vat_plugin_path = (char *) s;
+}
+
int
main (int argc, char **argv)
{
u8 *this_input_file;
u8 interactive = 1;
u8 json_output = 0;
- u8 *heap;
- mheap_t *h;
int i;
f64 timeout;
- clib_mem_init (0, 128 << 20);
-
- heap = clib_mem_get_per_cpu_heap ();
- h = mheap_header (heap);
-
- /* make the main heap thread-safe */
- h->flags |= MHEAP_FLAG_THREAD_SAFE;
+ clib_mem_init_thread_safe (0, 128 << 20);
clib_macro_init (&vam->macro_main);
clib_macro_add_builtin (&vam->macro_main, "current_file",
vec_validate (vam->cmd_reply, 0);
vec_reset_length (vam->cmd_reply);
+ vat_find_plugin_path ();
+
unformat_init_command_line (a, argv);
while (unformat_check_input (a) != UNFORMAT_END_OF_INPUT)