Changeset 197


Ignore:
Timestamp:
Jan 5, 2017, 12:01:27 PM (8 years ago)
Author:
g7moreau
Message:
  • Little error when no dev define for ip neight command
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/klask

    r196 r197  
    233233   return %ret if not defined $packed_ip;
    234234   $ret{ipv4_address} = inet_ntoa($packed_ip);
     235   #if ($ret{ipv4_address} !~ m/$RE_IPv4_ADDRESS/) {
     236   #   print "Error: for computer $param_ip_or_host on interface $interface, IP $ret{ipv4_address} is not valide\n";
     237   #   return %ret;
     238   #   }
    235239
    236240   # perl -MSocket -E 'say scalar gethostbyaddr(inet_aton("194.254.66.240"), AF_INET)'
     
    265269   # LANG=C ip neigh show to 194.254.66.62 dev eth331
    266270   # 194.254.66.62 lladdr 00:08:7c:bb:0f:c0 REACHABLE
     271   # LANG=C ip neigh show to 194.254.66.62
     272   # 194.254.66.62 dev eth331 lladdr 00:08:7c:bb:0f:c0 REACHABLE
    267273#   my $cmd_arp  = shell_command "arp -a $param_ip_or_host -i $ret{interface}";
    268274#   if ( $cmd_arp =~ m{ (\S*) \s \( ( $RE_IPv4_ADDRESS ) \) \s at \s ( $RE_MAC_ADDRESS ) }xms ) {
     
    271277   if ($ret{mac_address} eq 'unknow') {
    272278      # Last chance to have the mac_address
    273       my $cmd_arp  = shell_command "ip neigh show to $ret{ipv4_address} dev $ret{interface}";
    274       if ( $cmd_arp =~ m{ ^$RE_IPv4_ADDRESS \s lladdr \s ( $RE_MAC_ADDRESS ) \s }xms ) {
    275          $ret{mac_address} = $1;
     279      if ($ret{interface} eq '*') {
     280         my $cmd_arp  = shell_command "ip neigh show to $ret{ipv4_address}";
     281         if ( $cmd_arp =~ m{ ^$RE_IPv4_ADDRESS \s dev \s ([\w\d\.\:]+) \s lladdr \s ( $RE_MAC_ADDRESS ) \s }xms ) {
     282            ($ret{interface}, $ret{mac_address}) = ($1, $2);
     283            }
     284         }
     285      else {
     286         my $cmd_arp  = shell_command "ip neigh show to $ret{ipv4_address} dev $ret{interface}";
     287         if ( $cmd_arp =~ m{ ^$RE_IPv4_ADDRESS \s lladdr \s ( $RE_MAC_ADDRESS ) \s }xms ) {
     288            $ret{mac_address} = $1;
     289            }
    276290         }
    277291      }
     
    369383      # Ligne à virer car on récupère maintenant le modèle du switch
    370384      #my ($desc, $type) = split m/ : /xms, $sw->{description}, 2;
    371       printf "%-26s 0--------->>>> %-25s %s\n", $sw->{hostname}, $desc, $sw->{model} if $verbose;
     385      printf "%-26s 0--------->>>> %-25s %s\n", $sw->{hostname}, $sw->{description}, $sw->{model} if $verbose;
    372386      }
    373387
Note: See TracChangeset for help on using the changeset viewer.