summaryrefslogtreecommitdiff
path: root/accel-pppd
diff options
context:
space:
mode:
Diffstat (limited to 'accel-pppd')
-rw-r--r--accel-pppd/cli/show_sessions.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/accel-pppd/cli/show_sessions.c b/accel-pppd/cli/show_sessions.c
index 73c6a41..fb3ff52 100644
--- a/accel-pppd/cli/show_sessions.c
+++ b/accel-pppd/cli/show_sessions.c
@@ -565,10 +565,19 @@ static void format_bytes(char *buf, unsigned long long bytes)
sprintf(buf, "%.1f %s", d, suffix);
}
+static void get_stats(struct ap_session *ses) {
+ if(ap_session_read_stats(ses, &stats) == -1) {
+ stats.rx_bytes = 0;
+ stats.tx_bytes = 0;
+ stats.rx_packets = 0;
+ stats.tx_packets = 0;
+ }
+}
+
static void print_rx_bytes(struct ap_session *ses, char *buf)
{
if (!stats_set) {
- ap_session_read_stats(ses, &stats);
+ get_stats(ses);
stats_set = 1;
}
format_bytes(buf, 4294967296ll*ses->acct_input_gigawords + stats.rx_bytes);
@@ -577,7 +586,7 @@ static void print_rx_bytes(struct ap_session *ses, char *buf)
static void print_tx_bytes(struct ap_session *ses, char *buf)
{
if (!stats_set) {
- ap_session_read_stats(ses, &stats);
+ get_stats(ses);
stats_set = 1;
}
format_bytes(buf, 4294967296ll*ses->acct_output_gigawords + stats.tx_bytes);
@@ -586,7 +595,7 @@ static void print_tx_bytes(struct ap_session *ses, char *buf)
static void print_rx_bytes_raw(struct ap_session *ses, char *buf)
{
if (!stats_set) {
- ap_session_read_stats(ses, &stats);
+ get_stats(ses);
stats_set = 1;
}
sprintf(buf, "%llu", 4294967296ll*ses->acct_input_gigawords + stats.rx_bytes);
@@ -595,7 +604,7 @@ static void print_rx_bytes_raw(struct ap_session *ses, char *buf)
static void print_tx_bytes_raw(struct ap_session *ses, char *buf)
{
if (!stats_set) {
- ap_session_read_stats(ses, &stats);
+ get_stats(ses);
stats_set = 1;
}
sprintf(buf, "%llu", 4294967296ll*ses->acct_output_gigawords + stats.tx_bytes);
@@ -604,7 +613,7 @@ static void print_tx_bytes_raw(struct ap_session *ses, char *buf)
static void print_rx_pkts(struct ap_session *ses, char *buf)
{
if (!stats_set) {
- ap_session_read_stats(ses, &stats);
+ get_stats(ses);
stats_set = 1;
}
sprintf(buf, "%u", stats.rx_packets);
@@ -613,7 +622,7 @@ static void print_rx_pkts(struct ap_session *ses, char *buf)
static void print_tx_pkts(struct ap_session *ses, char *buf)
{
if (!stats_set) {
- ap_session_read_stats(ses, &stats);
+ get_stats(ses);
stats_set = 1;
}
sprintf(buf, "%u", stats.tx_packets);