]> git.ozlabs.org Git - ppp.git/blob - pppd/plugins/radius/radiusclient/login.radius/migs/ip-down
Add these files, used with TDB.
[ppp.git] / pppd / plugins / radius / radiusclient / login.radius / migs / ip-down
1 #!/usr/bin/perl
2 #
3 # ip-down
4
5 # Script started when the PPP daemon disconnects.
6 #
7
8 use strict;
9 use GDBM_File;
10
11
12 #### RADIUS Begins
13
14 my ($sessionid, $username, $port, $portid, $timeout) = split (/:/, $ARGV[5]);
15
16 if ($sessionid) 
17 {
18 # Code to inform the server that we're getting out.
19
20 # Port information database.
21     my $path_portinfo = "/var/ipoint/acct/portinfo"; 
22
23
24 # Radius accounting record generator.
25     my $prog_radacct = "/usr/local/lib/radiusclient/radacct";
26
27 # The session ID, username, raw port and ID are given to this script 
28 # through the ipparam parameter of pppd 2.2.0e and above.
29
30 # Generate the accounting entry, and hand it over to RADIUS.
31
32 # Delete the port info entry since the user has logged off, but make use
33 # of the starting time.
34     my (%s, @e, $sessiontime);
35     tie (%s, "GDBM_File", $path_portinfo, GDBM_WRCREAT, 0600);
36     @e = split (':', $s{$portid});
37
38     if ($e[4])
39     {
40         $sessiontime = time() - $e[4];
41     }
42
43     delete $s{$portid};
44     untie (%s);
45
46 # Generate the accounting entry, and hand it over to RADIUS.
47
48     open  (H, "| $prog_radacct -i $port");
49
50     my $cmd =
51         "Acct-Session-ID = \"$sessionid\"\n" .
52         "User-Name = \"$username\"\n" .
53         "Acct-Status-Type = Stop\n" .
54         "Acct-Authentic = RADIUS\n" .
55         "Service-Type = Framed\n" .
56         "Framed-Protocol = PPP\n" .
57         "Framed-IP-Address = $ARGV[4]\n";
58
59     if ($sessiontime)
60     {
61         $cmd .= "Acct-Session-Time = $sessiontime\n";
62     }
63
64     print H $cmd;
65     close (H);
66 }
67
68 #### RADIUS Ends
69