#include <netdb.h>
#include <libcli.h>
+#include "dhcp6.h"
#include "l2tpns.h"
#include "constants.h"
#include "util.h"
#endif
-static int cmd_show_session(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_show_tunnels(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_show_users(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_show_radius(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_show_version(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_show_pool(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_show_run(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_show_banana(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_show_plugins(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_show_throttle(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_write_memory(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_drop_user(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_drop_tunnel(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_drop_session(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_snoop(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_no_snoop(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_throttle(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_no_throttle(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_debug(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_no_debug(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_set(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_load_plugin(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_remove_plugin(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_uptime(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_shutdown(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_reload(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_setforward(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_show_rmtlnsconf(struct cli_def *cli, char *command, char **argv, int argc);
+static int cmd_show_session(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_show_tunnels(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_show_users(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_show_radius(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_show_version(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_show_pool(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_show_run(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_show_banana(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_show_plugins(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_show_throttle(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_write_memory(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_drop_user(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_drop_tunnel(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_drop_session(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_snoop(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_no_snoop(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_throttle(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_no_throttle(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_debug(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_no_debug(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_set(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_load_plugin(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_remove_plugin(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_uptime(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_shutdown(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_reload(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_setforward(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_show_rmtlnsconf(struct cli_def *cli, const char *command, char **argv, int argc);
static int regular_stuff(struct cli_def *cli);
#ifdef STATISTICS
-static int cmd_show_counters(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_clear_counters(struct cli_def *cli, char *command, char **argv, int argc);
+static int cmd_show_counters(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_clear_counters(struct cli_def *cli, const char *command, char **argv, int argc);
#endif /* STATISTICS */
#ifdef BGP
#define MODE_CONFIG_BGP 8
-static int cmd_router_bgp(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_router_bgp_neighbour(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_router_bgp_no_neighbour(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_show_bgp(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_suspend_bgp(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_no_suspend_bgp(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_restart_bgp(struct cli_def *cli, char *command, char **argv, int argc);
+static int cmd_router_bgp(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_router_bgp_neighbour(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_router_bgp_no_neighbour(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_show_bgp(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_suspend_bgp(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_no_suspend_bgp(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_restart_bgp(struct cli_def *cli, const char *command, char **argv, int argc);
#endif /* BGP */
#define MODE_CONFIG_NACL 9
-static int cmd_ip_access_list(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_no_ip_access_list(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_ip_access_list_rule(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_filter(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_no_filter(struct cli_def *cli, char *command, char **argv, int argc);
-static int cmd_show_access_list(struct cli_def *cli, char *command, char **argv, int argc);
+static int cmd_ip_access_list(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_no_ip_access_list(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_ip_access_list_rule(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_filter(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_no_filter(struct cli_def *cli, const char *command, char **argv, int argc);
+static int cmd_show_access_list(struct cli_def *cli, const char *command, char **argv, int argc);
/* match if b is a substr of a */
#define MATCH(a,b) (!strncmp((a), (b), strlen(b)))
exit(0);
}
-static void cli_print_log(struct cli_def *cli, char *string)
+static void cli_print_log(struct cli_def *cli, const char *string)
{
LOG(3, 0, 0, "%s\n", string);
}
return CLI_OK;
}
-static int cmd_show_session(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_show_session(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i;
return CLI_OK;
}
-static int cmd_show_tunnels(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_show_tunnels(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i, x, show_all = 0;
char *states[] = {
return CLI_OK;
}
-static int cmd_show_users(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_show_users(struct cli_def *cli, const char *command, char **argv, int argc)
{
char sid[32][8];
char *sargv[32];
}
#ifdef STATISTICS
-static int cmd_show_counters(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_show_counters(struct cli_def *cli, const char *command, char **argv, int argc)
{
if (CLI_HELP_REQUESTED)
return CLI_HELP_NO_ARGS;
GET_STAT(tun_tx_bytes),
GET_STAT(tun_tx_packets),
GET_STAT(tun_tx_errors));
- cli_print(cli, "");
+ cli_print(cli, " ");
cli_print(cli, "%-10s %10s %10s %10s %10s", "Tunnel", "Bytes", "Packets", "Errors", "Retries");
cli_print(cli, "%-10s %10u %10u %10u", "RX",
GET_STAT(tunnel_tx_packets),
GET_STAT(tunnel_tx_errors),
GET_STAT(tunnel_retries));
- cli_print(cli, "");
+ cli_print(cli, " ");
cli_print(cli, "%-30s%-10s", "Counter", "Value");
cli_print(cli, "-----------------------------------------");
char *p = strchr(t, '\n');
if (p) *p = 0;
- cli_print(cli, "");
+ cli_print(cli, " ");
cli_print(cli, "Last counter reset %s", t);
}
return CLI_OK;
}
-static int cmd_clear_counters(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_clear_counters(struct cli_def *cli, const char *command, char **argv, int argc)
{
if (CLI_HELP_REQUESTED)
return CLI_HELP_NO_ARGS;
}
#endif /* STATISTICS */
-static int cmd_show_version(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_show_version(struct cli_def *cli, const char *command, char **argv, int argc)
{
if (CLI_HELP_REQUESTED)
return CLI_HELP_NO_ARGS;
return CLI_OK;
}
-static int cmd_show_pool(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_show_pool(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i;
int used = 0, free = 0, show_all = 0;
}
static FILE *save_config_fh = 0;
-static void print_save_config(struct cli_def *cli, char *string)
+static void print_save_config(struct cli_def *cli, const char *string)
{
if (save_config_fh)
fprintf(save_config_fh, "%s\n", string);
}
-static int cmd_write_memory(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_write_memory(struct cli_def *cli, const char *command, char **argv, int argc)
{
if (CLI_HELP_REQUESTED)
return CLI_HELP_NO_ARGS;
static char const *show_access_list_rule(int extended, ip_filter_rulet *rule);
-static int cmd_show_run(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_show_run(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i;
char ipv6addr[INET6_ADDRSTRLEN];
return CLI_OK;
}
-static int cmd_show_radius(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_show_radius(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i, free = 0, used = 0, show_all = 0;
char *states[] = {
return CLI_OK;
}
-static int cmd_show_plugins(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_show_plugins(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i;
return CLI_OK;
}
-static int cmd_show_throttle(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_show_throttle(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i;
return CLI_OK;
}
-static int cmd_show_banana(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_show_banana(struct cli_def *cli, const char *command, char **argv, int argc)
{
if (CLI_HELP_REQUESTED)
return CLI_HELP_NO_ARGS;
return CLI_OK;
}
-static int cmd_drop_user(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_drop_user(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i;
sessionidt s;
return CLI_OK;
}
-static int cmd_drop_tunnel(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_drop_tunnel(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i;
tunnelidt t;
return CLI_OK;
}
-static int cmd_drop_session(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_drop_session(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i;
sessionidt s;
return CLI_OK;
}
-static int cmd_snoop(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_snoop(struct cli_def *cli, const char *command, char **argv, int argc)
{
in_addr_t ip;
uint16_t port;
return CLI_OK;
}
-static int cmd_no_snoop(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_no_snoop(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i;
sessionidt s;
return CLI_OK;
}
-static int cmd_throttle(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_throttle(struct cli_def *cli, const char *command, char **argv, int argc)
{
int rate_in = 0;
int rate_out = 0;
return CLI_OK;
}
-static int cmd_no_throttle(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_no_throttle(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i;
sessionidt s;
return CLI_OK;
}
-static int cmd_debug(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_debug(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i;
return CLI_OK;
}
-static int cmd_no_debug(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_no_debug(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i;
return CLI_OK;
}
-static int cmd_load_plugin(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_load_plugin(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i, firstfree = 0;
return CLI_OK;
}
-static int cmd_remove_plugin(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_remove_plugin(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i;
return buf;
}
-static int cmd_uptime(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_uptime(struct cli_def *cli, const char *command, char **argv, int argc)
{
FILE *fh;
char buf[100], *p = buf, *loads[3];
return CLI_HELP_NO_ARGS;
fh = fopen("/proc/loadavg", "r");
- fgets(buf, 100, fh);
+ p = fgets(buf, 100, fh);
fclose(fh);
for (i = 0; i < 3; i++)
return CLI_OK;
}
-static int cmd_set(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_set(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i;
}
#ifdef BGP
-static int cmd_router_bgp(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_router_bgp(struct cli_def *cli, const char *command, char **argv, int argc)
{
int as;
return new;
}
-static int cmd_router_bgp_neighbour(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_router_bgp_neighbour(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i;
int keepalive;
return CLI_OK;
}
-static int cmd_router_bgp_no_neighbour(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_router_bgp_no_neighbour(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i;
return CLI_OK;
}
-static int cmd_show_bgp(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_show_bgp(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i;
int hdr = 0;
if (!hdr++)
{
- cli_print(cli, "");
+ cli_print(cli, " ");
cli_print(cli, "Peer AS Address "
"State Retries Retry in Route Pend Timers");
cli_print(cli, "------------------ ----- --------------- "
return CLI_OK;
}
-static int cmd_suspend_bgp(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_suspend_bgp(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i;
char *addr;
return CLI_OK;
}
-static int cmd_no_suspend_bgp(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_no_suspend_bgp(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i;
char *addr;
return CLI_OK;
}
-static int cmd_restart_bgp(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_restart_bgp(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i;
char *addr;
return CLI_OK;
}
-static int cmd_ip_access_list(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_ip_access_list(struct cli_def *cli, const char *command, char **argv, int argc)
{
return access_list(cli, argv, argc, 1);
}
-static int cmd_no_ip_access_list(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_no_ip_access_list(struct cli_def *cli, const char *command, char **argv, int argc)
{
return access_list(cli, argv, argc, 0);
}
return buf;
}
-static ip_filter_rulet *access_list_rule_ext(struct cli_def *cli, char *command, char **argv, int argc)
+static ip_filter_rulet *access_list_rule_ext(struct cli_def *cli, const char *command, char **argv, int argc)
{
static ip_filter_rulet rule;
struct in_addr addr;
return &rule;
}
-static ip_filter_rulet *access_list_rule_std(struct cli_def *cli, char *command, char **argv, int argc)
+static ip_filter_rulet *access_list_rule_std(struct cli_def *cli, const char *command, char **argv, int argc)
{
static ip_filter_rulet rule;
struct in_addr addr;
return &rule;
}
-static int cmd_ip_access_list_rule(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_ip_access_list_rule(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i;
ip_filter_rulet *rule = ip_filters[filt].extended
return CLI_OK;
}
-static int cmd_filter(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_filter(struct cli_def *cli, const char *command, char **argv, int argc)
{
sessionidt s;
int i;
return CLI_OK;
}
-static int cmd_no_filter(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_no_filter(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i;
sessionidt s;
return CLI_OK;
}
-static int cmd_show_access_list(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_show_access_list(struct cli_def *cli, const char *command, char **argv, int argc)
{
int i;
return CLI_OK;
}
-static int cmd_shutdown(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_shutdown(struct cli_def *cli, const char *command, char **argv, int argc)
{
if (CLI_HELP_REQUESTED)
return CLI_HELP_NO_ARGS;
return CLI_OK;
}
-static int cmd_reload(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_reload(struct cli_def *cli, const char *command, char **argv, int argc)
{
if (CLI_HELP_REQUESTED)
return CLI_HELP_NO_ARGS;
return CLI_OK;
}
-static int cmd_setforward(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_setforward(struct cli_def *cli, const char *command, char **argv, int argc)
{
int ret;
return CLI_OK;
}
-static int cmd_show_rmtlnsconf(struct cli_def *cli, char *command, char **argv, int argc)
+static int cmd_show_rmtlnsconf(struct cli_def *cli, const char *command, char **argv, int argc)
{
confrlnsidt idrlns;
char strdisp[1024];