diff options
author | Stephan Brunner <s.brunner@stephan-brunner.net> | 2022-11-01 10:08:06 +0100 |
---|---|---|
committer | Stephan Brunner <s.brunner@stephan-brunner.net> | 2022-11-01 10:08:06 +0100 |
commit | 5d3e96a67dc6ea6ca81156bdccd83b9b7e241ccb (patch) | |
tree | d4df4990549815fecb1880766117a5fcf1f13920 | |
parent | ffe3a1337c1380a5b79651b34037c6c9f66b9ea1 (diff) | |
download | accel-ppp-5d3e96a67dc6ea6ca81156bdccd83b9b7e241ccb.tar.gz accel-ppp-5d3e96a67dc6ea6ca81156bdccd83b9b7e241ccb.zip |
Add PACKETS_SENT and PACKETS_RCVD to the pppd-compat environment.
-rw-r--r-- | accel-pppd/extra/pppd_compat.c | 24 | ||||
-rw-r--r-- | accel-pppd/include/ap_session.h | 2 | ||||
-rw-r--r-- | accel-pppd/session.c | 2 |
3 files changed, 27 insertions, 1 deletions
diff --git a/accel-pppd/extra/pppd_compat.c b/accel-pppd/extra/pppd_compat.c index 9bc393b..040e7d9 100644 --- a/accel-pppd/extra/pppd_compat.c +++ b/accel-pppd/extra/pppd_compat.c @@ -30,7 +30,7 @@ #include "memdebug.h" #define ENV_MEM 1024 -#define ENV_MAX 16 +#define ENV_MAX 32 static char *conf_ip_up; static char *conf_ip_pre_up; @@ -686,9 +686,13 @@ static void fill_env(char **env, char *mem, struct pppd_compat_pd *pd) if (pd->ses->stop_time) { uint64_t tx_bytes; uint64_t rx_bytes; + uint64_t tx_packets; + uint64_t rx_packets; tx_bytes = ses->acct_tx_bytes; rx_bytes = ses->acct_rx_bytes; + tx_packets = ses->acct_tx_packets; + rx_packets = ses->acct_rx_packets; env[n] = mem; write_sz = snprintf(mem, mem_sz, "CONNECT_TIME=%lu", @@ -714,6 +718,24 @@ static void fill_env(char **env, char *mem, struct pppd_compat_pd *pd) rx_bytes); if (write_sz < 0 || write_sz >= mem_sz) goto out; + mem_sz -= write_sz + 1; + mem += write_sz + 1; + ++n; + + env[n] = mem; + write_sz = snprintf(mem, mem_sz, "PACKETS_SENT=%" PRIu64, + tx_packets); + if (write_sz < 0 || write_sz >= mem_sz) + goto out; + mem_sz -= write_sz + 1; + mem += write_sz + 1; + ++n; + + env[n] = mem; + write_sz = snprintf(mem, mem_sz, "PACKETS_RCVD=%" PRIu64, + rx_packets); + if (write_sz < 0 || write_sz >= mem_sz) + goto out; ++n; } diff --git a/accel-pppd/include/ap_session.h b/accel-pppd/include/ap_session.h index 629b58e..7051513 100644 --- a/accel-pppd/include/ap_session.h +++ b/accel-pppd/include/ap_session.h @@ -110,6 +110,8 @@ struct ap_session int session_timeout; struct triton_timer_t timer; + uint64_t acct_rx_packets; + uint64_t acct_tx_packets; uint64_t acct_rx_bytes; uint64_t acct_tx_bytes; uint64_t acct_rx_packets_i; diff --git a/accel-pppd/session.c b/accel-pppd/session.c index af70b1d..c01417f 100644 --- a/accel-pppd/session.c +++ b/accel-pppd/session.c @@ -401,6 +401,8 @@ int __export ap_session_read_stats(struct ap_session *ses, struct rtnl_link_stat if (stats->rx_bytes != ses->acct_rx_bytes) ses->idle_time = _time(); + ses->acct_rx_packets = stats->rx_packets; + ses->acct_tx_packets = stats->tx_packets; ses->acct_rx_bytes = stats->rx_bytes; ses->acct_tx_bytes = stats->tx_bytes; |