Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 156606
Collapse All | Expand All

(-)ppp/pppd/main.c (-2 / +2 lines)
Lines 1245-1253 update_link_stats(u) Link Here
1245
1245
1246
    slprintf(numbuf, sizeof(numbuf), "%u", link_connect_time);
1246
    slprintf(numbuf, sizeof(numbuf), "%u", link_connect_time);
1247
    script_setenv("CONNECT_TIME", numbuf, 0);
1247
    script_setenv("CONNECT_TIME", numbuf, 0);
1248
    slprintf(numbuf, sizeof(numbuf), "%u", link_stats.bytes_out);
1248
    snprintf(numbuf, sizeof(numbuf), "%llu", link_stats.bytes_out);
1249
    script_setenv("BYTES_SENT", numbuf, 0);
1249
    script_setenv("BYTES_SENT", numbuf, 0);
1250
    slprintf(numbuf, sizeof(numbuf), "%u", link_stats.bytes_in);
1250
    snprintf(numbuf, sizeof(numbuf), "%llu", link_stats.bytes_in);
1251
    script_setenv("BYTES_RCVD", numbuf, 0);
1251
    script_setenv("BYTES_RCVD", numbuf, 0);
1252
}
1252
}
1253
1253
(-)ppp/pppd/Makefile.linux (-3 / +3 lines)
Lines 48-54 MPPE=y Link Here
48
# Uncomment the next line to include support for PPP packet filtering.
48
# Uncomment the next line to include support for PPP packet filtering.
49
# This requires that the libpcap library and headers be installed
49
# This requires that the libpcap library and headers be installed
50
# and that the kernel driver support PPP packet filtering.
50
# and that the kernel driver support PPP packet filtering.
51
FILTER=y
51
#FILTER=y
52
52
53
# Uncomment the next line to enable multilink PPP (enabled by default)
53
# Uncomment the next line to enable multilink PPP (enabled by default)
54
# Linux distributions: Please leave multilink ENABLED in your builds
54
# Linux distributions: Please leave multilink ENABLED in your builds
Lines 58-66 HAVE_MULTILINK=y Link Here
58
# Uncomment the next line to enable the TDB database (enabled by default.)
58
# Uncomment the next line to enable the TDB database (enabled by default.)
59
# If you enable multilink, then TDB is automatically enabled also.
59
# If you enable multilink, then TDB is automatically enabled also.
60
# Linux distributions: Please leave TDB ENABLED in your builds.
60
# Linux distributions: Please leave TDB ENABLED in your builds.
61
USE_TDB=y
61
#USE_TDB=y
62
62
63
HAS_SHADOW=y
63
#HAS_SHADOW=y
64
#USE_PAM=y
64
#USE_PAM=y
65
#HAVE_INET6=y
65
#HAVE_INET6=y
66
66
(-)ppp/pppd/pathnames.h (-1 / +1 lines)
Lines 57-63 Link Here
57
57
58
#ifdef PLUGIN
58
#ifdef PLUGIN
59
#ifdef __STDC__
59
#ifdef __STDC__
60
#define _PATH_PLUGIN	DESTDIR "/lib/pppd/" VERSION
60
#define _PATH_PLUGIN	DESTDIR "/lib/pppd/"
61
#else /* __STDC__ */
61
#else /* __STDC__ */
62
#define _PATH_PLUGIN	"/usr/lib/pppd"
62
#define _PATH_PLUGIN	"/usr/lib/pppd"
63
#endif /* __STDC__ */
63
#endif /* __STDC__ */
(-)ppp/pppd/plugins/radius/avpair.c (-3 / +13 lines)
Lines 291-299 static void rc_extract_vendor_specific_a Link Here
291
    /* Set attrlen to length of data */
291
    /* Set attrlen to length of data */
292
    attrlen -= 4;
292
    attrlen -= 4;
