From 199019e26a434afe45c376cfb563ebd6c22d2c90 Mon Sep 17 00:00:00 2001 From: hjp Date: Wed, 11 Apr 2001 14:31:29 +0000 Subject: [PATCH] mac-port: convert mac address to switch port using snmp. --- snmp/GNUmakefile | 14 ++++++++++++++ snmp/mac-port | 31 +++++++++++++++++++++++++++++++ snmp/mac-port-bay | 29 +++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 snmp/GNUmakefile create mode 100755 snmp/mac-port create mode 100755 snmp/mac-port-bay diff --git a/snmp/GNUmakefile b/snmp/GNUmakefile new file mode 100644 index 0000000..6619118 --- /dev/null +++ b/snmp/GNUmakefile @@ -0,0 +1,14 @@ +# $Id: GNUmakefile,v 1.1 2001-04-11 14:31:28 hjp Exp $ + +include GNUmakevars + +clean: + +install: $(SBINDIR)/mac-port-bay $(SBINDIR)/mac-port + +include GNUmakerules + +# $Log: GNUmakefile,v $ +# Revision 1.1 2001-04-11 14:31:28 hjp +# mac-port: convert mac address to switch port using snmp. +# diff --git a/snmp/mac-port b/snmp/mac-port new file mode 100755 index 0000000..c20ad21 --- /dev/null +++ b/snmp/mac-port @@ -0,0 +1,31 @@ +#!/usr/bin/perl -w +# +# $Id: mac-port,v 1.1 2001-04-11 14:31:29 hjp Exp $ +# +# find the port of a baystack 350 T switch to which a given +# mac address is connected. +# +use strict; + +sub usage { + print STDERR "Usage: $0 switch mac-address\n"; + exit(1); +} + + +if (@ARGV != 2) {usage();} + +my @hmac = split(/:/, $ARGV[1]); + +my $switch = $ARGV[0]; + +my @dmac = map { hex } @hmac; + +my $object = "17.4.3.1.2." . join(".", @dmac); + +system("snmpget", $switch, "public", $object); + +# $Log: mac-port,v $ +# Revision 1.1 2001-04-11 14:31:29 hjp +# mac-port: convert mac address to switch port using snmp. +# diff --git a/snmp/mac-port-bay b/snmp/mac-port-bay new file mode 100755 index 0000000..b67f11b --- /dev/null +++ b/snmp/mac-port-bay @@ -0,0 +1,29 @@ +#!/usr/bin/perl -w +# +# $Id: mac-port-bay,v 1.1 2001-04-11 14:31:29 hjp Exp $ +# +# find the port of a baystack 350 T switch to which a given +# mac address is connected. +# +use strict; + +sub usage { + print STDERR "Usage: $0 mac-address\n"; + exit(1); +} + + +if (@ARGV != 1) {usage();} + +my @hmac = split(/:/, $ARGV[0]); + +my @dmac = map { hex } @hmac; + +my $object = "17.4.3.1.2." . join(".", @dmac); + +system("snmpget", "bay-switch-1", "public", $object); + +# $Log: mac-port-bay,v $ +# Revision 1.1 2001-04-11 14:31:29 hjp +# mac-port: convert mac address to switch port using snmp. +#