From d67f89f45bef2d44e7e23fa2b7c2ae6b4daeb3de Mon Sep 17 00:00:00 2001 From: Anders Broman Date: Fri, 30 Nov 2012 11:31:28 +0000 Subject: From Michal Labedzki: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Couple of coding style changes and fixes for: warning: declaration of ‘k_frame_number’ shadows a previous local warning: assignment discards qualifiers from pointer target type Part of: https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5032 svn path=/trunk/; revision=46304 --- epan/dissectors/packet-bthci_acl.c | 86 +++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 44 deletions(-) (limited to 'epan/dissectors/packet-bthci_acl.c') diff --git a/epan/dissectors/packet-bthci_acl.c b/epan/dissectors/packet-bthci_acl.c index 894fb5a649..e5051f3cb6 100644 --- a/epan/dissectors/packet-bthci_acl.c +++ b/epan/dissectors/packet-bthci_acl.c @@ -69,21 +69,20 @@ typedef struct _chandle_data_t { static emem_tree_t *chandle_tree = NULL; static const value_string pb_flag_vals[] = { - {0, "First Non-automatically Flushable Packet"}, - {1, "Continuing Fragment"}, - {2, "First Automatically Flushable Packet"}, - {0, NULL } + { 0, "First Non-automatically Flushable Packet" }, + { 1, "Continuing Fragment" }, + { 2, "First Automatically Flushable Packet" }, + { 0, NULL } }; static const value_string bc_flag_vals[] = { - {0, "Point-To-Point"}, - {1, "Active Broadcast"}, - {2, "Piconet Broadcast"}, - {0, NULL } + { 0, "Point-To-Point" }, + { 1, "Active Broadcast" }, + { 2, "Piconet Broadcast" }, + { 0, NULL } }; - /* Code to actually dissect the packets */ static void dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) @@ -106,11 +105,11 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) guint32 k_interface_id; guint32 k_adapter_id; remote_bdaddr_t *remote_bdaddr; - gchar *localhost_name; + const gchar *localhost_name; guint8 localhost_bdaddr[6]; - gchar *localhost_ether_addr; + const gchar *localhost_ether_addr; gchar *localhost_addr_name; - gint localhost_length; + gint localhost_length; localhost_bdaddr_entry_t *localhost_bdaddr_entry; localhost_name_entry_t *localhost_name_entry; @@ -131,14 +130,14 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) hci_data = (hci_data_t *) pinfo->private_data; acl_data = ep_alloc(sizeof(bthci_acl_data_t)); - acl_data->chandle = flags&0x0fff; + acl_data->chandle = flags & 0x0fff; pd_save = pinfo->private_data; pinfo->private_data = acl_data; - k_interface_id = hci_data->interface_id; - k_adapter_id = hci_data->adapter_id; + k_interface_id = hci_data->interface_id; + k_adapter_id = hci_data->adapter_id; k_connection_handle = flags & 0x0fff; - k_frame_number = pinfo->fd->num; + k_frame_number = pinfo->fd->num; key[0].length = 1; key[0].key = &k_interface_id; @@ -158,19 +157,18 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) remote_bdaddr->chandle == (flags & 0x0fff)) { guint32 k_bd_addr_oui; guint32 k_bd_addr_id; - guint32 k_frame_number; guint32 bd_addr_oui; guint32 bd_addr_id; - device_name_t *device_name; - gchar *remote_name; - gchar *remote_ether_addr; - gchar *remote_addr_name; + device_name_t *device_name; + const gchar *remote_name; + const gchar *remote_ether_addr; + gchar *remote_addr_name; gint remote_length; bd_addr_oui = remote_bdaddr->bd_addr[0] << 16 | remote_bdaddr->bd_addr[1] << 8 | remote_bdaddr->bd_addr[2]; - bd_addr_id = remote_bdaddr->bd_addr[3] << 16 | remote_bdaddr->bd_addr[4] << 8 | remote_bdaddr->bd_addr[5]; + bd_addr_id = remote_bdaddr->bd_addr[3] << 16 | remote_bdaddr->bd_addr[4] << 8 | remote_bdaddr->bd_addr[5]; k_bd_addr_oui = bd_addr_oui; - k_bd_addr_id = bd_addr_id; + k_bd_addr_id = bd_addr_id; key[0].length = 1; key[0].key = &k_bd_addr_id; @@ -194,13 +192,13 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) g_snprintf(remote_addr_name, remote_length, "%s (%s)", remote_ether_addr, remote_name); if (pinfo->p2p_dir == P2P_DIR_RECV) { - SET_ADDRESS(&pinfo->net_src, AT_STRINGZ, (int)strlen(remote_name), remote_name); + SET_ADDRESS(&pinfo->net_src, AT_STRINGZ, (int) strlen(remote_name), remote_name); SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, remote_bdaddr->bd_addr); - SET_ADDRESS(&pinfo->src, AT_STRINGZ, (int)strlen(remote_addr_name), remote_addr_name); + SET_ADDRESS(&pinfo->src, AT_STRINGZ, (int) strlen(remote_addr_name), remote_addr_name); } else if (pinfo->p2p_dir == P2P_DIR_SENT) { - SET_ADDRESS(&pinfo->net_dst, AT_STRINGZ, (int)strlen(remote_name), remote_name); + SET_ADDRESS(&pinfo->net_dst, AT_STRINGZ, (int) strlen(remote_name), remote_name); SET_ADDRESS(&pinfo->dl_dst, AT_ETHER, 6, remote_bdaddr->bd_addr); - SET_ADDRESS(&pinfo->dst, AT_STRINGZ, (int)strlen(remote_addr_name), remote_addr_name); + SET_ADDRESS(&pinfo->dst, AT_STRINGZ, (int) strlen(remote_addr_name), remote_addr_name); } } else { if (pinfo->p2p_dir == P2P_DIR_RECV) { @@ -237,7 +235,7 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) localhost_name_entry->adapter_id == k_adapter_id) localhost_name = localhost_name_entry->name; else - localhost_name =""; + localhost_name = ""; localhost_length = (gint)(strlen(localhost_ether_addr) + 3 + strlen(localhost_name) + 1); localhost_addr_name = ep_alloc(localhost_length); @@ -245,13 +243,13 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) g_snprintf(localhost_addr_name, localhost_length, "%s (%s)", localhost_ether_addr, localhost_name); if (pinfo->p2p_dir == P2P_DIR_RECV) { - SET_ADDRESS(&pinfo->net_dst, AT_STRINGZ, (int)strlen(localhost_name), localhost_name); + SET_ADDRESS(&pinfo->net_dst, AT_STRINGZ, (int) strlen(localhost_name), localhost_name); SET_ADDRESS(&pinfo->dl_dst, AT_ETHER, 6, localhost_bdaddr); - SET_ADDRESS(&pinfo->dst, AT_STRINGZ, (int)strlen(localhost_addr_name), localhost_addr_name); + SET_ADDRESS(&pinfo->dst, AT_STRINGZ, (int) strlen(localhost_addr_name), localhost_addr_name); } else if (pinfo->p2p_dir == P2P_DIR_SENT) { - SET_ADDRESS(&pinfo->net_src, AT_STRINGZ, (int)strlen(localhost_name), localhost_name); + SET_ADDRESS(&pinfo->net_src, AT_STRINGZ, (int) strlen(localhost_name), localhost_name); SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, localhost_bdaddr); - SET_ADDRESS(&pinfo->src, AT_STRINGZ, (int)strlen(localhost_addr_name), localhost_addr_name); + SET_ADDRESS(&pinfo->src, AT_STRINGZ, (int) strlen(localhost_addr_name), localhost_addr_name); } /* find the chandle_data structure associated with this chandle */ @@ -264,7 +262,7 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) length = tvb_get_letohs(tvb, offset); proto_tree_add_item(bthci_acl_tree, hf_bthci_acl_length, tvb, offset, 2, ENC_LITTLE_ENDIAN); - offset+=2; + offset += 2; /* determine if packet is fragmented */ switch(pb_flag) { @@ -274,7 +272,7 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) case 0x00: /* First fragment/packet, non-auto flushable */ case 0x02: /* First fragment/packet, auto flushable */ l2cap_length = tvb_get_letohs(tvb, offset); - fragmented = ((l2cap_length+4)!=length); + fragmented = (l2cap_length + 4 != length); break; default: /* unknown pb_flag */ @@ -282,8 +280,7 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } - if ((!fragmented) - || ((!acl_reassembly)&& !(pb_flag&0x01))) { + if (!fragmented || (!acl_reassembly && !(pb_flag & 0x01))) { /* call L2CAP dissector for PDUs that are not fragmented * also for the first fragment if reassembly is disabled */ @@ -299,16 +296,16 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) multi_fragment_pdu_t *mfp = NULL; gint len; - if (!(pb_flag&0x01)) { /* first fragment */ + if (!(pb_flag & 0x01)) { /* first fragment */ if (!pinfo->fd->flags.visited) { mfp = se_alloc(sizeof(multi_fragment_pdu_t)); mfp->first_frame = pinfo->fd->num; mfp->last_frame = 0; - mfp->tot_len = l2cap_length+4; + mfp->tot_len = l2cap_length + 4; mfp->reassembled = se_alloc(mfp->tot_len); len = tvb_length_remaining(tvb, offset); if (len <= mfp->tot_len) { - tvb_memcpy(tvb, (guint8*)mfp->reassembled, offset, len); + tvb_memcpy(tvb, (guint8 *) mfp->reassembled, offset, len); mfp->cur_off = len; se_tree_insert32(chandle_data->start_fragments, pinfo->fd->num, mfp); } @@ -317,6 +314,7 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } if (mfp != NULL && mfp->last_frame) { proto_item *item; + item = proto_tree_add_uint(bthci_acl_tree, hf_bthci_acl_reassembled_in, tvb, 0, 0, mfp->last_frame); PROTO_ITEM_SET_GENERATED(item); col_append_fstr(pinfo->cinfo, COL_INFO, " [Reassembled in #%u]", mfp->last_frame); @@ -326,9 +324,9 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) mfp = se_tree_lookup32_le(chandle_data->start_fragments, pinfo->fd->num); if (!pinfo->fd->flags.visited) { len = tvb_length_remaining(tvb, offset); - if (mfp != NULL && !mfp->last_frame && (mfp->tot_len>=mfp->cur_off+len)) { - tvb_memcpy(tvb, (guint8*)mfp->reassembled+mfp->cur_off, offset, len); - mfp->cur_off+=len; + if (mfp != NULL && !mfp->last_frame && (mfp->tot_len >= mfp->cur_off + len)) { + tvb_memcpy(tvb, (guint8 *) mfp->reassembled + mfp->cur_off, offset, len); + mfp->cur_off += len; if (mfp->cur_off == mfp->tot_len) { mfp->last_frame = pinfo->fd->num; } @@ -336,12 +334,13 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } if (mfp) { proto_item *item; + item = proto_tree_add_uint(bthci_acl_tree, hf_bthci_acl_continuation_to, tvb, 0, 0, mfp->first_frame); PROTO_ITEM_SET_GENERATED(item); col_append_fstr(pinfo->cinfo, COL_INFO, " [Continuation to #%u]", mfp->first_frame); } if (mfp != NULL && mfp->last_frame == pinfo->fd->num) { - next_tvb = tvb_new_child_real_data(tvb, (guint8*)mfp->reassembled, mfp->tot_len, mfp->tot_len); + next_tvb = tvb_new_child_real_data(tvb, (guint8 *) mfp->reassembled, mfp->tot_len, mfp->tot_len); add_new_data_source(pinfo, next_tvb, "Reassembled BTHCI ACL"); /* call L2CAP dissector */ @@ -432,7 +431,6 @@ proto_reg_handoff_bthci_acl(void) dissector_add_uint("hci_h4.type", HCI_H4_TYPE_ACL, bthci_acl_handle); dissector_add_uint("hci_h1.type", BTHCI_CHANNEL_ACL, bthci_acl_handle); - btl2cap_handle = find_dissector("btl2cap"); } -- cgit v1.2.3