From 46f4512ed36a7266c5416e31229f9c60938c1770 Mon Sep 17 00:00:00 2001 From: hjp Date: Wed, 3 Dec 2003 13:51:47 +0000 Subject: [PATCH] Added list-mac-port. bay-mac-port is obsolete, won't be installed any more. --- snmp/GNUmakefile | 10 +++++++--- snmp/list-mac-port | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) create mode 100755 snmp/list-mac-port diff --git a/snmp/GNUmakefile b/snmp/GNUmakefile index 6619118..1d23986 100644 --- a/snmp/GNUmakefile +++ b/snmp/GNUmakefile @@ -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. # diff --git a/snmp/list-mac-port b/snmp/list-mac-port new file mode 100755 index 0000000..c203b84 --- /dev/null +++ b/snmp/list-mac-port @@ -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() { + 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. +# +