18 #include <sys/types.h> 23 #include <netinet/in.h> 58 memset (ma, 0,
sizeof (*ma));
79 fformat (stdout,
"%s\n", rv ? rv :
"UNSET");
158 for (i = 0; i < 11; i++)
190 for (
i = 0;
i < nitems;
i++)
198 value =
format (0,
"%s%c", add_value, 0);
202 fformat (stdout,
"Resulting installed_sw vector:\n");
208 fformat (stdout,
"%s\n", values[
i]);
230 opaque &= ~(0xF0000000);
232 clib_warning (
"signal %d, action %d, opaque %x", signum, action, opaque);
246 memset (&sa, 0,
sizeof (sa));
248 sa.sa_flags = SA_SIGINFO;
249 if (sigaction (SIGUSR2, &sa, 0) < 0)
255 memset (a, 0,
sizeof (*a));
261 a->
var = (
char *) vbl;
317 clib_warning (
"Grab region mutex and crash deliberately!");
344 u8 *vbl = 0, *value = 0;
345 char *chroot_path = 0;
350 struct passwd _pw, *pw;
351 struct group _grp, *grp;
354 svmdbtool_main.
uid = geteuid ();
355 svmdbtool_main.
gid = getegid ();
361 if (
unformat (&input,
"get-string %s", &vbl))
367 else if (
unformat (&input,
"set-string %s %s", &vbl, &value))
374 else if (
unformat (&input,
"unset-string %s", &vbl))
380 else if (
unformat (&input,
"dump-strings"))
385 else if (
unformat (&input,
"unset-vec %s", &vbl))
391 else if (
unformat (&input,
"dump-vecs"))
396 else if (
unformat (&input,
"test-vec %s", &vbl))
402 else if (
unformat (&input,
"vlib-vec-rate %f", &vr))
407 else if (
unformat (&input,
"test-reg %s", &vbl))
412 else if (
unformat (&input,
"crash-test"))
416 else if (
unformat (&input,
"chroot %s", &chroot_path_u8))
418 chroot_path = (
char *) chroot_path_u8;
420 else if (
unformat (&input,
"fake-install %s", &value))
425 else if (
unformat (&input,
"size %d", &size))
430 else if (
unformat (&input,
"uid %d", &uid))
431 svmdbtool_main.
uid = uid;
432 else if (
unformat (&input,
"gid %d", &gid))
433 svmdbtool_main.
gid = gid;
434 else if (
unformat (&input,
"uid %s", &s))
438 rv = getpwnam_r (s, &_pw, buf,
sizeof (buf), &pw);
441 fformat (stderr,
"cannot fetch username %s", s);
446 fformat (stderr,
"username %s does not exist", s);
450 svmdbtool_main.
uid = pw->pw_uid;
452 else if (
unformat (&input,
"gid %s", &s))
456 rv = getgrnam_r (s, &_grp, buf,
sizeof (buf), &grp);
459 fformat (stderr,
"cannot fetch group %s", s);
464 fformat (stderr,
"group %s does not exist", s);
468 svmdbtool_main.
gid = grp->gr_gid;
480 fformat (stdout,
"%s: get-string <name> | set-string <name> <value>\n",
482 fformat (stdout,
" unset-string <name> | dump-strings\n");
483 fformat (stdout,
" test-vec <name> |\n");
484 fformat (stdout,
" unset-vec <name> | dump-vecs\n");
485 fformat (stdout,
" chroot <prefix> [uid <nnn-or-userid>]\n");
486 fformat (stdout,
" [gid <nnn-or-group-name>]\n");
sll srl srl sll sra u16x4 i
static u64 unserialize_likely_small_unsigned_integer(serialize_main_t *m)
void svmdb_local_dump_vecs(svmdb_client_t *client)
Fixed length block allocator.
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)
#define clib_warning(format, args...)
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)
#define vec_free(V)
Free vector's memory (no header).
#define clib_unix_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)
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".