1 #Add this to the modules section of radiusd.conf
5 # #module=/usr/local/share/perl/5.10.1/FS/SelfService/FreeRadiusVoip.pm
7 # module=/usr/local/share/perl/5.14.2/FS/SelfService/FreeRadiusVoip.pm
9 # func_authorize = authorize;
13 #In the Authorize section
14 #Make sure that you have 'files' uncommented. Then add a line containing 'perl'
17 # #N/A# Add a line containing 'perl' to the Accounting section.
19 # and on debian 6 systems, add this to /etc/init.d/freeradius, with the
20 # correct path (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=416266)
21 # LD_PRELOAD=/usr/lib/libperl.so.5.10
24 BEGIN { $FS::SelfService::skip_uid_check = 1; }
27 use vars qw(%RAD_REQUEST %RAD_REPLY %RAD_CHECK);
29 use FS::SelfService qw(call_time);
31 use constant RLM_MODULE_REJECT=> 0; #immediately reject the request
32 use constant RLM_MODULE_FAIL=> 1; #module failed, don't reply
33 use constant RLM_MODULE_OK=> 2; #the module is OK, continue
34 use constant RLM_MODULE_HANDLED=> 3; #the module handled the request, so stop
35 use constant RLM_MODULE_INVALID=> 4; #the module considers the request invalid
36 use constant RLM_MODULE_USERLOCK=> 5; #reject the request (user is locked out)
37 use constant RLM_MODULE_NOTFOUND=> 6; #user not found
38 use constant RLM_MODULE_NOOP=> 7; #module succeeded without doing anything
39 use constant RLM_MODULE_UPDATED=> 8; #OK (pairs modified)
40 use constant RLM_MODULE_NUMCODES=> 9; #How many return codes there are
44 #&log_request_attributes();
46 my $response = call_time( 'src' => $RAD_REQUEST{'Calling-Station-Id'},
47 'dst' => $RAD_REQUEST{'Called-Station-Id'}, );
49 if ( $response->{'error'} ) {
50 $RAD_REPLY{'Reply-Message'} = $response->{'error'};
51 return RLM_MODULE_REJECT;
52 } elsif ( $response->{'seconds'} ) {
53 $RAD_REPLY{'Session-Timeout'} = $response->{'seconds'};
54 $RAD_REPLY{'Termination-Action'} = 0;
57 # if the called number is free, put 1 in the Termination-Action attribute
58 $RAD_REPLY{'Termination-Action'} = 1;
64 sub log_request_attributes {
65 # This shouldn't be done in production environments!
66 # This is only meant for debugging!
67 for (keys %RAD_REQUEST) {
68 &radiusd::radlog(1, "RAD_REQUEST: $_ = $RAD_REQUEST{$_}");