293
    for (; attrlen; attrlen -= vlen+2, ptr += vlen) {
293
    for (; attrlen; attrlen -= vlen+2, ptr += vlen) {
294
	vtype = *ptr++;
294
295
	vlen = *ptr++;
295
	if ( vendor_id == VENDOR_USR ) {
296
	vlen -= 2;
296
		vlen = attrlen - 4;
297
	        vtype = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | ptr[3];
298
	        ptr += 4;
299
	        /* fixup */ 
300
	        attrlen -= 2;
301
	} else {
302
	        vtype = *ptr++;
303
	        vlen = *ptr++;
304
	        vlen -= 2;
305
	}
306
297
	if (vlen < 0 || vlen > attrlen - 2) {
307
	if (vlen < 0 || vlen > attrlen - 2) {
298
	    /* Do not log an error.  We are supposed to be able to cope with
308
	    /* Do not log an error.  We are supposed to be able to cope with
299
	       arbitrary vendor-specific gunk */
309
	       arbitrary vendor-specific gunk */
(-)ppp/pppd/plugins/radius/etc/dictionary (+2 lines)
Lines 81-86 ATTRIBUTE Acct-Authentic 45 integer Link Here
81
ATTRIBUTE	Acct-Session-Time	46	integer
81
ATTRIBUTE	Acct-Session-Time	46	integer
82
ATTRIBUTE	Acct-Input-Packets	47	integer
82
ATTRIBUTE	Acct-Input-Packets	47	integer
83
ATTRIBUTE	Acct-Output-Packets	48	integer
83
ATTRIBUTE	Acct-Output-Packets	48	integer
84
ATTRIBUTE      Acct-Input-Gigawords    52      integer
85
ATTRIBUTE      Acct-Output-Gigawords   53      integer
84
ATTRIBUTE	Acct-Terminate-Cause	49	integer
86
ATTRIBUTE	Acct-Terminate-Cause	49	integer
85
ATTRIBUTE       Chap-Challenge          60      string
87
ATTRIBUTE       Chap-Challenge          60      string
86
ATTRIBUTE	NAS-Port-Type		61	integer
88
ATTRIBUTE	NAS-Port-Type		61	integer
(-)ppp/pppd/plugins/radius/radius.c (-5 / +56 lines)
Lines 963-980 radius_acct_stop(void) Link Here
963
963
964
964
965
    if (link_stats_valid) {
965
    if (link_stats_valid) {
966
    	DICT_ATTR*      attr;
967
	static char     bigint[64];
968
966
	av_type = link_connect_time;
969
	av_type = link_connect_time;
967
	rc_avpair_add(&send, PW_ACCT_SESSION_TIME, &av_type, 0, VENDOR_NONE);
970
	rc_avpair_add(&send, PW_ACCT_SESSION_TIME, &av_type, 0, VENDOR_NONE);
968
971
969
	av_type = link_stats.bytes_out;
972
	if ( (attr=rc_dict_findattr("Acct-Output-Octets-64")) ) {
973
		snprintf(bigint,sizeof(bigint),"%llu",link_stats.bytes_out);
974
		rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode);
975
	}
976
	av_type = (UINT4)link_stats.bytes_out;
970
	rc_avpair_add(&send, PW_ACCT_OUTPUT_OCTETS, &av_type, 0, VENDOR_NONE);
977
	rc_avpair_add(&send, PW_ACCT_OUTPUT_OCTETS, &av_type, 0, VENDOR_NONE);
971
978
972
	av_type = link_stats.bytes_in;
979
	av_type = (UINT4)(link_stats.bytes_out >> 32);
980
	rc_avpair_add(&send, PW_ACCT_OUTPUT_GIGAWORDS, &av_type, 0, VENDOR_NONE);
981
	  
982
	if ( (attr=rc_dict_findattr("Acct-Input-Octets-64")) ) {
983
		snprintf(bigint,sizeof(bigint),"%llu",link_stats.bytes_in);
984
		rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode);
985
	}
986
	av_type = (UINT4)link_stats.bytes_in;
973
	rc_avpair_add(&send, PW_ACCT_INPUT_OCTETS, &av_type, 0, VENDOR_NONE);
987
	rc_avpair_add(&send, PW_ACCT_INPUT_OCTETS, &av_type, 0, VENDOR_NONE);
974
988
989
	av_type = (UINT4)(link_stats.bytes_in >> 32);
990
        rc_avpair_add(&send, PW_ACCT_INPUT_GIGAWORDS, &av_type, 0, VENDOR_NONE);
991
  
992
        if ( (attr=rc_dict_findattr("Acct-Output-Packets-64")) ) {
993
        	snprintf(bigint,sizeof(bigint),"%llu",link_stats.pkts_out);
994
	        rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode);
995
        }
996
975
	av_type = link_stats.pkts_out;
997
	av_type = link_stats.pkts_out;
976
	rc_avpair_add(&send, PW_ACCT_OUTPUT_PACKETS, &av_type, 0, VENDOR_NONE);
998
	rc_avpair_add(&send, PW_ACCT_OUTPUT_PACKETS, &av_type, 0, VENDOR_NONE);
977
999
 
1000
        if ( (attr=rc_dict_findattr("Acct-Input-Packets-64")) ) {
1001
                snprintf(bigint,sizeof(bigint),"%llu",link_stats.pkts_in);
1002
                rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode);
1003
        }
978
	av_type = link_stats.pkts_in;
1004
	av_type = link_stats.pkts_in;
979
	rc_avpair_add(&send, PW_ACCT_INPUT_PACKETS, &av_type, 0, VENDOR_NONE);
1005
	rc_avpair_add(&send, PW_ACCT_INPUT_PACKETS, &av_type, 0, VENDOR_NONE);
980
    }
1006
    }
