Added list-mac-port.
bay-mac-port is obsolete, won't be installed any more.
This commit is contained in:
parent
22e6213acb
commit
46f4512ed3
|
@ -1,14 +1,18 @@
|
|||
# $Id: GNUmakefile,v 1.1 2001-04-11 14:31:28 hjp Exp $
|
||||
# $Id: GNUmakefile,v 1.2 2003-12-03 13:51:47 hjp Exp $
|
||||
|
||||
include GNUmakevars
|
||||
|
||||
clean:
|
||||
|
||||
install: $(SBINDIR)/mac-port-bay $(SBINDIR)/mac-port
|
||||
install: $(SBINDIR)/mac-port $(SBINDIR)/list-mac-port
|
||||
|
||||
include GNUmakerules
|
||||
|
||||
# $Log: GNUmakefile,v $
|
||||
# Revision 1.1 2001-04-11 14:31:28 hjp
|
||||
# Revision 1.2 2003-12-03 13:51:47 hjp
|
||||
# Added list-mac-port.
|
||||
# bay-mac-port is obsolete, won't be installed any more.
|
||||
#
|
||||
# Revision 1.1 2001/04/11 14:31:28 hjp
|
||||
# mac-port: convert mac address to switch port using snmp.
|
||||
#
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# $Id: list-mac-port,v 1.1 2003-12-03 13:51:47 hjp Exp $
|
||||
#
|
||||
# list mac/port mapping of a switch
|
||||
#
|
||||
use strict;
|
||||
|
||||
sub usage {
|
||||
print STDERR "Usage: $0 switch\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
if (@ARGV != 1) {usage();}
|
||||
|
||||
my $switch = $ARGV[0];
|
||||
|
||||
open (W, "snmpwalk $switch public 17.4.3.1.2 |")
|
||||
or die "cannot invoke snmpwalk: $!";
|
||||
|
||||
while(<W>) {
|
||||
my ($p, $port) = split / = /;
|
||||
my @p = split(/\./, $p);
|
||||
my $mac = join(":", map { sprintf("%02x", $_) } @p[-6 .. -1]);
|
||||
|
||||
next if ($mac =~ /^00:e0:63:/); # Ignore internal MAC addresses
|
||||
# of Enterasys switches.
|
||||
print "$switch\t$mac\t$port";
|
||||
}
|
||||
|
||||
|
||||
# $Log: list-mac-port,v $
|
||||
# Revision 1.1 2003-12-03 13:51:47 hjp
|
||||
# Added list-mac-port.
|
||||
# bay-mac-port is obsolete, won't be installed any more.
|
||||
#
|
||||
# Revision 1.1 2001/04/11 14:31:29 hjp
|
||||
# mac-port: convert mac address to switch port using snmp.
|
||||
#
|
||||
|
Loading…
Reference in New Issue