| 1 | package VUser::Radius::Acct; | ||
| 2 | use warnings; | ||
| 3 | use strict; | ||
| 4 | |||
| 5 | # Copyright 2007 Randy Smith <perlstalker@vuser.org> | ||
| 6 | # $Id: Acct.pm,v 1.2 2007/04/09 17:43:39 perlstalker Exp $ | ||
| 7 | |||
| 8 | use VUser::Meta; | ||
| 9 | use VUser::Log; | ||
| 10 | use VUser::ResultSet; | ||
| 11 | use VUser::ExtLib qw(:config); | ||
| 12 | |||
| 13 | our $VERSION = '0.1.0'; | ||
| 14 | |||
| 15 | our $c_sec = 'Extension Radius::Acct'; | ||
| 16 | our %meta = ('username' => VUser::Meta->new('name' => 'username', | ||
| 17 | 'type' => 'string', | ||
| 18 | 'description' => 'User name'), | ||
| 19 | 'password' => VUser::Meta->new('name' => 'password', | ||
| 20 | 'type' => 'string', | ||
| 21 | 'description' => 'User\'s password'), | ||
| 22 | 'realm' => VUser::Meta->new('name' => 'realm', | ||
| 23 | 'type' => 'string', | ||
| 24 | 'description' => 'Realm for this user'), | ||
| 25 | 'starttime' => VUser::Meta->new('name' => 'starttime', | ||
| 26 | 'type' => 'string', | ||
| 27 | 'description' => 'Start time. Format: "CCYY-MM-DD HH:mm:ss.h"'), | ||
| 28 | 'endtime' => VUser::Meta->new('name' => 'endtime', | ||
| 29 | 'type' => 'string', | ||
| 30 | 'description' => 'End time. Format: "CCYY-MM-DD HH:mm:ss.h"'), | ||
| 31 | 'phones' => VUser::Meta->new('name' => 'phones', | ||
| 32 | 'type' => 'string', | ||
| 33 | 'description' => 'Comma seperated list of called station IDs.'), | ||
| 34 | 'report-type' => VUser::Meta->new('name' => 'report-type', | ||
| 35 | 'type' => 'string', | ||
| 36 | 'description' => 'Report type. "total" or "records" for total seconds and octets used or each connection record'), | ||
| 37 | # Common result set types | ||
| 38 | 'session-id' => VUser::Meta->new('name' => 'session-id', | ||
| 39 | 'type' => 'string', | ||
| 40 | 'description' => 'Unique session ID'), | ||
| 41 | 'timestamp' => VUser::Meta->new('name' => 'timestamp', | ||
| 42 | 'type' => 'string', | ||
| 43 | 'description' => 'Timestamp'), | ||
| 44 | 'nas-ip-address' => VUser::Meta->new('name' => 'nas-ip-address', | ||
| 45 | 'type' => 'string', | ||
| 46 | 'description' => 'IP address of NAS'), | ||
| 47 | 'session-time' => VUser::Meta->new('name' => 'session-time', | ||
| 48 | 'type' => 'int', | ||
| 49 | 'description' => 'Session time in seconds'), | ||
| 50 | 'input-octets' => VUser::Meta->new('name' => 'input-octets', | ||
| 51 | 'type' => 'int', | ||
| 52 | 'description' => 'Number of input octets'), | ||
| 53 | 'output-octets' => VUser::Meta->new('name' => 'output-octets', | ||
| 54 | 'type' => 'int', | ||
| 55 | 'description' => 'Number of output octets'), | ||
| 56 | 'framed-ip-address' => VUser::Meta->new('name' => 'framed-ip-address', | ||
| 57 | 'type' => 'string', | ||
| 58 | 'description' => 'Framed IP address'), | ||
| 59 | 'called-station-id' => VUser::Meta->new('name' => 'called-station-id', | ||
| 60 | 'type' => 'string', | ||
| 61 | 'description' => 'Called station ID'), | ||
| 62 | 'calling-station-id' => VUser::Meta->new('name' => 'calling-station-id', | ||
| 63 | 'type' => 'string', | ||
| 64 | 'description' => 'Calling station id') | ||
| 65 | |||
| 66 | ); | ||
| 67 | my $log; | ||
| 68 | |||
| 69 | sub init { | ||
| 70 | my $eh = shift; | ||
| 71 | my %cfg = @_; | ||
| 72 | |||
| 73 | if (defined $main::log) { | ||
| 74 | $log = $main::log; | ||
| 75 | } else { | ||
| 76 | $log = VUser::Log->new(\%cfg, 'vuser') | ||
| 77 | } | ||
| 78 | |||
| 79 | # Radius | ||
| 80 | $eh->register_keyword ('radius', 'Manage RADIUS users'); | ||
| 81 | |||
| 82 | # radius-acct | ||
| 83 | $eh->register_action ('radius', 'acct', 'View accouting data for a user'); | ||
| 84 | $eh->register_option ('radius', 'acct', $meta{'username'}, 'req'); | ||
| 85 | $eh->register_option ('radius', 'acct', $meta{'starttime'}, 'req'); | ||
| 86 | $eh->register_option ('radius', 'acct', $meta{'endtime'}, 'req'); | ||
| 87 | $eh->register_option ('radius', 'acct', $meta{'realm'}); | ||
| 88 | $eh->register_option ('radius', 'acct', $meta{'phones'}); | ||
| 89 | $eh->register_option ('radius', 'acct', $meta{'report-type'}); | ||
| 90 | |||
| 91 | } | ||
| 92 | |||
| 93 | sub meta { return %meta; } | ||
| 94 | sub c_sec { return $c_sec; } | ||
| 95 | |||
| 96 | 1; | ||
| 97 | |||
| 98 | =head1 NAME | ||
| 99 | |||
| 100 | VUser::Radius::Acct - vuser extension to view RADIUS accounting records | ||
| 101 | |||
| 102 | =head1 DESCRIPTION | ||
| 103 | |||
| 104 | VUser::Radius::Acct is an extension to vuser that allows one to view RADIUS | ||
| 105 | accounting data. VUser::Radius::Acct is not meant to be used by itself but, | ||
| 106 | instead, registers the basic keywords, actions and options that other | ||
| 107 | VUser::Radius::Acct::* extensions will use. Other options may be added by | ||
| 108 | RADIUS server specific extensions. | ||
| 109 | |||
| 110 | B<Note:> VUser::Radius::Acct does not need VUser::Radius to function. | ||
| 111 | |||
| 112 | =head1 CONFIGURATION | ||
| 113 | |||
| 114 | [Extension Radius::Acct] | ||
| 115 | |||
| 116 | Any Radius::* extensions will automatically load I<Radius::Acct>. There is no | ||
| 117 | need to add I<Radius::Acct> to I<vuser|extensions>. | ||
| 118 | Other VUser::Radius::Acct::* extensions may have their own configuration. | ||
| 119 | |||
| 120 | =head1 META SHORTCUTS | ||
| 121 | |||
| 122 | VUser::Radius::Acct provides a few VUser::Meta objects that may be used by | ||
| 123 | other radius extensions. The safest way to access them is to call | ||
| 124 | VUser::Radius::Acct::meta() from within the extension's init() function. | ||
| 125 | |||
| 126 | Provided keys: username, password, realm, starttime, endtime, report-type | ||
| 127 | |||
| 128 | =head1 AUTHOR | ||
| 129 | |||
| 130 | Randy Smith <perlstalker@vuser.org> | ||
| 131 | |||
| 132 | =head1 LICENSE | ||
| 133 | |||
| 134 | This file is part of VUser-Radius-Acct. | ||
| 135 | |||
| 136 | VUser-Radius-Acct is free software; you can redistribute it and/or modify | ||
| 137 | it under the terms of the GNU General Public License as published by | ||
| 138 | the Free Software Foundation; either version 2 of the License, or | ||
| 139 | (at your option) any later version. | ||
| 140 | |||
| 141 | VUser-Radius is distributed in the hope that it will be useful, | ||
| 142 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 143 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 144 | GNU General Public License for more details. | ||
| 145 | |||
| 146 | You should have received a copy of the GNU General Public License | ||
| 147 | along with VUser-Radius-Acct; if not, write to the Free Software | ||
| 148 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 149 | |||
| 150 | =cut |