aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2013-10-25 02:02:02 +0000
committerMichael Mann <mmann78@netscape.net>2013-10-25 02:02:02 +0000
commitc09b328e137c2b320fd881e8e4afb9874f376be1 (patch)
treeb03bef7cc642e0c98e63c7ec082a90052a605dee /epan
parentab0ad4aa1ce2de7ad9c9ed082d649caed5cb5582 (diff)
Pass ieee802154_packet data into the heuristic check instead of using private_data.
svn path=/trunk/; revision=52836
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-ieee802154.c13
-rw-r--r--epan/dissectors/packet-zbee-nwk.c41
2 files changed, 22 insertions, 32 deletions
diff --git a/epan/dissectors/packet-ieee802154.c b/epan/dissectors/packet-ieee802154.c
index 132a49000a..a906817b97 100644
--- a/epan/dissectors/packet-ieee802154.c
+++ b/epan/dissectors/packet-ieee802154.c
@@ -596,7 +596,7 @@ dissect_ieee802154_cc24xx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* have been called to determine what sort of FCS is present.
* The dissect_ieee802154* functions will set the parameters
* in the ieee802154_packet structure, and pass it to this one
- * through the pinfo->private_data pointer.
+ * through the data parameter.
*
* PARAMETERS
* tvbuff_t *tvb - pointer to buffer containing raw packet.
@@ -615,7 +615,6 @@ dissect_ieee802154_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, g
proto_item *volatile proto_root = NULL;
proto_item *hidden_item;
proto_item *ti;
- void *pd_save;
guint offset = 0;
volatile gboolean fcs_ok = TRUE;
@@ -626,11 +625,6 @@ dissect_ieee802154_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, g
ieee802154_short_addr addr16;
ieee802154_hints_t *ieee_hints;
- /* Link our packet info structure into the private data field for the
- * Network-Layer heuristic subdissectors. */
- pd_save = pinfo->private_data;
- pinfo->private_data = packet;
-
packet->short_table = ieee802154_map.short_table;
/* Allocate frame data with hints for upper layers */
@@ -754,7 +748,6 @@ dissect_ieee802154_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, g
else if (packet->dst_addr_mode != IEEE802154_FCF_ADDR_NONE) {
/* Invalid Destination Address Mode. Abort Dissection. */
expert_add_info(pinfo, proto_root, &ei_ieee802154_dst);
- pinfo->private_data = pd_save;
return;
}
@@ -864,7 +857,6 @@ dissect_ieee802154_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, g
else if (packet->src_addr_mode != IEEE802154_FCF_ADDR_NONE) {
/* Invalid Destination Address Mode. Abort Dissection. */
expert_add_info(pinfo, proto_root, &ei_ieee802154_src);
- pinfo->private_data = pd_save;
return;
}
@@ -1077,7 +1069,7 @@ dissect_ieee802154_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, g
/* Beacon and Data packets contain a payload. */
if ((fcs_ok || !ieee802154_fcs_ok) && (tvb_reported_length(payload_tvb)>0)) {
/* Attempt heuristic subdissection. */
- if (!dissector_try_heuristic(ieee802154_heur_subdissector_list, payload_tvb, pinfo, tree, NULL)) {
+ if (!dissector_try_heuristic(ieee802154_heur_subdissector_list, payload_tvb, pinfo, tree, packet)) {
/* Could not subdissect, call the data dissector instead. */
call_dissector(data_handle, payload_tvb, pinfo, tree);
}
@@ -1244,7 +1236,6 @@ dissect_ieee802154_fcs:
/* Flag packet as having a bad crc. */
expert_add_info(pinfo, proto_root, &ei_ieee802154_fcs);
}
- pinfo->private_data = pd_save;
} /* dissect_ieee802154_common */
/*FUNCTION:------------------------------------------------------
diff --git a/epan/dissectors/packet-zbee-nwk.c b/epan/dissectors/packet-zbee-nwk.c
index 5a0944423e..e3bd7e8f85 100644
--- a/epan/dissectors/packet-zbee-nwk.c
+++ b/epan/dissectors/packet-zbee-nwk.c
@@ -46,9 +46,9 @@
/* Function Declarations */
/*************************/
/* Dissector Routines */
-static void dissect_zbee_nwk (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
+static int dissect_zbee_nwk (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data);
static void dissect_zbee_nwk_cmd (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, zbee_nwk_packet* packet);
-static void dissect_zbee_beacon (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
+static int dissect_zbee_beacon (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data);
/* Command Dissector Helpers */
static guint dissect_zbee_nwk_route_req (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
@@ -300,9 +300,9 @@ zbee_get_bit_field(guint input, guint mask)
*---------------------------------------------------------------
*/
static gboolean
-dissect_zbee_nwk_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
+dissect_zbee_nwk_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
- ieee802154_packet *packet = (ieee802154_packet *)pinfo->private_data;
+ ieee802154_packet *packet = (ieee802154_packet *)data;
/* All ZigBee frames must always have a 16-bit source address. */
if (packet->src_addr_mode != IEEE802154_FCF_ADDR_SHORT) {
@@ -311,14 +311,14 @@ dissect_zbee_nwk_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void
/* ZigBee MAC frames must always contain a 16-bit destination address. */
if ( (packet->frame_type == IEEE802154_FCF_DATA) &&
(packet->dst_addr_mode == IEEE802154_FCF_ADDR_SHORT) ) {
- dissect_zbee_nwk(tvb, pinfo, tree);
+ dissect_zbee_nwk(tvb, pinfo, tree, packet);
return TRUE;
}
/* ZigBee MAC Beacons must have the first byte (protocol ID) equal to the
* ZigBee protocol ID. */
if ( (packet->frame_type == IEEE802154_FCF_BEACON) &&
(tvb_get_guint8(tvb, 0) == ZBEE_NWK_BEACON_PROCOL_ID) ) {
- dissect_zbee_beacon(tvb, pinfo, tree);
+ dissect_zbee_beacon(tvb, pinfo, tree, packet);
return TRUE;
}
/* If we get this far, then this packet did not meet the requirements for
@@ -340,8 +340,8 @@ dissect_zbee_nwk_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void
* void
*---------------------------------------------------------------
*/
-static void
-dissect_zbee_nwk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+static int
+dissect_zbee_nwk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
tvbuff_t *payload_tvb = NULL;
@@ -351,7 +351,7 @@ dissect_zbee_nwk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_tree *field_tree = NULL;
zbee_nwk_packet packet;
- ieee802154_packet *ieee_packet = (ieee802154_packet *)pinfo->private_data;
+ ieee802154_packet *ieee_packet = (ieee802154_packet *)data;
guint offset = 0;
static gchar src_addr[32], dst_addr[32]; /* has to be static due to SET_ADDRESS */
@@ -542,9 +542,7 @@ dissect_zbee_nwk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (packet.ext_src) {
packet.src64 = tvb_get_letoh64(tvb, offset);
- if (tree) {
- proto_tree_add_item(nwk_tree, hf_zbee_nwk_src64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
- }
+ proto_tree_add_item(nwk_tree, hf_zbee_nwk_src64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
if (!pinfo->fd->flags.visited && nwk_hints) {
@@ -666,7 +664,7 @@ dissect_zbee_nwk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
payload_tvb = dissect_zbee_secure(tvb, pinfo, nwk_tree, offset);
if (payload_tvb == NULL) {
/* If Payload_tvb is NULL, then the security dissector cleaned up. */
- return;
+ return tvb_length(tvb);
}
}
/* Plaintext payload. */
@@ -686,6 +684,8 @@ dissect_zbee_nwk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* Invalid type. */
call_dissector(data_handle, payload_tvb, pinfo, tree);
}
+
+ return tvb_length(tvb);
} /* dissect_zbee_nwk */
/*FUNCTION:------------------------------------------------------
@@ -1388,9 +1388,9 @@ dissect_zbee_nwk_update(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gui
* void
*---------------------------------------------------------------
*/
-static void dissect_zbee_beacon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+static int dissect_zbee_beacon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
- ieee802154_packet *packet = (ieee802154_packet *)pinfo->private_data;
+ ieee802154_packet *packet = (ieee802154_packet *)data;
proto_item *beacon_root = NULL;
proto_tree *beacon_tree = NULL;
@@ -1414,10 +1414,7 @@ static void dissect_zbee_beacon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t
col_append_fstr(pinfo->cinfo, COL_INFO, "Beacon, Src: 0x%04x", packet->src16);
/* Get and display the protocol id, must be 0 on all ZigBee beacons. */
- temp = tvb_get_guint8(tvb, offset);
- if (tree) {
- proto_tree_add_uint(beacon_tree, hf_zbee_beacon_protocol, tvb, offset, 1, temp);
- }
+ proto_tree_add_uint(beacon_tree, hf_zbee_beacon_protocol, tvb, offset, 1, ENC_NA);
offset += 1;
/* Get and display the stack profile and protocol version. */
@@ -1500,6 +1497,8 @@ static void dissect_zbee_beacon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t
/* Dump the leftover to the data dissector. */
call_dissector(data_handle, leftover_tvb, pinfo, root);
}
+
+ return tvb_length(tvb);
} /* dissect_zbee_beacon */
/*FUNCTION:------------------------------------------------------
@@ -1824,8 +1823,8 @@ void proto_register_zbee_nwk(void)
proto_register_subtree_array(ett, array_length(ett));
/* Register the dissectors with Wireshark. */
- register_dissector(ZBEE_PROTOABBREV_NWK, dissect_zbee_nwk, proto_zbee_nwk);
- register_dissector("zbee_beacon", dissect_zbee_beacon, proto_zbee_nwk);
+ new_register_dissector(ZBEE_PROTOABBREV_NWK, dissect_zbee_nwk, proto_zbee_nwk);
+ new_register_dissector("zbee_beacon", dissect_zbee_beacon, proto_zbee_nwk);
/* Register the Security dissector. */
zbee_security_register(NULL, proto_zbee_nwk);