Lines 1105-1124 radius_acct_interim(void *ignored) Link Here
1105
    update_link_stats(0);
1131
    update_link_stats(0);
1106
1132
1107
    if (link_stats_valid) {
1133
    if (link_stats_valid) {
1134
	DICT_ATTR*      attr;
1135
	static char     bigint[64];
1136
 
1108
	link_stats_valid = 0; /* Force later code to update */
1137
	link_stats_valid = 0; /* Force later code to update */
1109
1138
1110
	av_type = link_connect_time;
1139
	av_type = link_connect_time;
1111
	rc_avpair_add(&send, PW_ACCT_SESSION_TIME, &av_type, 0, VENDOR_NONE);
1140
	rc_avpair_add(&send, PW_ACCT_SESSION_TIME, &av_type, 0, VENDOR_NONE);
1112
1141
1113
	av_type = link_stats.bytes_out;
1142
	if ( (attr=rc_dict_findattr("Acct-Output-Octets-64")) ) {
1143
		snprintf(bigint,sizeof(bigint),"%llu",link_stats.bytes_out);
1144
		rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode);
1145
	}
1146
	av_type = (UINT4)link_stats.bytes_out;
1114
	rc_avpair_add(&send, PW_ACCT_OUTPUT_OCTETS, &av_type, 0, VENDOR_NONE);
1147
	rc_avpair_add(&send, PW_ACCT_OUTPUT_OCTETS, &av_type, 0, VENDOR_NONE);
1115
1148
1116
	av_type = link_stats.bytes_in;
1149
	av_type = (UINT4)(link_stats.bytes_out >> 32);
1150
	rc_avpair_add(&send, PW_ACCT_OUTPUT_GIGAWORDS, &av_type, 0, VENDOR_NONE);
1151
	  
1152
	if ( (attr=rc_dict_findattr("Acct-Input-Octets-64")) ) {
1153
		snprintf(bigint,sizeof(bigint),"%llu",link_stats.bytes_in);
1154
		rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode);
1155
	}
1156
	av_type = (UINT4)link_stats.bytes_in;
1117
	rc_avpair_add(&send, PW_ACCT_INPUT_OCTETS, &av_type, 0, VENDOR_NONE);
1157
	rc_avpair_add(&send, PW_ACCT_INPUT_OCTETS, &av_type, 0, VENDOR_NONE);
1118
1158
1159
	av_type = (UINT4)(link_stats.bytes_in >> 32);
1160
	rc_avpair_add(&send, PW_ACCT_INPUT_GIGAWORDS, &av_type, 0, VENDOR_NONE);
1161
	  
1162
	if ( (attr=rc_dict_findattr("Acct-Output-Packets-64")) ) {
1163
		snprintf(bigint,sizeof(bigint),"%llu",link_stats.pkts_out);
1164
		rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode);
1165
	}
1119
	av_type = link_stats.pkts_out;
1166
	av_type = link_stats.pkts_out;
1120
	rc_avpair_add(&send, PW_ACCT_OUTPUT_PACKETS, &av_type, 0, VENDOR_NONE);
1167
	rc_avpair_add(&send, PW_ACCT_OUTPUT_PACKETS, &av_type, 0, VENDOR_NONE);
1121
1168
1169
	if ( (attr=rc_dict_findattr("Acct-Input-Packets-64")) ) {
1170
		snprintf(bigint,sizeof(bigint),"%llu",link_stats.pkts_in);
1171
		rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode);
