1 package ServerPackages;
3 use Exporter;
4 @ISA = ("Exporter");
6 # Each module has to have a function 'process_incoming_msg'. This function works as a interface to gosa-sd and receives the msg hash from gosa-sd. 'process_incoming_function checks, wether it has a function to process the incoming msg and forward the msg to it.
8 use strict;
9 use warnings;
10 use GOSA::GosaSupportDaemon;
12 #use IO::Socket::INET;
13 #use XML::Simple;
14 #use Data::Dumper;
15 #use NetAddr::IP;
16 #use Net::LDAP;
17 #use Socket;
18 #use Net::hostent;
20 my $event_dir = "/usr/lib/gosa-si/server/ServerPackages";
21 use lib "/usr/lib/gosa-si/server/ServerPackages";
23 BEGIN{}
24 END {}
27 ### START #####################################################################
29 # import local events
30 my ($error, $result, $event_hash) = &import_events($event_dir);
31 if ($error == 0) {
32 foreach my $log_line (@$result) {
33 &main::daemon_log("0 DEBUG: ServerPackages - $log_line", 7);
34 }
35 } else {
36 foreach my $log_line (@$result) {
37 &main::daemon_log("0 ERROR: ServerPackages - $log_line", 1);
38 }
39 }
41 ### FUNCTIONS #####################################################################
43 sub get_module_info {
44 my @info = ($main::server_address,
45 $main::foreign_server_key,
46 );
47 return \@info;
48 }
50 sub process_incoming_msg {
51 my ($msg, $msg_hash, $session_id) = @_ ;
52 my $header = @{$msg_hash->{header}}[0];
53 my $source = @{$msg_hash->{source}}[0];
54 my @target_l = @{$msg_hash->{target}};
56 my @msg_l;
57 my @out_msg_l;
59 &main::daemon_log("$session_id DEBUG: ServerPackages: msg to process '$header'", 7);
60 if( exists $event_hash->{$header} ) {
61 # a event exists with the header as name
62 &main::daemon_log("$session_id INFO: found event '$header' at event-module '".$event_hash->{$header}."'", 5);
63 no strict 'refs';
64 @out_msg_l = &{$event_hash->{$header}."::$header"}($msg, $msg_hash, $session_id);
65 } else {
66 }
68 return @out_msg_l;
69 }
71 1;