PATCH: Accounting Gigawords
Gunter Burchardt
gbur
Mon Jul 12 02:13:35 PDT 2004
Hello,
I wrote a patch for accounting. At the moment only traffic up to 4 GB
for each direction can be accounted. After 4 GB the counters roll over!
This patch defines the rx/tx_bytes per sta as unsigned long long. If a
counter roll over Acct-Input-Gigawords and/of Acct-Output-Gigawords will
be set in the accounting packet (RFC 2869).
At the moment a session could roll over in about 2 hours. After the
patch it will roll over after the end of the universe.
This patch is experimental!
regards
gunter
-------------- next part --------------
diff -Nur hostap.old/driver/modules/hostap_ap.c hostap/driver/modules/hostap_ap.c
--- hostap.old/driver/modules/hostap_ap.c 2004-07-12 04:10:45.000000000 +0200
+++ hostap/driver/modules/hostap_ap.c 2004-07-12 10:18:49.000000000 +0200
@@ -1023,7 +1023,7 @@
p += sprintf(p, "\njiffies=%lu\nlast_auth=%lu\nlast_assoc=%lu\n"
"last_rx=%lu\nlast_tx=%lu\nrx_packets=%lu\n"
"tx_packets=%lu\n"
- "rx_bytes=%lu\ntx_bytes=%lu\nbuffer_count=%d\n"
+ "rx_bytes=%llu\ntx_bytes=%llu\nbuffer_count=%d\n"
"last_rx: silence=%d dBm signal=%d dBm rate=%d%s Mbps\n"
"tx_rate=%d\ntx[1M]=%d\ntx[2M]=%d\ntx[5.5M]=%d\n"
"tx[11M]=%d\n"
diff -Nur hostap.old/driver/modules/hostap_ap.h hostap/driver/modules/hostap_ap.h
--- hostap.old/driver/modules/hostap_ap.h 2004-04-06 06:00:42.000000000 +0200
+++ hostap/driver/modules/hostap_ap.h 2004-07-12 10:18:49.000000000 +0200
@@ -61,7 +61,7 @@
unsigned long last_rx;
unsigned long last_tx;
unsigned long rx_packets, tx_packets;
- unsigned long rx_bytes, tx_bytes;
+ unsigned long long rx_bytes, tx_bytes;
struct sk_buff_head tx_buf;
/* FIX: timeout buffers with an expiry time somehow derived from
* listen_interval */
diff -Nur hostap.old/hostapd/accounting.c hostap/hostapd/accounting.c
--- hostap.old/hostapd/accounting.c 2004-06-17 06:28:44.000000000 +0200
+++ hostap/hostapd/accounting.c 2004-07-12 10:18:49.000000000 +0200
@@ -225,29 +225,47 @@
&data, sta->addr) == 0) {
if (!radius_msg_add_attr_int32(msg,
RADIUS_ATTR_ACCT_INPUT_PACKETS,
- data.rx_packets)) {
+ (long)data.rx_packets)) {
printf("Could not add Acct-Input-Packets\n");
goto fail;
}
if (!radius_msg_add_attr_int32(msg,
RADIUS_ATTR_ACCT_OUTPUT_PACKETS,
- data.tx_packets)) {
+ (long)data.tx_packets)) {
printf("Could not add Acct-Output-Packets\n");
goto fail;
}
if (!radius_msg_add_attr_int32(msg,
RADIUS_ATTR_ACCT_INPUT_OCTETS,
- data.rx_bytes)) {
+ (long)data.rx_bytes)) {
printf("Could not add Acct-Input-Octets\n");
goto fail;
}
+ if(data.rx_bytes>>32)
+ {
+ if (!radius_msg_add_attr_int32(msg,
+ RADIUS_ATTR_ACCT_INPUT_GIGAWORDS,
+ (long)(data.rx_bytes>>32))) {
+ printf("Could not add Acct-Input-Gigawords\n");
+ goto fail;
+ }
+ }
if (!radius_msg_add_attr_int32(msg,
RADIUS_ATTR_ACCT_OUTPUT_OCTETS,
- data.tx_bytes)) {
+ (long)data.tx_bytes)) {
printf("Could not add Acct-Output-Octets\n");
goto fail;
}
- }
+ if(data.tx_bytes>>32)
+ {
+ if (!radius_msg_add_attr_int32(msg,
+ RADIUS_ATTR_ACCT_OUTPUT_GIGAWORDS,
+ (long)(data.tx_bytes>>32))) {
+ printf("Could not add Acct-Output-Gigawords\n");
+ goto fail;
+ }
+ }
+ }
if (eloop_terminated())
cause = RADIUS_ACCT_TERMINATE_CAUSE_ADMIN_REBOOT;
diff -Nur hostap.old/hostapd/driver.c hostap/hostapd/driver.c
--- hostap.old/hostapd/driver.c 2004-06-20 18:22:24.000000000 +0200
+++ hostap/hostapd/driver.c 2004-07-12 10:18:49.000000000 +0200
@@ -305,7 +305,7 @@
struct hostap_driver_data *drv = priv;
char buf[1024], line[128], *pos;
FILE *f;
- unsigned long val;
+ unsigned long long val;
memset(data, 0, sizeof(*data));
snprintf(buf, sizeof(buf), "/proc/net/hostap/%s/" MACSTR,
@@ -323,7 +323,7 @@
if (!pos)
continue;
*pos++ = '\0';
- val = atoi(pos);
+ val = atoll(pos);
if (strcmp(line, "rx_packets") == 0)
data->rx_packets = val;
else if (strcmp(line, "tx_packets") == 0)
diff -Nur hostap.old/hostapd/driver.h hostap/hostapd/driver.h
--- hostap.old/hostapd/driver.h 2004-06-20 18:22:24.000000000 +0200
+++ hostap/hostapd/driver.h 2004-07-12 10:18:49.000000000 +0200
@@ -2,7 +2,7 @@
#define DRIVER_H
struct hostap_sta_driver_data {
- unsigned long rx_packets, tx_packets, rx_bytes, tx_bytes;
+ unsigned long long rx_packets, tx_packets, rx_bytes, tx_bytes;
};
struct hostap_driver_data {
diff -Nur hostap.old/hostapd/radius.c hostap/hostapd/radius.c
--- hostap.old/hostapd/radius.c 2004-07-08 06:11:17.000000000 +0200
+++ hostap/hostapd/radius.c 2004-07-12 10:18:50.000000000 +0200
@@ -163,6 +163,10 @@
{ RADIUS_ATTR_ACCT_MULTI_SESSION_ID, "Acct-Multi-Session-Id",
RADIUS_ATTR_TEXT },
{ RADIUS_ATTR_ACCT_LINK_COUNT, "Acct-Link-Count", RADIUS_ATTR_INT32 },
+ { RADIUS_ATTR_ACCT_INPUT_GIGAWORDS, "Acct-Input-Gigawords",
+ RADIUS_ATTR_INT32 },
+ { RADIUS_ATTR_ACCT_OUTPUT_GIGAWORDS, "Acct-output-Gigawords",
+ RADIUS_ATTR_INT32 },
{ RADIUS_ATTR_NAS_PORT_TYPE, "NAS-Port-Type", RADIUS_ATTR_INT32 },
{ RADIUS_ATTR_CONNECT_INFO, "Connect-Info", RADIUS_ATTR_TEXT },
{ RADIUS_ATTR_EAP_MESSAGE, "EAP-Message", RADIUS_ATTR_UNDIST },
diff -Nur hostap.old/hostapd/radius.h hostap/hostapd/radius.h
--- hostap.old/hostapd/radius.h 2004-07-08 06:11:17.000000000 +0200
+++ hostap/hostapd/radius.h 2004-07-12 10:18:50.000000000 +0200
@@ -56,7 +56,9 @@
RADIUS_ATTR_ACCT_TERMINATE_CAUSE = 49,
RADIUS_ATTR_ACCT_MULTI_SESSION_ID = 50,
RADIUS_ATTR_ACCT_LINK_COUNT = 51,
- RADIUS_ATTR_NAS_PORT_TYPE = 61,
+ RADIUS_ATTR_ACCT_INPUT_GIGAWORDS=52,
+ RADIUS_ATTR_ACCT_OUTPUT_GIGAWORDS=53,
+ RADIUS_ATTR_NAS_PORT_TYPE = 61,
RADIUS_ATTR_CONNECT_INFO = 77,
RADIUS_ATTR_EAP_MESSAGE = 79,
RADIUS_ATTR_MESSAGE_AUTHENTICATOR = 80,
More information about the Hostap
mailing list