Grahame Jordan wrote:
> What I am wanting is a way to get the total bytes in, bytes out that a
> particular ppp user has used and log that.
Ah... are these dialin connections to your machine then, are they?
> I would think that the best
> place to implement this would be in pppd.
It looks like the place to do it is in the ipcp.c function "ipcp_down".
>From ppp-2.3.5:
static void
ipcp_down(f)
fsm *f;
{
IPCPDEBUG((LOG_INFO, "ipcp: down"));
np_down(f->unit, PPP_IP);
sifvjcomp(f->unit, 0, 0, 0);
/*
* If we are doing dial-on-demand, set the interface
* to queue up outgoing packets (for now).
*/
if (demand) {
sifnpmode(f->unit, PPP_IP, NPMODE_QUEUE);
} else {
sifdown(f->unit);
ipcp_clear_addrs(f->unit);
}
/* Execute the ip-down script */
ipcp_script(f, _PATH_IPDOWN);
}
The sifdown(f->unit) is the bit that actually takes the interface down,
so if you added another ipcp_script at the top of the function
("ip-goingdown"?), it would be the last thing that happened before the
interface went down.
What I do at the moment (well, actually I took it out yesterday, as I
don't need it any more) is, or was:
ip-up:
#!/usr/bin/perl
open PPPLOG, ">>/var/log/ppptimes";
my $date = `date`;
chop $date;
print PPPLOG "UP $date -->> ";
FORK: {
if ($pid = fork) {
# parent
if (open PIDLOG, ">/var/run/ip-up") {
print PIDLOG "$pid\n";
}
else {
kill 1, $pid;
waitpid $pid, 0;
}
exit;
}
elsif (defined $pid) {
# child
exec "/usr/local/sbin/tcpdump -i ppp0 -w /var/log/lastppp";
exit;
}
elsif ($! =~ /No more process/) {
# EAGAIN, supposedly recoverable fork error
sleep 5;
redo FORK;
}
else {
# Weird fork error
exit;
}
}
exit;
ip-down:
#!/usr/bin/perl
open PPPLOG, ">>/var/log/ppptimes";
my $date = `date`;
chop $date;
print PPPLOG "$date DOWN\n";
open PIDLOG, "</var/run/ip-up" or exit;
$pid = <PIDLOG>;
chomp $pid;
kill 1, $pid;
exit;
...and that seemed to work OK, but the machine it was running on was a
knackered old 486, so I thought I'd remove it to make it run a bit
faster.
--
Nick Phillips ([EMAIL PROTECTED])
-
To unsubscribe from this list: send the line "unsubscribe linux-ppp" in
the body of a message to [EMAIL PROTECTED]