Пример #1
0
void
cli_cmd_profile(char *cmdline) {
    uint64_t task_counts[CFG_MAX_USER_TASKS+SYS_TASK_NUM];
    uint64_t count, pct, total = 0;
    void *heap;
    int i;

    DISABLE_IRQ();
    for(i = 0; i < CFG_MAX_USER_TASKS+SYS_TASK_NUM; i++) {
        task_counts[i] = count = TCBTbl[i].tick_count;
        total += count;
    }
    ENABLE_IRQ();

    cli_printf("#      Counts         %%    Name\r\n");
    for(i = 0; i < CFG_MAX_USER_TASKS+SYS_TASK_NUM; i++) {
        count = task_counts[i];
        pct = 10000 * count / total;
        cli_printf("%2d %08x%08x %3u.%02u%% %s\r\n",
                i,
                (uint32_t)(count >> 32),
                (uint32_t)count,
                (uint32_t)(pct / 100),
                (uint32_t)(pct % 100),
                TCBTbl[i].name);
    }

    heap = _sbrk(0);
    if (heap != (void*)-1) {
        cli_printf("Heap usage: %d bytes\r\n", heap - (void*)&_sheap);
    }
}
int
cli_ssld_https_server_port_show(const bn_binding_array *bindings,
                            uint32 idx, const bn_binding *binding,
                            const tstring *name,
                            const tstr_array *name_components,
                            const tstring *name_last_part,
                            const tstring *value, void *callback_data)
{
    int err = 0;
    char *port = 0;

    UNUSED_ARGUMENT(bindings);
    UNUSED_ARGUMENT(name);
    UNUSED_ARGUMENT(name_components);
    UNUSED_ARGUMENT(name_last_part);
    UNUSED_ARGUMENT(value);
    UNUSED_ARGUMENT(callback_data);

    if ((idx != 0) && ((idx % 3) == 0)) {
        cli_printf(_("\n"));
    }

    err = bn_binding_get_str(binding, ba_value, bt_uint16, NULL, &port);
    bail_error(err);

    err = cli_printf(
            _("     %-5s"), port);
    bail_error(err);


bail:
    return err;

}
Пример #3
0
void
cliPrintVar(const clivalue_t *var, uint8_t full) {
    switch (var->type) {
    case VAR_UINT32:
        cli_printf("%u", *(uint32_t*)var->ptr);
        break;
    case VAR_UINT16:
        cli_printf("%u", *(uint16_t*)var->ptr);
        break;
#if CLI_TYPE_IP4
    case VAR_IP4:
        {
            ip_addr_t *ptr = (ip_addr_t*)var->ptr;
            cli_printf(IP_DIGITS_FMT, IP_DIGITS(ptr));
            break;
        }
#endif
#if CLI_TYPE_IP6
    case VAR_IP6:
        {
            ip6_addr_t *ptr = (ip6_addr_t*)var->ptr;
            cli_printf(IP6_DIGITS_FMT,
                    IP6_ADDR_BLOCK1(ptr),
                    IP6_ADDR_BLOCK2(ptr),
                    IP6_ADDR_BLOCK3(ptr),
                    IP6_ADDR_BLOCK4(ptr),
                    IP6_ADDR_BLOCK5(ptr),
                    IP6_ADDR_BLOCK6(ptr),
                    IP6_ADDR_BLOCK7(ptr),
                    IP6_ADDR_BLOCK8(ptr));
            break;
        }
#endif
#if CLI_TYPE_HEX
    case VAR_HEX:
        {
            uint8_t *ptr = (uint8_t*)var->ptr;
            int i;
            for (i = 0; i < var->len; i++) {
                cli_printf("%02x", *ptr++);
            }
            break;
        }
#endif
#if CLI_TYPE_FLAG
    case VAR_FLAG:
        if ( (*(uint32_t*)var->ptr) & var->len ) {
            cli_puts("true");
        } else {
            cli_puts("false");
        }
        break;
#endif
    case VAR_INVALID:
        break;
    }
}
Пример #4
0
int cli_do(const struct cli_cmd *cmds, char **args, unsigned int n)
{
	unsigned int i;
	const char *cmd;
	int r;

	if (!n)
		return -EAGAIN;

	cmd = *args++;
	--n;

	for (i = 0; cmds[i].cmd; ++i) {
		if (strcmp(cmd, cmds[i].cmd))
			continue;
		if (is_cli() && cmds[i].cli_cmp == CLI_N)
			continue;
		if (!is_cli() && cmds[i].cli_cmp == CLI_Y)
			continue;

		switch (cmds[i].argc_cmp) {
		case CLI_EQUAL:
			if (n != cmds[i].argc) {
				cli_printf("Invalid number of arguments\n");
				return -EINVAL;
			}

			break;
		case CLI_MORE:
			if (n < cmds[i].argc) {
				cli_printf("too few arguments\n");
				return -EINVAL;
			}

			break;
		case CLI_LESS:
			if (n > cmds[i].argc) {
				cli_printf("too many arguments\n");
				return -EINVAL;
			}

			break;
		}

		if (cmds[i].fn) {
			r = cmds[i].fn(args, n);
			return (r == -EAGAIN) ? -EINVAL : r;
		}

		break;
	}

	if (!strcmp(cmd, "help"))
		return cli_help(cmds);

	return -EAGAIN;
}
int cli_show_bgp(void *arg,
        const cli_command *cmd,
        const tstr_array  *cmd_line,
        const tstr_array  *params)
{
    int err = 0;
    tstr_array *local_as_array = NULL;
    const char *local_as = NULL;
    int num_names = 0;
    int32   status = 0;
    tstring *ret_output = NULL;

    UNUSED_ARGUMENT(arg);
    UNUSED_ARGUMENT(cmd);
    UNUSED_ARGUMENT(cmd_line);
    UNUSED_ARGUMENT(params);

    err = mdc_get_binding_children_tstr_array(cli_mcc,
            NULL, NULL, &local_as_array,
            "/nkn/bgp/config/local_as", NULL);
    bail_error_null(err, local_as_array);
   
    num_names = tstr_array_length_quick(local_as_array);
   
    /* BGP only allows one AS at a time */
    if (num_names > 1) {
        cli_printf_error(_("There are more than one BGP Local AS number\n"));
        goto bail;    
    } 

    if (num_names == 1) {
        local_as = tstr_array_get_str_quick(local_as_array, 0);
        bail_null(local_as);
        cli_printf(_("BGP local AS number is %s\n\n"), local_as);
    }

    err = lc_launch_quick_status(&status, &ret_output, true, 3,
            VTYSH_PATH, "-c", "show ip bgp neighbors");
    bail_error(err);

    if (ret_output) { 
        cli_printf(_("%s\n"), ts_str(ret_output));
    }

    err = lc_launch_quick_status(&status, &ret_output, true, 3,
            VTYSH_PATH, "-c", "show ip bgp");
    bail_error(err);

    if (ret_output) {
        cli_printf(_("%s\n"), ts_str(ret_output));
    }

bail:
    tstr_array_free(&local_as_array);
    return (err);
}
Пример #6
0
int show_users (void)
{
    int  i = -1;
    cli_printf (" %-16s   %-16s    %-16s\n","Username","Password","Level");
    cli_printf (" %-16s   %-16s    %-16s\n","--------","--------", "--------");
    while (++i < MAX_USERS) {
        if (userdb[i].status)
            cli_printf (" %-16s   %-16s    %4d\n",
                        userdb[i].user_name, "******", userdb[i].priv_level);
    }
    return 0;
}
Пример #7
0
int user_db_init (void)
{
    if (create_user ((char *)"guest", (char *)"guest", 5)  < 0) {
        cli_printf ("Default User \"guest\" creation failed\n");
        return -1;
    }
    if (create_user ((char *)"linux", (char *)"linux", 0) < 0) {
        cli_printf ("Default User \"linux\" creation failed\n");
        return -1;
    }
    return 0;

}
int
cli_nvsd_rtstream_media_show_one(const bn_binding_array *bindings,
                            uint32 idx, const bn_binding *binding,
                            const tstring *name,
                            const tstr_array *name_components,
                            const tstring *name_last_part,
                            const tstring *value, void *callback_data)
{
    int err = 0;
    char *c_ext = NULL;
    char *c_lib = NULL;
    tstring *t_ext = NULL;
    tstring *t_lib = NULL;

    UNUSED_ARGUMENT(binding);
    UNUSED_ARGUMENT(name_components);
    UNUSED_ARGUMENT(name_last_part);
    UNUSED_ARGUMENT(value);
    UNUSED_ARGUMENT(callback_data);

    c_ext = smprintf("%s/extension", ts_str(name));
    bail_null(c_ext);

    c_lib = smprintf("%s/module", ts_str(name));
    bail_null(c_lib);

    err = bn_binding_array_get_value_tstr_by_name(bindings, c_ext, NULL, &t_ext);
    bail_error(err);

    err = bn_binding_array_get_value_tstr_by_name(bindings, c_lib, NULL, &t_lib);
    bail_error(err);

    if (idx == 0) {
        cli_printf(_(
                    "  S.No.  Extension     Module\n"));
        cli_printf(_(
                    "---------------------------------\n"));
    }
    cli_printf(_(
                "   %3d.   %5s     %-10s\n"), idx+1, ts_str(t_ext), ts_str(t_lib));

bail:
   safe_free(c_ext);
   safe_free(c_lib);
   ts_free(&t_ext);
   ts_free(&t_lib);
    return err;
}
Пример #9
0
Файл: cli.c Проект: yubo/bird
static void
cli_event(void *data)
{
  struct cli *c = data;
  int err;

  while (c->ring_read != c->ring_write &&
      c->async_msg_size < CLI_MAX_ASYNC_QUEUE)
    cli_copy_message(c);

  if (c->tx_pos)
    ;
  else if (c->cont)
    c->cont(c);
  else
    {
      err = cli_get_command(c);
      if (!err)
	return;
      if (err < 0)
	cli_printf(c, 9000, "Command too long");
      else
	cli_command(c);
    }

  cli_write_trigger(c);
}
int
cli_nvsd_am_show_tier(
	void *data,
	const cli_command *cmd,
	const tstr_array *cmd_line,
	const tstr_array *params)
{
    int err = 0;
    uint32 ret_err = 0;

    UNUSED_ARGUMENT(data);
    UNUSED_ARGUMENT(cmd);
    UNUSED_ARGUMENT(cmd_line);
    UNUSED_ARGUMENT(params);

    err = mdc_send_action
            (cli_mcc, &ret_err, NULL, "/nkn/nvsd/am/actions/tier");
    bail_error(err);

    if (ret_err != 0) {
        cli_printf(_("Error in executing command.\n"));
        goto bail;
    } 

#if 0
    tmp_filename = (char*) file_out;
    // This is where the file needs to be dumped
    if (clish_paging_is_enabled()) {
        err = tstr_array_new_va_str(&argv, NULL, 9, prog_cli_pager_path,
                "-i", 
                "-M",
                "-e", 
                "+G", 
                "-X",
                "-d",
                "--",
                tmp_filename);
        bail_error(err);

        err = clish_run_program_fg(prog_cli_pager_path, argv, NULL,
                cli_nvsd_am_show_terminate, tmp_filename);
        bail_error(err);
    } 
    else {
        cat_prog = prog_zcat_path;
        err = tstr_array_new_va_str(&argv, NULL, 3, cat_prog, "--",
                tmp_filename);
        bail_error(err);

        err = clish_run_program_fg(cat_prog, argv, NULL,
                cli_nvsd_am_show_terminate, tmp_filename);
        bail_error(err);
    }
#endif /* 0 */


bail:
    return err;

}
Пример #11
0
static void cli_handler_fn(char *input)
{
	_shl_free_ char *original = input;
	_shl_strv_free_ char **args = NULL;
	int r;

	if (!input) {
		rl_insert_text("quit");
		rl_redisplay();
		rl_crlf();
		sd_event_exit(cli_event, 0);
		return;
	}

	r = shl_qstr_tokenize(input, &args);
	if (r < 0)
		return cli_vENOMEM();
	else if (!r)
		return;

	add_history(original);
	r = cli_do(cli_cmds, args, r);
	if (r != -EAGAIN)
		return;

	cli_printf("Command not found\n");
}
Пример #12
0
int cli_help(const struct cli_cmd *cmds)
{
	unsigned int i;

	if (is_cli()) {
		cli_printf("Available commands:\n");
	} else {
		cli_fn_help();
	}

	for (i = 0; cmds[i].cmd; ++i) {
		if (!cmds[i].desc)
			continue;
		if (is_cli() && cmds[i].cli_cmp == CLI_N)
			continue;
		if (!is_cli() && cmds[i].cli_cmp == CLI_Y)
			continue;

		cli_printf("  %s %-*s %s\n",
			   cmds[i].cmd,
			   (int)(40 - strlen(cmds[i].cmd)),
			   cmds[i].args ? : "",
			   cmds[i].desc ? : "");
	}

	return 0;
}
/*--------------------------------------------------------------------------*/
int cli_nvsd_rtstream_media_show_cmd(
        void *data,
        const cli_command *cmd,
        const tstr_array *cmd_line,
        const tstr_array *params)
{
    int err = 0;
    uint32 num_matches = 0;

    UNUSED_ARGUMENT(data);
    UNUSED_ARGUMENT(cmd);
    UNUSED_ARGUMENT(cmd_line);
    UNUSED_ARGUMENT(params);

    err = mdc_foreach_binding(cli_mcc, 
            "/nkn/nvsd/rtstream/config/media-encode/*", NULL,
            cli_nvsd_rtstream_media_show_one, NULL, &num_matches);
    bail_error(err);

    if ( num_matches == 0) {
        cli_printf(_("No Media encode mappings configured.\n"));
    }

bail :
    return err;
}
int
cli_ssld_https_show_interface(const bn_binding_array *bindings,
                            uint32 idx, const bn_binding *binding,
                            const tstring *name,
                            const tstr_array *name_components,
                            const tstring *name_last_part,
                            const tstring *value, void *callback_data)
{
    int err = 0;
    tstring *interface = NULL;

    UNUSED_ARGUMENT(bindings);
    UNUSED_ARGUMENT(idx);
    UNUSED_ARGUMENT(name);
    UNUSED_ARGUMENT(name_components);
    UNUSED_ARGUMENT(name_last_part);
    UNUSED_ARGUMENT(value);
    UNUSED_ARGUMENT(callback_data);

    err = bn_binding_get_tstr(binding, ba_value, bt_string, NULL, &interface);
    bail_error(err);

    err = cli_printf(
                _("     Interface: %s\n"), ts_str(interface));
    bail_error(err);

bail:
    ts_free(&interface);
    return err;
}
Пример #15
0
static void
cliInfo(char *cmdline) {
    cliVersion(NULL);
    cli_print_serial();
    cli_print_hwaddr();
    cli_print_link();
    cli_print_netif();
    cliUptime(NULL);
    cli_printf("System clock:   %d Hz (nominal)\r\n", (int)system_frequency);
}
Пример #16
0
static void
cliVersion(char *cmdline) {
    const char *bootver;
    cli_printf("Hardware:       %d.%d\r\n", hwver >> 8, hwver & 0xff);
    cli_puts(  "Software:       " VERSION "\r\n");
    bootver = info_get(boot_table, INFO_BOOTVER);
    if (bootver == NULL) {
        bootver = "no bootloader";
    }
    cli_printf("Bootloader:     %s\r\n", bootver);
}
/* 
 *  [no] router bgp <local-as> network <prefix> mask <mask>
 */
