There was a recent comment about a Usenet positing I made back in 2002 in comp.protocols.snmp.
In the post I was responding to someone looking for information on how to decode the value returned from the ipNetToMediaIfIndex when querying an ERS 8600 switch. Thankfully Shane (Nortel) was able to help me come up with the forumla.
card = ( $value AND 62914560 ) / 4194304 port = (( $value AND 4128768) / 65536 ) + 1
With that formula you could now walk the ipNetToMediaTable and retreieve the entire ARP table providing you the card and port number, MAC address, and IP address for each entry in the table.
The next issue was how to deal with MultiLink Trunk interfaces. In this case (and with my current software code) I build a table of all the MLT interfaces prior to polling the ipNetToMediaTable. I still use Perl but it shouldn’t be very hard to convert to PHP.
# rcMltNumMlts
$nummlts = $sess->get("rcMltNumMlts.0");
for ($i = 1; $i <= $nummlts; $i++) {
# rcMltName
$mltname[$i] = $sess->get("rcMltName.$i");
# rcMltId
$mltindex[$i] = $sess->get("rcMltId.$i");
# rcMltIfIndex
$mltifindex[$i] = $sess->get("rcMltIfIndex.$i");
print "DEBUG: MltId = $i and MltName = $mltname[$i] and MltIndex = $mltindex[$i] and MltIfIndex = $mltifindex[$i]\n" if ($DEBUG);
};Now that we have the rcMltTable in an array we can walk the ipNetToMediaTable and match up any entries. Here’s the code I use (again it’s Perl but you should be able to convert to PHP);
# Evaulate with bitwise operation
$card = (($vals[0] & 62914560) / 4194304);
$port = (($vals[0] & 4128768) / 65536) + 1;
# Evaulate to determine if port is a MLT
if ($card != 0) {
$intf = (((64 * $card) + $port) - 1);
print "DEBUG: $vals[1] address found on card $card port $port\n";
} else {
$mlt = 1;
print "DEBUG: $vals[1] address found on MLT $mltname[$port]\n";
} # end elseHopefully that doesn’t look too complicated. The important piece here is that you need to merge the rcMltTable with the ipNetToMediaTable to get your results. If you name the MLT with something meaningful you can then return that string to the application that is making the query.
I wrote a Perl application that would search the ARP table of an Ethernet Routing Switch 8600 dynamically for a specific IP address entry. Here’s an example of the output;
Nortel Passport 8600 Gigabit Switch IP ARP Table Search Initializing query for sw-ccr-8600.datacenter.acme.org for IP address 1.1.1.10... sysDescr = ERS-8610 (4.1.3.0) sysObjectID = .1.3.6.1.4.1.2272.30 sysUpTime = 169 Days 6 Hours 43 mins 11 secs sysContact = Acme Network Infrastructure Team sysName = sw-ccr-8600.datacenter.acme.org sysLocation = USA Please be patient it may take a while to complete the search... DEVICE FOUND 1.1.1.10 (000AE4753FC9) address found on MLT SMLT-5500 We searched through 1183 forwarding records... That's all folks!
I will look to publish the complete code on my website sometime in the near future.
Cheers!