Add these files, used with TDB.
[mpls-ppp.git] / pppd / plugins / radius / radiusclient / login.radius / migs / ip-down
blobc29bd2a5cf89d2ceb79129ce3e9a9f9d9f5ca430
1 #!/usr/bin/perl
3 # ip-down
4 #
5 # Script started when the PPP daemon disconnects.
8 use strict;
9 use GDBM_File;
12 #### RADIUS Begins
14 my ($sessionid, $username, $port, $portid, $timeout) = split (/:/, $ARGV[5]);
16 if ($sessionid)
18 # Code to inform the server that we're getting out.
20 # Port information database.
21 my $path_portinfo = "/var/ipoint/acct/portinfo";
24 # Radius accounting record generator.
25 my $prog_radacct = "/usr/local/lib/radiusclient/radacct";
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.
30 # Generate the accounting entry, and hand it over to RADIUS.
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});
38 if ($e[4])
40 $sessiontime = time() - $e[4];
43 delete $s{$portid};
44 untie (%s);
46 # Generate the accounting entry, and hand it over to RADIUS.
48 open (H, "| $prog_radacct -i $port");
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";
59 if ($sessiontime)
61 $cmd .= "Acct-Session-Time = $sessiontime\n";
64 print H $cmd;
65 close (H);
68 #### RADIUS Ends