int cli_bgp_network(void *data, const cli_command *cmd,
                     const tstr_array *cmd_line,
                     const tstr_array *params)
{
    int err = 0;
    const char *local_as = NULL, *prefix_str = NULL, *mask_str = NULL;
    node_name_t network_nd = {0};
    uint32      ret_err = 0;
    tstring     *ret_msg = NULL;

    UNUSED_ARGUMENT(data);
    UNUSED_ARGUMENT(cmd_line);
    UNUSED_ARGUMENT(cmd);

    local_as  = tstr_array_get_str_quick(params, 0);
    bail_null(local_as);
    prefix_str = tstr_array_get_str_quick(params, 1);
    bail_null(prefix_str);
    mask_str = tstr_array_get_str_quick(params, 2);
    bail_null(mask_str);  
 
    if (*mask_str != '/' || *(mask_str + 1) == 0) {
        cli_printf("Mask length must start with a '/' followed by a number\n");
        goto bail;
    }

    /* don't use the leading '/' */    
    mask_str++;
    snprintf(network_nd, sizeof(network_nd), 
             "/nkn/bgp/config/local_as/%s/network/%s/%s",
             local_as, prefix_str, mask_str);
    switch(cmd->cc_magic) {
    case BGP_ADD:
        err = mdc_create_binding(cli_mcc,
                    &ret_err,
                    &ret_msg,
                    bt_string,
                    mask_str,
                    network_nd);
        bail_error(err);
        bail_error_msg(ret_err, "%s", ts_str(ret_msg));
        break;

    case BGP_DELETE:
        err = mdc_delete_binding(cli_mcc, &ret_err, &ret_msg, network_nd);
        bail_error_msg(ret_err, "%s", ts_str(ret_msg));
        bail_error(err);
        break;
    }

bail:
    ts_free(&ret_msg);
    return(err);
}
Пример #18
0
int create_user (char *username, char *password, int priv_level)
{

    int i = MAX_USERS;

    if (!username || !password) {
        cli_printf("Error!!! Creating Username and Password...\n");
        return -1;
    }

#if 0
    if (password_validation (password) < 0) {
        cli_printf("Error!!! Passwords should be AlphaNumberic... eg: \"PassWord123\"\n");
        return -1;
    }
#endif
    if (priv_level < 0 || priv_level > 5) {
        cli_printf("Error!!! Priority Level Range Between 0 to 5\n");
        return -1;
    }

    if(!update_user_info (username, password, priv_level))
        return 0;

    while (i--) {
        if (!userdb[i].status) {
            strncpy (userdb[i].user_name, username, MAX_USER_NAME);
            strncpy (userdb[i].password, password, MAX_USER_PASSWORD);
            if (priv_level >= 0)
                userdb[i].priv_level = priv_level;
            else
                userdb[i].priv_level = 5;
            userdb[i].status  = 1;
            return 0;
        }
    }

    cli_printf("Oops!!! Unable to Create User\n");
    return -1;
}
Пример #19
0
void
shell_main(void *thiz) {
    Shell *s = (Shell *)thiz;
    char *args[MAX_ARGUMENT_NUM];
    int nargs;

    cli_set_cwd(s->cli, (char *)"/");
    cli_set_prompt(s->cli, (char *)"/");

    while (!s->cli->cli_quit) {
        input_new_line(s->input, s->cli->cli_prompt);

        while (!s->cmd) {
            vTaskDelay(20);
        }

        cli_parse_args(s->cmd, args, &nargs);
        s->cmd = NULL;

        if (nargs == 0) continue;

        // special case for man command
        if (!strcmp(args[0], "man")) {
            if (nargs == 2) {
                if (cli_cmd_help(s->cli, args) != 0) {
                    cli_printf(s->cli, "man: no manual for command '%s' available\n", args[1]);
                }
            } else {
                cli_printf(s->cli, "USAGE: man [command]\n");
            }

            continue;
        }

        if (cli_cmd_exec(s->cli, args) == 0) continue;

        cli_printf(s->cli, "%s: command not found\n", args[0]);
    }
}
Пример #20
0
void
cli_cmd_set(char *cmdline) {
    uint32_t len;
    const clivalue_t *val;
    char *eqptr, *ptr2;

    len = strlen(cmdline);
    if (len == 0 || (len == 1 && cmdline[0] == '*')) {
        cli_puts("Current settings:\r\n");
        for (val = &value_table[0]; val->name != NULL; val++) {
            cli_printf("%s = ", val->name);
            cliPrintVar(val, len);
            cli_puts("\r\n");
        }
    } else if ((eqptr = strstr(cmdline, "="))) {
        /* Null-terminate the setting name */
        ptr2 = eqptr;
        *ptr2 = 0;
        while (*--ptr2 == ' ') {
            *ptr2 = 0;
        }
        eqptr++;
        len--;
        while (*eqptr == ' ') {
            eqptr++;
            len--;
        }
        for (val = &value_table[0]; val->name != NULL; val++) {
            if (!strcmp(cmdline, val->name)) {
                cliSetVar(val, eqptr);
                cli_printf("%s set to ", val->name);
                cliPrintVar(val, 0);
                return;
            }
        }
        cli_puts("ERR: Unknown variable name\r\n");
    }
}
int
cli_print_restart_msg(void *data, const cli_command *cmd,
			const tstr_array *cmd_line,
			const tstr_array *params)
{
    int err = 0;

    err = cli_std_exec(data, cmd, cmd_line, params);
    bail_error(err);

    /* Print the restart message */
    err = cli_printf("WARNING: if command successful, please use service restart mod-delivery command for changes to take effect\n");
    bail_error(err);

 bail:
    return(err);
}
Пример #22
0
Файл: cli.c Проект: yubo/bird
/**
 * cli_printf - send reply to a CLI connection
 * @c: CLI connection
 * @code: numeric code of the reply, negative for continuation lines
 * @msg: a printf()-like formatting string.
 *
 * This function send a single line of reply to a given CLI connection.
 * In works in all aspects like bsprintf() except that it automatically
 * prepends the reply line prefix.
 *
 * Please note that if the connection can be already busy sending some
 * data in which case cli_printf() stores the output to a temporary buffer,
 * so please avoid sending a large batch of replies without waiting
 * for the buffers to be flushed.
 *
 * If you want to write to the current CLI output, you can use the cli_msg()
 * macro instead.
 */
