38a93a57a6efc9edf4ea1e637b400a796e697504
1 package ArpHandler;
3 use Exporter;
4 @ISA = ("Exporter");
6 use strict;
7 use warnings;
8 use GOSA::GosaSupportDaemon;
9 use Getopt::Long;
10 use Config::IniFiles;
11 use POSIX;
12 use Fcntl;
13 use Net::LDAP;
14 use Net::LDAP::LDIF;
15 use Net::LDAP::Entry;
16 use Net::DNS;
17 use Switch;
18 use Data::Dumper;
19 use Socket qw/PF_INET SOCK_DGRAM inet_ntoa sockaddr_in/;
20 use POE qw(Component::Pcap Component::ArpWatch);
22 BEGIN{}
23 END{}
25 my ($timeout, $mailto, $mailfrom, $user, $group);
26 my %daemon_children;
27 my ($ldap, $bind_phrase, $password, $ldap_base, $interface) ;
28 my $hosts_database={};
29 my $resolver=Net::DNS::Resolver->new;
31 $ldap_base = "dc=gonicus,dc=de" ;
32 $interface = "all";
34 sub get_module_info {
35 my @info = (undef,
36 undef,
37 undef,
38 undef,
39 "socket",
40 );
42 $ldap = Net::LDAP->new("ldap.intranet.gonicus.de") or die "$@";
44 if ((!defined($interface)) || $interface eq 'all') {
45 foreach my $device(&get_interfaces) {
46 if(not(&get_mac($device) eq "00:00:00:00:00:00")) {
47 &main::daemon_log("Starting ArpWatch on $device", 1);
48 POE::Session->create(
49 inline_states => {
50 _start => sub {
51 &start(@_,$device);
52 },
53 _stop => sub {
54 $_[KERNEL]->post( eval("arp_watch_$device") => 'shutdown' )
55 },
56 got_packet => \&got_packet,
57 },
58 );
59 }
60 }
61 } else {
62 &main::daemon_log("Starting ArpWatch on $interface", 1);
63 POE::Session->create(
64 inline_states => {
65 _start => \&start,
66 _stop => sub {
67 $_[KERNEL]->post( arp_watch => 'shutdown' )
68 },
69 got_packet => \&got_packet,
70 },
71 );
72 }
74 return \@info;
75 }
77 sub process_incoming_msg {
78 return 0;
79 }
81 sub start {
82 my $device = $_[ARG0] || 'eth0';
83 POE::Component::ArpWatch->spawn(
84 Alias => eval("arp_watch_$device"),
85 Device => 'eth0',
86 Dispatch => 'got_packet',
87 Session => $_[SESSION],
88 );
90 $_[KERNEL]->post( arp_watch => 'run' );
91 }
93 sub got_packet {
94 my $packet = $_[ARG0];
96 if( $packet->{source_haddr} eq "00:00:00:00:00:00" ||
97 $packet->{source_haddr} eq "ff:ff:ff:ff:ff:ff" ||
98 $packet->{source_ipaddr} eq "0.0.0.0") {
99 return;
100 }
102 if(!exists($hosts_database->{$packet->{source_haddr}})) {
103 my $dnsresult= $resolver->search($packet->{source_ipaddr});
104 my $dnsname= (defined($dnsresult))?$dnsresult->{answer}[0]->{ptrdname}:$packet->{source_ipaddr};
105 my $ldap_result=&get_host_from_ldap($packet->{source_haddr});
106 if(exists($ldap_result->{dn})) {
107 $hosts_database->{$packet->{source_haddr}}=$ldap_result;
108 if(!exists($ldap_result->{ipHostNumber})) {
109 $hosts_database->{$packet->{source_haddr}}->{ipHostNumber}=$packet->{source_ipaddr};
110 } else {
111 if(!($ldap_result->{ipHostNumber} eq $packet->{source_ipaddr})) {
112 &main::daemon_log(
113 "Current IP Address ".$packet->{source_ipaddr}.
114 " of host ".$ldap_result->{dnsname}.
115 " differs from LDAP (".$ldap_result->{ipHostNumber}.")", 4);
116 }
117 }
118 $hosts_database->{$packet->{source_haddr}}->{dnsname}=$dnsname;
119 &main::daemon_log("Host was found in LDAP as ".$ldap_result->{dn}, 6);
120 } else {
121 $hosts_database->{$packet->{source_haddr}}={
122 macAddress => $packet->{source_haddr},
123 ipHostNumber => $packet->{source_ipaddr},
124 dnsname => $dnsname,
125 };
126 &main::daemon_log("Host was not found in LDAP (".($hosts_database->{$packet->{source_haddr}}->{dnsname}).")",6);
127 &main::daemon_log(
128 "New Host ".($hosts_database->{$packet->{source_haddr}}->{dnsname}).
129 ": ".$hosts_database->{$packet->{source_haddr}}->{ipHostNumber}.
130 "/".$hosts_database->{$packet->{source_haddr}}->{macAddress},4);
131 }
132 } else {
133 if(!($hosts_database->{$packet->{source_haddr}}->{ipHostNumber} eq $packet->{source_ipaddr})) {
134 &main::daemon_log(
135 "IP Address change of MAC ".$packet->{source_haddr}.
136 ": ".$hosts_database->{$packet->{source_haddr}}->{ipHostNumber}.
137 "->".$packet->{source_ipaddr}, 4);
138 $hosts_database->{$packet->{source_haddr}}->{ipHostNumber}= $packet->{source_ipaddr};
139 }
140 &main::daemon_log("Host already in cache (".($hosts_database->{$packet->{source_haddr}}->{dnsname}).")",6);
141 }
142 }
144 sub get_host_from_ldap {
145 my $mac=shift;
146 my $result={};
148 my $ldap_result= search_ldap_entry(
149 $ldap,
150 $ldap_base,
151 "(|(macAddress=$mac)(dhcpHWAddress=ethernet $mac))"
152 );
154 if($ldap_result->count==1) {
155 if(exists($ldap_result->{entries}[0]) &&
156 exists($ldap_result->{entries}[0]->{asn}->{objectName}) &&
157 exists($ldap_result->{entries}[0]->{asn}->{attributes})) {
159 for my $attribute(@{$ldap_result->{entries}[0]->{asn}->{attributes}}) {
160 if($attribute->{type} eq 'cn') {
161 $result->{cn} = $attribute->{vals}[0];
162 }
163 if($attribute->{type} eq 'macAddress') {
164 $result->{macAddress} = $attribute->{vals}[0];
165 }
166 if($attribute->{type} eq 'dhcpHWAddress') {
167 $result->{dhcpHWAddress} = $attribute->{vals}[0];
168 }
169 if($attribute->{type} eq 'ipHostNumber') {
170 $result->{ipHostNumber} = $attribute->{vals}[0];
171 }
172 }
173 }
174 $result->{dn} = $ldap_result->{entries}[0]->{asn}->{objectName};
175 }
177 return $result;
178 }
180 #=== FUNCTION ================================================================
181 # NAME: get_interfaces
182 # PARAMETERS: none
183 # RETURNS: (list of interfaces)
184 # DESCRIPTION: Uses proc fs (/proc/net/dev) to get list of interfaces.
185 #===============================================================================
186 sub get_interfaces {
187 my @result;
188 my $PROC_NET_DEV= ('/proc/net/dev');
190 open(PROC_NET_DEV, "<$PROC_NET_DEV")
191 or die "Could not open $PROC_NET_DEV";
193 my @ifs = <PROC_NET_DEV>;
195 close(PROC_NET_DEV);
197 # Eat first two line
198 shift @ifs;
199 shift @ifs;
201 chomp @ifs;
202 foreach my $line(@ifs) {
203 my $if= (split /:/, $line)[0];
204 $if =~ s/^\s+//;
205 push @result, $if;
206 }
208 return @result;
209 }
211 #=== FUNCTION ================================================================
212 # NAME: get_mac
213 # PARAMETERS: interface name (i.e. eth0)
214 # RETURNS: (mac address)
215 # DESCRIPTION: Uses ioctl to get mac address directly from system.
216 #===============================================================================
217 sub get_mac {
218 my $ifreq= shift;
219 my $result;
220 if ($ifreq && length($ifreq) > 0) {
221 if($ifreq eq "all") {
222 $result = "00:00:00:00:00:00";
223 } else {
224 my $SIOCGIFHWADDR= 0x8927; # man 2 ioctl_list
226 socket SOCKET, PF_INET, SOCK_DGRAM, getprotobyname('ip')
227 or die "socket: $!";
229 if(ioctl SOCKET, $SIOCGIFHWADDR, $ifreq) {
230 my ($if, $mac)= unpack 'h36 H12', $ifreq;
232 if (length($mac) > 0) {
233 $mac=~ m/^([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])$/;
234 $mac= sprintf("%s:%s:%s:%s:%s:%s", $1, $2, $3, $4, $5, $6);
235 $result = $mac;
236 }
237 }
238 }
239 }
240 return $result;
241 }
243 #=== FUNCTION ================================================================
244 # NAME: add_ldap_entry
245 # PURPOSE: adds an element to ldap-tree
246 # PARAMETERS:
247 # RETURNS: none
248 # DESCRIPTION: ????
249 # THROWS: no exceptions
250 # COMMENTS: none
251 # SEE ALSO: n/a
252 #===============================================================================
253 #sub add_ldap_entry {
254 # my ($ldap_tree, $ldap_base, $mac, $gotoSysStatus, $ip, $interface, $desc) = @_;
255 # my $dn = "cn=$mac,ou=incoming,$ldap_base";
256 # my $s_res = &search_ldap_entry($ldap_tree, $ldap_base, "(|(macAddress=$mac)(dhcpHWAddress=ethernet $mac))");
257 # my $c_res = $s_res->count;
258 # if($c_res == 1) {
259 # daemon_log("WARNING: macAddress $mac already in LDAP", 1);
260 # return;
261 # } elsif($c_res > 0) {
262 # daemon_log("ERROR: macAddress $mac exists $c_res times in LDAP", 1);
263 # return;
264 # }
265 #
266 # # create LDAP entry
267 # my $entry = Net::LDAP::Entry->new( $dn );
268 # $entry->dn($dn);
269 # $entry->add("objectClass" => "goHard");
270 # $entry->add("cn" => $mac);
271 # $entry->add("macAddress" => $mac);
272 # if(defined $gotoSysStatus) {$entry->add("gotoSysStatus" => $gotoSysStatus)}
273 # if(defined $ip) {$entry->add("ipHostNumber" => $ip) }
274 # #if(defined $interface) { }
275 # if(defined $desc) {$entry->add("description" => $desc) }
276 #
277 # # submit entry to LDAP
278 # my $result = $entry->update ($ldap_tree);
279 #
280 # # for $result->code constants please look at Net::LDAP::Constant
281 # my $log_time = localtime( time );
282 # if($result->code == 68) { # entry already exists
283 # daemon_log("WARNING: $log_time: $dn ".$result->error, 3);
284 # } elsif($result->code == 0) { # everything went fine
285 # daemon_log("$log_time: add entry $dn to ldap", 1);
286 # } else { # if any other error occur
287 # daemon_log("ERROR: $log_time: $dn, ".$result->code.", ".$result->error, 1);
288 # }
289 # return;
290 #}
293 #=== FUNCTION ================================================================
294 # NAME: change_ldap_entry
295 # PURPOSE: ????
296 # PARAMETERS: ????
297 # RETURNS: ????
298 # DESCRIPTION: ????
299 # THROWS: no exceptions
300 # COMMENTS: none
301 # SEE ALSO: n/a
302 #===============================================================================
303 #sub change_ldap_entry {
304 # my ($ldap_tree, $ldap_base, $mac, $gotoSysStatus ) = @_;
305 #
306 # # check if ldap_entry exists or not
307 # my $s_res = &search_ldap_entry($ldap_tree, $ldap_base, "(|(macAddress=$mac)(dhcpHWAddress=ethernet $mac))");
308 # my $c_res = $s_res->count;
309 # if($c_res == 0) {
310 # daemon_log("WARNING: macAddress $mac not in LDAP", 1);
311 # return;
312 # } elsif($c_res > 1) {
313 # daemon_log("ERROR: macAddress $mac exists $c_res times in LDAP", 1);
314 # return;
315 # }
316 #
317 # my $s_res_entry = $s_res->pop_entry();
318 # my $dn = $s_res_entry->dn();
319 # my $result = $ldap->modify( $dn, replace => {'gotoSysStatus' => $gotoSysStatus } );
320 #
321 # # for $result->code constants please look at Net::LDAP::Constant
322 # my $log_time = localtime( time );
323 # if($result->code == 32) { # entry doesnt exists
324 # &add_ldap_entry($mac, $gotoSysStatus);
325 # } elsif($result->code == 0) { # everything went fine
326 # daemon_log("$log_time: entry $dn changed successful", 1);
327 # } else { # if any other error occur
328 # daemon_log("ERROR: $log_time: $dn, ".$result->code.", ".$result->error, 1);
329 # }
330 #
331 # return;
332 #}
334 #=== FUNCTION ================================================================
335 # NAME: search_ldap_entry
336 # PURPOSE: ????
337 # PARAMETERS: [Net::LDAP] $ldap_tree - object of an ldap-tree
338 # string $sub_tree - dn of the subtree the search is performed
339 # string $search_string - either a string or a Net::LDAP::Filter object
340 # RETURNS: [Net::LDAP::Search] $msg - result object of the performed search
341 # DESCRIPTION: ????
342 # THROWS: no exceptions
343 # COMMENTS: none
344 # SEE ALSO: n/a
345 #===============================================================================
346 sub search_ldap_entry {
347 my ($ldap_tree, $sub_tree, $search_string) = @_;
348 my $msg = $ldap_tree->search( # perform a search
349 base => $sub_tree,
350 filter => $search_string,
351 ) or daemon_log("cannot perform search at ldap: $@", 1);
352 # if(defined $msg) {
353 # print $sub_tree."\t".$search_string."\t";
354 # print $msg->count."\n";
355 # foreach my $entry ($msg->entries) { $entry->dump; };
356 # }
358 return $msg;
359 }
363 #========= MAIN = main ========================================================
364 #daemon_log( "####### START DAEMON ######\n", 1 );
365 #&check_cmdline_param ;
366 #&check_pid;
367 #&open_fifo($fifo_path);
368 #
369 ## Just fork, if we"re not in foreground mode
370 #if( ! $foreground ) { $pid = fork(); }
371 #else { $pid = $$; }
372 #
373 ## Do something useful - put our PID into the pid_file
374 #if( 0 != $pid ) {
375 # open( LOCK_FILE, ">$pid_file" );
376 # print LOCK_FILE "$pid\n";
377 # close( LOCK_FILE );
378 # if( !$foreground ) { exit( 0 ) };
379 #}
380 #
381 #
382 #if( not -p $fifo_path ) { die "fifo file disappeared\n" }
383 #if($c_res == 1) {
384 # daemon_log("WARNING: macAddress $mac already in LDAP", 1);
385 # return;
386 # } elsif($c_res > 0) {
387 # daemon_log("ERROR: macAddress $mac exists $c_res times in LDAP", 1);
388 # return;
389 # }
390 #
391 # # create LDAP entry
392 # my $entry = Net::LDAP::Entry->new( $dn );
393 # $entry->dn($dn);
394 # $entry->add("objectClass" => "goHard");
395 # $entry->add("cn" => $mac);
396 # $entry->add("macAddress" => $mac);
397 # if(defined $gotoSysStatus) {$entry->add("gotoSysStatus" => $gotoSysStatus)}
398 # if(defined $ip) {$entry->add("ipHostNumber" => $ip) }
399 # #if(defined $interface) { }
400 # if(defined $desc) {$entry->add("description" => $desc) }
401 #
402 # # submit entry to LDAP
403 # my $result = $entry->update ($ldap_tree);
404 #
405 # # for $result->code constants please look at Net::LDAP::Constant
406 # my $log_time = localtime( time );
407 # if($result->code == 68) { # entry already exists
408 # daemon_log("WARNING: $log_time: $dn ".$result->error, 3);
409 # } elsif($result->code == 0) { # everything went fine
410 # daemon_log("$log_time: add entry $dn to ldap", 1);
411 # } else { # if any other error occur
412 # daemon_log("ERROR: $log_time: $dn, ".$result->code.", ".$result->error, 1);
413 # }
414 # return;
415 #}
418 #=== FUNCTION ================================================================
419 # NAME: change_ldap_entry
420 # PURPOSE: ????
421 # PARAMETERS: ????
422 # RETURNS: ????
423 # DESCRIPTION: ????
424 # THROWS: no exceptions
425 # COMMENTS: none
426 # SEE ALSO: n/a
427 #===============================================================================
428 #sub change_ldap_entry {
429 # my ($ldap_tree, $ldap_base, $mac, $gotoSysStatus ) = @_;
430 #
431 # # check if ldap_entry exists or not
432 # my $s_res = &search_ldap_entry($ldap_tree, $ldap_base, "(|(macAddress=$mac)(dhcpHWAddress=ethernet $mac))");
433 # my $c_res = $s_res->count;
434 # if($c_res == 0) {
435 # daemon_log("WARNING: macAddress $mac not in LDAP", 1);
436 # return;
437 # } elsif($c_res > 1) {
438 # daemon_log("ERROR: macAddress $mac exists $c_res times in LDAP", 1);
439 # return;
440 # }
441 #
442 # my $s_res_entry = $s_res->pop_entry();
443 # my $dn = $s_res_entry->dn();
444 # my $result = $ldap->modify( $dn, replace => {'gotoSysStatus' => $gotoSysStatus } );
445 #
446 # # for $result->code constants please look at Net::LDAP::Constant
447 # my $log_time = localtime( time );
448 # if($result->code == 32) { # entry doesnt exists
449 # &add_ldap_entry($mac, $gotoSysStatus);
450 # } elsif($result->code == 0) { # everything went fine
451 # daemon_log("$log_time: entry $dn changed successful", 1);
452 # } else { # if any other error occur
453 # daemon_log("ERROR: $log_time: $dn, ".$result->code.", ".$result->error, 1);
454 # }
455 #
456 # return;
457 #}
459 #=== FUNCTION ================================================================
460 # NAME: search_ldap_entry
461 # PURPOSE: ????
462 # PARAMETERS: [Net::LDAP] $ldap_tree - object of an ldap-tree
463 # string $sub_tree - dn of the subtree the search is performed
464 # string $search_string - either a string or a Net::LDAP::Filter object
465 # RETURNS: [Net::LDAP::Search] $msg - result object of the performed search
466 # DESCRIPTION: ????
467 # THROWS: no exceptions
468 # COMMENTS: none
469 # SEE ALSO: n/a
470 #===============================================================================
471 #sub search_ldap_entry {
472 # my ($ldap_tree, $sub_tree, $search_string) = @_;
473 # my $msg = $ldap_tree->search( # perform a search
474 # base => $sub_tree,
475 # filter => $search_string,
476 # ) or daemon_log("cannot perform search at ldap: $@", 1);
477 ## if(defined $msg) {
478 ## print $sub_tree."\t".$search_string."\t";
479 ## print $msg->count."\n";
480 ## foreach my $entry ($msg->entries) { $entry->dump; };
481 ## }
482 #
483 # return $msg;
484 #}
488 #========= MAIN = main ========================================================
489 #daemon_log( "####### START DAEMON ######\n", 1 );
490 #&check_cmdline_param ;
491 #&check_pid;
492 #&open_fifo($fifo_path);
493 #
494 ## Just fork, if we"re not in foreground mode
495 #if( ! $foreground ) { $pid = fork(); }
496 #else { $pid = $$; }
497 #
498 ## Do something useful - put our PID into the pid_file
499 #if( 0 != $pid ) {
500 # open( LOCK_FILE, ">$pid_file" );
501 # print LOCK_FILE "$pid\n";
502 # close( LOCK_FILE );
503 # if( !$foreground ) { exit( 0 ) };
504 #}
505 #
506 #
507 #if( not -p $fifo_path ) { die "fifo file disappeared\n" }
508 #sysopen(FIFO, $fifo_path, O_RDONLY) or die "can't read from $fifo_path: $!" ;
509 #
510 #while( 1 ) {
511 # # checke alle prozesse im hash daemon_children ob sie noch aktiv sind, wenn
512 # # nicht, dann entferne prozess aus hash
513 # while( (my $key, my $val) = each( %daemon_children) ) {
514 # my $status = waitpid( $key, &WNOHANG) ;
515 # if( $status == -1 ) {
516 # delete $daemon_children{$key} ;
517 # daemon_log("childprocess finished: $key", 3) ;
518 # }
519 # }
520 #
521 # # ist die max_process anzahl von prozesskindern erreicht, dann warte und
522 # # prüfe erneut, ob in der zwischenzeit prozesse fertig geworden sind
523 # if( keys( %daemon_children ) >= $max_process ) {
524 # sleep($max_process_timeout) ;
525 # next ;
526 # }
527 #
528 # my $msg = <FIFO>;
529 # if( not defined( $msg )) { next ; }
530 #
531 # chomp( $msg );
532 # if( length( $msg ) == 0 ) { next ; }
533 #
534 # my $forked_pid = fork();
535 ##=== PARENT = parent ==========================================================
536 # if ( $forked_pid != 0 ) {
537 # daemon_log("childprocess forked: $forked_pid", 3) ;
538 # $daemon_children{$forked_pid} = 0 ;
539 # }
540 ##=== CHILD = child ============================================================
541 # else {
542 # # parse the incoming message from arp, split the message and return
543 # # the values in an array. not defined values are set to "none"
544 # #my ($mac, $ip, $interface, $arp_sig, $desc) = &parse_input( $msg ) ;
545 # daemon_log( "childprocess read from arp: $fifo_path\nline: $msg", 3);
546 # my ($mac, $ip, $interface, $arp_sig, $desc) = split('\s', $msg, 5);
547 #
548 # # create connection to LDAP
549 # $#sysopen(FIFO, $fifo_path, O_RDONLY) or die "can't read from $fifo_path: $!" ;
550 #
551 #while( 1 ) {
552 # # checke alle prozesse im hash daemon_children ob sie noch aktiv sind, wenn
553 # # nicht, dann entferne prozess aus hash
554 # while( (my $key, my $val) = each( %daemon_children) ) {
555 # my $status = waitpid( $key, &WNOHANG) ;
556 # if( $status == -1 ) {
557 # delete $daemon_children{$key} ;
558 # daemon_log("childprocess finished: $key", 3) ;
559 # }
560 # }
561 #
562 # # ist die max_process anzahl von prozesskindern erreicht, dann warte und
563 # # prüfe erneut, ob in der zwischenzeit prozesse fertig geworden sind
564 # if( keys( %daemon_children ) >= $max_process ) {
565 # sleep($max_process_timeout) ;
566 # next ;
567 # }
568 #
569 # my $msg = <FIFO>;
570 # if( not defined( $msg )) { next ; }
571 #
572 # chomp( $msg );
573 # if( length( $msg ) == 0 ) { next ; }
574 #
575 # my $forked_pid = fork();
576 ##=== PARENT = parent ==========================================================
577 # if ( $forked_pid != 0 ) {
578 # daemon_log("childprocess forked: $forked_pid", 3) ;
579 # $daemon_children{$forked_pid} = 0 ;
580 # }
581 ##=== CHILD = child ============================================================
582 # else {
583 # # parse the incoming message from arp, split the message and return
584 # # the values in an array. not defined values are set to "none"
585 # #my ($mac, $ip, $interface, $arp_sig, $desc) = &parse_input( $msg ) ;
586 # daemon_log( "childprocess read from arp: $fifo_path\nline: $msg", 3);
587 # my ($mac, $ip, $interface, $arp_sig, $desc) = split('\s', $msg, 5);
588 #
589 # # create connection to LDAP
590 # $ldap = Net::LDAP->new( "localhost" ) or die "$@";
591 # $ldap->bind($bind_phrase,
592 # password => $password,
593 # ) ;
594 #
595 # switch($arp_sig) {
596 # case 0 {&change_ldap_entry($ldap, $ldap_base,
597 # $mac, "ip-changed",
598 # )}
599 # case 1 {&change_ldap_entry($ldap, $ldap_base,
600 # $mac, "mac-not-whitelisted",
601 # )}
602 # case 2 {&change_ldap_entry($ldap, $ldap_base,
603 # $mac, "mac-in-blacklist",
604 # )}
605 # case 3 {&add_ldap_entry($ldap, $ldap_base,
606 # $mac, "new-mac-address", $ip,
607 # $interface, $desc,
608 # )}
609 # case 4 {&change_ldap_entry($ldap, $ldap_base,
610 # $mac, "unauthorized-arp-request",
611 # )}
612 # case 5 {&change_ldap_entry($ldap, $ldap_base,
613 # $mac, "abusive-number-of-arp-requests",
614 # )}
615 # case 6 {&change_ldap_entry($ldap, $ldap_base,
616 # $mac, "ether-and-arp-mac-differs",
617 # )}
618 # case 7 {&change_ldap_entry($ldap, $ldap_base,
619 # $mac, "flood-detected",
620 # )}
621 # case 8 {&add_ldap_entry($ldap, $ldap_base,
622 # $mac, $ip, "new-system",
623 # )}
624 # case 9 {&change_ldap_entry($ldap, $ldap_base,
625 # $mac, "mac-changed",
626 # )}
627 # }
628 #
629 #
630 # ldap search
631 # my $base_phrase = "dc=gonicus,dc=de";
632 # my $filter_phrase = "cn=keinesorge";
633 # my $attrs_phrase = "cn macAdress";
634 # my $msg_search = $ldap->search( base => $base_phrase,
635 # filter => $filter_phrase,
636 # attrs => $attrs_phrase,
637 # );
638 # $msg_search->code && die $msg_search->error;
639 #
640 # my @entries = $msg_search->entries;
641 # my $max = $msg_search->count;
642 # print "anzahl der entries: $max\n";
643 # my $i;
644 # for ( $i = 0 ; $i < $max ; $i++ ) {
645 # my $entry = $msg_search->entry ( $i );
646 # foreach my $attr ( $entry->attributes ) {
647 # if( not $attr eq "cn") {
648 # next;
649 # }
650 # print join( "\n ", $attr, $entry->get_value( $attr ) ), "\n\n";
651 # }
652 # }
653 #
654 # # ldap add
655 #
656 #
657 # $ldap->unbind;
658 # exit;
659 # }
660 #
661 #}
663 1;