summaryrefslogtreecommitdiff
path: root/accel-pppd/radius/acct.c
diff options
context:
space:
mode:
authorKozlov Dmitry <xeb@mail.ru>2012-09-05 23:24:51 +0400
committerKozlov Dmitry <xeb@mail.ru>2012-09-05 23:24:51 +0400
commit490f6384f6a54e388587329c0309a6602d5544e8 (patch)
tree5e70a9e4e7a8f6714a4694826ec68f293d1e55a8 /accel-pppd/radius/acct.c
parenta10ec0f4636cd559209659304709924daad96340 (diff)
downloadaccel-ppp-xebd-490f6384f6a54e388587329c0309a6602d5544e8.tar.gz
accel-ppp-xebd-490f6384f6a54e388587329c0309a6602d5544e8.zip
generalize interface statistics gathering
Diffstat (limited to 'accel-pppd/radius/acct.c')
-rw-r--r--accel-pppd/radius/acct.c45
1 files changed, 4 insertions, 41 deletions
diff --git a/accel-pppd/radius/acct.c b/accel-pppd/radius/acct.c
index ab71c45..81145cd 100644
--- a/accel-pppd/radius/acct.c
+++ b/accel-pppd/radius/acct.c
@@ -12,7 +12,7 @@
#include "log.h"
#include "backup.h"
#include "ap_session_backup.h"
-#include "iplink.h"
+#include "iputils.h"
#include "radius_p.h"
@@ -21,33 +21,6 @@
#define STAT_UPDATE_INTERVAL (10 * 60 * 1000)
#define INTERIM_SAFE_TIME 10
-int rad_read_stats(struct radius_pd_t *rpd, struct rtnl_link_stats *stats)
-{
- int r;
-
- if (iplink_get_stats(rpd->ses->ifindex, stats)) {
- log_ppp_warn("radius: failed to get interface statistics\n");
- return -1;
- }
-
- stats->rx_packets -= rpd->acct_rx_packets_i;
- stats->tx_packets -= rpd->acct_tx_packets_i;
- stats->rx_bytes -= rpd->acct_rx_bytes_i;
- stats->tx_bytes -= rpd->acct_tx_bytes_i;
-
- r = stats->rx_bytes != rpd->acct_rx_bytes || stats->tx_bytes < rpd->acct_tx_bytes;
-
- if (stats->rx_bytes < rpd->acct_rx_bytes)
- rpd->acct_input_gigawords++;
- rpd->acct_rx_bytes = stats->rx_packets;
-
- if (stats->tx_bytes < rpd->acct_tx_bytes)
- rpd->acct_output_gigawords++;
- rpd->acct_tx_bytes = stats->tx_bytes;
-
- return r;
-}
-
static int req_set_RA(struct rad_req_t *req, const char *secret)
{
MD5_CTX ctx;
@@ -75,13 +48,13 @@ static void req_set_stat(struct rad_req_t *req, struct ap_session *ses)
else
time(&stop_time);
- if (rad_read_stats(rpd, &stats) > 0) {
+ if (ap_session_read_stats(ses, &stats) == 0) {
rad_packet_change_int(req->pack, NULL, "Acct-Input-Octets", stats.rx_bytes);
rad_packet_change_int(req->pack, NULL, "Acct-Output-Octets", stats.tx_bytes);
rad_packet_change_int(req->pack, NULL, "Acct-Input-Packets", stats.rx_packets);
rad_packet_change_int(req->pack, NULL, "Acct-Output-Packets", stats.tx_packets);
- rad_packet_change_int(req->pack, NULL, "Acct-Input-Gigawords", rpd->acct_input_gigawords);
- rad_packet_change_int(req->pack, NULL, "Acct-Output-Gigawords", rpd->acct_output_gigawords);
+ rad_packet_change_int(req->pack, NULL, "Acct-Input-Gigawords", rpd->ses->acct_input_gigawords);
+ rad_packet_change_int(req->pack, NULL, "Acct-Output-Gigawords", rpd->ses->acct_output_gigawords);
}
rad_packet_change_int(req->pack, NULL, "Acct-Session-Time", stop_time - ses->start_time);
@@ -248,20 +221,10 @@ int rad_acct_start(struct radius_pd_t *rpd)
int i;
time_t ts;
unsigned int dt;
- struct rtnl_link_stats stats;
if (!conf_accounting)
return 0;
- if (iplink_get_stats(rpd->ses->ifindex, &stats))
- log_ppp_warn("radius: failed to get interface statistics\n");
- else {
- rpd->acct_rx_packets_i = stats.rx_packets;
- rpd->acct_tx_packets_i = stats.tx_packets;
- rpd->acct_rx_bytes_i = stats.rx_bytes;
- rpd->acct_tx_bytes_i = stats.tx_bytes;
- }
-
if (!rpd->acct_req)
rpd->acct_req = rad_req_alloc(rpd, CODE_ACCOUNTING_REQUEST, rpd->ses->username);