void
cli_printf(struct cli *c, int code, char *msg, ...)
{
  va_list args;
  byte buf[CLI_LINE_SIZE];
  int cd = code;
  int errcode;
  int size, cnt;

  if (cd < 0)
    {
      cd = -cd;
      if (cd == c->last_reply)
	size = bsprintf(buf, " ");
      else
	size = bsprintf(buf, "%04d-", cd);
      errcode = -8000;
    }
  else if (cd == CLI_ASYNC_CODE)
    {
      size = 1; buf[0] = '+'; 
      errcode = cd;
    }
  else
    {
      size = bsprintf(buf, "%04d ", cd);
      errcode = 8000;
    }

  c->last_reply = cd;
  va_start(args, msg);
  cnt = bvsnprintf(buf+size, sizeof(buf)-size-1, msg, args);
  va_end(args);
  if (cnt < 0)
    {
      cli_printf(c, errcode, "<line overflow>");
      return;
    }
  size += cnt;
  buf[size++] = '\n';
  memcpy(cli_alloc_out(c, size), buf, size);
}
Пример #23
0
Файл: cli.c Проект: yubo/bird
static void
cli_command(struct cli *c)
{
  struct config f;
  int res;

  if (config->cli_debug > 1)
    log(L_TRACE "CLI: %s", c->rx_buf);
  bzero(&f, sizeof(f));
  f.mem = c->parser_pool;
  cf_read_hook = cli_cmd_read_hook;
  cli_rh_pos = c->rx_buf;
  cli_rh_len = strlen(c->rx_buf);
  cli_rh_trick_flag = 0;
  this_cli = c;
  lp_flush(c->parser_pool);
  res = cli_parse(&f);
  if (!res)
    cli_printf(c, 9001, f.err_msg);
}
Пример #24
0
int  cli_show_ip_route (void)
{
	struct route_table *table;
	struct route_node *rn;
	struct rib *rib;
	int first = 1;

	table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
	if (! table)
	  return 0;

	/* Show all IPv4 routes. */
	for (rn = route_top (table); rn; rn = route_next (rn))
	  for (rib = rn->info; rib; rib = rib->next)
	    {
	     if (first)
	       {
		 cli_printf (SHOW_ROUTE_V4_HEADER);
		 first = 0;
	       }
	     show_ip_route (rn, rib);
	    }
	return 0;
}
int
 cli_cachelog_warning_message(void *data, const cli_command *cmd,
 			const tstr_array *cmd_line,
 			const tstr_array *params)
 {
 	int err = 0;
 	char *bn_name = NULL;
 	const char *time_interval = NULL;
 	uint32 ret = 0;
 	tstring *ret_msg = NULL;

	UNUSED_ARGUMENT(data);
	UNUSED_ARGUMENT(cmd);
	UNUSED_ARGUMENT(cmd_line);

 
 	time_interval = tstr_array_get_str_quick(params, 0);
 	bail_null(time_interval);
 
 	bn_name = smprintf("/nkn/cachelog/config/time-interval");
 	bail_null(bn_name);
 
 	err = mdc_set_binding(cli_mcc, &ret, &ret_msg,
 			bsso_modify, bt_uint32, time_interval, bn_name);
 	if(ret) {
 		goto bail;
 
 	}else {
 	        err = cli_printf("warning: Setting a low value can lead to"
 				" High CPU utilization\n");
 	}
 bail:
 	safe_free(bn_name);
 	ts_free(&ret_msg);
 	return err;
 }
