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!");
370 u8 *vbl = 0, *value = 0;
371 char *chroot_path = 0;
377 struct passwd _pw, *pw;
378 struct group _grp, *grp;
381 svmdbtool_main.
uid = geteuid ();
382 svmdbtool_main.
gid = getegid ();
388 if (
unformat (&input,
"get-string %s", &vbl))
394 else if (
unformat (&input,
"set-string %s %s", &vbl, &value))
401 else if (
unformat (&input,
"unset-string %s", &vbl))
407 else if (
unformat (&input,
"dump-strings"))
412 else if (
unformat (&input,
"unset-vec %s", &vbl))
418 else if (
unformat (&input,
"dump-vecs"))
423 else if (
unformat (&input,
"test-vec %s", &vbl))
429 else if (
unformat (&input,
"vlib-vec-rate %f", &vr))
434 else if (
unformat (&input,
"test-reg %s", &vbl))
439 else if (
unformat (&input,
"crash-test"))
443 else if (
unformat (&input,
"chroot %s", &chroot_path_u8))
445 chroot_path = (
char *) chroot_path_u8;
447 else if (
unformat (&input,
"fake-install %s", &value))
452 else if (
unformat (&input,
"size %d", &size))
457 else if (
unformat (&input,
"uid %d", &uid))
458 svmdbtool_main.
uid = uid;
459 else if (
unformat (&input,
"gid %d", &gid))
460 svmdbtool_main.
gid = gid;
461 else if (
unformat (&input,
"uid %s", &s))
465 rv = getpwnam_r (s, &_pw, buf,
sizeof (buf), &pw);
468 fformat (stderr,
"cannot fetch username %s", s);
473 fformat (stderr,
"username %s does not exist", s);
477 svmdbtool_main.
uid = pw->pw_uid;
479 else if (
unformat (&input,
"gid %s", &s))
483 rv = getgrnam_r (s, &_grp, buf,
sizeof (buf), &grp);
486 fformat (stderr,
"cannot fetch group %s", s);
491 fformat (stderr,
"group %s does not exist", s);
495 svmdbtool_main.
gid = grp->gr_gid;
497 else if (
unformat (&input,
"serialize-strings %s", &filename))
503 else if (
unformat (&input,
"unserialize-strings %s", &filename))
519 fformat (stdout,
"%s: get-string <name> | set-string <name> <value>\n",
521 fformat (stdout,
" unset-string <name> | dump-strings\n");
522 fformat (stdout,
" test-vec <name> |\n");
523 fformat (stdout,
" unset-vec <name> | dump-vecs\n");
524 fformat (stdout,
" chroot <prefix> [uid <nnn-or-userid>]\n");
525 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)
#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)
#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)
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".