add an expansion to ethernet source and destination addresses
authorsahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 23 Feb 2006 09:54:08 +0000 (09:54 +0000)
committersahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 23 Feb 2006 09:54:08 +0000 (09:54 +0000)
inside this expansion show
1,    eth.addr      so people can see that this field exists (i think it is futile to use "hidden" fields and expect people to search through the infinitely long list of fields,   better show everything and they will see themself what fuields they can filter on)
2,  bit 0x01 of the first byte to show if it is Multi or Uni-cast
3, bit 0x02 of the first byte to show if it is a locally administrated address or not.
I do use the (to laymen) more descriptive names  "factory default"    instead of LocallyAdminAddr in the true_false string though.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@17378 f5534014-38df-0310-8fa8-9805f1628bb7

epan/dissectors/packet-eth.c

index 06bbd86b6f6611a376edf33c89ab6435ea72e4b5..eec1d2e7d6c7497305d9d1983cdc704dfc15b9cc 100644 (file)
@@ -49,10 +49,13 @@ static int hf_eth_src = -1;
 static int hf_eth_len = -1;
 static int hf_eth_type = -1;
 static int hf_eth_addr = -1;
+static int hf_eth_multicast = -1;
+static int hf_eth_local_admin = -1;
 static int hf_eth_trailer = -1;
 
 static gint ett_ieee8023 = -1;
 static gint ett_ether2 = -1;
+static gint ett_addr = -1;
 
 static dissector_handle_t fw1_handle;
 static heur_dissector_list_t heur_subdissector_list;
@@ -61,6 +64,15 @@ static int eth_tap = -1;
 
 #define ETH_HEADER_SIZE        14
 
+static const true_false_string multicast_tfs = {
+       "This is a MULTICAST frame",
+       "This is a UNICAST frame"
+};
+static const true_false_string local_admin_tfs = {
+       "This is NOT a factory default address",
+       "This is a FACTORY DEFAULT address"
+};
+
 /* These are the Netware-ish names for the different Ethernet frame types.
        EthernetII: The ethernet with a Type field instead of a length field
        Ethernet802.2: An 802.3 header followed by an 802.2 header
@@ -171,6 +183,8 @@ dissect_eth_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
   static eth_hdr       ehdrs[4];
   static int           ehdr_num=0;
   proto_tree           *volatile tree;
+  proto_item           *addr_item;
+  proto_tree           *addr_tree=NULL;
 
   ehdr_num++;
   if(ehdr_num>=4){
@@ -274,12 +288,21 @@ dissect_eth_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
       fh_tree=NULL;
     }
 
-    proto_tree_add_ether(fh_tree, hf_eth_dst, tvb, 0, 6, dst_addr);
-    proto_tree_add_ether(fh_tree, hf_eth_src, tvb, 6, 6, src_addr);
+    addr_item=proto_tree_add_ether(fh_tree, hf_eth_dst, tvb, 0, 6, dst_addr);
+    if(addr_item){
+        addr_tree = proto_item_add_subtree(addr_item, ett_addr);
+    }
+    proto_tree_add_ether(addr_tree, hf_eth_addr, tvb, 0, 6, dst_addr);
+    proto_tree_add_item(addr_tree, hf_eth_multicast, tvb, 0, 3, FALSE);
+    proto_tree_add_item(addr_tree, hf_eth_local_admin, tvb, 0, 3, FALSE);
 
-/* add items for eth.addr filter */
-    proto_tree_add_ether_hidden(fh_tree, hf_eth_addr, tvb, 0, 6, dst_addr);
-    proto_tree_add_ether_hidden(fh_tree, hf_eth_addr, tvb, 6, 6, src_addr);
+    addr_item=proto_tree_add_ether(fh_tree, hf_eth_src, tvb, 6, 6, src_addr);
+    if(addr_item){
+        addr_tree = proto_item_add_subtree(addr_item, ett_addr);
+    }
+    proto_tree_add_ether(addr_tree, hf_eth_addr, tvb, 6, 6, src_addr);
+    proto_tree_add_item(addr_tree, hf_eth_multicast, tvb, 6, 3, FALSE);
+    proto_tree_add_item(addr_tree, hf_eth_local_admin, tvb, 6, 3, FALSE);
 
     dissect_802_3(ehdr->type, is_802_2, tvb, ETH_HEADER_SIZE, pinfo, parent_tree, fh_tree,
                  hf_eth_len, hf_eth_trailer, fcs_len);
