1 package FS::part_export::broadband_sqlradius;
4 use vars qw($DEBUG @ISA %options %info $conf);
7 use FS::Record qw( dbh str2time_sql ); #qsearch qsearchs );
8 use FS::part_export::sqlradius qw(sqlradius_connect);
10 FS::UID->install_callback(sub { $conf = new FS::Conf });
12 @ISA = qw(FS::part_export::sqlradius);
16 tie %options, 'Tie::IxHash',
17 'datasrc' => { label=>'DBI data source ' },
18 'username' => { label=>'Database username' },
19 'password' => { label=>'Database password' },
20 'usergroup'=> { label => 'Group table',
22 options => [qw( radusergroup usergroup )],
24 # session report doesn't currently know about this export anyway
27 # label => 'Hide IP address on session reports',
30 label => 'Export MAC address as',
32 options => [ qw(uppercase lowercase) ],
35 label => 'Separate MAC address octets with',
38 'mac_as_password' => {
41 label => 'Use MAC address as password',
43 'radius_password' => { label=>'Fixed password' },
44 'ip_addr_as' => { label => 'Send IP address as',
45 default => 'Framed-IP-Address' },
48 label => 'Export RADIUS group attributes to this database',
53 'svc' => 'svc_broadband',
54 'desc' => 'Real-time export to SQL-backed RADIUS (such as FreeRadius) for broadband services',
55 'options' => \%options,
58 Real-time export of <b>radcheck</b>, <b>radreply</b>, and <b>usergroup</b>
59 tables to any SQL database for
60 <a href="http://www.freeradius.org/">FreeRADIUS</a>
61 or <a href="http://radius.innercite.com/">ICRADIUS</a>.
64 This export is for broadband service access control based on MAC address.
65 For a more typical RADIUS export, see sqlradius.
69 <a href="http://search.cpan.org/dist/DBI/DBI.pm#connect">DBI documentation</a>
71 <a href="http://search.cpan.org/search?mode=module&query=DBD%3A%3A">documentation for your DBD</a>
72 for the exact syntax of a DBI data source.
77 sub rebless { shift; }
80 my($self, $svc_broadband) = (shift, shift);
81 $svc_broadband->mac_addr_formatted(
82 $self->option('mac_case'), $self->option('mac_delimiter')
87 my($self, $svc_broadband) = (shift, shift);
89 if ( length($self->option('ip_addr_as',1))
90 and length($svc_broadband->ip_addr) ) {
91 $reply{$self->option('ip_addr_as')} = $svc_broadband->ip_addr;
97 my($self, $svc_broadband) = (shift, shift);
98 my $password_attrib = $conf->config('radius-password') || 'Password';
100 if ( $self->option('mac_as_password') ) {
101 $check{$password_attrib} = $self->export_username($svc_broadband);
103 elsif ( length( $self->option('radius_password',1)) ) {
104 $check{$password_attrib} = $self->option('radius_password');
109 sub _export_suspend {}
110 sub _export_unsuspend {}
112 sub update_svc {} #do nothing