Wireshark-dev: [Wireshark-dev] Issue with packet-ieee802154.c

From: Robert Cragie <robert.cragie@xxxxxxxxxxxxx>
Date: Tue, 20 Jan 2015 18:29:26 +0000
Recent commit ecaa1f8d21b1284a267ca08d4d698ca99fbcab83 (onvert variables that were static just because of SET_ADDRESS macro to use the proper pinfo->pool instead) has introduced an error in packet-ieee802154.c. The extended addresses were network byte order before but are now being interpreted the other way around. Perhaps there is still a way of using TVB_SET_ADDRESS but it is not obvious to me right now. I reverted as follows (note I am using an experimental version of packet-ieee802154.c so the line numbers may be different):

diff --git a/epan/dissectors/packet-ieee802154.c b/epan/dissectors/packet-ieee802154.c
index 0c2bc84..ca0b8cb 100644
--- a/epan/dissectors/packet-ieee802154.c
+++ b/epan/dissectors/packet-ieee802154.c
@@ -768,16 +768,21 @@ dissect_ieee802154_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, g
         offset += 2;
     }
     else if (packet->dst_addr_mode == IEEE802154_FCF_ADDR_EXT) {
+        static guint64 addr; /* has to be static due to SET_ADDRESS */
+
         /* Get the address */
         packet->dst64 = tvb_get_letoh64(tvb, offset);
 
+        /* Copy and convert the address to network byte order. */
+        addr = pntoh64(&(packet->dst64));
+
         /* Display the destination address. */
         /* XXX - OUI resolution doesn't happen when displaying resolved
          * EUI64 addresses; that should probably be fixed in
          * epan/addr_resolv.c.
          */
-        TVB_SET_ADDRESS(&pinfo->dl_dst, AT_EUI64, tvb, offset, 8);
-        TVB_SET_ADDRESS(&pinfo->dst, AT_EUI64, tvb, offset, 8);
+        SET_ADDRESS(&pinfo->dl_dst, AT_EUI64, 8, &addr);
+        SET_ADDRESS(&pinfo->dst, AT_EUI64, 8, &addr);
         if (tree) {
             proto_tree_add_item(ieee802154_tree, hf_ieee802154_dst64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
             proto_item_append_text(proto_root, ", Dst: %s", eui64_to_display(wmem_packet_scope(), packet->dst64));
@@ -876,16 +881,21 @@ dissect_ieee802154_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, g
         offset += 2;
     }
     else if (packet->src_addr_mode == IEEE802154_FCF_ADDR_EXT) {
+        static guint64 addr; /* has to be static due to SET_ADDRESS */
+
         /* Get the address. */
         packet->src64 = tvb_get_letoh64(tvb, offset);
 
+        /* Copy and convert the address to network byte order. */
+        addr = pntoh64(&(packet->src64));
+
         /* Display the source address. */
         /* XXX - OUI resolution doesn't happen when displaying resolved
          * EUI64 addresses; that should probably be fixed in
          * epan/addr_resolv.c.
          */
-        TVB_SET_ADDRESS(&pinfo->dl_src, AT_EUI64, tvb, offset, 8);
-        TVB_SET_ADDRESS(&pinfo->src, AT_EUI64, tvb, offset, 8);
+        SET_ADDRESS(&pinfo->dl_src, AT_EUI64, 8, &addr);
+        SET_ADDRESS(&pinfo->src, AT_EUI64, 8, &addr);
         if (tree) {
             proto_tree_add_item(ieee802154_tree, hf_ieee802154_src64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
             proto_item_append_text(proto_root, ", Src: %s", eui64_to_display(wmem_packet_scope(), packet->src64));