1172
	}
1122
	av_type = link_stats.pkts_in;
1173
	av_type = link_stats.pkts_in;
1123
	rc_avpair_add(&send, PW_ACCT_INPUT_PACKETS, &av_type, 0, VENDOR_NONE);
1174
	rc_avpair_add(&send, PW_ACCT_INPUT_PACKETS, &av_type, 0, VENDOR_NONE);
1124
    }
1175
    }
(-)ppp/pppd/plugins/radius/radiusclient.h (+3 lines)
Lines 167-172 typedef struct pw_auth_hdr Link Here
167
#define PW_ACCT_TERMINATE_CAUSE		49	/* integer */
167
#define PW_ACCT_TERMINATE_CAUSE		49	/* integer */
168
#define PW_ACCT_MULTI_SESSION_ID	50	/* string */
168
#define PW_ACCT_MULTI_SESSION_ID	50	/* string */
169
#define PW_ACCT_LINK_COUNT		51	/* integer */
169
#define PW_ACCT_LINK_COUNT		51	/* integer */
170
#define PW_ACCT_INPUT_GIGAWORDS         52      /* integer */
171
#define PW_ACCT_OUTPUT_GIGAWORDS        53      /* integer */
170
172
171
/* From RFC 2869 */
173
/* From RFC 2869 */
172
#define PW_ACCT_INTERIM_INTERVAL        85	/* integer */
174
#define PW_ACCT_INTERIM_INTERVAL        85	/* integer */
Lines 292-297 typedef struct pw_auth_hdr Link Here
292
/* Vendor codes */
294
/* Vendor codes */
293
#define VENDOR_NONE     (-1)
295
#define VENDOR_NONE     (-1)
294
#define VENDOR_MICROSOFT	311
296
#define VENDOR_MICROSOFT	311
297
#define VENDOR_USR             429
295
298
296
/* Server data structures */
299
/* Server data structures */
297
300
(-)ppp/pppd/plugins/radius/sendserver.c (-2 / +16 lines)
Lines 56-61 static int rc_pack_list (VALUE_PAIR *vp, Link Here
56
		*buf++ = (((unsigned int) vp->vendorcode) >> 8) & 255;
56
		*buf++ = (((unsigned int) vp->vendorcode) >> 8) & 255;
57
		*buf++ = ((unsigned int) vp->vendorcode) & 255;
57
		*buf++ = ((unsigned int) vp->vendorcode) & 255;
58
58
59
		/* Stolen from freeradius's source, that USR vendor
60
		/* attributes are to handled otherwise */
61
		if ( vp->vendorcode == VENDOR_USR ) {
62
			*buf++ = (vp->attribute >> 24) & 0xff;
63
			*buf++ = (vp->attribute >> 16) & 0xff;
64
			*buf++ = (vp->attribute >> 8) & 0xff;
65
		}
66
59
		/* Insert vendor-type */
67
		/* Insert vendor-type */
60
		*buf++ = vp->attribute;
68
		*buf++ = vp->attribute;
61
69
Lines 64-70 static int rc_pack_list (VALUE_PAIR *vp, Link Here
64
		case PW_TYPE_STRING:
72
		case PW_TYPE_STRING:
65
		    length = vp->lvalue;
73
		    length = vp->lvalue;
66
		    *lenptr = length + 8;
74
		    *lenptr = length + 8;
67
		    *buf++ = length+2;
75
		    if ( vp->vendorcode != VENDOR_USR )
76
		    	*buf++ = length+2;
68
		    memcpy(buf, vp->strvalue, (size_t) length);
77
		    memcpy(buf, vp->strvalue, (size_t) length);
69
		    buf += length;
78
		    buf += length;
70
		    total_length += length+8;
79
		    total_length += length+8;
Lines 73-79 static int rc_pack_list (VALUE_PAIR *vp, Link Here
73
		case PW_TYPE_IPADDR:
82
		case PW_TYPE_IPADDR:
74
		    length = sizeof(UINT4);
83
		    length = sizeof(UINT4);
75
		    *lenptr = length + 8;
84
		    *lenptr = length + 8;
76
		    *buf++ = length+2;
85
		    if ( vp->vendorcode != VENDOR_USR )
86
		    	*buf++ = length+2;
77
		    lvalue = htonl(vp->lvalue);
87
		    lvalue = htonl(vp->lvalue);
78
		    memcpy(buf, (char *) &lvalue, sizeof(UINT4));
88
		    memcpy(buf, (char *) &lvalue, sizeof(UINT4));
79
		    buf += length;
89
		    buf += length;
Lines 82-87 static int rc_pack_list (VALUE_PAIR *vp, Link Here
82
		default:
92
		default:
83
		    break;
93
		    break;
84
		}
94
		}
95
		if ( vp->vendorcode == VENDOR_USR ) {
96
			*lenptr += 2;
97
			total_length += 2;
98
		}
85
	    } else {
99
	    } else {
86
		*buf++ = vp->attribute;
100
		*buf++ = vp->attribute;
87
		switch (vp->attribute) {
101
		switch (vp->attribute) {
(-)ppp/pppd/pppd.h (-4 / +4 lines)
Lines 170-179 struct permitted_ip { Link Here
170
 * pppd needs.
170
 * pppd needs.
171
 */
171
 */
172
struct pppd_stats {
172
struct pppd_stats {
173
    unsigned int	bytes_in;
173
    unsigned long long	bytes_in;
174
    unsigned int	bytes_out;
174
    unsigned long long	bytes_out;
175
    unsigned int	pkts_in;
175
    unsigned long long	pkts_in;
176
    unsigned int	pkts_out;
176
    unsigned long long	pkts_out;
177
};
177
};
178
178
179
/* Used for storing a sequence of words.  Usually malloced. */
179
/* Used for storing a sequence of words.  Usually malloced. */
(-)ppp/pppd/sys-linux.c (-4 / +23 lines)
Lines 1332-1337 get_idle_time(u, ip) Link Here
1332
 *
1332
 *
1333
 * get_ppp_stats - return statistics for the link.
1333
 * get_ppp_stats - return statistics for the link.
1334
 */
1334
 */
1335
1336
static struct ifpppstatsreq prev_stat_req;
1337
static struct pppd_stats static_stats;
1338
1335
int
1339
int
1336
get_ppp_stats(u, stats)
1340
get_ppp_stats(u, stats)
1337
    int u;
1341
    int u;
Lines 1347-1356 get_ppp_stats(u, stats) Link Here
1347
	error("Couldn't get PPP statistics: %m");
1351
	error("Couldn't get PPP statistics: %m");
1348
	return 0;
1352
	return 0;
1349
    }
1353
    }
1350
    stats->bytes_in = req.stats.p.ppp_ibytes;
1354
    // Calculate the elapsed bytes since the last query
1351
    stats->bytes_out = req.stats.p.ppp_obytes;
1355
    static_stats.bytes_in +=
1352
    stats->pkts_in = req.stats.p.ppp_ipackets;
1356
        (req.stats.p.ppp_ibytes - prev_stat_req.stats.p.ppp_ibytes);
1353
    stats->pkts_out = req.stats.p.ppp_opackets;
1357
    static_stats.bytes_out +=
1358
        (req.stats.p.ppp_obytes - prev_stat_req.stats.p.ppp_obytes);
1359
    static_stats.pkts_in +=
1360
        (req.stats.p.ppp_ipackets - prev_stat_req.stats.p.ppp_ipackets);
1361
    static_stats.pkts_out +=
1362
        (req.stats.p.ppp_opackets - prev_stat_req.stats.p.ppp_opackets);
1363
    // Store the current state
1364
    memcpy(&prev_stat_req,&req,sizeof(prev_stat_req));
1365
    
1366
    // Give out the statistics
1367
    memcpy(stats,&static_stats,sizeof(static_stats));
1368
1354
    return 1;
1369
    return 1;
1355
}
1370
}
1356
1371
Lines 2236-2241 int sifup(int u) Link Here
2236
{
2251
{
2237
    struct ifreq ifr;
2252
    struct ifreq ifr;
2238
2253
2254
    // Initialize the 'previous stats struct'
2255
    memset(&prev_stat_req,0,sizeof(prev_stat_req));
2256
    // And the static statistics puffer
2257
    memset(&static_stats,0,sizeof(static_stats));
2239
    memset (&ifr, '\0', sizeof (ifr));
2258
    memset (&ifr, '\0', sizeof (ifr));
2240
    strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
2259
    strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
2241
    if (ioctl(sock_fd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
2260
    if (ioctl(sock_fd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {

Return to bug 156606