summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 83369b3)
raw | patch | inline | side by side (parent: 83369b3)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 3 Sep 2008 09:21:20 +0000 (09:21 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 3 Sep 2008 09:21:20 +0000 (09:21 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12353 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/gosa-si-client | patch | blob | history | |
gosa-si/modules/GosaSupportDaemon.pm | patch | blob | history |
diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client
index d653aaad383596a36c2a9a60afcc8cbbe6935022..2e5a36166d8423204bb0bca7f40762efe720cdd1 100755 (executable)
--- a/gosa-si/gosa-si-client
+++ b/gosa-si/gosa-si-client
return $result;
}
-sub get_local_ip_for_remote_ip {
- my $server_ip= shift;
- my $result="0.0.0.0";
-
- if($server_ip =~ /^(\d\d?\d?\.){3}\d\d?\d?$/) {
- # client should always have a 'valid' ip-address, which is available from other hosts too,
- # 127.0.0.1 says nothing to foreign host
- #if($server_ip eq "127.0.0.1") {
- # $result="127.0.0.1";
- #} else {
- my $PROC_NET_ROUTE= ('/proc/net/route');
-
- open(PROC_NET_ROUTE, "<$PROC_NET_ROUTE")
- or die "Could not open $PROC_NET_ROUTE";
-
- my @ifs = <PROC_NET_ROUTE>;
-
- close(PROC_NET_ROUTE);
-
- # Eat header line
- shift @ifs;
- chomp @ifs;
- foreach my $line(@ifs) {
- my ($Iface,$Destination,$Gateway,$Flags,$RefCnt,$Use,$Metric,$Mask,$MTU,$Window,$IRTT)=split(/\s/, $line);
- my $destination;
- my $mask;
- my ($d,$c,$b,$a)=unpack('a2 a2 a2 a2', $Destination);
- $destination= sprintf("%d.%d.%d.%d", hex($a), hex($b), hex($c), hex($d));
- ($d,$c,$b,$a)=unpack('a2 a2 a2 a2', $Mask);
- $mask= sprintf("%d.%d.%d.%d", hex($a), hex($b), hex($c), hex($d));
- if(new NetAddr::IP($server_ip)->within(new NetAddr::IP($destination, $mask))) {
- # destination matches route, save mac and exit
- $result= &get_ip($Iface);
- last;
- }
- }
- #}
- } else {
- daemon_log("get_local_ip_for_remote_ip was called with a non-ip parameter: $server_ip", 1);
- }
- return $result;
-}
-
sub generate_hw_digest {
my $hw_data;
index af77b7f4add9a5ea4bf193c3a67f4fa8cf1577a9..5de3ec4524d6632ccbee2478561596e0a1863f48 100644 (file)
"get_interfaces",
"get_mac_for_interface",
"get_local_ip_for_remote_ip",
- "get_local_mac_for_remote_ip",
"is_local",
"run_as",
"inform_all_other_si_server",
my $remote_ip= shift;
my $result="0.0.0.0";
- if($remote_ip =~ /^(\d\d?\d?\.){3}\d\d?\d?$/) {
- if($remote_ip eq "127.0.0.1") {
- $result = "127.0.0.1";
- } else {
- my $PROC_NET_ROUTE= ('/proc/net/route');
-
- open(PROC_NET_ROUTE, "<$PROC_NET_ROUTE")
- or die "Could not open $PROC_NET_ROUTE";
-
- my @ifs = <PROC_NET_ROUTE>;
-
- close(PROC_NET_ROUTE);
-
- # Eat header line
- shift @ifs;
- chomp @ifs;
- foreach my $line(@ifs) {
- my ($Iface,$Destination,$Gateway,$Flags,$RefCnt,$Use,$Metric,$Mask,$MTU,$Window,$IRTT)=split(/\s/, $line);
- my $destination;
- my $mask;
- my ($d,$c,$b,$a)=unpack('a2 a2 a2 a2', $Destination);
- $destination= sprintf("%d.%d.%d.%d", hex($a), hex($b), hex($c), hex($d));
- ($d,$c,$b,$a)=unpack('a2 a2 a2 a2', $Mask);
- $mask= sprintf("%d.%d.%d.%d", hex($a), hex($b), hex($c), hex($d));
- if(new NetAddr::IP($remote_ip)->within(new NetAddr::IP($destination, $mask))) {
- # destination matches route, save mac and exit
- $result= &get_ip($Iface);
- last;
- }
- }
- }
- } else {
+ if($remote_ip =~ /^(\d\d?\d?\.){3}\d\d?\d?$/) {
+ my $PROC_NET_ROUTE= ('/proc/net/route');
+
+ open(PROC_NET_ROUTE, "<$PROC_NET_ROUTE")
+ or die "Could not open $PROC_NET_ROUTE";
+
+ my @ifs = <PROC_NET_ROUTE>;
+
+ close(PROC_NET_ROUTE);
+
+ # Eat header line
+ shift @ifs;
+ chomp @ifs;
+ foreach my $line(@ifs) {
+ my ($Iface,$Destination,$Gateway,$Flags,$RefCnt,$Use,$Metric,$Mask,$MTU,$Window,$IRTT)=split(/\s/, $line);
+ my $destination;
+ my $mask;
+ my ($d,$c,$b,$a)=unpack('a2 a2 a2 a2', $Destination);
+ $destination= sprintf("%d.%d.%d.%d", hex($a), hex($b), hex($c), hex($d));
+ ($d,$c,$b,$a)=unpack('a2 a2 a2 a2', $Mask);
+ $mask= sprintf("%d.%d.%d.%d", hex($a), hex($b), hex($c), hex($d));
+ if(new NetAddr::IP($remote_ip)->within(new NetAddr::IP($destination, $mask))) {
+ # destination matches route, save mac and exit
+ $result= &get_ip($Iface);
+ last;
+ }
+ }
+ } else {
daemon_log("0 WARNING: get_local_ip_for_remote_ip() was called with a non-ip parameter: '$remote_ip'", 1);
}
return $result;
}
-sub get_local_mac_for_remote_ip {
- my $ip = shift;
-
- my $local_ip = &get_local_ip_for_remote_ip($ip);
- my $network_interface= &get_interface_for_ip($local_ip);
- my $mac = &get_mac_for_interface($network_interface);
-
- return $mac
-}
-
-
#=== FUNCTION ================================================================
# NAME: is_local
# PARAMETERS: Server Address