@@ -302,11 +325,21 @@ dissect_eth_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
       fh_tree = proto_item_add_subtree(ti, ett_ether2);
     }
 
-    proto_tree_add_ether(fh_tree, hf_eth_dst, tvb, 0, 6, dst_addr);
-    proto_tree_add_ether(fh_tree, hf_eth_src, tvb, 6, 6, src_addr);
-/* add items for eth.addr filter */
-    proto_tree_add_ether_hidden(fh_tree, hf_eth_addr, tvb, 0, 6, dst_addr);
-    proto_tree_add_ether_hidden(fh_tree, hf_eth_addr, tvb, 6, 6, src_addr);
+    addr_item=proto_tree_add_ether(fh_tree, hf_eth_dst, tvb, 0, 6, dst_addr);
+    if(addr_item){
+        addr_tree = proto_item_add_subtree(addr_item, ett_addr);
+    }
+    proto_tree_add_ether(addr_tree, hf_eth_addr, tvb, 0, 6, dst_addr);
+    proto_tree_add_item(addr_tree, hf_eth_multicast, tvb, 0, 3, FALSE);
+    proto_tree_add_item(addr_tree, hf_eth_local_admin, tvb, 0, 3, FALSE);
+
+    addr_item=proto_tree_add_ether(fh_tree, hf_eth_src, tvb, 6, 6, src_addr);
+    if(addr_item){
+        addr_tree = proto_item_add_subtree(addr_item, ett_addr);
+    }
+    proto_tree_add_ether(addr_tree, hf_eth_addr, tvb, 6, 6, src_addr);
+    proto_tree_add_item(addr_tree, hf_eth_multicast, tvb, 6, 3, FALSE);
+    proto_tree_add_item(addr_tree, hf_eth_local_admin, tvb, 6, 3, FALSE);
 
     ethertype(ehdr->type, tvb, ETH_HEADER_SIZE, pinfo, parent_tree, fh_tree, hf_eth_type,
           hf_eth_trailer, fcs_len);
@@ -444,17 +477,28 @@ proto_register_eth(void)
                { "Type",               "eth.type", FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0,
                        "", HFILL }},
                { &hf_eth_addr,
-               { "Source or Destination Address", "eth.addr", FT_ETHER, BASE_NONE, NULL, 0x0,
+               { "Address", "eth.addr", FT_ETHER, BASE_NONE, NULL, 0x0,
                        "Source or Destination Hardware Address", HFILL }},
 
                 { &hf_eth_trailer,
                { "Trailer", "eth.trailer", FT_BYTES, BASE_NONE, NULL, 0x0,
                        "Ethernet Trailer or Checksum", HFILL }},
 
+                { &hf_eth_multicast,
+               { "Multicast", "eth.multicast", FT_BOOLEAN, 24,
+                       VALS(&multicast_tfs), 0x010000,
+                       "Whether this is a multicast frame or not", HFILL }},
+
+                { &hf_eth_local_admin,
+               { "Locally Administrated Address", "eth.local_admin", FT_BOOLEAN, 24,
+                       VALS(&local_admin_tfs), 0x020000,
+                       "Whether this is a \"factory default\" address or not", HFILL }},
+
        };
        static gint *ett[] = {
                &ett_ieee8023,
                &ett_ether2,
+               &ett_addr,
        };
        module_t *eth_module;