X-Git-Url: http://git.sameswireless.fr/l2tpns.git/blobdiff_plain/4df24fd868177859ddd778f1f45bc825f6264cfb..709b2b0419595bd99594840118740bb243566dcb:/cli.c diff --git a/cli.c b/cli.c index 5b0bcbc..09ea768 100644 --- a/cli.c +++ b/cli.c @@ -104,6 +104,7 @@ static int cmd_shutdown(struct cli_def *cli, char *command, char **argv, int arg static int cmd_reload(struct cli_def *cli, char *command, char **argv, int argc); #ifdef LAC 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); #endif static int regular_stuff(struct cli_def *cli); @@ -155,6 +156,9 @@ void init_cli() cli_register_command(cli, c, "pool", cmd_show_pool, PRIVILEGE_UNPRIVILEGED, MODE_EXEC, "Show the IP address allocation pool"); cli_register_command(cli, c, "radius", cmd_show_radius, PRIVILEGE_UNPRIVILEGED, MODE_EXEC, "Show active radius queries"); cli_register_command(cli, c, "running-config", cmd_show_run, PRIVILEGE_PRIVILEGED, MODE_EXEC, "Show the currently running configuration"); +#ifdef LAC + cli_register_command(cli, c, "remotelns-conf", cmd_show_rmtlnsconf, PRIVILEGE_PRIVILEGED, MODE_EXEC, "Show a list of remote LNS configuration"); +#endif cli_register_command(cli, c, "session", cmd_show_session, PRIVILEGE_UNPRIVILEGED, MODE_EXEC, "Show a list of sessions or details for a single session"); cli_register_command(cli, c, "tbf", cmd_show_tbf, PRIVILEGE_UNPRIVILEGED, MODE_EXEC, "List all token bucket filters in use"); cli_register_command(cli, c, "throttle", cmd_show_throttle, PRIVILEGE_UNPRIVILEGED, MODE_EXEC, "List all throttled sessions and associated TBFs"); @@ -538,8 +542,15 @@ static int cmd_show_session(struct cli_def *cli, char *command, char **argv, int } // Show Summary +#ifdef LAC + cli_print(cli, "%5s %7s %4s %-32s %-15s %s %s %s %s %10s %10s %10s %4s %10s %-18s %s", +#else cli_print(cli, "%5s %4s %-32s %-15s %s %s %s %s %10s %10s %10s %4s %10s %-15s %s", +#endif "SID", +#ifdef LAC + "LkToSID", +#endif "TID", "Username", "IP", @@ -552,7 +563,11 @@ static int cmd_show_session(struct cli_def *cli, char *command, char **argv, int "uploaded", "idle", "Rem.Time", +#ifdef LAC + "LAC(L)/R LNS(R)", +#else "LAC", +#endif "CLI"); for (i = 1; i < MAXSESSION; i++) @@ -563,9 +578,15 @@ static int cmd_show_session(struct cli_def *cli, char *command, char **argv, int rem_time = session[i].timeout ? (session[i].timeout - bundle[session[i].bundle].online_time) : 0; else rem_time = session[i].timeout ? (session[i].timeout - (time_now-session[i].opened)) : 0; - +#ifdef LAC + cli_print(cli, "%5d %7d %4d %-32s %-15s %s %s %s %s %10u %10lu %10lu %4u %10lu %3s%-15s %s", +#else cli_print(cli, "%5d %4d %-32s %-15s %s %s %s %s %10u %10lu %10lu %4u %10lu %-15s %s", +#endif i, +#ifdef LAC + session[i].forwardtosession, +#endif session[i].tunnel, session[i].user[0] ? session[i].user : "*", fmtaddr(htonl(session[i].ip), 0), @@ -578,6 +599,9 @@ static int cmd_show_session(struct cli_def *cli, char *command, char **argv, int (unsigned long)session[i].cin, abs(time_now - (session[i].last_packet ? session[i].last_packet : time_now)), (unsigned long)(rem_time), +#ifdef LAC + tunnel[session[i].tunnel].isremotelns?"(R)":"(L)", +#endif fmtaddr(htonl(tunnel[ session[i].tunnel ].ip), 1), session[i].calling[0] ? session[i].calling : "*"); } @@ -662,12 +686,20 @@ static int cmd_show_tunnels(struct cli_def *cli, char *command, char **argv, int if (!show_all && (!tunnel[i].ip || tunnel[i].die)) continue; for (x = 0; x < MAXSESSION; x++) if (session[x].tunnel == i && session[x].opened && !session[x].die) sessions++; +#ifdef LAC + cli_print(cli, "%4d %20s %20s %6s %6d %s", +#else cli_print(cli, "%4d %20s %20s %6s %6d", +#endif i, *tunnel[i].hostname ? tunnel[i].hostname : "(null)", fmtaddr(htonl(tunnel[i].ip), 0), states[tunnel[i].state], - sessions); + sessions +#ifdef LAC + ,(tunnel[i].isremotelns?"Tunnel To Remote LNS":"Tunnel To LAC") +#endif + ); } return CLI_OK; @@ -1277,6 +1309,13 @@ static int cmd_drop_session(struct cli_def *cli, char *command, char **argv, int cli_print(cli, "Dropping session %d", s); cli_session_actions[s].action |= CLI_SESS_KILL; } +#ifdef LAC + else if (session[s].forwardtosession && session[s].opened && !session[s].die) + { + cli_print(cli, "Dropping session %d", s); + cli_session_actions[s].action |= CLI_SESS_KILL; + } +#endif else { cli_error(cli, "Session %d is not active.", s); @@ -3142,15 +3181,39 @@ static int cmd_setforward(struct cli_def *cli, char *command, char **argv, int a return CLI_OK; } - // adremotelns(mask, IP_RemoteLNS, Port_RemoteLNS, SecretRemoteLNS) - ret = addremotelns(argv[0], argv[1], argv[2], argv[3]); + // lac_addremotelns(mask, IP_RemoteLNS, Port_RemoteLNS, SecretRemoteLNS) + ret = lac_addremotelns(argv[0], argv[1], argv[2], argv[3]); if (ret) + { cli_print(cli, "setforward %s %s %s %s", argv[0], argv[1], argv[2], argv[3]); + if (ret == 2) + cli_print(cli, "%s Updated, the tunnel must be dropped", argv[0]); + } else cli_error(cli, "ERROR setforward %s %s %s %s", argv[0], argv[1], argv[2], argv[3]); return CLI_OK; } +static int cmd_show_rmtlnsconf(struct cli_def *cli, char *command, char **argv, int argc) +{ + confrlnsidt idrlns; + char strdisp[1024]; + + if (CLI_HELP_REQUESTED) + { + return cli_arg_help(cli, 0, "remotelns-conf", "Show a list of remote LNS configurations", NULL); + } + + for (idrlns = 0; idrlns < MAXRLNSTUNNEL; idrlns++) + { + if (lac_cli_show_remotelns(idrlns, strdisp) != 0) + cli_print(cli, "%s", strdisp); + else + break; + } + + return CLI_OK; +} #endif