#endif
static int cmd_show_session(struct cli_def *cli, char *command, char **argv, int argc);
+static int cmd_show_group(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);
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, "group", cmd_show_group, PRIVILEGE_UNPRIVILEGED, MODE_EXEC, "Show a list of groups or details for a single group");
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");
cli_register_command(cli, c, "tunnels", cmd_show_tunnels, PRIVILEGE_UNPRIVILEGED, MODE_EXEC, "Show a list of tunnels or details for a single tunnel");
}
if (i)
- cli_print(cli, "");
+ cli_print(cli, " ");
cli_print(cli, "%s IP access list %s",
ip_filters[f].extended ? "Extended" : "Standard",
return CLI_OK;
}
+static int cmd_show_group(struct cli_def *cli, char *command, char **argv, int argc)
+{
+ int i;
+ groupidt g;
+
+ if (CLI_HELP_REQUESTED)
+ return cli_arg_help(cli, 1,
+ "<1-%d>", MAXGROUPE-1, "Show specific group by id",
+ NULL);
+
+ time(&time_now);
+ if (argc > 0)
+ {
+ // Show individual group
+ for (i = 0; i < argc; i++)
+ {
+ sessionidt s;
+
+ g = atoi(argv[i]);
+ if (g <= 0 || g >= MAXGROUPE)
+ {
+ cli_print(cli, "Invalid group id \"%s\"", argv[i]);
+ continue;
+ }
+
+ cli_print(cli, "\r\nGroup %d:", g);
+ cli_print(cli, "\tNb Session:\t\t%d", grpsession[g].nbsession);
+ cli_print(cli, "\tNb Routes:\t\t%d", grpsession[g].nbroutesgrp);
+ cli_print(cli, "\ttime_changed:\t\t%d\n", grpsession[g].time_changed);
+
+ for (i = 0; i < grpsession[g].nbsession; i++)
+ {
+ if ((s = grpsession[g].sesslist[i].sid))
+ {
+ cli_print(cli, "\tSession:\t%d\tTx Rate:%d Kbps\t\t\tweight:\t%d",
+ s,
+ grpsession[g].sesslist[i].tx_rate/(1024/8),
+ grpsession[g].sesslist[i].weight);
+ }
+ }
+
+ for (i = 0; i < grpsession[g].nbroutesgrp; i++)
+ {
+ if (grpsession[g].route[i].ip != 0)
+ {
+ cli_print(cli, "\tRoute:\t%s/%d", fmtaddr(htonl(grpsession[g].route[i].ip), 0), grpsession[g].route[i].prefixlen);
+ }
+ }
+ }
+ return CLI_OK;
+ }
+
+ // Show Summary
+ cli_print(cli, "%5s %7s %9s %12s",
+ "GID",
+ "Nb Sess",
+ "Nb Routes",
+ "Time changed");
+
+ for (g = gnextgrpid; g != 0; g = grpsession[g].prev)
+ {
+ cli_print(cli, "%5d %7d %9d %12d",
+ g,
+ grpsession[g].nbsession,
+ grpsession[g].nbroutesgrp,
+ grpsession[g].time_changed);
+ }
+
+ return CLI_OK;
+}
+
#ifdef LAC
static int cmd_setforward(struct cli_def *cli, char *command, char **argv, int argc)
union grp_iphash *idx;
} grp_ip_hash[256]; // Mapping from IP address to group structures.
-static groupidt gnextgrpid = 0;
+groupidt gnextgrpid = 0;
// Find gruop by IP, < 1 for not found
//
// return the next session can be used on the group
sessionidt grp_getnextsession(groupidt g, in_addr_t ip)
{
- sessionidt s = 0, s2 = 0, s3 = 0, smax = 0;
+ sessionidt s = 0, s2 = 0, s3 = 0;
int i;
uint32_t ltime_changed = 0, mintxrate = 0xFFFFFFFF, maxtxrate = 0;
uint32_t txrate;
if (g >= MAXGROUPE)
return 0;
- if (grpsession[g].time_changed < config->grp_txrate_average_time)
- {
- if ((s = sessionbyip(ip)))
- {
- if ( (session[s].ppp.phase > Establish) &&
- (time_now - session[s].last_packet <= (config->echo_timeout + 1)) )
- {
- return s;
- }
- s = 0;
- }
- }
- else
+ if (grpsession[g].time_changed >= config->grp_txrate_average_time)
{
// recalculation txrate
ltime_changed = grpsession[g].time_changed;
grpsession[g].time_changed = 0;
- s = 0;
for (i = 0; i < grpsession[g].nbsession; i++)
{
if ((s2 = grpsession[g].sesslist[i].sid))
{
- s3 = s2;
-
grpsession[g].sesslist[i].tx_rate = session[s2].coutgrp_delta/ltime_changed;
session[s2].coutgrp_delta = 0;
- //LOG(3, s2, session[s2].tunnel, "TX Rate: %d session weight: %d\n",
- // grpsession[g].sesslist[i].tx_rate, grpsession[g].sesslist[i].weight);
-
txrate = grpsession[g].sesslist[i].tx_rate/grpsession[g].sesslist[i].weight;
if (txrate < mintxrate)
{
if ( session[s2].ppp.phase > Establish &&
(time_now - session[s2].last_packet <= (config->echo_timeout + 1)) )
{
- s = s2;
+ grpsession[g].smin = s2;
mintxrate = txrate;
}
}
if ( session[s2].ppp.phase > Establish &&
(time_now - session[s2].last_packet <= (config->echo_timeout + 1)) )
{
- smax = s2;
+ grpsession[g].smax = s2;
maxtxrate = txrate;
}
}
}
}
+ }
- if (smax && (maxtxrate != mintxrate))
+ if ((s = sessionbyip(ip)))
+ {
+ if (s == grpsession[g].smax)
+ {
+ s = grpsession[g].smin;
+ grpsession[g].smax = 0;
+ }
+ else if ( (session[s].ppp.phase > Establish) &&
+ (time_now - session[s].last_packet <= (config->echo_timeout + 1)) )
{
- grp_uncache_ipsession(g, smax);
+ return s;
+ }
+ else
+ {
+ s = 0;
}
}
(time_now - session[s2].last_packet <= (config->echo_timeout + 1)))
{
s = s2;
- //LOG(3, s, session[s].tunnel, "New random session\n");
}
else
{