# Partial list from http://www.iana.org/assignments/ethernet-numbers my %Ethernet_Type_Name = ( (ETH_TYPE_IP) =>{NAME=>'IP', DECODER => \&Decode_IP}, (ETH_TYPE_ARP) =>{NAME=>'ARP', DECODER => \&Decode_ARP}, (ETH_TYPE_APPLETALK) =>{NAME=>'APPLETALK', DECODER => 0}, 0x8035 =>{NAME=>'RARP', DECODER => \&Decode_ARP}, # (ETH_TYPE_RARP is NOT exported!!!) (ETH_TYPE_SNMP) =>{NAME=>'SNMP', DECODER => 0}, (ETH_TYPE_IPv6) =>{NAME=>'IPv6', DECODER => 0}, (ETH_TYPE_PPP) =>{NAME=>'PPP' ,DECODER => 0} ); ...snip ... if (&Dispach_Decoder_If_Any(\%Ethernet_Type_Name, $eth_obj->{type}, $eth_obj,\$buf)){ # Decoder call failed.. ....snip .... ############################################################### sub Dispach_Decoder_If_Any(){ # Call the appropriate decoder, depending on pkt type my ($NameRef, $index, $Parent_obj, $bufref) = @_; my $Decode_Subroutine = $NameRef->{$index}{DECODER}; if ($Decode_Subroutine){ # Decoder for this proto has been specified !!, call it &$Decode_Subroutine($Parent_obj, $bufref); return 0; # Found the decoder & called it }; return 1; # Did not find a decoder.. }