int 
cli_nkn_fmsedgelog_show_config(
        void *data,
        const cli_command *cmd,
        const tstr_array *cmd_line,
        const tstr_array *params)
{
    int err = 0;
    bn_binding *binding = NULL;
    int iDivisor = 60;
    int iHour =0;
    uint32 val=0, code = 0;
   
    UNUSED_ARGUMENT(data);
    UNUSED_ARGUMENT(cmd);
    UNUSED_ARGUMENT(cmd_line);
    UNUSED_ARGUMENT(params);

    err = cli_printf_query
                    (_("Media Flow Director FMS Edge Log enabled : "
                       "#/nkn/fmsedgelog/config/enable#\n"));
    bail_error(err);
    
    err = cli_printf_query
            (_("  Replicate to Syslog : "
               "#/nkn/fmsedgelog/config/syslog#\n"));
    bail_error(err);

    err = cli_printf_query
            (_("  FMS Edge Log filename : "
               "#/nkn/fmsedgelog/config/filename#\n"));
    bail_error(err);
    err = cli_printf_query
            (_("  FMS Edge Log filesize : "
               "#/nkn/fmsedgelog/config/max-filesize# MiB\n"));
    bail_error(err);

    err = mdc_get_binding(cli_mcc,&code,NULL,false,&binding,
		             "/nkn/fmsedgelog/config/time-interval" ,NULL);
    bail_error(err);
                                                                                                                               
    if (binding ) {
	err = bn_binding_get_uint32(binding,ba_value,NULL,&val);
	bail_error(err);
	bn_binding_free(&binding);
    }
    
    iHour = val/iDivisor;

    err = cli_printf
            (_("  FMS Edge Log time interval : "
               "%d Hours\n"), iHour);
    bail_error(err);

    err = cli_printf_query
	    (_("  FMS Edge log On the hour log rotation : "
	       "#/nkn/fmsedgelog/config/on-the-hour#\n"));

    err = cli_printf_query
            (_("  Auto Copy URL : "
               "#/nkn/fmsedgelog/config/upload/url#\n"));
    bail_error(err);

bail:
    return err;
}
int 
cli_nvsd_ramcache_object_list(
	void *data,
	const cli_command *cmd,
	const tstr_array *cmd_line,
	const tstr_array *params)
{
    int err = 0;
    uint32 ret_err = 0;
    tstr_array *argv = NULL;
    tstring *ret_output = NULL;
    int status = 0;

    UNUSED_ARGUMENT(data);
    UNUSED_ARGUMENT(cmd);
    UNUSED_ARGUMENT(cmd_line);
    UNUSED_ARGUMENT(params);
    err = mdc_send_action_with_bindings_str_va
            (cli_mcc, &ret_err, NULL, "/nkn/nvsd/buffermgr/actions/object-list",
            0, NULL, bt_none, NULL);
    bail_error(err);

    if (ret_err != 0) {
        cli_printf(_("Error in executing command.\n"));
        goto bail;
    }

    /*
     * Read the first 50 lines of the list and display only them
     */
    err = lc_launch_quick_status(&status, &ret_output, true, 4, "/usr/bin/head", "-n", "54", "/var/log/nkn/buffermgr_object_list");
    bail_error(err);
    cli_printf("%s", ts_str(ret_output));

#if 0
    err = tstr_array_new_va_str(&argv, NULL, 4,
	    "/usr/bin/head", "-n",
	    "54", "/var/log/nkn/buffermgr_object_list");
    bail_error(err);
    err = lc_lauch_quick_status("/usr/bin/head", argv, NULL, NULL, NULL);
#endif

#if 0
    tmp_filename = (char*) file_out;
    // This is where the file needs to be dumped
    if (clish_paging_is_enabled()) {
        err = tstr_array_new_va_str(&argv, NULL, 9, prog_cli_pager_path,
                "-i", 
                "-M",
                "-e", 
                "+G", 
                "-X",
                "-d",
                "--",
                tmp_filename);
        bail_error(err);

        err = clish_run_program_fg(prog_cli_pager_path, argv, NULL,
                cli_nvsd_am_show_terminate, tmp_filename);
        bail_error(err);
    } 
    else {
        cat_prog = prog_zcat_path;
        err = tstr_array_new_va_str(&argv, NULL, 3, cat_prog, "--",
                tmp_filename);
        bail_error(err);

        err = clish_run_program_fg(cat_prog, argv, NULL,
                cli_nvsd_am_show_terminate, tmp_filename);
        bail_error(err);
    }
#endif /* 0 */
    cli_printf( _("The complete list is available in the file /var/log/nkn/buffermgr_object_list\n"));

bail:
    tstr_array_free(&argv);
    return err;
}
int
cli_nvsd_ramcache_show_cmd(
    void *data,
    const cli_command *cmd,
    const tstr_array *cmd_line,
    const tstr_array *params)
{
    int err = 0;

    UNUSED_ARGUMENT(data);
    UNUSED_ARGUMENT(cmd);
    UNUSED_ARGUMENT(cmd_line);
    UNUSED_ARGUMENT(params);

    err = cli_printf_query(_("\nConfigured Attribute Sync Interval: "
                "#/nkn/nvsd/buffermgr/config/attr_sync_interval#"
                " secs\n"));
    bail_error(err);

    err = cli_printf_query(_("Configured Revalidate Object Minimum Size: "
                "#/nkn/nvsd/buffermgr/config/revalidate_minsize#"
                " KiBytes\n"));
    bail_error(err);

    err = cli_printf_query(_("Configured Revalidate Window Size: "
                "#/nkn/nvsd/buffermgr/config/revalidate_window#"
                " secs\n\n"));
    bail_error(err);

    err = cli_printf_query(_("Maximum available RAM Cache size : "
                "#/nkn/nvsd/buffermgr/monitor/max_cachesize_calculated#"
                " MiBytes\n\n"));
    bail_error(err);


    err = cli_printf_query(_("Configured Max RAM Cache size : "
                "#/nkn/nvsd/buffermgr/config/max_cachesize#"
                " MiBytes\n\n"));
    bail_error(err);

    err = cli_printf_query(_("Current RAM Cache scale factor: "
                "#/nkn/nvsd/buffermgr/config/pageratio# \n\n"));
    bail_error(err);

    err = cli_printf_query(_("Current RAM Cache small attribute count: "
                "#/nkn/nvsd/buffermgr/monitor/attributecount#"
                " \n\n"));
    bail_error(err);


    err = cli_printf_query(_("Configured RAM Cache small attribute count: "
                "#/nkn/nvsd/buffermgr/config/attributecount#"
                " \n\n"));
    bail_error(err);
    
    err = cli_printf_query(_("Configured RAM Cache small attribute size: "
                "#/nkn/nvsd/buffermgr/config/attributesize#"
                " \n\n"));
    bail_error(err);

    err = cli_printf_query(_("Auto Calculated Max RAM Cache Dictionary size : "
                "#/nkn/nvsd/buffermgr/monitor/cal_max_dict_size#"
                " MiBytes\n\n"));
    bail_error(err);

    err = cli_printf_query(_("Configured Max RAM Cache Dictionary size : "
                "#/nkn/nvsd/buffermgr/config/max_dictsize#"
                " MiBytes\n\n"));
    bail_error(err);

    cli_printf(_("Note : Configured Max RAM Cache size of 0 indicates \n Maximum available RAM Cache size value\n"));

    err = cli_printf_query(_("Configured unsuccessful response RAM cache percentage: "
                "#/nkn/nvsd/buffermgr/config/unsuccessful_response/cachesize#"
                " \n\n"));
    bail_error(err);
bail:
    return err;
}
Пример #29
0
Файл: cli.c Проект: yubo/bird
static void
cli_hello(struct cli *c)
{
  cli_printf(c, 1, "BIRD " BIRD_VERSION " ready.");
  c->cont = NULL;
}
Пример #30
0
static void
cli_print_hwaddr(void) {
    cli_printf("MAC Address:    %02x:%02x:%02x:%02x:%02x:%02x\r\n",
            thisif.hwaddr[0], thisif.hwaddr[1], thisif.hwaddr[2],
            thisif.hwaddr[3], thisif.hwaddr[4], thisif.hwaddr[5]);
}