18 #include <sys/types.h> 23 #include <netinet/in.h> 78 fformat (stdout,
"%s\n", rv ? rv :
"UNSET");
183 for (i = 0; i < 11; i++)
215 for (
i = 0;
i < nitems;
i++)
223 value =
format (0,
"%s%c", add_value, 0);
227 fformat (stdout,
"Resulting installed_sw vector:\n");
233 fformat (stdout,
"%s\n", values[
i]);
255 opaque &= ~(0xF0000000);
257 clib_warning (
"signal %d, action %d, opaque %x", signum, action, opaque);
273 sa.sa_flags = SA_SIGINFO;
274 if (sigaction (SIGUSR2, &sa, 0) < 0)
286 a->
var = (
char *) vbl;
342 clib_warning (
"Grab region mutex and crash deliberately!");
370 char *chroot_path = 0;
376 struct passwd _pw, *pw;
377 struct group _grp, *grp;
382 svmdbtool_main.
uid = geteuid ();
383 svmdbtool_main.
gid = getegid ();
389 if (
unformat (&input,
"get-string %s", &vbl))
395 else if (
unformat (&input,
"set-string %s %s", &vbl, &
value))
402 else if (
unformat (&input,
"unset-string %s", &vbl))
408 else if (
unformat (&input,
"dump-strings"))
413 else if (
unformat (&input,
"unset-vec %s", &vbl))
419 else if (
unformat (&input,
"dump-vecs"))
424 else if (
unformat (&input,
"test-vec %s", &vbl))
430 else if (
unformat (&input,
"vlib-vec-rate %f", &vr))
435 else if (
unformat (&input,
"test-reg %s", &vbl))
440 else if (
unformat (&input,
"crash-test"))
444 else if (
unformat (&input,
"chroot %s", &chroot_path_u8))
446 chroot_path = (
char *) chroot_path_u8;
453 else if (
unformat (&input,
"size %d", &size))
458 else if (
unformat (&input,
"uid %d", &uid))
459 svmdbtool_main.
uid = uid;
460 else if (
unformat (&input,
"gid %d", &gid))
461 svmdbtool_main.
gid = gid;
462 else if (
unformat (&input,
"uid %s", &s))
466 rv = getpwnam_r (s, &_pw, buf,
sizeof (buf), &pw);
469 fformat (stderr,
"cannot fetch username %s", s);
474 fformat (stderr,
"username %s does not exist", s);
478 svmdbtool_main.
uid = pw->pw_uid;
480 else if (
unformat (&input,
"gid %s", &s))
484 rv = getgrnam_r (s, &_grp, buf,
sizeof (buf), &grp);
487 fformat (stderr,
"cannot fetch group %s", s);
492 fformat (stderr,
"group %s does not exist", s);
496 svmdbtool_main.
gid = grp->gr_gid;
498 else if (
unformat (&input,
"serialize-strings %s", &filename))
504 else if (
unformat (&input,
"unserialize-strings %s", &filename))
520 fformat (stdout,
"%s: get-string <name> | set-string <name> <value>\n",
522 fformat (stdout,
" unset-string <name> | dump-strings\n");
523 fformat (stdout,
" test-vec <name> |\n");
524 fformat (stdout,
" unset-vec <name> | dump-vecs\n");
525 fformat (stdout,
" chroot <prefix> [uid <nnn-or-userid>]\n");
526 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)
__clib_export void * serialize_close_vector(serialize_main_t *m)
void svmdb_local_dump_strings(svmdb_client_t *client)
description fragment has unexpected format
int svmdb_local_serialize_strings(svmdb_client_t *client, char *filename)
__clib_export void serialize_cstring(serialize_main_t *m, char *s)
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)
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)
__clib_export void unserialize_open_data(serialize_main_t *m, u8 *data, uword n_data_bytes)
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...)
__clib_export void unserialize_cstring(serialize_main_t *m, char **s)
svmdb_client_t * svmdb_map(svmdb_map_args_t *dba)
void * svmdb_local_get_vec_variable(svmdb_client_t *client, char *var, u32 elsize)
__clib_export void serialize_open_vector(serialize_main_t *m, u8 *vector)
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".