#!/usr/bin/perl -w use strict; my ($buffer, @pairs, $pair, $name, $value, %FORM); $ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/; if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else { $buffer = $ENV{'QUERY_STRING'}; } my @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%(..)/pack("C", hex($1))/eg; $FORM{$name} = $value; } my $iface = $FORM{"iface"}; my $fctype; if ($FORM{"fctype"}) { $fctype = $FORM{"fctype"}; } else { $fctype = 61; } my $fitype; if ($FORM{"fitype"}) { $fitype = $FORM{"fitype"}; } else { $fitype = "0011"; } my $fslot; if ($FORM{"fslot"}) { $fslot = $FORM{"fslot"}; } else { $fslot = 0; } my $fport = $FORM{"fport"}; if ($FORM{"fport"}) { $fport = $FORM{"fport"}; } else { $fport = 0; } my $subtoname = $FORM{"subtoname"}; my $subtonum = $FORM{"subtonum"}; my %ctypes = (55,"E48PF", 56,"E24PF3", 57,"E48TF3", 58,"E48TF", 59,"EXW4PF", 60,"EXW2PF3", 61,"E90MF", 62,"E48T1F", 63,"EXW16PF", 64,"EXW8PF3", 65,"EXW4PG", 66,"E48PG", 67,"E48TG", 68,"EXW2PG3", 69,"E24PG3", 70,"E24TG3", 71,"S48P4G", 72,"S48P4G3", 73,"EXW16PG", 74,"EXW8PG3"); my %itypes = ("0001","ManagementE", "0011","GigE", "0100","TenGigE", "1100","PortChannel", "1001","Null", "1010","Loopback", "1110","Vlan"); print "Content-type: text/html\n\n"; print < Force 10 Interface Convert

Force 10 Trap Number Conversion Tool

Build Interface Number from Interface Name
\n"; print " / Port

OR

Interface Number from Trap:
Trap Number
EndBODY1 if ($subtoname) { my $binterface = &dec2bin($iface); my $binctype = substr($binterface,18,14); my $ctype = bin2dec($binctype); my $cname = $ctypes{"$ctype"}; my $binitype = substr($binterface,14,4); my $itype = bin2dec($binitype); my $iname = $itypes{"$binitype"}; my $binslot = substr($binterface,0,7); my $slot = bin2dec($binslot) - 1; my $binport = substr($binterface,7,7); my $port = bin2dec($binport) - 1; print "

Number \"$iface\" = \"($cname) $iname$slot/$port\"

\n"; } if ($subtonum) { my $binctype = substr(&dec2bin($fctype),18,14); my $binslot = substr(&dec2bin($fslot + 1),25,7); my $binport = substr(&dec2bin($fport + 1),25,7); my $bininterface = $binslot . $binport . $fitype . $binctype; my $decinterface = &bin2dec($bininterface); print "

Interface \"($ctypes{\"$fctype\"}) $itypes{\"$fitype\"}$fslot/$fport\" = \"$decinterface\"

\n"; } print < EndTAIL sub bin2dec { return unpack("N", pack("B32", substr("0" x 32 . shift, -32))); } sub dec2bin { return unpack("B32", pack("N", shift)); }