18 #include <sys/types.h> 23 #include <netinet/in.h> 79 fformat (stdout,
"%s\n", rv ? rv :
"UNSET");
184 for (i = 0; i < 11; i++)
216 for (
i = 0;
i < nitems;
i++)
224 value =
format (0,
"%s%c", add_value, 0);
228 fformat (stdout,
"Resulting installed_sw vector:\n");
234 fformat (stdout,
"%s\n", values[
i]);
256 opaque &= ~(0xF0000000);
258 clib_warning (
"signal %d, action %d, opaque %x", signum, action, opaque);
274 sa.sa_flags = SA_SIGINFO;
275 if (sigaction (SIGUSR2, &sa, 0) < 0)
287 a->
var = (
char *) vbl;
343 clib_warning (
"Grab region mutex and crash deliberately!");
371 char *chroot_path = 0;
377 struct passwd _pw, *pw;
378 struct group _grp, *grp;
383 svmdbtool_main.
uid = geteuid ();
384 svmdbtool_main.
gid = getegid ();
390 if (
unformat (&input,
"get-string %s", &vbl))
396 else if (
unformat (&input,
"set-string %s %s", &vbl, &
value))
403 else if (
unformat (&input,
"unset-string %s", &vbl))
409 else if (
unformat (&input,
"dump-strings"))
414 else if (
unformat (&input,
"unset-vec %s", &vbl))
420 else if (
unformat (&input,
"dump-vecs"))
425 else if (
unformat (&input,
"test-vec %s", &vbl))
431 else if (
unformat (&input,
"vlib-vec-rate %f", &vr))
436 else if (
unformat (&input,
"test-reg %s", &vbl))
441 else if (
unformat (&input,
"crash-test"))
445 else if (
unformat (&input,
"chroot %s", &chroot_path_u8))
447 chroot_path = (
char *) chroot_path_u8;
454 else if (
unformat (&input,
"size %d", &size))
459 else if (
unformat (&input,
"uid %d", &uid))
460 svmdbtool_main.
uid = uid;
461 else if (
unformat (&input,
"gid %d", &gid))
462 svmdbtool_main.
gid = gid;
463 else if (
unformat (&input,
"uid %s", &s))
467 rv = getpwnam_r (s, &_pw, buf,
sizeof (buf), &pw);
470 fformat (stderr,
"cannot fetch username %s", s);
475 fformat (stderr,
"username %s does not exist", s);
479 svmdbtool_main.
uid = pw->pw_uid;
481 else if (
unformat (&input,
"gid %s", &s))
485 rv = getgrnam_r (s, &_grp, buf,
sizeof (buf), &grp);
488 fformat (stderr,
"cannot fetch group %s", s);
493 fformat (stderr,
"group %s does not exist", s);
497 svmdbtool_main.
gid = grp->gr_gid;
499 else if (
unformat (&input,
"serialize-strings %s", &filename))
505 else if (
unformat (&input,
"unserialize-strings %s", &filename))
521 fformat (stdout,
"%s: get-string <name> | set-string <name> <value>\n",
523 fformat (stdout,
" unset-string <name> | dump-strings\n");
524 fformat (stdout,
" test-vec <name> |\n");
525 fformat (stdout,
" unset-vec <name> | dump-vecs\n");
526 fformat (stdout,
" chroot <prefix> [uid <nnn-or-userid>]\n");
527 fformat (stdout,
" [gid <nnn-or-group-name>]\n");
static u64 unserialize_likely_small_unsigned_integer(serialize_main_t *m)
Optimized string handling code, including c11-compliant "safe C library" variants.
void svmdb_local_dump_vecs(svmdb_client_t *client)
Fixed length block allocator.
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
void svmdb_local_unset_vec_variable(svmdb_client_t *client, char *var)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
void svmdb_unmap(svmdb_client_t *client)
void svmdb_local_dump_strings(svmdb_client_t *client)
void unserialize_open_data(serialize_main_t *m, u8 *data, uword n_data_bytes)
int svmdb_local_serialize_strings(svmdb_client_t *client, char *filename)
static void serialize_likely_small_unsigned_integer(serialize_main_t *m, u64 x)
char * svmdb_local_get_string_variable(svmdb_client_t *client, char *var)
void unserialize_cstring(serialize_main_t *m, char **s)
void serialize_open_vector(serialize_main_t *m, u8 *vector)
int svmdb_local_unserialize_strings(svmdb_client_t *client, char *filename)
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
svmdb_map_args_t map_args
void svmdb_local_set_vec_variable(svmdb_client_t *client, char *var, void *val_arg, u32 elsize)
Bitmaps built as vectors of machine words.
int svmdb_local_add_del_notification(svmdb_client_t *client, svmdb_notification_args_t *a)
void serialize_cstring(serialize_main_t *m, char *s)
vl_api_mac_event_action_t action
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void svmdb_local_unset_string_variable(svmdb_client_t *client, char *var)
#define clib_unix_warning(format, args...)
svmdb_client_t * svmdb_map(svmdb_map_args_t *dba)
void * svmdb_local_get_vec_variable(svmdb_client_t *client, char *var, u32 elsize)
void * serialize_close_vector(serialize_main_t *m)
void svmdb_local_set_string_variable(svmdb_client_t *client, char *var, char *val)
void * clib_mem_init_thread_safe(void *memory, uword memory_size)
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".