summaryrefslogtreecommitdiff
path: root/fs_selfservice/FS-SelfService/SelfService
diff options
context:
space:
mode:
Diffstat (limited to 'fs_selfservice/FS-SelfService/SelfService')
-rw-r--r--fs_selfservice/FS-SelfService/SelfService/FreeRadiusVoip.pm61
-rw-r--r--fs_selfservice/FS-SelfService/SelfService/XMLRPC.pm88
2 files changed, 149 insertions, 0 deletions
diff --git a/fs_selfservice/FS-SelfService/SelfService/FreeRadiusVoip.pm b/fs_selfservice/FS-SelfService/SelfService/FreeRadiusVoip.pm
new file mode 100644
index 000000000..0df24f7d7
--- /dev/null
+++ b/fs_selfservice/FS-SelfService/SelfService/FreeRadiusVoip.pm
@@ -0,0 +1,61 @@
+#Add this to the modules section of radiusd.conf
+# perl {
+# #path to this module
+# module=/usr/local/share/perl/5.8.8/FS/SelfService/FreeRadiusVoip.pm
+# func_authorize = authorize;
+# }
+#
+#In the Authorize section
+#Make sure that you have 'files' uncommented. Then add a line containing 'perl'
+# after it.
+#
+# #N/A# Add a line containing 'perl' to the Accounting section.
+#
+# and on debian systems, add this to /etc/init.d/freeradius, with the
+# correct path (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=416266)
+# LD_PRELOAD=/usr/lib/libperl.so.5.8.8
+# export LD_PRELOAD
+
+BEGIN { $FS::SelfService::skip_uid_check = 1; }
+
+use strict;
+use vars qw(%RAD_REQUEST %RAD_REPLY %RAD_CHECK);
+#use Data::Dumper;
+use FS::SelfService qw(call_time);
+
+use constant RLM_MODULE_REJECT=> 0; #immediately reject the request
+use constant RLM_MODULE_FAIL=> 1; #module failed, don't reply
+use constant RLM_MODULE_OK=> 2; #the module is OK, continue
+use constant RLM_MODULE_HANDLED=> 3; #the module handled the request, so stop
+use constant RLM_MODULE_INVALID=> 4; #the module considers the request invalid
+use constant RLM_MODULE_USERLOCK=> 5; #reject the request (user is locked out)
+use constant RLM_MODULE_NOTFOUND=> 6; #user not found
+use constant RLM_MODULE_NOOP=> 7; #module succeeded without doing anything
+use constant RLM_MODULE_UPDATED=> 8; #OK (pairs modified)
+use constant RLM_MODULE_NUMCODES=> 9; #How many return codes there are
+
+sub authorize {
+
+ #&log_request_attributes();
+
+ my $response = call_time( 'src' => $RAD_REQUEST{'Calling-Station-Id'},
+ 'dst' => $RAD_REQUEST{'Called-Station-Id'}, );
+
+ if ( $response->{'error'} ) {
+ $RAD_REPLY{'Reply-Message'} = $response->{'error'};
+ return RLM_MODULE_REJECT;
+ } else {
+ $RAD_REPLY{'Session-Timeout'} = $response->{'seconds'};
+ return RLM_MODULE_OK;
+ }
+
+}
+
+sub log_request_attributes {
+ # This shouldn't be done in production environments!
+ # This is only meant for debugging!
+ for (keys %RAD_REQUEST) {
+ &radiusd::radlog(1, "RAD_REQUEST: $_ = $RAD_REQUEST{$_}");
+ }
+}
+
diff --git a/fs_selfservice/FS-SelfService/SelfService/XMLRPC.pm b/fs_selfservice/FS-SelfService/SelfService/XMLRPC.pm
new file mode 100644
index 000000000..4e0d3e909
--- /dev/null
+++ b/fs_selfservice/FS-SelfService/SelfService/XMLRPC.pm
@@ -0,0 +1,88 @@
+package FS::SelfService::XMLRPC;
+
+=head1 NAME
+
+FS::SelfService::XMLRPC - Freeside XMLRPC accessible self-service API
+
+=head1 SYNOPSIS
+
+=head1 DESCRIPTION
+
+Use this API to implement your own client "self-service" module vi XMLRPC.
+
+Each routine described in L<FS::SelfService> is available vi XMLRPC as the
+method FS.SelfService.XMLRPC.B<method>. All values are passed to the
+selfservice-server in a struct of strings. The return values are in a
+struct as strings, arrays, or structs as appropriate for the values
+described in L<FS::SelfService>.
+
+=head1 BUGS
+
+=head1 SEE ALSO
+
+L<freeside-selfservice-clientd>, L<freeside-selfservice-server>,L<FS::SelfService>
+
+=cut
+
+use strict;
+use vars qw($DEBUG $AUTOLOAD);
+use FS::SelfService;
+
+$DEBUG = 0;
+$FS::SelfService::DEBUG = $DEBUG;
+
+sub AUTOLOAD {
+ my $call = $AUTOLOAD;
+ $call =~ s/^FS::SelfService::XMLRPC:://;
+ if (exists($FS::SelfService::autoload{$call})) {
+ shift; #discard package name;
+ $call = "FS::SelfService::$call";
+ no strict 'refs';
+ &{$call}(@_);
+ }else{
+ die "No such procedure: $call";
+ }
+}
+
+package SOAP::Transport::HTTP::Daemon; # yuck
+
+use POSIX qw(:sys_wait_h);
+
+no warnings 'redefine';
+
+sub handle {
+ my $self = shift->new;
+
+ local $SIG{CHLD} = 'IGNORE';
+
+ACCEPT:
+ while (my $c = $self->accept) {
+
+ my $kid = 0;
+ do {
+ $kid = waitpid(-1, WNOHANG);
+ warn "found kid $kid";
+ } while $kid > 0;
+
+ my $pid = fork;
+ next ACCEPT if $pid;
+
+ if ( not defined $pid ) {
+ warn "fork() failed: $!";
+ $c = undef;
+ } else {
+ while (my $r = $c->get_request) {
+ $self->request($r);
+ $self->SUPER::handle;
+ $c->send_response($self->response);
+ }
+ # replaced ->close, thanks to Sean Meisner <Sean.Meisner@VerizonWireless.com>
+ # shutdown() doesn't work on AIX. close() is used in this case. Thanks to Jos Clijmans <jos.clijmans@recyfin.be>
+ UNIVERSAL::isa($c, 'shutdown') ? $c->shutdown(2) : $c->close();
+ $c->close;
+ }
+ exit;
+ }
+}
+
+1;