Files ppp/.patch.swp and ppp-2.4.4b1/.patch.swp differ diff -Npru ppp/pppd/main.c ppp-2.4.4b1/pppd/main.c --- ppp/pppd/main.c 2005-08-26 01:59:34.000000000 +0200 +++ ppp-2.4.4b1/pppd/main.c 2006-11-28 17:07:23.000000000 +0100 @@ -1245,9 +1245,9 @@ update_link_stats(u) slprintf(numbuf, sizeof(numbuf), "%u", link_connect_time); script_setenv("CONNECT_TIME", numbuf, 0); - slprintf(numbuf, sizeof(numbuf), "%u", link_stats.bytes_out); + snprintf(numbuf, sizeof(numbuf), "%llu", link_stats.bytes_out); script_setenv("BYTES_SENT", numbuf, 0); - slprintf(numbuf, sizeof(numbuf), "%u", link_stats.bytes_in); + snprintf(numbuf, sizeof(numbuf), "%llu", link_stats.bytes_in); script_setenv("BYTES_RCVD", numbuf, 0); } diff -Npru ppp/pppd/Makefile.linux ppp-2.4.4b1/pppd/Makefile.linux --- ppp/pppd/Makefile.linux 2005-07-12 03:50:23.000000000 +0200 +++ ppp-2.4.4b1/pppd/Makefile.linux 2006-11-28 17:40:24.000000000 +0100 @@ -48,7 +48,7 @@ MPPE=y # Uncomment the next line to include support for PPP packet filtering. # This requires that the libpcap library and headers be installed # and that the kernel driver support PPP packet filtering. -FILTER=y +#FILTER=y # Uncomment the next line to enable multilink PPP (enabled by default) # Linux distributions: Please leave multilink ENABLED in your builds @@ -58,9 +58,9 @@ HAVE_MULTILINK=y # Uncomment the next line to enable the TDB database (enabled by default.) # If you enable multilink, then TDB is automatically enabled also. # Linux distributions: Please leave TDB ENABLED in your builds. -USE_TDB=y +#USE_TDB=y -HAS_SHADOW=y +#HAS_SHADOW=y #USE_PAM=y #HAVE_INET6=y diff -Npru ppp/pppd/pathnames.h ppp-2.4.4b1/pppd/pathnames.h --- ppp/pppd/pathnames.h 2005-08-26 01:59:34.000000000 +0200 +++ ppp-2.4.4b1/pppd/pathnames.h 2006-11-28 17:08:23.000000000 +0100 @@ -57,7 +57,7 @@ #ifdef PLUGIN #ifdef __STDC__ -#define _PATH_PLUGIN DESTDIR "/lib/pppd/" VERSION +#define _PATH_PLUGIN DESTDIR "/lib/pppd/" #else /* __STDC__ */ #define _PATH_PLUGIN "/usr/lib/pppd" #endif /* __STDC__ */ diff -Npru ppp/pppd/plugins/radius/avpair.c ppp-2.4.4b1/pppd/plugins/radius/avpair.c --- ppp/pppd/plugins/radius/avpair.c 2004-11-14 08:26:26.000000000 +0100 +++ ppp-2.4.4b1/pppd/plugins/radius/avpair.c 2006-11-28 17:10:04.000000000 +0100 @@ -291,9 +291,19 @@ static void rc_extract_vendor_specific_a /* Set attrlen to length of data */ attrlen -= 4; for (; attrlen; attrlen -= vlen+2, ptr += vlen) { - vtype = *ptr++; - vlen = *ptr++; - vlen -= 2; + + if ( vendor_id == VENDOR_USR ) { + vlen = attrlen - 4; + vtype = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | ptr[3]; + ptr += 4; + /* fixup */ + attrlen -= 2; + } else { + vtype = *ptr++; + vlen = *ptr++; + vlen -= 2; + } + if (vlen < 0 || vlen > attrlen - 2) { /* Do not log an error. We are supposed to be able to cope with arbitrary vendor-specific gunk */ diff -Npru ppp/pppd/plugins/radius/etc/dictionary ppp-2.4.4b1/pppd/plugins/radius/etc/dictionary --- ppp/pppd/plugins/radius/etc/dictionary 2004-11-14 08:26:26.000000000 +0100 +++ ppp-2.4.4b1/pppd/plugins/radius/etc/dictionary 2006-11-28 17:43:12.000000000 +0100 @@ -81,6 +81,8 @@ ATTRIBUTE Acct-Authentic 45 integer ATTRIBUTE Acct-Session-Time 46 integer ATTRIBUTE Acct-Input-Packets 47 integer ATTRIBUTE Acct-Output-Packets 48 integer +ATTRIBUTE Acct-Input-Gigawords 52 integer +ATTRIBUTE Acct-Output-Gigawords 53 integer ATTRIBUTE Acct-Terminate-Cause 49 integer ATTRIBUTE Chap-Challenge 60 string ATTRIBUTE NAS-Port-Type 61 integer diff -Npru ppp/pppd/plugins/radius/radius.c ppp-2.4.4b1/pppd/plugins/radius/radius.c --- ppp/pppd/plugins/radius/radius.c 2005-07-10 12:28:55.000000000 +0200 +++ ppp-2.4.4b1/pppd/plugins/radius/radius.c 2006-11-28 17:57:00.000000000 +0100 @@ -963,18 +963,44 @@ radius_acct_stop(void) if (link_stats_valid) { + DICT_ATTR* attr; + static char bigint[64]; + av_type = link_connect_time; rc_avpair_add(&send, PW_ACCT_SESSION_TIME, &av_type, 0, VENDOR_NONE); - av_type = link_stats.bytes_out; + if ( (attr=rc_dict_findattr("Acct-Output-Octets-64")) ) { + snprintf(bigint,sizeof(bigint),"%llu",link_stats.bytes_out); + rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode); + } + av_type = (UINT4)link_stats.bytes_out; rc_avpair_add(&send, PW_ACCT_OUTPUT_OCTETS, &av_type, 0, VENDOR_NONE); - av_type = link_stats.bytes_in; + av_type = (UINT4)(link_stats.bytes_out >> 32); + rc_avpair_add(&send, PW_ACCT_OUTPUT_GIGAWORDS, &av_type, 0, VENDOR_NONE); + + if ( (attr=rc_dict_findattr("Acct-Input-Octets-64")) ) { + snprintf(bigint,sizeof(bigint),"%llu",link_stats.bytes_in); + rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode); + } + av_type = (UINT4)link_stats.bytes_in; rc_avpair_add(&send, PW_ACCT_INPUT_OCTETS, &av_type, 0, VENDOR_NONE); + av_type = (UINT4)(link_stats.bytes_in >> 32); + rc_avpair_add(&send, PW_ACCT_INPUT_GIGAWORDS, &av_type, 0, VENDOR_NONE); + + if ( (attr=rc_dict_findattr("Acct-Output-Packets-64")) ) { + snprintf(bigint,sizeof(bigint),"%llu",link_stats.pkts_out); + rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode); + } + av_type = link_stats.pkts_out; rc_avpair_add(&send, PW_ACCT_OUTPUT_PACKETS, &av_type, 0, VENDOR_NONE); - + + if ( (attr=rc_dict_findattr("Acct-Input-Packets-64")) ) { + snprintf(bigint,sizeof(bigint),"%llu",link_stats.pkts_in); + rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode); + } av_type = link_stats.pkts_in; rc_avpair_add(&send, PW_ACCT_INPUT_PACKETS, &av_type, 0, VENDOR_NONE); } @@ -1105,20 +1131,45 @@ radius_acct_interim(void *ignored) update_link_stats(0); if (link_stats_valid) { + DICT_ATTR* attr; + static char bigint[64]; + link_stats_valid = 0; /* Force later code to update */ av_type = link_connect_time; rc_avpair_add(&send, PW_ACCT_SESSION_TIME, &av_type, 0, VENDOR_NONE); - av_type = link_stats.bytes_out; + if ( (attr=rc_dict_findattr("Acct-Output-Octets-64")) ) { + snprintf(bigint,sizeof(bigint),"%llu",link_stats.bytes_out); + rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode); + } + av_type = (UINT4)link_stats.bytes_out; rc_avpair_add(&send, PW_ACCT_OUTPUT_OCTETS, &av_type, 0, VENDOR_NONE); - av_type = link_stats.bytes_in; + av_type = (UINT4)(link_stats.bytes_out >> 32); + rc_avpair_add(&send, PW_ACCT_OUTPUT_GIGAWORDS, &av_type, 0, VENDOR_NONE); + + if ( (attr=rc_dict_findattr("Acct-Input-Octets-64")) ) { + snprintf(bigint,sizeof(bigint),"%llu",link_stats.bytes_in); + rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode); + } + av_type = (UINT4)link_stats.bytes_in; rc_avpair_add(&send, PW_ACCT_INPUT_OCTETS, &av_type, 0, VENDOR_NONE); + av_type = (UINT4)(link_stats.bytes_in >> 32); + rc_avpair_add(&send, PW_ACCT_INPUT_GIGAWORDS, &av_type, 0, VENDOR_NONE); + + if ( (attr=rc_dict_findattr("Acct-Output-Packets-64")) ) { + snprintf(bigint,sizeof(bigint),"%llu",link_stats.pkts_out); + rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode); + } av_type = link_stats.pkts_out; rc_avpair_add(&send, PW_ACCT_OUTPUT_PACKETS, &av_type, 0, VENDOR_NONE); + if ( (attr=rc_dict_findattr("Acct-Input-Packets-64")) ) { + snprintf(bigint,sizeof(bigint),"%llu",link_stats.pkts_in); + rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode); + } av_type = link_stats.pkts_in; rc_avpair_add(&send, PW_ACCT_INPUT_PACKETS, &av_type, 0, VENDOR_NONE); } diff -Npru ppp/pppd/plugins/radius/radiusclient.h ppp-2.4.4b1/pppd/plugins/radius/radiusclient.h --- ppp/pppd/plugins/radius/radiusclient.h 2004-11-14 08:26:26.000000000 +0100 +++ ppp-2.4.4b1/pppd/plugins/radius/radiusclient.h 2006-11-28 17:42:32.000000000 +0100 @@ -167,6 +167,8 @@ typedef struct pw_auth_hdr #define PW_ACCT_TERMINATE_CAUSE 49 /* integer */ #define PW_ACCT_MULTI_SESSION_ID 50 /* string */ #define PW_ACCT_LINK_COUNT 51 /* integer */ +#define PW_ACCT_INPUT_GIGAWORDS 52 /* integer */ +#define PW_ACCT_OUTPUT_GIGAWORDS 53 /* integer */ /* From RFC 2869 */ #define PW_ACCT_INTERIM_INTERVAL 85 /* integer */ @@ -292,6 +294,7 @@ typedef struct pw_auth_hdr /* Vendor codes */ #define VENDOR_NONE (-1) #define VENDOR_MICROSOFT 311 +#define VENDOR_USR 429 /* Server data structures */ diff -Npru ppp/pppd/plugins/radius/sendserver.c ppp-2.4.4b1/pppd/plugins/radius/sendserver.c --- ppp/pppd/plugins/radius/sendserver.c 2004-11-14 08:26:26.000000000 +0100 +++ ppp-2.4.4b1/pppd/plugins/radius/sendserver.c 2006-11-28 17:32:34.000000000 +0100 @@ -56,6 +56,14 @@ static int rc_pack_list (VALUE_PAIR *vp, *buf++ = (((unsigned int) vp->vendorcode) >> 8) & 255; *buf++ = ((unsigned int) vp->vendorcode) & 255; + /* Stolen from freeradius's source, that USR vendor + /* attributes are to handled otherwise */ + if ( vp->vendorcode == VENDOR_USR ) { + *buf++ = (vp->attribute >> 24) & 0xff; + *buf++ = (vp->attribute >> 16) & 0xff; + *buf++ = (vp->attribute >> 8) & 0xff; + } + /* Insert vendor-type */ *buf++ = vp->attribute; @@ -64,7 +72,8 @@ static int rc_pack_list (VALUE_PAIR *vp, case PW_TYPE_STRING: length = vp->lvalue; *lenptr = length + 8; - *buf++ = length+2; + if ( vp->vendorcode != VENDOR_USR ) + *buf++ = length+2; memcpy(buf, vp->strvalue, (size_t) length); buf += length; total_length += length+8; @@ -73,7 +82,8 @@ static int rc_pack_list (VALUE_PAIR *vp, case PW_TYPE_IPADDR: length = sizeof(UINT4); *lenptr = length + 8; - *buf++ = length+2; + if ( vp->vendorcode != VENDOR_USR ) + *buf++ = length+2; lvalue = htonl(vp->lvalue); memcpy(buf, (char *) &lvalue, sizeof(UINT4)); buf += length; @@ -82,6 +92,10 @@ static int rc_pack_list (VALUE_PAIR *vp, default: break; } + if ( vp->vendorcode == VENDOR_USR ) { + *lenptr += 2; + total_length += 2; + } } else { *buf++ = vp->attribute; switch (vp->attribute) { diff -Npru ppp/pppd/pppd.h ppp-2.4.4b1/pppd/pppd.h --- ppp/pppd/pppd.h 2005-08-26 01:59:34.000000000 +0200 +++ ppp-2.4.4b1/pppd/pppd.h 2006-11-28 17:33:38.000000000 +0100 @@ -170,10 +170,10 @@ struct permitted_ip { * pppd needs. */ struct pppd_stats { - unsigned int bytes_in; - unsigned int bytes_out; - unsigned int pkts_in; - unsigned int pkts_out; + unsigned long long bytes_in; + unsigned long long bytes_out; + unsigned long long pkts_in; + unsigned long long pkts_out; }; /* Used for storing a sequence of words. Usually malloced. */ diff -Npru ppp/pppd/sys-linux.c ppp-2.4.4b1/pppd/sys-linux.c --- ppp/pppd/sys-linux.c 2005-08-28 07:23:26.000000000 +0200 +++ ppp-2.4.4b1/pppd/sys-linux.c 2006-11-28 17:37:16.000000000 +0100 @@ -1332,6 +1332,10 @@ get_idle_time(u, ip) * * get_ppp_stats - return statistics for the link. */ + +static struct ifpppstatsreq prev_stat_req; +static struct pppd_stats static_stats; + int get_ppp_stats(u, stats) int u; @@ -1347,10 +1351,21 @@ get_ppp_stats(u, stats) error("Couldn't get PPP statistics: %m"); return 0; } - stats->bytes_in = req.stats.p.ppp_ibytes; - stats->bytes_out = req.stats.p.ppp_obytes; - stats->pkts_in = req.stats.p.ppp_ipackets; - stats->pkts_out = req.stats.p.ppp_opackets; + // Calculate the elapsed bytes since the last query + static_stats.bytes_in += + (req.stats.p.ppp_ibytes - prev_stat_req.stats.p.ppp_ibytes); + static_stats.bytes_out += + (req.stats.p.ppp_obytes - prev_stat_req.stats.p.ppp_obytes); + static_stats.pkts_in += + (req.stats.p.ppp_ipackets - prev_stat_req.stats.p.ppp_ipackets); + static_stats.pkts_out += + (req.stats.p.ppp_opackets - prev_stat_req.stats.p.ppp_opackets); + // Store the current state + memcpy(&prev_stat_req,&req,sizeof(prev_stat_req)); + + // Give out the statistics + memcpy(stats,&static_stats,sizeof(static_stats)); + return 1; } @@ -2236,6 +2251,10 @@ int sifup(int u) { struct ifreq ifr; + // Initialize the 'previous stats struct' + memset(&prev_stat_req,0,sizeof(prev_stat_req)); + // And the static statistics puffer + memset(&static_stats,0,sizeof(static_stats)); memset (&ifr, '\0', sizeof (ifr)); strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); if (ioctl(sock_fd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {