diff options
26 files changed, 787 insertions, 1082 deletions
diff --git a/epan/dissectors/packet-dec-dnart.c b/epan/dissectors/packet-dec-dnart.c index a3454f7fba..464f1cc7d3 100644 --- a/epan/dissectors/packet-dec-dnart.c +++ b/epan/dissectors/packet-dec-dnart.c @@ -704,11 +704,19 @@ do_hello_msg( guint msg) { guint my_offset = offset; - guint8 iinfo, priority; + guint8 priority; guint16 version, eco_nr, user_eco; proto_item *ti; - proto_tree *iinfo_tree; char *addr; + static const int * info_flags[] = { + &hf_dec_rt_iinfo_node_type, + &hf_dec_rt_iinfo_vrf, + &hf_dec_rt_iinfo_rej, + &hf_dec_rt_iinfo_verf, + &hf_dec_rt_iinfo_mta, + &hf_dec_rt_iinfo_blkreq, + NULL + }; version = tvb_get_guint8(tvb, my_offset); eco_nr = tvb_get_guint8(tvb, my_offset + 1); @@ -724,23 +732,9 @@ do_hello_msg( proto_item_append_text(ti, " (%s)", addr); } my_offset += 6; - iinfo = tvb_get_guint8(tvb, my_offset); - ti = proto_tree_add_uint( - tree, hf_dec_rt_iinfo, tvb, my_offset, 1, iinfo); - iinfo_tree = proto_item_add_subtree(ti, ett_dec_rt_info_flags); - proto_tree_add_uint( - iinfo_tree, hf_dec_rt_iinfo_node_type, tvb, my_offset, 1, iinfo); - proto_tree_add_boolean(iinfo_tree, hf_dec_rt_iinfo_vrf, - tvb, my_offset, 1, iinfo); - proto_tree_add_boolean(iinfo_tree, hf_dec_rt_iinfo_rej, - tvb, my_offset, 1, iinfo); - proto_tree_add_boolean(iinfo_tree, hf_dec_rt_iinfo_verf, - tvb, my_offset, 1, iinfo); - proto_tree_add_boolean(iinfo_tree, hf_dec_rt_iinfo_mta, - tvb, my_offset, 1, iinfo); - proto_tree_add_boolean(iinfo_tree, hf_dec_rt_iinfo_blkreq, - tvb, my_offset, 1, iinfo); + proto_tree_add_bitmask(tree, tvb, my_offset, hf_dec_rt_iinfo, ett_dec_rt_info_flags, info_flags, ENC_NA); my_offset++; + proto_tree_add_item(tree, hf_dec_rt_blk_size, tvb, my_offset, 2, ENC_LITTLE_ENDIAN); my_offset += 2; diff --git a/epan/dissectors/packet-dnp.c b/epan/dissectors/packet-dnp.c index fad69845b4..d0717b8fa5 100644 --- a/epan/dissectors/packet-dnp.c +++ b/epan/dissectors/packet-dnp.c @@ -2764,9 +2764,17 @@ dissect_dnp3_al(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) guint16 bytes, obj_type = 0; guint data_len = 0, offset = 0; proto_item *ti, *tc; - proto_tree *al_tree, *field_tree, *robj_tree; + proto_tree *al_tree, *robj_tree; const gchar *func_code_str, *obj_type_str; nstime_t al_cto; + static const int * control_flags[] = { + &hf_dnp3_al_fir, + &hf_dnp3_al_fin, + &hf_dnp3_al_con, + &hf_dnp3_al_uns, + &hf_dnp3_al_seq, + NULL + }; nstime_set_zero (&al_cto); @@ -2792,20 +2800,13 @@ dissect_dnp3_al(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item_append_text(ti, "Sequence %u, %s)", al_seq, func_code_str); /* Application Layer control byte subtree */ - tc = proto_tree_add_uint_format(al_tree, hf_dnp3_al_ctl, tvb, offset, 1, al_ctl, - "Control: 0x%02x (", al_ctl); + tc = proto_tree_add_bitmask(al_tree, tvb, offset, hf_dnp3_al_ctl, ett_dnp3_al_ctl, control_flags, ENC_BIG_ENDIAN); + proto_item_append_text(tc, "("); if (al_ctl & DNP3_AL_FIR) proto_item_append_text(tc, "FIR, "); if (al_ctl & DNP3_AL_FIN) proto_item_append_text(tc, "FIN, "); if (al_ctl & DNP3_AL_CON) proto_item_append_text(tc, "CON, "); if (al_ctl & DNP3_AL_UNS) proto_item_append_text(tc, "UNS, "); proto_item_append_text(tc, "Sequence %u)", al_seq); - - field_tree = proto_item_add_subtree(tc, ett_dnp3_al_ctl); - proto_tree_add_boolean(field_tree, hf_dnp3_al_fir, tvb, offset, 1, al_ctl); - proto_tree_add_boolean(field_tree, hf_dnp3_al_fin, tvb, offset, 1, al_ctl); - proto_tree_add_boolean(field_tree, hf_dnp3_al_con, tvb, offset, 1, al_ctl); - proto_tree_add_boolean(field_tree, hf_dnp3_al_uns, tvb, offset, 1, al_ctl); - proto_tree_add_item(field_tree, hf_dnp3_al_seq, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; #if 0 @@ -3145,7 +3146,7 @@ dissect_dnp3_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* if ((dl_func != DL_FUNC_LINK_STAT) && (dl_func != DL_FUNC_STAT_LINK) && (dl_func != DL_FUNC_RESET_LINK) && (dl_func != DL_FUNC_ACK)) { - proto_tree *tr_tree, *al_tree; + proto_tree *al_tree; guint8 tr_ctl, tr_seq; gboolean tr_fir, tr_fin; guint8 *tmp, *tmp_ptr; @@ -3154,6 +3155,12 @@ dissect_dnp3_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* gboolean crc_OK = FALSE; tvbuff_t *next_tvb; guint i; + static const int * transport_flags[] = { + &hf_dnp3_tr_fin, + &hf_dnp3_tr_fir, + &hf_dnp3_tr_seq, + NULL + }; /* get the transport layer byte */ tr_ctl = tvb_get_guint8(tvb, offset); @@ -3162,19 +3169,14 @@ dissect_dnp3_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* tr_fin = tr_ctl & DNP3_TR_FIN; /* Add Transport Layer Tree */ - tc = proto_tree_add_uint_format(dnp3_tree, hf_dnp3_tr_ctl, tvb, offset, 1, tr_ctl, - "Transport Layer: 0x%02x (", tr_ctl); + tc = proto_tree_add_bitmask(dnp3_tree, tvb, offset, hf_dnp3_tr_ctl, ett_dnp3_tr_ctl, transport_flags, ENC_BIG_ENDIAN); + proto_item_append_text(tc, "("); if (tr_fir) proto_item_append_text(tc, "FIR, "); if (tr_fin) proto_item_append_text(tc, "FIN, "); proto_item_append_text(tc, "Sequence %u)", tr_seq); - tr_tree = proto_item_add_subtree(tc, ett_dnp3_tr_ctl); - proto_tree_add_boolean(tr_tree, hf_dnp3_tr_fin, tvb, offset, 1, tr_ctl); - proto_tree_add_boolean(tr_tree, hf_dnp3_tr_fir, tvb, offset, 1, tr_ctl); - proto_tree_add_item(tr_tree, hf_dnp3_tr_seq, tvb, offset, 1, ENC_BIG_ENDIAN); - /* Allocate AL chunk tree */ - al_tree = proto_tree_add_subtree(tr_tree, tvb, offset + 1, -1, ett_dnp3_al_data, NULL, "Application data chunks"); + al_tree = proto_tree_add_subtree(dnp3_tree, tvb, offset + 1, -1, ett_dnp3_al_data, NULL, "Application data chunks"); /* extract the application layer data, validating the CRCs */ @@ -3282,7 +3284,7 @@ dissect_dnp3_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* next_tvb = process_reassembled_data(al_tvb, 0, pinfo, "Reassembled DNP 3.0 Application Layer message", frag_msg, &dnp3_frag_items, - NULL, tr_tree); + NULL, dnp3_tree); if (next_tvb) /* Reassembled */ { diff --git a/epan/dissectors/packet-dplay.c b/epan/dissectors/packet-dplay.c index 6854c7ab5d..11df65c128 100644 --- a/epan/dissectors/packet-dplay.c +++ b/epan/dissectors/packet-dplay.c @@ -462,34 +462,30 @@ static gint dissect_sockaddr_in(proto_tree *tree, tvbuff_t *tvb, gint offset) static gint dissect_session_desc(proto_tree *tree, tvbuff_t *tvb, gint offset) { - guint32 flags; - proto_item *flags_item; - proto_tree *flags_tree; - - flags = tvb_get_letohl(tvb, offset+4); + static const int * flags[] = { + &hf_dplay_flags_no_sess_desc_changes, + &hf_dplay_flags_acqire_voice, + &hf_dplay_flags_optimize_latency, + &hf_dplay_flags_preserve_order, + &hf_dplay_flags_reliable, + &hf_dplay_flags_server_player_only, + &hf_dplay_flags_route, + &hf_dplay_flags_password_req, + &hf_dplay_flags_private_session, + &hf_dplay_flags_use_auth, + &hf_dplay_flags_no_player_updates, + &hf_dplay_flags_use_ping, + &hf_dplay_flags_can_join, + &hf_dplay_flags_ignored, + &hf_dplay_flags_short_player_msg, + &hf_dplay_flags_migrate_host, + &hf_dplay_flags_0002, + &hf_dplay_flags_no_create_players, + NULL + }; proto_tree_add_item(tree, hf_dplay_sess_desc_length, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - flags_item = proto_tree_add_item(tree, hf_dplay_sess_desc_flags, tvb, offset, 4, ENC_LITTLE_ENDIAN); - flags_tree = proto_item_add_subtree(flags_item, ett_dplay_sess_desc_flags); - proto_tree_add_boolean(flags_tree, hf_dplay_flags_no_sess_desc_changes, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dplay_flags_acqire_voice, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dplay_flags_optimize_latency, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dplay_flags_preserve_order, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dplay_flags_reliable, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dplay_flags_server_player_only, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dplay_flags_route, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dplay_flags_password_req, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dplay_flags_private_session, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dplay_flags_use_auth, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dplay_flags_no_player_updates, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dplay_flags_use_ping, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dplay_flags_can_join, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dplay_flags_ignored, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dplay_flags_short_player_msg, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dplay_flags_migrate_host, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dplay_flags_0002, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dplay_flags_no_create_players, tvb, offset, 4, flags); - offset += 4; + proto_tree_add_bitmask(tree, tvb, offset, hf_dplay_sess_desc_flags, ett_dplay_sess_desc_flags, flags, ENC_LITTLE_ENDIAN); offset += 4; proto_tree_add_item(tree, hf_dplay_instance_guid, tvb, offset, 16, ENC_BIG_ENDIAN); offset += 16; proto_tree_add_item(tree, hf_dplay_game_guid, tvb, offset, 16, ENC_BIG_ENDIAN); offset += 16; @@ -509,23 +505,20 @@ static gint dissect_session_desc(proto_tree *tree, tvbuff_t *tvb, gint offset) static gint dissect_packed_player(proto_tree *tree, tvbuff_t *tvb, gint offset) { - proto_tree *flags_tree; - proto_item *flags_item; - guint32 flags, sn_len, ln_len, sd_len, pd_len, num_players, i; + guint32 sn_len, ln_len, sd_len, pd_len, num_players, i; gint size; + static const int * flags[] = { + &hf_dplay_pp_flag_sending, + &hf_dplay_pp_flag_in_group, + &hf_dplay_pp_flag_nameserver, + &hf_dplay_pp_flag_sysplayer, + NULL + }; size = tvb_get_letohl(tvb, offset); proto_tree_add_item(tree, hf_dplay_pp_size, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - flags = tvb_get_letohl(tvb, offset); - flags_item = proto_tree_add_item(tree, hf_dplay_pp_flags, tvb, offset, 4, ENC_LITTLE_ENDIAN); - flags_tree = proto_item_add_subtree(flags_item, ett_dplay_pp_flags); - proto_tree_add_boolean(flags_tree, hf_dplay_pp_flag_sending, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dplay_pp_flag_in_group, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dplay_pp_flag_nameserver, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dplay_pp_flag_sysplayer, tvb, offset, 4, flags); - offset += 4; - + proto_tree_add_bitmask(tree, tvb, offset, hf_dplay_pp_flags, ett_dplay_pp_flags, flags, ENC_LITTLE_ENDIAN); offset += 4; proto_tree_add_item(tree, hf_dplay_pp_id, tvb, offset, 4, ENC_NA); offset += 4; sn_len = tvb_get_letohl(tvb, offset); @@ -600,21 +593,22 @@ static gint dissect_dplay_super_packed_player(proto_tree *tree, tvbuff_t *tvb, g guint32 have_short_name, have_long_name, sp_length_type, pd_length_type; guint32 player_count_type, have_parent_id, shortcut_count_type; guint32 player_data_length, sp_data_length, player_count, shortcut_count; - proto_item *flags_item = NULL, *im_item = NULL; - proto_tree *flags_tree = NULL, *im_tree = NULL; + proto_item *im_item = NULL; + proto_tree *im_tree = NULL; gint len; + static const int * ssp_flags[] = { + &hf_dplay_spp_flags_sending, + &hf_dplay_spp_flags_in_group, + &hf_dplay_spp_flags_nameserver, + &hf_dplay_spp_flags_sysplayer, + NULL + }; proto_tree_add_item(tree, hf_dplay_spp_size, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; flags = tvb_get_letohl(tvb, offset); is_sysplayer = flags & 0x00000001; - flags_item = proto_tree_add_item(tree, hf_dplay_spp_flags, tvb, offset, 4, ENC_LITTLE_ENDIAN); - flags_tree = proto_item_add_subtree(flags_item, ett_dplay_spp_flags); - proto_tree_add_boolean(flags_tree, hf_dplay_spp_flags_sending, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dplay_spp_flags_in_group, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dplay_spp_flags_nameserver, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dplay_spp_flags_sysplayer, tvb, offset, 4, flags); - offset += 4; + proto_tree_add_bitmask(tree, tvb, offset, hf_dplay_spp_flags, ett_dplay_spp_flags, ssp_flags, ENC_LITTLE_ENDIAN); offset += 4; proto_tree_add_item(tree, hf_dplay_spp_id, tvb, offset, 4, ENC_NA); offset += 4; info_mask = tvb_get_letohl(tvb, offset); @@ -745,22 +739,18 @@ static gint dissect_type01_message(proto_tree *tree, tvbuff_t *tvb, gint offset) static gint dissect_type02_message(proto_tree *tree, tvbuff_t *tvb, gint offset) { guint32 passwd_offset; - guint32 flags; - proto_item *flags_item; - proto_tree *flags_tree; + static const int * flags[] = { + &hf_enum_sess_flag_passwd, + &hf_enum_sess_flag_all, + &hf_enum_sess_flag_join, + NULL + }; passwd_offset = tvb_get_letohl(tvb, offset + 16); - flags = tvb_get_letohl(tvb, offset + 20); proto_tree_add_item(tree, hf_dplay_type_02_game_guid, tvb, offset, 16, ENC_BIG_ENDIAN); offset += 16; proto_tree_add_item(tree, hf_dplay_type_02_password_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; - - flags_item = proto_tree_add_item(tree, hf_dplay_type_02_flags, tvb, offset, 4, ENC_LITTLE_ENDIAN); - flags_tree = proto_item_add_subtree(flags_item, ett_dplay_type02_flags); - proto_tree_add_boolean(flags_tree, hf_enum_sess_flag_passwd, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_enum_sess_flag_all, tvb, offset, 4, flags); - proto_tree_add_boolean(flags_tree, hf_enum_sess_flag_join, tvb, offset, 4, flags); - offset += 4; + proto_tree_add_bitmask(tree, tvb, offset, hf_dplay_type_02_flags, ett_dplay_type02_flags, flags, ENC_LITTLE_ENDIAN); offset += 4; if (passwd_offset != 0) { offset = display_unicode_string(tree, hf_dplay_type_02_password, tvb, offset); @@ -770,18 +760,16 @@ static gint dissect_type02_message(proto_tree *tree, tvbuff_t *tvb, gint offset) static gint dissect_type05_message(proto_tree *tree, tvbuff_t *tvb, gint offset) { - proto_item *flag_item; - proto_item *flag_tree; - guint32 flags; + static const int * flags[] = { + &hf_dplay_type_05_secure, + &hf_dplay_type_05_unknown, + &hf_dplay_type_05_local, + &hf_dplay_type_05_name_server, + &hf_dplay_type_05_system_player, + NULL + }; - flags = tvb_get_letohl(tvb, offset); - flag_item = proto_tree_add_item(tree, hf_dplay_type_05_flags, tvb, offset, 4, ENC_LITTLE_ENDIAN); - flag_tree = proto_item_add_subtree(flag_item, ett_dplay_type05_flags); - proto_tree_add_boolean(flag_tree, hf_dplay_type_05_secure, tvb, offset, 4, flags); - proto_tree_add_boolean(flag_tree, hf_dplay_type_05_unknown, tvb, offset, 4, flags); - proto_tree_add_boolean(flag_tree, hf_dplay_type_05_local, tvb, offset, 4, flags); - proto_tree_add_boolean(flag_tree, hf_dplay_type_05_name_server, tvb, offset, 4, flags); - proto_tree_add_boolean(flag_tree, hf_dplay_type_05_system_player, tvb, offset, 4, flags); + proto_tree_add_bitmask(tree, tvb, offset, hf_dplay_type_05_flags, ett_dplay_type05_flags, flags, ENC_LITTLE_ENDIAN); offset += 4; return offset; } diff --git a/epan/dissectors/packet-drda.c b/epan/dissectors/packet-drda.c index 17d366be1b..b0dedae4fe 100644 --- a/epan/dissectors/packet-drda.c +++ b/epan/dissectors/packet-drda.c @@ -270,10 +270,10 @@ static gboolean drda_desegment = TRUE; #define DRDA_CP_SRVLST 0x244E #define DRDA_CP_SQLATTR 0x2450 -#define DRDA_DSSFMT_SAME_CORR 0x01 -#define DRDA_DSSFMT_CONTINUE 0x02 -#define DRDA_DSSFMT_CHAINED 0x04 -#define DRDA_DSSFMT_RESERVED 0x08 +#define DRDA_DSSFMT_SAME_CORR 0x10 +#define DRDA_DSSFMT_CONTINUE 0x20 +#define DRDA_DSSFMT_CHAINED 0x40 +#define DRDA_DSSFMT_RESERVED 0x80 #define DRDA_DSSFMT_RQSDSS 0x01 #define DRDA_DSSFMT_RPYDSS 0x02 @@ -678,13 +678,18 @@ dissect_drda(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ guint16 iLength; guint16 iCommandEnd = 0; - guint8 iFormatFlags; - guint8 iDSSType; - guint8 iDSSFlags; - guint16 iParameterCP; gint iLengthParam; + static const int * format_flags[] = { + &hf_drda_ddm_fmt_reserved, + &hf_drda_ddm_fmt_chained, + &hf_drda_ddm_fmt_errcont, + &hf_drda_ddm_fmt_samecorr, + &hf_drda_ddm_fmt_dsstyp, + NULL + }; + col_set_str(pinfo->cinfo, COL_PROTOCOL, "DRDA"); /* This is a trick to know whether this is the first PDU in this packet or not */ if (iPreviousFrameNumber != pinfo->fd->num) @@ -726,19 +731,7 @@ dissect_drda(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ proto_tree_add_item(drda_tree, hf_drda_ddm_length, tvb, offset + 0, 2, ENC_BIG_ENDIAN); proto_tree_add_item(drda_tree, hf_drda_ddm_magic, tvb, offset + 2, 1, ENC_BIG_ENDIAN); - iFormatFlags = tvb_get_guint8(tvb, offset + 3); - iDSSType = iFormatFlags & 0x0F; - iDSSFlags = iFormatFlags >> 4; - - ti = proto_tree_add_item(drda_tree, hf_drda_ddm_format, tvb, offset + 3, 1, ENC_BIG_ENDIAN); - drda_tree_sub = proto_item_add_subtree(ti, ett_drda_ddm_format); - - proto_tree_add_boolean(drda_tree_sub, hf_drda_ddm_fmt_reserved, tvb, offset + 3, 1, iDSSFlags); - proto_tree_add_boolean(drda_tree_sub, hf_drda_ddm_fmt_chained, tvb, offset + 3, 1, iDSSFlags); - proto_tree_add_boolean(drda_tree_sub, hf_drda_ddm_fmt_errcont, tvb, offset + 3, 1, iDSSFlags); - proto_tree_add_boolean(drda_tree_sub, hf_drda_ddm_fmt_samecorr, tvb, offset + 3, 1, iDSSFlags); - proto_tree_add_uint(drda_tree_sub, hf_drda_ddm_fmt_dsstyp, tvb, offset + 3, 1, iDSSType); - + proto_tree_add_bitmask(drda_tree, tvb, offset + 3, hf_drda_ddm_format, ett_drda_ddm_format, format_flags, ENC_BIG_ENDIAN); proto_tree_add_item(drda_tree, hf_drda_ddm_rc, tvb, offset + 4, 2, ENC_BIG_ENDIAN); proto_tree_add_item(drda_tree, hf_drda_ddm_length2, tvb, offset + 6, 2, ENC_BIG_ENDIAN); proto_tree_add_item(drda_tree, hf_drda_ddm_codepoint, tvb, offset + 8, 2, ENC_BIG_ENDIAN); @@ -851,27 +844,27 @@ proto_register_drda(void) { &hf_drda_ddm_fmt_reserved, { "Reserved", "drda.ddm.fmt.bit0", - FT_BOOLEAN, 4, TFS(&tfs_set_notset), DRDA_DSSFMT_RESERVED, + FT_BOOLEAN, 8, TFS(&tfs_set_notset), DRDA_DSSFMT_RESERVED, "DSSFMT reserved", HFILL }}, { &hf_drda_ddm_fmt_chained, { "Chained", "drda.ddm.fmt.bit1", - FT_BOOLEAN, 4, TFS(&tfs_set_notset), DRDA_DSSFMT_CHAINED, + FT_BOOLEAN, 8, TFS(&tfs_set_notset), DRDA_DSSFMT_CHAINED, "DSSFMT chained", HFILL }}, { &hf_drda_ddm_fmt_errcont, { "Continue", "drda.ddm.fmt.bit2", - FT_BOOLEAN, 4, TFS(&tfs_set_notset), DRDA_DSSFMT_CONTINUE, + FT_BOOLEAN, 8, TFS(&tfs_set_notset), DRDA_DSSFMT_CONTINUE, "DSSFMT continue on error", HFILL }}, { &hf_drda_ddm_fmt_samecorr, { "Same correlation", "drda.ddm.fmt.bit3", - FT_BOOLEAN, 4, TFS(&tfs_set_notset), DRDA_DSSFMT_SAME_CORR, + FT_BOOLEAN, 8, TFS(&tfs_set_notset), DRDA_DSSFMT_SAME_CORR, "DSSFMT same correlation", HFILL }}, { &hf_drda_ddm_fmt_dsstyp, { "DSS type", "drda.ddm.fmt.dsstyp", - FT_UINT8, BASE_DEC, VALS(drda_dsstyp_abbr), 0x0, + FT_UINT8, BASE_DEC, VALS(drda_dsstyp_abbr), 0x0F, "DSSFMT type", HFILL }}, { &hf_drda_ddm_rc, diff --git a/epan/dissectors/packet-dtn.c b/epan/dissectors/packet-dtn.c index 1b14ad69bf..a35c184573 100644 --- a/epan/dissectors/packet-dtn.c +++ b/epan/dissectors/packet-dtn.c @@ -1587,9 +1587,13 @@ display_metadata_block(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int } case BUNDLE_BLOCK_TYPE_EXTENDED_COS: { - proto_item *ecos_flag_item; - proto_tree *ecos_flag_tree; int flags, flow_label; + static const int * ecos_flags_fields[] = { + &hf_ecos_flags_critical, + &hf_ecos_flags_streaming, + &hf_ecos_flags_ordinal, + NULL + }; /* check requirements for Block Processing Control Flags */ if ((control_flags & BLOCK_CONTROL_REPLICATE) == 0) { @@ -1601,11 +1605,7 @@ display_metadata_block(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int /* flags byte */ flags = (int)tvb_get_guint8(tvb, offset); - ecos_flag_item = proto_tree_add_item(block_tree, hf_ecos_flags, tvb, offset, 1, ENC_BIG_ENDIAN); - ecos_flag_tree = proto_item_add_subtree(ecos_flag_item, ett_block_flags); - proto_tree_add_boolean(ecos_flag_tree, hf_ecos_flags_critical, tvb, offset, 1, flags); - proto_tree_add_boolean(ecos_flag_tree, hf_ecos_flags_streaming, tvb, offset, 1, flags); - proto_tree_add_boolean(ecos_flag_tree, hf_ecos_flags_ordinal, tvb, offset, 1, flags); + proto_tree_add_bitmask(block_tree, tvb, offset, hf_ecos_flags, ett_block_flags, ecos_flags_fields, ENC_BIG_ENDIAN); offset += 1; /* ordinal byte */ diff --git a/epan/dissectors/packet-dtpt.c b/epan/dissectors/packet-dtpt.c index 83a3317e06..eb4171b3ba 100644 --- a/epan/dissectors/packet-dtpt.c +++ b/epan/dissectors/packet-dtpt.c @@ -665,7 +665,6 @@ dissect_dtpt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ proto_item *dtpt_item; guint8 version; guint8 message_type; - guint32 flags; guint32 payload_size; version = tvb_get_guint8(tvb, 0); @@ -708,80 +707,74 @@ dissect_dtpt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ switch (message_type) { case LookupBeginRequest: { - proto_item* flags_item = NULL; - proto_tree* flags_tree = NULL; + static const int * flags[] = { + &hf_dtpt_flags_res_service, + &hf_dtpt_flags_flushprevious, + &hf_dtpt_flags_flushcache, + &hf_dtpt_flags_return_query_string, + &hf_dtpt_flags_return_aliases, + &hf_dtpt_flags_return_blob, + &hf_dtpt_flags_return_addr, + &hf_dtpt_flags_return_comment, + &hf_dtpt_flags_return_version, + &hf_dtpt_flags_return_type, + &hf_dtpt_flags_return_name, + &hf_dtpt_flags_nearest, + &hf_dtpt_flags_nocontainers, + &hf_dtpt_flags_containers, + &hf_dtpt_flags_deep, + NULL + }; + + proto_tree_add_bitmask(dtpt_tree, tvb, 12, hf_dtpt_flags, ett_dtpt_flags, flags, ENC_LITTLE_ENDIAN); - flags = tvb_get_letohl(tvb, 12); - - flags_item = proto_tree_add_uint(dtpt_tree, hf_dtpt_flags, - tvb, 12, 4, flags); - if (flags_item) { - flags_tree = proto_item_add_subtree(flags_item, ett_dtpt_flags); - } - if (flags_tree) { - proto_tree_add_boolean(flags_tree, hf_dtpt_flags_res_service, tvb, 12, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dtpt_flags_flushprevious, tvb, 12, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dtpt_flags_flushcache, tvb, 12, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dtpt_flags_return_query_string, tvb, 12, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dtpt_flags_return_aliases, tvb, 12, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dtpt_flags_return_blob, tvb, 12, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dtpt_flags_return_addr, tvb, 12, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dtpt_flags_return_comment, tvb, 12, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dtpt_flags_return_version, tvb, 12, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dtpt_flags_return_type, tvb, 12, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dtpt_flags_return_name, tvb, 12, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dtpt_flags_nearest, tvb, 12, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dtpt_flags_nocontainers, tvb, 12, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dtpt_flags_containers, tvb, 12, 4, flags); - proto_tree_add_boolean(flags_tree, hf_dtpt_flags_deep, tvb, 12, 4, flags); - } payload_size = tvb_get_letohl(tvb, 16); proto_tree_add_uint(dtpt_tree, hf_dtpt_payload_size, tvb, 16, 4, payload_size); } break; case LookupBeginResponse: { - proto_tree_add_uint64(dtpt_tree, hf_dtpt_handle, - tvb, 4, 8, tvb_get_letoh64(tvb, 4)); - proto_tree_add_uint(dtpt_tree, hf_dtpt_error, - tvb, 12, 4, tvb_get_letohl(tvb, 12)); + proto_tree_add_item(dtpt_tree, hf_dtpt_handle, + tvb, 4, 8, ENC_LITTLE_ENDIAN); + proto_tree_add_item(dtpt_tree, hf_dtpt_error, + tvb, 12, 4, ENC_LITTLE_ENDIAN); } break; case LookupNextRequest: { - proto_tree_add_uint64(dtpt_tree, hf_dtpt_handle, - tvb, 4, 8, tvb_get_letoh64(tvb, 4)); - proto_tree_add_uint(dtpt_tree, hf_dtpt_buffer_size, - tvb, 16, 4, tvb_get_letohl(tvb, 16)); + proto_tree_add_item(dtpt_tree, hf_dtpt_handle, + tvb, 4, 8, ENC_LITTLE_ENDIAN); + proto_tree_add_item(dtpt_tree, hf_dtpt_buffer_size, + tvb, 16, 4, ENC_LITTLE_ENDIAN); } break; case LookupNextResponse: { - proto_tree_add_uint(dtpt_tree, hf_dtpt_error, - tvb, 12, 4, tvb_get_letohl(tvb, 12)); - proto_tree_add_uint(dtpt_tree, hf_dtpt_data_size, - tvb, 16, 4, tvb_get_letohl(tvb, 16)); + proto_tree_add_item(dtpt_tree, hf_dtpt_error, + tvb, 12, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(dtpt_tree, hf_dtpt_data_size, + tvb, 16, 4, ENC_LITTLE_ENDIAN); } break; case LookupEndRequest: { - proto_tree_add_uint64(dtpt_tree, hf_dtpt_handle, - tvb, 4, 8, tvb_get_letoh64(tvb, 4)); + proto_tree_add_item(dtpt_tree, hf_dtpt_handle, + tvb, 4, 8, ENC_LITTLE_ENDIAN); } break; case ConnectRequest: { dissect_dtpt_sockaddr(tvb, 2, dtpt_tree, hf_dtpt_connect_addr, SOCKADDR_CONNECT); - proto_tree_add_uint(dtpt_tree, hf_dtpt_error, - tvb, 32, 4, tvb_get_letohl(tvb, 32)); + proto_tree_add_item(dtpt_tree, hf_dtpt_error, + tvb, 32, 4, ENC_LITTLE_ENDIAN); } break; case ConnectResponseOK: { dissect_dtpt_sockaddr(tvb, 2, dtpt_tree, hf_dtpt_connect_addr, SOCKADDR_CONNECT); - proto_tree_add_uint(dtpt_tree, hf_dtpt_error, - tvb, 32, 4, tvb_get_letohl(tvb, 32)); + proto_tree_add_item(dtpt_tree, hf_dtpt_error, + tvb, 32, 4, ENC_LITTLE_ENDIAN); } break; case ConnectResponseERR: { dissect_dtpt_sockaddr(tvb, 2, dtpt_tree, hf_dtpt_connect_addr, SOCKADDR_CONNECT); - proto_tree_add_uint(dtpt_tree, hf_dtpt_error, - tvb, 32, 4, tvb_get_letohl(tvb, 32)); + proto_tree_add_item(dtpt_tree, hf_dtpt_error, + tvb, 32, 4, ENC_LITTLE_ENDIAN); } break; } diff --git a/epan/dissectors/packet-dvmrp.c b/epan/dissectors/packet-dvmrp.c index ef0d1c9dce..10bdfa0f59 100644 --- a/epan/dissectors/packet-dvmrp.c +++ b/epan/dissectors/packet-dvmrp.c @@ -320,7 +320,7 @@ dissect_v3_report(tvbuff_t *tvb, proto_tree *parent_tree, int offset) static int dissect_dvmrp_v3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset) { - guint8 code,count; + guint8 code; /* version */ proto_tree_add_uint(parent_tree, hf_version, tvb, 0, 0, 3); @@ -347,20 +347,18 @@ dissect_dvmrp_v3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int /* PROBE and NEIGHBORS 2 packets have capabilities flags, unused for other packets */ if (code==DVMRP_V3_PROBE || code==DVMRP_V3_NEIGHBORS_2) { - proto_tree *tree; - proto_item *item; - - item = proto_tree_add_item(parent_tree, hf_capabilities, - tvb, offset, 1, ENC_NA); - tree = proto_item_add_subtree(item, ett_capabilities); - - count = tvb_get_guint8(tvb, offset); - proto_tree_add_boolean(tree, hf_cap_netmask, tvb, offset, 1, count); - proto_tree_add_boolean(tree, hf_cap_snmp, tvb, offset, 1, count); - proto_tree_add_boolean(tree, hf_cap_mtrace, tvb, offset, 1, count); - proto_tree_add_boolean(tree, hf_cap_genid, tvb, offset, 1, count); - proto_tree_add_boolean(tree, hf_cap_prune, tvb, offset, 1, count); - proto_tree_add_boolean(tree, hf_cap_leaf, tvb, offset, 1, count); + static const int * capabilities[] = { + &hf_cap_netmask, + &hf_cap_snmp, + &hf_cap_mtrace, + &hf_cap_genid, + &hf_cap_prune, + &hf_cap_leaf, + NULL + }; + + proto_tree_add_bitmask(parent_tree, tvb, offset, hf_capabilities, + ett_capabilities, capabilities, ENC_NA); } offset += 1; diff --git a/epan/dissectors/packet-epl.c b/epan/dissectors/packet-epl.c index 690c20f98b..b3e64f33d3 100644 --- a/epan/dissectors/packet-epl.c +++ b/epan/dissectors/packet-epl.c @@ -1041,11 +1041,13 @@ static gint hf_epl_node = -1; static gint hf_epl_dest = -1; static gint hf_epl_src = -1; +static gint hf_epl_soc = -1; static gint hf_epl_soc_mc = -1; static gint hf_epl_soc_ps = -1; static gint hf_epl_soc_nettime = -1; static gint hf_epl_soc_relativetime = -1; +static gint hf_epl_preq = -1; static gint hf_epl_preq_ms = -1; static gint hf_epl_preq_ea = -1; static gint hf_epl_preq_rd = -1; @@ -1054,6 +1056,7 @@ static gint hf_epl_preq_size = -1; static gint hf_epl_pres_stat_ms = -1; static gint hf_epl_pres_stat_cs = -1; +static gint hf_epl_pres = -1; static gint hf_epl_pres_ms = -1; static gint hf_epl_pres_en = -1; static gint hf_epl_pres_rd = -1; @@ -1275,6 +1278,9 @@ static gint hf_epl_asnd_sdo_cmd_abort_code = -1; /* Initialize the subtree pointers */ static gint ett_epl = -1; +static gint ett_epl_soc = -1; +static gint ett_epl_preq = -1; +static gint ett_epl_pres = -1; static gint ett_epl_feat = -1; static gint ett_epl_seb = -1; static gint ett_epl_el = -1; @@ -1689,12 +1695,17 @@ dissect_epl_soc(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint of { nstime_t nettime; guint8 flags; + static const int * soc_flags[] = { + &hf_epl_soc_mc, + &hf_epl_soc_ps, + NULL + }; offset += 1; flags = tvb_get_guint8(tvb, offset); - proto_tree_add_boolean(epl_tree, hf_epl_soc_mc, tvb, offset, 1, flags); - proto_tree_add_boolean(epl_tree, hf_epl_soc_ps, tvb, offset, 1, flags); + proto_tree_add_bitmask(epl_tree, tvb, offset, hf_epl_soc, ett_epl_soc, soc_flags, ENC_NA); + offset += 2; if (show_soc_flags) @@ -1721,13 +1732,17 @@ dissect_epl_preq(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint o guint16 len; guint8 pdoversion; guint8 flags; + static const int * req_flags[] = { + &hf_epl_preq_ms, + &hf_epl_preq_ea, + &hf_epl_preq_rd, + NULL + }; offset += 1; flags = tvb_get_guint8(tvb, offset); - proto_tree_add_boolean(epl_tree, hf_epl_preq_ms, tvb, offset, 1, flags); - proto_tree_add_boolean(epl_tree, hf_epl_preq_ea, tvb, offset, 1, flags); - proto_tree_add_boolean(epl_tree, hf_epl_preq_rd, tvb, offset, 1, flags); + proto_tree_add_bitmask(epl_tree, tvb, offset, hf_epl_preq, ett_epl_preq, req_flags, ENC_NA); offset += 2; pdoversion = tvb_get_guint8(tvb, offset); @@ -1755,6 +1770,12 @@ dissect_epl_pres(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, guint8 guint16 len; guint8 pdoversion; guint8 flags; + static const int * res_flags[] = { + &hf_epl_pres_ms, + &hf_epl_pres_en, + &hf_epl_pres_rd, + NULL + }; if (epl_src != EPL_MN_NODEID) /* check if the sender is CN or MN */ { @@ -1767,9 +1788,7 @@ dissect_epl_pres(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, guint8 offset += 1; flags = tvb_get_guint8(tvb, offset); - proto_tree_add_boolean(epl_tree, hf_epl_pres_ms, tvb, offset, 1, flags); - proto_tree_add_boolean(epl_tree, hf_epl_pres_en, tvb, offset, 1, flags); - proto_tree_add_boolean(epl_tree, hf_epl_pres_rd, tvb, offset, 1, flags); + proto_tree_add_bitmask(epl_tree, tvb, offset, hf_epl_pres, ett_epl_pres, res_flags, ENC_NA); offset += 1; proto_tree_add_item(epl_tree, hf_epl_pres_pr, tvb, offset, 1, ENC_LITTLE_ENDIAN); @@ -3197,6 +3216,10 @@ proto_register_epl(void) }, /* SoC data fields*/ + { &hf_epl_soc, + { "Flags", "epl.soc", + FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } + }, { &hf_epl_soc_mc, { "MC (Multiplexed Cycle Completed)", "epl.soc.mc", FT_BOOLEAN, 8, NULL, EPL_SOC_MC_MASK, NULL, HFILL } @@ -3215,6 +3238,10 @@ proto_register_epl(void) }, /* PReq data fields*/ + { &hf_epl_preq, + { "Flags", "epl.preq", + FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } + }, { &hf_epl_preq_ms, { "MS (Multiplexed Slot)", "epl.preq.ms", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL } @@ -3245,6 +3272,10 @@ proto_register_epl(void) { "NMTStatus", "epl.pres.stat", FT_UINT8, BASE_HEX, VALS(epl_nmt_cs_vals), 0x00, NULL, HFILL } }, + { &hf_epl_pres, + { "Flags", "epl.pres", + FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } + }, { &hf_epl_pres_ms, { "MS (Multiplexed Slot)", "epl.pres.ms", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL } @@ -3915,6 +3946,9 @@ proto_register_epl(void) /* Setup protocol subtree array */ static gint *ett[] = { &ett_epl, + &ett_epl_soc, + &ett_epl_preq, + &ett_epl_pres, &ett_epl_feat, &ett_epl_seb, &ett_epl_el, diff --git a/epan/dissectors/packet-ftp.c b/epan/dissectors/packet-ftp.c index b153ad7bf3..1b9ce094d2 100644 --- a/epan/dissectors/packet-ftp.c +++ b/epan/dissectors/packet-ftp.c @@ -578,21 +578,12 @@ dissect_ftp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) ti = proto_tree_add_item(tree, proto_ftp, tvb, 0, -1, ENC_NA); ftp_tree = proto_item_add_subtree(ti, ett_ftp); - if (is_request) { - hidden_item = proto_tree_add_boolean(ftp_tree, - hf_ftp_request, tvb, 0, 0, TRUE); - PROTO_ITEM_SET_HIDDEN(hidden_item); - hidden_item = proto_tree_add_boolean(ftp_tree, - hf_ftp_response, tvb, 0, 0, FALSE); - PROTO_ITEM_SET_HIDDEN(hidden_item); - } else { - hidden_item = proto_tree_add_boolean(ftp_tree, - hf_ftp_request, tvb, 0, 0, FALSE); - PROTO_ITEM_SET_HIDDEN(hidden_item); - hidden_item = proto_tree_add_boolean(ftp_tree, - hf_ftp_response, tvb, 0, 0, TRUE); - PROTO_ITEM_SET_HIDDEN(hidden_item); - } + hidden_item = proto_tree_add_boolean(ftp_tree, + hf_ftp_request, tvb, 0, 0, is_request); + PROTO_ITEM_SET_HIDDEN(hidden_item); + hidden_item = proto_tree_add_boolean(ftp_tree, + hf_ftp_response, tvb, 0, 0, is_request == FALSE); + PROTO_ITEM_SET_HIDDEN(hidden_item); /* Put the line into the protocol tree. */ ti = proto_tree_add_format_text(ftp_tree, tvb, 0, next_offset); diff --git a/epan/dissectors/packet-gprs-llc.c b/epan/dissectors/packet-gprs-llc.c index 7cc96c1f08..ab5f96c0c7 100644 --- a/epan/dissectors/packet-gprs-llc.c +++ b/epan/dissectors/packet-gprs-llc.c @@ -781,7 +781,6 @@ dissect_llcgprs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) break; case S_FORMAT: nu = ctrl_fld_ui_s = tvb_get_ntohs(tvb, offset); - offset +=2; epm = ctrl_fld_ui_s & 0x3; nu = (nu >>2)&0x01FF; @@ -791,24 +790,21 @@ dissect_llcgprs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (tree) { - ctrl_f_tree = proto_tree_add_subtree_format(llcgprs_tree, tvb, offset-2, 2, - ett_llcgprs_sframe, NULL, "Supervisory format: %s: N(R) = %u", - val_to_str(epm, cr_formats_ipluss, "Unknown (%d)"), nu); - - proto_tree_add_uint(ctrl_f_tree, hf_llcgprs_S_fmt, tvb, offset-2, - 2, ctrl_fld_ui_s); - proto_tree_add_boolean(ctrl_f_tree, hf_llcgprs_As, tvb, offset-2, - 2, ctrl_fld_ui_s); - + static const int * s_formats[] = { + &hf_llcgprs_S_fmt, + &hf_llcgprs_As, /* MLT CHANGES - added spare bits */ - proto_tree_add_uint(ctrl_f_tree, hf_llcgprs_sspare, tvb, offset-2, - 2, ctrl_fld_ui_s); + &hf_llcgprs_sspare, /* END MLT CHANGES */ - proto_tree_add_uint(ctrl_f_tree, hf_llcgprs_NR, tvb, offset-2, - 2, ctrl_fld_ui_s); - proto_tree_add_uint(ctrl_f_tree, hf_llcgprs_sjsd, tvb, offset-2, - 2, ctrl_fld_ui_s); + &hf_llcgprs_NR, + &hf_llcgprs_sjsd, + NULL + }; + + proto_tree_add_bitmask_text(llcgprs_tree, tvb, offset, 2, + "Supervisory format: ", NULL, ett_llcgprs_sframe, s_formats, ENC_BIG_ENDIAN, 0); } + offset +=2; /* MLT CHANGES - additional parsing code to handle SACK */ if ((ctrl_fld_ui_s & 0x03) == 0x03) /* It is a SACK frame */ @@ -913,20 +909,17 @@ dissect_llcgprs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (tree) { - ctrl_f_tree = proto_tree_add_subtree_format(llcgprs_tree, tvb, offset-2, - 2, ett_llcgprs_ctrlf, NULL, - "Unconfirmed Information format - UI, N(U) = %u", nu); - - proto_tree_add_uint(ctrl_f_tree, hf_llcgprs_U_fmt, tvb, offset-2, - 2, ctrl_fld_ui_s); - proto_tree_add_uint(ctrl_f_tree, hf_llcgprs_sp_bits, tvb, offset-2, - 2, ctrl_fld_ui_s); - proto_tree_add_uint(ctrl_f_tree, hf_llcgprs_NU, tvb, offset-2, 2, - ctrl_fld_ui_s); - proto_tree_add_boolean(ctrl_f_tree, hf_llcgprs_E_bit, tvb, offset-2, - 2, ctrl_fld_ui_s); - proto_tree_add_boolean(ctrl_f_tree, hf_llcgprs_PM_bit, tvb, offset-2, - 2, ctrl_fld_ui_s); + static const int * i_formats[] = { + &hf_llcgprs_U_fmt, + &hf_llcgprs_sp_bits, + &hf_llcgprs_NU, + &hf_llcgprs_E_bit, + &hf_llcgprs_PM_bit, + NULL + }; + + proto_tree_add_bitmask_text(llcgprs_tree, tvb, offset-2, 2, + "Unconfirmed Information format - UI: ", NULL, ett_llcgprs_ctrlf, i_formats, ENC_BIG_ENDIAN, 0); } /* MLT CHANGES - TOM parsing added */ diff --git a/epan/dissectors/packet-icmp.c b/epan/dissectors/packet-icmp.c index de871c7e7f..6e0e5bebc9 100644 --- a/epan/dissectors/packet-icmp.c +++ b/epan/dissectors/packet-icmp.c @@ -360,12 +360,24 @@ dissect_mip_extensions(tvbuff_t * tvb, int offset, proto_tree * tree) { guint8 type; guint8 length; - guint16 flags; proto_item *ti; proto_tree *mip_tree = NULL; - proto_tree *flags_tree = NULL; gint numCOAs; gint i; + static const int * flags[] = { + &hf_icmp_mip_r, + &hf_icmp_mip_b, + &hf_icmp_mip_h, + &hf_icmp_mip_f, + &hf_icmp_mip_m, + &hf_icmp_mip_g, + &hf_icmp_mip_v, + &hf_icmp_mip_rt, + &hf_icmp_mip_u, + &hf_icmp_mip_x, + &hf_icmp_mip_reserved, + NULL + }; /* Not much to do if we're not parsing everything */ if (!tree) @@ -416,37 +428,7 @@ dissect_mip_extensions(tvbuff_t * tvb, int offset, proto_tree * tree) ENC_BIG_ENDIAN); offset += 2; /* flags */ - flags = tvb_get_ntohs(tvb, offset); - ti = proto_tree_add_uint(mip_tree, - hf_icmp_mip_flags, tvb, - offset, 2, flags); - flags_tree = - proto_item_add_subtree(ti, ett_icmp_mip_flags); - proto_tree_add_boolean(flags_tree, hf_icmp_mip_r, - tvb, offset, 2, flags); - proto_tree_add_boolean(flags_tree, hf_icmp_mip_b, - tvb, offset, 2, flags); - proto_tree_add_boolean(flags_tree, hf_icmp_mip_h, - tvb, offset, 2, flags); - proto_tree_add_boolean(flags_tree, hf_icmp_mip_f, - tvb, offset, 2, flags); - proto_tree_add_boolean(flags_tree, hf_icmp_mip_m, - tvb, offset, 2, flags); - proto_tree_add_boolean(flags_tree, hf_icmp_mip_g, - tvb, offset, 2, flags); - proto_tree_add_boolean(flags_tree, hf_icmp_mip_v, - tvb, offset, 2, flags); - proto_tree_add_boolean(flags_tree, hf_icmp_mip_rt, - tvb, offset, 2, flags); - proto_tree_add_boolean(flags_tree, hf_icmp_mip_u, - tvb, offset, 2, flags); - proto_tree_add_boolean(flags_tree, hf_icmp_mip_x, - tvb, offset, 2, flags); - - /* Reserved */ - proto_tree_add_uint(flags_tree, - hf_icmp_mip_reserved, tvb, - offset, 2, flags); + proto_tree_add_bitmask(mip_tree, tvb, offset, hf_icmp_mip_flags, ett_icmp_mip_flags, flags, ENC_BIG_ENDIAN); offset += 2; /* COAs */ diff --git a/epan/dissectors/packet-ieee80211-radiotap.c b/epan/dissectors/packet-ieee80211-radiotap.c index f46949a54e..fcee5fd4de 100644 --- a/epan/dissectors/packet-ieee80211-radiotap.c +++ b/epan/dissectors/packet-ieee80211-radiotap.c @@ -932,10 +932,23 @@ dissect_radiotap(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) case IEEE80211_RADIOTAP_CHANNEL: { if (tree) { - proto_item *it; - proto_tree *flags_tree; guint16 flags; gchar *chan_str; + static const int * channel_flags[] = { + &hf_radiotap_channel_flags_turbo, + &hf_radiotap_channel_flags_cck, + &hf_radiotap_channel_flags_ofdm, + &hf_radiotap_channel_flags_2ghz, + &hf_radiotap_channel_flags_5ghz, + &hf_radiotap_channel_flags_passive, + &hf_radiotap_channel_flags_dynamic, + &hf_radiotap_channel_flags_gfsk, + &hf_radiotap_channel_flags_gsm, + &hf_radiotap_channel_flags_sturbo, + &hf_radiotap_channel_flags_half, + &hf_radiotap_channel_flags_quarter, + NULL + }; freq = tvb_get_letohs(tvb, offset); flags = tvb_get_letohs(tvb, offset + 2); @@ -948,49 +961,9 @@ dissect_radiotap(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) "%s", chan_str); g_free(chan_str); + /* We're already 2-byte aligned. */ - it = proto_tree_add_uint(radiotap_tree, - hf_radiotap_channel_flags, - tvb, offset + 2, 2, flags); - flags_tree = - proto_item_add_subtree(it, - ett_radiotap_channel_flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_channel_flags_turbo, - tvb, offset + 2, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_channel_flags_cck, - tvb, offset + 2, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_channel_flags_ofdm, - tvb, offset + 2, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_channel_flags_2ghz, - tvb, offset + 2, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_channel_flags_5ghz, - tvb, offset + 3, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_channel_flags_passive, - tvb, offset + 3, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_channel_flags_dynamic, - tvb, offset + 3, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_channel_flags_gfsk, - tvb, offset + 3, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_channel_flags_gsm, - tvb, offset + 3, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_channel_flags_sturbo, - tvb, offset + 3, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_channel_flags_half, - tvb, offset + 3, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_channel_flags_quarter, - tvb, offset + 3, 1, flags); + proto_tree_add_bitmask(radiotap_tree, tvb, offset + 2, hf_radiotap_channel_flags, ett_radiotap_channel_flags, channel_flags, ENC_LITTLE_ENDIAN); radiotap_info->freq = freq; radiotap_info->flags = flags; } @@ -1103,103 +1076,56 @@ dissect_radiotap(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) hdr_fcs_offset = offset; } } else { + static const int * rxflags[] = { + &hf_radiotap_rxflags_badplcp, + NULL + }; - if (tree) { - proto_tree *flags_tree; - proto_item *it; - guint16 flags; - flags = tvb_get_letohs(tvb, offset); - it = proto_tree_add_uint(radiotap_tree, - hf_radiotap_rxflags, - tvb, offset, 2, flags); - flags_tree = - proto_item_add_subtree(it, - ett_radiotap_rxflags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_rxflags_badplcp, - tvb, offset, 1, flags); - } + proto_tree_add_bitmask(radiotap_tree, tvb, offset, hf_radiotap_rxflags, ett_radiotap_rxflags, rxflags, ENC_LITTLE_ENDIAN); } break; } case IEEE80211_RADIOTAP_XCHANNEL: { - if (tree) { - proto_item *it; - proto_tree *flags_tree; - guint32 flags; - int channel; + static const int * xchannel_flags[] = { + &hf_radiotap_xchannel_flags_turbo, + &hf_radiotap_xchannel_flags_cck, + &hf_radiotap_xchannel_flags_ofdm, + &hf_radiotap_xchannel_flags_2ghz, + &hf_radiotap_xchannel_flags_5ghz, + &hf_radiotap_xchannel_flags_passive, + &hf_radiotap_xchannel_flags_dynamic, + &hf_radiotap_xchannel_flags_gfsk, + &hf_radiotap_xchannel_flags_gsm, + &hf_radiotap_xchannel_flags_sturbo, + &hf_radiotap_xchannel_flags_half, + &hf_radiotap_xchannel_flags_quarter, + &hf_radiotap_xchannel_flags_ht20, + &hf_radiotap_xchannel_flags_ht40u, + &hf_radiotap_xchannel_flags_ht40d, + NULL + }; + + proto_tree_add_item(radiotap_tree, + hf_radiotap_xchannel, + tvb, offset + 6, 1, + ENC_LITTLE_ENDIAN); + proto_tree_add_item(radiotap_tree, + hf_radiotap_xchannel_frequency, + tvb, offset + 4, 2, ENC_LITTLE_ENDIAN); + + proto_tree_add_bitmask(radiotap_tree, tvb, offset, hf_radiotap_xchannel_flags, ett_radiotap_xchannel_flags, xchannel_flags, ENC_LITTLE_ENDIAN); + - flags = tvb_get_letohl(tvb, offset); - freq = tvb_get_letohs(tvb, offset + 4); - channel = tvb_get_guint8(tvb, offset + 6); - proto_tree_add_uint(radiotap_tree, - hf_radiotap_xchannel, - tvb, offset + 6, 1, - (guint32) channel); - proto_tree_add_uint(radiotap_tree, - hf_radiotap_xchannel_frequency, - tvb, offset + 4, 2, freq); - it = proto_tree_add_uint(radiotap_tree, - hf_radiotap_xchannel_flags, - tvb, offset + 0, 4, flags); - flags_tree = - proto_item_add_subtree(it, ett_radiotap_xchannel_flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_xchannel_flags_turbo, - tvb, offset + 0, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_xchannel_flags_cck, - tvb, offset + 0, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_xchannel_flags_ofdm, - tvb, offset + 0, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_xchannel_flags_2ghz, - tvb, offset + 0, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_xchannel_flags_5ghz, - tvb, offset + 1, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_xchannel_flags_passive, - tvb, offset + 1, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_xchannel_flags_dynamic, - tvb, offset + 1, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_xchannel_flags_gfsk, - tvb, offset + 1, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_xchannel_flags_gsm, - tvb, offset + 1, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_xchannel_flags_sturbo, - tvb, offset + 1, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_xchannel_flags_half, - tvb, offset + 1, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_xchannel_flags_quarter, - tvb, offset + 1, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_xchannel_flags_ht20, - tvb, offset + 2, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_xchannel_flags_ht40u, - tvb, offset + 2, 1, flags); - proto_tree_add_boolean(flags_tree, - hf_radiotap_xchannel_flags_ht40d, - tvb, offset + 2, 1, flags); #if 0 - proto_tree_add_uint(radiotap_tree, - hf_radiotap_xchannel_maxpower, - tvb, offset + 7, 1, maxpower); + proto_tree_add_uint(radiotap_tree, + hf_radiotap_xchannel_maxpower, + tvb, offset + 7, 1, maxpower); #endif - } break; } case IEEE80211_RADIOTAP_MCS: { - proto_tree *mcs_tree = NULL, *mcs_known_tree; + proto_tree *mcs_tree = NULL; guint8 mcs_known, mcs_flags; guint8 mcs; guint bandwidth; @@ -1219,31 +1145,26 @@ dissect_radiotap(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) if (tree) { proto_item *it; + static const int * mcs_haves[] = { + &hf_radiotap_mcs_have_bw, + &hf_radiotap_mcs_have_index, + &hf_radiotap_mcs_have_gi, + &hf_radiotap_mcs_have_format, + &hf_radiotap_mcs_have_fec, + &hf_radiotap_mcs_have_stbc, + NULL + }; it = proto_tree_add_item(radiotap_tree, hf_radiotap_mcs, tvb, offset, 3, ENC_NA); mcs_tree = proto_item_add_subtree(it, ett_radiotap_mcs); - it = proto_tree_add_uint(mcs_tree, hf_radiotap_mcs_known, - tvb, offset, 1, mcs_known); - mcs_known_tree = proto_item_add_subtree(it, ett_radiotap_mcs_known); - proto_tree_add_item(mcs_known_tree, hf_radiotap_mcs_have_bw, - tvb, offset, 1, ENC_LITTLE_ENDIAN); - proto_tree_add_item(mcs_known_tree, hf_radiotap_mcs_have_index, - tvb, offset, 1, ENC_LITTLE_ENDIAN); - proto_tree_add_item(mcs_known_tree, hf_radiotap_mcs_have_gi, - tvb, offset, 1, ENC_LITTLE_ENDIAN); - proto_tree_add_item(mcs_known_tree, hf_radiotap_mcs_have_format, - tvb, offset, 1, ENC_LITTLE_ENDIAN); - proto_tree_add_item(mcs_known_tree, hf_radiotap_mcs_have_fec, - tvb, offset, 1, ENC_LITTLE_ENDIAN); - proto_tree_add_item(mcs_known_tree, hf_radiotap_mcs_have_stbc, - tvb, offset, 1, ENC_LITTLE_ENDIAN); + + proto_tree_add_bitmask(mcs_tree, tvb, offset, hf_radiotap_mcs_known, ett_radiotap_mcs_known, mcs_haves, ENC_LITTLE_ENDIAN); } if (mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_BW) { bandwidth = ((mcs_flags & IEEE80211_RADIOTAP_MCS_BW_MASK) == IEEE80211_RADIOTAP_MCS_BW_40) ? 1 : 0; - if (mcs_tree) - proto_tree_add_uint(mcs_tree, hf_radiotap_mcs_bw, + proto_tree_add_uint(mcs_tree, hf_radiotap_mcs_bw, tvb, offset + 1, 1, mcs_flags); } else { bandwidth = 0; @@ -1252,31 +1173,26 @@ dissect_radiotap(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) if (mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_GI) { gi_length = (mcs_flags & IEEE80211_RADIOTAP_MCS_SGI) ? 1 : 0; - if (mcs_tree) - proto_tree_add_uint(mcs_tree, hf_radiotap_mcs_gi, + proto_tree_add_uint(mcs_tree, hf_radiotap_mcs_gi, tvb, offset + 1, 1, mcs_flags); } else { gi_length = 0; can_calculate_rate = FALSE; /* no GI width */ } if (mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_FMT) { - if (mcs_tree) - proto_tree_add_uint(mcs_tree, hf_radiotap_mcs_format, + proto_tree_add_uint(mcs_tree, hf_radiotap_mcs_format, tvb, offset + 1, 1, mcs_flags); } if (mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_FEC) { - if (mcs_tree) - proto_tree_add_uint(mcs_tree, hf_radiotap_mcs_fec, + proto_tree_add_uint(mcs_tree, hf_radiotap_mcs_fec, tvb, offset + 1, 1, mcs_flags); } if (mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_STBC) { - if (mcs_tree) - proto_tree_add_boolean(mcs_tree, hf_radiotap_mcs_stbc, + proto_tree_add_boolean(mcs_tree, hf_radiotap_mcs_stbc, tvb, offset + 1, 1, mcs_flags); } if (mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_MCS) { - if (mcs_tree) - proto_tree_add_uint(mcs_tree, hf_radiotap_mcs_index, + proto_tree_add_uint(mcs_tree, hf_radiotap_mcs_index, tvb, offset + 2, 1, mcs); } else can_calculate_rate = FALSE; /* no MCS index */ diff --git a/epan/dissectors/packet-ieee802154.c b/epan/dissectors/packet-ieee802154.c index 6051c84e97..9c26381151 100644 --- a/epan/dissectors/packet-ieee802154.c +++ b/epan/dissectors/packet-ieee802154.c @@ -1205,23 +1205,17 @@ dissect_ieee802154_fcs: static void dissect_ieee802154_superframe(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint *offset) { - proto_tree *field_tree; - guint16 superframe; - - /* Parse the superframe spec. */ - superframe = tvb_get_letohs(tvb, *offset); - if (tree) { - /* Add Subtree for superframe specification */ - field_tree = proto_tree_add_subtree(tree, tvb, *offset, 2, ett_ieee802154_superframe, NULL, "Superframe Specification"); + static const int * superframe[] = { + &hf_ieee802154_beacon_order, + &hf_ieee802154_superframe_order, + &hf_ieee802154_cap, + &hf_ieee802154_superframe_battery_ext, + &hf_ieee802154_superframe_coord, + &hf_ieee802154_assoc_permit, + NULL + }; - /* Add Beacon Order to the superframe spec. */ - proto_tree_add_uint(field_tree, hf_ieee802154_beacon_order, tvb, *offset, 2, superframe & IEEE802154_BEACON_ORDER_MASK); - proto_tree_add_uint(field_tree, hf_ieee802154_superframe_order, tvb, *offset, 2, superframe & IEEE802154_SUPERFRAME_ORDER_MASK); - proto_tree_add_uint(field_tree, hf_ieee802154_cap, tvb, *offset, 2, superframe & IEEE802154_SUPERFRAME_CAP_MASK); - proto_tree_add_boolean(field_tree, hf_ieee802154_superframe_battery_ext, tvb, *offset, 2, superframe & IEEE802154_BATT_EXTENSION_MASK); - proto_tree_add_boolean(field_tree, hf_ieee802154_superframe_coord, tvb, *offset, 2, superframe & IEEE802154_SUPERFRAME_COORD_MASK); - proto_tree_add_boolean(field_tree, hf_ieee802154_assoc_permit, tvb, *offset, 2, superframe & IEEE802154_ASSOC_PERMIT_MASK); - } + proto_tree_add_bitmask_text(tree, tvb, *offset, 2, "Superframe Specification", NULL , ett_ieee802154_superframe, superframe, ENC_LITTLE_ENDIAN, BMT_NO_INT|BMT_NO_TFS); (*offset) += 2; } /* dissect_ieee802154_superframe */ diff --git a/epan/dissectors/packet-interlink.c b/epan/dissectors/packet-interlink.c index 88a0223ee7..b655cdaece 100644 --- a/epan/dissectors/packet-interlink.c +++ b/epan/dissectors/packet-interlink.c @@ -102,19 +102,14 @@ dissect_interlink(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } if (ilh_tree) { - proto_item *flags_item; - proto_tree *flags_tree; - - flags_item = proto_tree_add_item(ilh_tree, hf_interlink_flags, - tvb, offset, 2, ENC_LITTLE_ENDIAN); - flags_tree = proto_item_add_subtree(flags_item, ett_interlink_flags); - - if (flags_tree) { - guint16 il_flags; - il_flags = tvb_get_letohs(tvb, offset); - proto_tree_add_boolean(flags_tree, hf_interlink_flags_req_ack, tvb, offset, 2, il_flags); - proto_tree_add_boolean(flags_tree, hf_interlink_flags_inc_ack_port, tvb, offset, 2, il_flags); - } + static const int * flags[] = { + &hf_interlink_flags_req_ack, + &hf_interlink_flags_inc_ack_port, + NULL + }; + + proto_tree_add_bitmask(ilh_tree, tvb, offset, hf_interlink_flags, ett_interlink_flags, flags, ENC_LITTLE_ENDIAN); + } offset += 2; diff --git a/epan/dissectors/packet-iscsi.c b/epan/dissectors/packet-iscsi.c index 3dde9d7b86..e44f8ad024 100644 --- a/epan/dissectors/packet-iscsi.c +++ b/epan/dissectors/packet-iscsi.c @@ -940,20 +940,22 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off guint32 ahsLen = tvb_get_guint8(tvb, offset + 4) * 4; { gint b = tvb_get_guint8(tvb, offset + 1); + static const int * flags[] = { + &hf_iscsi_SCSICommand_F, + &hf_iscsi_SCSICommand_R, + &hf_iscsi_SCSICommand_W, + &hf_iscsi_SCSICommand_Attr, + NULL + }; - proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); - proto_tree *tt = proto_item_add_subtree(tf, ett_iscsi_Flags); + proto_tree_add_bitmask(tree, tvb, offset + 1, hf_iscsi_Flags, ett_iscsi_Flags, flags, ENC_NA); - proto_tree_add_boolean(tt, hf_iscsi_SCSICommand_F, tvb, offset + 1, 1, b); - proto_tree_add_boolean(tt, hf_iscsi_SCSICommand_R, tvb, offset + 1, 1, b); if(b&0x40){ cdata->itlq.task_flags|=SCSI_DATA_READ; } - proto_tree_add_boolean(tt, hf_iscsi_SCSICommand_W, tvb, offset + 1, 1, b); if(b&0x20){ cdata->itlq.task_flags|=SCSI_DATA_WRITE; } - proto_tree_add_uint(tt, hf_iscsi_SCSICommand_Attr, tvb, offset + 1, 1, b); } if(iscsi_protocol_version < ISCSI_PROTOCOL_DRAFT12) { proto_tree_add_item(ti, hf_iscsi_SCSICommand_CRN, tvb, offset + 3, 1, ENC_BIG_ENDIAN); @@ -1017,16 +1019,15 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off immediate_data_length=offset-immediate_data_offset; } else if(opcode == ISCSI_OPCODE_SCSI_RESPONSE) { /* SCSI Response */ - { - gint b = tvb_get_guint8(tvb, offset + 1); - proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); - proto_tree *tt = proto_item_add_subtree(tf, ett_iscsi_Flags); - - proto_tree_add_boolean(tt, hf_iscsi_SCSIResponse_o, tvb, offset + 1, 1, b); - proto_tree_add_boolean(tt, hf_iscsi_SCSIResponse_u, tvb, offset + 1, 1, b); - proto_tree_add_boolean(tt, hf_iscsi_SCSIResponse_O, tvb, offset + 1, 1, b); - proto_tree_add_boolean(tt, hf_iscsi_SCSIResponse_U, tvb, offset + 1, 1, b); - } + static const int * flags[] = { + &hf_iscsi_SCSIResponse_o, + &hf_iscsi_SCSIResponse_u, + &hf_iscsi_SCSIResponse_O, + &hf_iscsi_SCSIResponse_U, + NULL + }; + + proto_tree_add_bitmask(tree, tvb, offset + 1, hf_iscsi_Flags, ett_iscsi_Flags, flags, ENC_NA); proto_tree_add_item(ti, hf_iscsi_SCSIResponse_Response, tvb, offset + 2, 1, ENC_BIG_ENDIAN); proto_tree_add_item(ti, hf_iscsi_SCSIResponse_Status, tvb, offset + 3, 1, ENC_BIG_ENDIAN); if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT09) { @@ -1273,13 +1274,13 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off offset = handleDataSegmentAsTextKeys(iscsi_session, pinfo, ti, tvb, offset, data_segment_len, end_offset, TRUE); } else if(opcode == ISCSI_OPCODE_SCSI_DATA_OUT) { /* SCSI Data Out (write) */ - { - gint b = tvb_get_guint8(tvb, offset + 1); - proto_item *tf = proto_tree_add_uint(ti, hf_iscsi_Flags, tvb, offset + 1, 1, b); - proto_tree *tt = proto_item_add_subtree(tf, ett_iscsi_Flags); + static const int * flags[] = { + &hf_iscsi_SCSIData_F, + NULL + }; + + proto_tree_add_bitmask(tree, tvb, offset + 1, hf_iscsi_Flags, ett_iscsi_Flags, flags, ENC_NA); - proto_tree_add_boolean(tt, hf_iscsi_SCSIData_F, tvb, offset + 1, 1, b); - } if(iscsi_protocol_version > ISCSI_PROTOCOL_DRAFT09) { proto_tree_add_item(ti, hf_iscsi_TotalAHSLength, tvb, offset + 4, 1, ENC_BIG_ENDIAN); } diff --git a/epan/dissectors/packet-isis-hello.c b/epan/dissectors/packet-isis-hello.c index 3fa6c71dbd..d4ef6bfee6 100644 --- a/epan/dissectors/packet-isis-hello.c +++ b/epan/dissectors/packet-isis-hello.c @@ -519,22 +519,20 @@ dissect_hello_restart_clv(tvbuff_t *tvb, packet_info* pinfo _U_, proto_tree *tree, int offset, int id_length, int length) { int restart_options=0; - proto_tree *flags_tree; proto_item *restart_flags_item; proto_item *hold_time_item; const char *sep; if (length >= 1) { + static const int * flags[] = { + &hf_isis_hello_clv_restart_flags_sa, + &hf_isis_hello_clv_restart_flags_ra, + &hf_isis_hello_clv_restart_flags_rr, + NULL + }; + restart_options = tvb_get_guint8(tvb, offset); - restart_flags_item = proto_tree_add_uint ( tree, hf_isis_hello_clv_restart_flags, - tvb, offset, 1, restart_options); - flags_tree = proto_item_add_subtree(restart_flags_item, ett_isis_hello_clv_restart_flags); - proto_tree_add_boolean (flags_tree, hf_isis_hello_clv_restart_flags_sa, - tvb, offset, 1, restart_options ); - proto_tree_add_boolean (flags_tree, hf_isis_hello_clv_restart_flags_ra, - tvb, offset, 1, restart_options ); - proto_tree_add_boolean (flags_tree, hf_isis_hello_clv_restart_flags_rr, - tvb, offset, 1, restart_options ); + restart_flags_item = proto_tree_add_bitmask(tree, tvb, offset, hf_isis_hello_clv_restart_flags, ett_isis_hello_clv_restart_flags, flags, ENC_NA); /* Append an indication of which flags are set in the restart * options @@ -545,7 +543,7 @@ dissect_hello_restart_clv(tvbuff_t *tvb, packet_info* pinfo _U_, APPEND_BOOLEAN_FLAG(ISIS_MASK_RESTART_RR(restart_options), restart_flags_item, "%sRR"); if (sep != initial_sep) { - proto_item_append_text (restart_flags_item, ")"); + proto_item_append_text (restart_flags_item, ")"); } } diff --git a/epan/dissectors/packet-isns.c b/epan/dissectors/packet-isns.c index 1252be9b43..b2b2110e9c 100644 --- a/epan/dissectors/packet-isns.c +++ b/epan/dissectors/packet-isns.c @@ -940,25 +940,21 @@ dissect_isns_attr_iscsi_node_type(tvbuff_t *tvb, guint offset, proto_tree *paren static guint dissect_isns_attr_portal_security_bitmap(tvbuff_t *tvb, guint offset, proto_tree *parent_tree, int hf_index, guint32 tag, guint32 len) { - if(parent_tree){ - proto_item *item; - proto_tree *tree; - guint32 psb = tvb_get_ntohl(tvb, offset + 8); - - item = proto_tree_add_item(parent_tree, hf_index, tvb, offset + 8, len, ENC_BIG_ENDIAN); - tree = proto_item_add_subtree(item, ett_isns_attribute); + static const int * flags[] = { + &hf_isns_psb_tunnel_mode, + &hf_isns_psb_transport_mode, + &hf_isns_psb_pfs, + &hf_isns_psb_aggressive_mode, + &hf_isns_psb_main_mode, + &hf_isns_psb_ike_ipsec, + &hf_isns_psb_bitmap, + NULL + }; - proto_tree_add_boolean(tree, hf_isns_psb_tunnel_mode, tvb, offset+8, 4, psb); - proto_tree_add_boolean(tree, hf_isns_psb_transport_mode, tvb, offset+8, 4, psb); - proto_tree_add_boolean(tree, hf_isns_psb_pfs, tvb, offset+8, 4, psb); - proto_tree_add_boolean(tree, hf_isns_psb_aggressive_mode, tvb, offset+8, 4, psb); - proto_tree_add_boolean(tree, hf_isns_psb_main_mode, tvb, offset+8, 4, psb); - proto_tree_add_boolean(tree, hf_isns_psb_ike_ipsec, tvb, offset+8, 4, psb); - proto_tree_add_boolean(tree, hf_isns_psb_bitmap, tvb, offset+8, 4, psb); + proto_tree_add_bitmask(parent_tree, tvb, offset+8, hf_index, ett_isns_attribute, flags, ENC_BIG_ENDIAN); - proto_tree_add_uint(tree, hf_isns_attr_tag, tvb, offset, 4, tag); - proto_tree_add_uint(tree, hf_isns_attr_len, tvb, offset+4, 4, len); - } + proto_tree_add_uint(parent_tree, hf_isns_attr_tag, tvb, offset, 4, tag); + proto_tree_add_uint(parent_tree, hf_isns_attr_len, tvb, offset+4, 4, len); return offset+8+len; } @@ -968,36 +964,32 @@ dissect_isns_attr_portal_security_bitmap(tvbuff_t *tvb, guint offset, proto_tree static guint dissect_isns_attr_scn_bitmap(tvbuff_t *tvb, guint offset, proto_tree *parent_tree, int hf_index, guint32 tag, guint32 len) { - if(parent_tree){ - proto_item *item; - proto_tree *tree; - guint32 scn_bitmap = tvb_get_ntohl(tvb, offset + 8); - - item = proto_tree_add_item(parent_tree, hf_index, tvb, offset + 8, len, ENC_BIG_ENDIAN); - tree = proto_item_add_subtree(item, ett_isns_attribute); + /* + 24 INITIATOR AND SELF INFORMATION ONLY + 25 TARGET AND SELF INFORMATION ONLY + 26 MANAGEMENT REGISTRATION/SCN + 27 OBJECT REMOVED + 28 OBJECT ADDED + 29 OBJECT UPDATED + 30 DD/DDS MEMBER REMOVED (Mgmt Reg/SCN only) + 31 (Lsb) DD/DDS MEMBER ADDED (Mgmt Reg/SCN only) + */ + static const int * flags[] = { + &hf_isns_scn_bitmap_initiator_and_self_information_only, + &hf_isns_scn_bitmap_target_and_self_information_only, + &hf_isns_scn_bitmap_management_registration_scn, + &hf_isns_scn_bitmap_object_removed, + &hf_isns_scn_bitmap_object_added, + &hf_isns_scn_bitmap_object_updated, + &hf_isns_scn_bitmap_dd_dds_member_removed, + &hf_isns_scn_bitmap_dd_dds_member_added, + NULL + }; - /* - 24 INITIATOR AND SELF INFORMATION ONLY - 25 TARGET AND SELF INFORMATION ONLY - 26 MANAGEMENT REGISTRATION/SCN - 27 OBJECT REMOVED - 28 OBJECT ADDED - 29 OBJECT UPDATED - 30 DD/DDS MEMBER REMOVED (Mgmt Reg/SCN only) - 31 (Lsb) DD/DDS MEMBER ADDED (Mgmt Reg/SCN only) - */ - proto_tree_add_boolean(tree, hf_isns_scn_bitmap_initiator_and_self_information_only, tvb, offset+8, 4, scn_bitmap); - proto_tree_add_boolean(tree, hf_isns_scn_bitmap_target_and_self_information_only, tvb, offset+8, 4, scn_bitmap); - proto_tree_add_boolean(tree, hf_isns_scn_bitmap_management_registration_scn, tvb, offset+8, 4, scn_bitmap); - proto_tree_add_boolean(tree, hf_isns_scn_bitmap_object_removed, tvb, offset+8, 4, scn_bitmap); - proto_tree_add_boolean(tree, hf_isns_scn_bitmap_object_added, tvb, offset+8, 4, scn_bitmap); - proto_tree_add_boolean(tree, hf_isns_scn_bitmap_object_updated, tvb, offset+8, 4, scn_bitmap); - proto_tree_add_boolean(tree, hf_isns_scn_bitmap_dd_dds_member_removed, tvb, offset+8, 4, scn_bitmap); - proto_tree_add_boolean(tree, hf_isns_scn_bitmap_dd_dds_member_added, tvb, offset+8, 4, scn_bitmap); + proto_tree_add_bitmask(parent_tree, tvb, offset+8, hf_index, ett_isns_attribute, flags, ENC_BIG_ENDIAN); - proto_tree_add_uint(tree, hf_isns_attr_tag, tvb, offset, 4, tag); - proto_tree_add_uint(tree, hf_isns_attr_len, tvb, offset+4, 4, len); - } + proto_tree_add_uint(parent_tree, hf_isns_attr_tag, tvb, offset, 4, tag); + proto_tree_add_uint(parent_tree, hf_isns_attr_len, tvb, offset+4, 4, len); return offset+8+len; } diff --git a/epan/dissectors/packet-jxta.c b/epan/dissectors/packet-jxta.c index 2e4ec17010..c0ba8e66c1 100644 --- a/epan/dissectors/packet-jxta.c +++ b/epan/dissectors/packet-jxta.c @@ -867,9 +867,7 @@ static int dissect_jxta_welcome(tvbuff_t * tvb, packet_info * pinfo, proto_tree } if (NULL != *current_token) { - if (jxta_welcome_tree) { - proto_tree_add_item(jxta_welcome_tree, hf_jxta_welcome_sig, tvb, token_offset, (gint) strlen(*current_token), ENC_ASCII|ENC_NA); - } + proto_tree_add_item(jxta_welcome_tree, hf_jxta_welcome_sig, tvb, token_offset, (gint) strlen(*current_token), ENC_ASCII|ENC_NA); token_offset += (guint) strlen(*current_token) + 1; current_token++; @@ -1061,7 +1059,7 @@ static int dissect_jxta_message_framing(tvbuff_t * tvb, packet_info * pinfo, pro break; } else { headervalue_len = tvb_get_ntohs(tvb, offset); - offset += (int)sizeof(guint16); + offset += 2; headervalue_offset = offset; available = tvb_reported_length_remaining(tvb, offset); @@ -1136,18 +1134,18 @@ static int dissect_jxta_message_framing(tvbuff_t * tvb, packet_info * pinfo, pro if (tree) { proto_tree_add_uint(framing_header_tree, hf_jxta_framing_header_value_length, tvb, tree_offset, - (int)sizeof(guint16), headervaluelen); + 2, headervaluelen); /** TODO bondolo Add specific handling for known header types */ /* * Put header value into protocol tree. */ - proto_tree_add_item(framing_header_tree, hf_jxta_framing_header_value, tvb, tree_offset + (int)sizeof(guint16), + proto_tree_add_item(framing_header_tree, hf_jxta_framing_header_value, tvb, tree_offset + 2, headervaluelen, ENC_NA); } - tree_offset += (int)sizeof(guint16) + headervaluelen; + tree_offset += 2 + headervaluelen; } proto_item_set_end(framing_header_tree_item, tvb, tree_offset); @@ -1245,7 +1243,7 @@ static int dissect_jxta_message(tvbuff_t * tvb, packet_info * pinfo, proto_tree guint16 msg_names_count = tvb_get_ntohs(tvb, offset); guint each_name; - offset += (int)sizeof(guint16); + offset += 2; for (each_name = 0; each_name < msg_names_count; each_name++) { guint16 name_len; @@ -1277,7 +1275,7 @@ static int dissect_jxta_message(tvbuff_t * tvb, packet_info * pinfo, proto_tree guint16 elem_count = tvb_get_ntohs(tvb, offset); guint each_elem; - offset += (int)sizeof(guint16); + offset += 2; /* parse elements */ for (each_elem = 0; each_elem < elem_count; each_elem++) { @@ -1414,21 +1412,23 @@ static int dissect_jxta_message(tvbuff_t * tvb, packet_info * pinfo, proto_tree } message_version = tvb_get_guint8(tvb, tree_offset); - proto_tree_add_uint(jxta_msg_tree, hf_jxta_message_version, tvb, tree_offset, (int)sizeof(guint8), message_version); - tree_offset += (int)sizeof(guint8); + proto_tree_add_uint(jxta_msg_tree, hf_jxta_message_version, tvb, tree_offset, 1, message_version); + tree_offset += 1; if( message_version > 0 ) { - guint8 flags = tvb_get_guint8(tvb, tree_offset); - proto_item *flags_ti = proto_tree_add_uint(jxta_msg_tree, hf_jxta_message_flags, tvb, tree_offset, (int)sizeof(guint8), flags); - proto_tree *jxta_msg_flags_tree = proto_item_add_subtree(flags_ti, ett_jxta_msg_flags); - proto_tree_add_boolean(jxta_msg_flags_tree, hf_jxta_message_flag_utf16be, tvb, tree_offset, 1, flags); - proto_tree_add_boolean(jxta_msg_flags_tree, hf_jxta_message_flag_ucs32be, tvb, tree_offset, 1, flags); - tree_offset += (int)sizeof(guint8); + static const int * flags[] = { + &hf_jxta_message_flag_utf16be, + &hf_jxta_message_flag_ucs32be, + NULL + }; + + proto_tree_add_bitmask(jxta_msg_tree, tvb, tree_offset, hf_jxta_message_flags, ett_jxta_msg_flags, flags, ENC_NA); + tree_offset += 1; } msg_names_count = tvb_get_ntohs(tvb, tree_offset); - proto_tree_add_uint(jxta_msg_tree, hf_jxta_message_names_count, tvb, tree_offset, (int)sizeof(guint16), msg_names_count); - tree_offset += (int)sizeof(guint16); + proto_tree_add_uint(jxta_msg_tree, hf_jxta_message_names_count, tvb, tree_offset, 2, msg_names_count); + tree_offset += 2; names_table = (const gchar **)wmem_alloc(wmem_packet_scope(), (msg_names_count + 2) * sizeof(const gchar *)); names_table[0] = ""; @@ -1438,15 +1438,15 @@ static int dissect_jxta_message(tvbuff_t * tvb, packet_info * pinfo, proto_tree for (each_name = 0; each_name < msg_names_count; each_name++) { guint16 name_len = tvb_get_ntohs(tvb, tree_offset); - names_table[2 + each_name] = tvb_get_string_enc(wmem_packet_scope(), tvb, tree_offset + (int)sizeof(name_len), name_len, ENC_ASCII); - proto_tree_add_item(jxta_msg_tree, hf_jxta_message_names_name, tvb, tree_offset, (int)sizeof(name_len), ENC_ASCII|ENC_BIG_ENDIAN); - tree_offset += (int)sizeof(name_len) + name_len; + names_table[2 + each_name] = tvb_get_string_enc(wmem_packet_scope(), tvb, tree_offset + 2, name_len, ENC_ASCII); + proto_tree_add_item(jxta_msg_tree, hf_jxta_message_names_name, tvb, tree_offset, 2, ENC_ASCII|ENC_BIG_ENDIAN); + tree_offset += 2 + name_len; } /* parse element count */ elem_count = tvb_get_ntohs(tvb, tree_offset); - proto_tree_add_item(jxta_msg_tree, hf_jxta_message_element_count, tvb, tree_offset, (int)sizeof(guint16), ENC_BIG_ENDIAN); - tree_offset += (int)sizeof(guint16); + proto_tree_add_item(jxta_msg_tree, hf_jxta_message_element_count, tvb, tree_offset, 2, ENC_BIG_ENDIAN); + tree_offset += 2; /* FIXME bondolo Element count 0 (Process elements until FIN) should be supported. */ @@ -1539,7 +1539,7 @@ static int dissect_jxta_message_element_1(tvbuff_t * tvb, packet_info * pinfo, p break; } else { guint16 name_len = tvb_get_ntohs(tvb, offset); - offset += (int)sizeof(guint16); + offset += 2; available = tvb_reported_length_remaining(tvb, offset); if (available < name_len) { @@ -1561,7 +1561,7 @@ static int dissect_jxta_message_element_1(tvbuff_t * tvb, packet_info * pinfo, p } type_len = tvb_get_ntohs(tvb, offset); - offset += (int)sizeof(guint16); + offset += 2; available = tvb_reported_length_remaining(tvb, offset); if (available < type_len) { @@ -1583,7 +1583,7 @@ static int dissect_jxta_message_element_1(tvbuff_t * tvb, packet_info * pinfo, p } encoding_len = tvb_get_ntohs(tvb, offset); - offset += (int)sizeof(guint16); + offset += 2; available = tvb_reported_length_remaining(tvb, offset); if (available < encoding_len) { @@ -1651,43 +1651,43 @@ static int dissect_jxta_message_element_1(tvbuff_t * tvb, packet_info * pinfo, p guint8 namespaceID; proto_item *namespace_ti; guint16 name_len; - proto_item *flags_ti; - proto_tree *jxta_elem_flags_tree = NULL; guint32 content_len; gchar *mediatype = NULL; tvbuff_t *element_content_tvb; + static const int * element_flags[] = { + &hf_jxta_element1_flag_hasType, + &hf_jxta_element1_flag_hasEncoding, + &hf_jxta_element1_flag_hasSignature, + NULL + }; proto_tree_add_item(jxta_elem_tree, hf_jxta_element_sig, tvb, tree_offset, (int)sizeof(JXTA_MSGELEM_SIG), ENC_ASCII|ENC_NA); tree_offset += (int)sizeof(JXTA_MSGELEM_SIG); namespaceID = tvb_get_guint8(tvb, tree_offset); namespace_ti = - proto_tree_add_uint(jxta_elem_tree, hf_jxta_element1_namespaceid, tvb, tree_offset, (int)sizeof(guint8), namespaceID); + proto_tree_add_uint(jxta_elem_tree, hf_jxta_element1_namespaceid, tvb, tree_offset, 1, namespaceID); if (namespaceID < ns_count) { proto_item_append_text(namespace_ti, " (%s)", names_table[namespaceID]); } else { proto_item_append_text(namespace_ti, " * BAD *"); } - tree_offset += (int)sizeof(guint8); + tree_offset += 1; flags = tvb_get_guint8(tvb, tree_offset); - flags_ti = proto_tree_add_uint(jxta_elem_tree, hf_jxta_element_flags, tvb, tree_offset, (int)sizeof(guint8), flags); - jxta_elem_flags_tree = proto_item_add_subtree(flags_ti, ett_jxta_elem_1_flags); - proto_tree_add_boolean(jxta_elem_flags_tree, hf_jxta_element1_flag_hasType, tvb, tree_offset, 1, flags); - proto_tree_add_boolean(jxta_elem_flags_tree, hf_jxta_element1_flag_hasEncoding, tvb, tree_offset, 1, flags); - proto_tree_add_boolean(jxta_elem_flags_tree, hf_jxta_element1_flag_hasSignature, tvb, tree_offset, 1, flags); - tree_offset += (int)sizeof(guint8); + proto_tree_add_bitmask(jxta_elem_tree, tvb, tree_offset, hf_jxta_element_flags, ett_jxta_elem_1_flags, element_flags, ENC_NA); + tree_offset += 1; name_len = tvb_get_ntohs(tvb, tree_offset); - proto_item_append_text(jxta_elem_tree_item, " \"%s\"", tvb_format_text(tvb, tree_offset + (int)sizeof(guint16), name_len)); - proto_tree_add_item(jxta_elem_tree, hf_jxta_element_name, tvb, tree_offset, (int)sizeof(guint16), ENC_ASCII|ENC_BIG_ENDIAN); - tree_offset += (int)sizeof(guint16) + name_len; + proto_item_append_text(jxta_elem_tree_item, " \"%s\"", tvb_format_text(tvb, tree_offset + 2, name_len)); + proto_tree_add_item(jxta_elem_tree, hf_jxta_element_name, tvb, tree_offset, 2, ENC_ASCII|ENC_BIG_ENDIAN); + tree_offset += 2 + name_len; /* process type */ if ((flags & JXTAMSG1_ELMFLAG_TYPE) != 0) { guint16 type_len = tvb_get_ntohs(tvb, tree_offset); - proto_tree_add_item(jxta_elem_tree, hf_jxta_element_type, tvb, tree_offset, (int)sizeof(guint16), ENC_ASCII|ENC_BIG_ENDIAN); - tree_offset += (int)sizeof(guint16); + proto_tree_add_item(jxta_elem_tree, hf_jxta_element_type, tvb, tree_offset, 2, ENC_ASCII|ENC_BIG_ENDIAN); + tree_offset += 2; mediatype = tvb_get_string_enc(wmem_packet_scope(), tvb, tree_offset, type_len, ENC_ASCII); @@ -1697,14 +1697,14 @@ static int dissect_jxta_message_element_1(tvbuff_t * tvb, packet_info * pinfo, p /* process encoding */ if ((flags & JXTAMSG1_ELMFLAG_ENCODING) != 0) { guint16 encoding_len = tvb_get_ntohs(tvb, tree_offset); - proto_tree_add_item(jxta_elem_tree, hf_jxta_element_encoding, tvb, tree_offset, (int)sizeof(guint16), ENC_ASCII|ENC_BIG_ENDIAN); - tree_offset += (int)sizeof(guint16) + encoding_len; + proto_tree_add_item(jxta_elem_tree, hf_jxta_element_encoding, tvb, tree_offset, 2, ENC_ASCII|ENC_BIG_ENDIAN); + tree_offset += 2 + encoding_len; } /* content */ content_len = tvb_get_ntohl(tvb, tree_offset); - proto_tree_add_item(jxta_elem_tree, hf_jxta_element_content_len, tvb, tree_offset, (int)sizeof(guint32), ENC_BIG_ENDIAN); - tree_offset += (int)sizeof(guint32); + proto_tree_add_item(jxta_elem_tree, hf_jxta_element_content_len, tvb, tree_offset, 4, ENC_BIG_ENDIAN); + tree_offset += 4; element_content_tvb = tvb_new_subset_length(tvb, tree_offset, content_len); @@ -1778,7 +1778,7 @@ static int dissect_jxta_message_element_2(tvbuff_t * tvb, packet_info * pinfo, p break; } - offset += (int)sizeof(guint16); + offset += 2; /* name field */ if ((flags & JXTAMSG2_ELMFLAG_NAME_LITERAL) == 0) { @@ -1788,7 +1788,7 @@ static int dissect_jxta_message_element_2(tvbuff_t * tvb, packet_info * pinfo, p break; } - offset += (int)sizeof(guint16); + offset += 2; } else { /* literal name field */ available = tvb_reported_length_remaining(tvb, offset); @@ -1797,7 +1797,7 @@ static int dissect_jxta_message_element_2(tvbuff_t * tvb, packet_info * pinfo, p break; } else { guint16 name_len = tvb_get_ntohs(tvb, offset); - offset += (int)sizeof(guint16); + offset += 2; available = tvb_reported_length_remaining(tvb, offset); if (available < name_len) { @@ -1817,7 +1817,7 @@ static int dissect_jxta_message_element_2(tvbuff_t * tvb, packet_info * pinfo, p break; } - offset += (int)sizeof(guint16); + offset += 2; } /* encoding field */ @@ -1828,7 +1828,7 @@ static int dissect_jxta_message_element_2(tvbuff_t * tvb, packet_info * pinfo, p break; } - offset += (int)sizeof(guint16); + offset += 2; } @@ -1905,8 +1905,6 @@ static int dissect_jxta_message_element_2(tvbuff_t * tvb, packet_info * pinfo, p guint tree_offset = 0; proto_item *jxta_elem_tree_item = proto_tree_add_item(tree, hf_jxta_element, tvb, tree_offset, -1, ENC_NA); proto_tree *jxta_elem_tree = proto_item_add_subtree(jxta_elem_tree_item, ett_jxta_elem); - proto_item *flags_ti; - proto_tree *jxta_elem_flags_tree = NULL; guint16 namespaceID; proto_item *namespace_ti; guint16 nameID; @@ -1914,56 +1912,58 @@ static int dissect_jxta_message_element_2(tvbuff_t * tvb, packet_info * pinfo, p guint64 content_len; const gchar *mediatype = NULL; tvbuff_t *element_content_tvb; + static const int * element_flags[] = { + &hf_jxta_element2_flag_64bitlens, + &hf_jxta_element2_flag_nameLiteral, + &hf_jxta_element2_flag_hasType, + &hf_jxta_element2_flag_hasSignature, + &hf_jxta_element2_flag_hasEncoding, + &hf_jxta_element2_flag_sigOfEncoded, + NULL + }; proto_tree_add_item(jxta_elem_tree, hf_jxta_element_sig, tvb, tree_offset, (int)sizeof(JXTA_MSGELEM_SIG), ENC_ASCII|ENC_NA); tree_offset += (int)sizeof(JXTA_MSGELEM_SIG); flags = tvb_get_guint8(tvb, tree_offset); - flags_ti = proto_tree_add_uint(jxta_elem_tree, hf_jxta_element_flags, tvb, tree_offset, (int)sizeof(guint8), flags); - jxta_elem_flags_tree = proto_item_add_subtree(flags_ti, ett_jxta_elem_2_flags); - proto_tree_add_boolean(jxta_elem_flags_tree, hf_jxta_element2_flag_64bitlens, tvb, tree_offset, 1, flags); - proto_tree_add_boolean(jxta_elem_flags_tree, hf_jxta_element2_flag_nameLiteral, tvb, tree_offset, 1, flags); - proto_tree_add_boolean(jxta_elem_flags_tree, hf_jxta_element2_flag_hasType, tvb, tree_offset, 1, flags); - proto_tree_add_boolean(jxta_elem_flags_tree, hf_jxta_element2_flag_hasSignature, tvb, tree_offset, 1, flags); - proto_tree_add_boolean(jxta_elem_flags_tree, hf_jxta_element2_flag_hasEncoding, tvb, tree_offset, 1, flags); - proto_tree_add_boolean(jxta_elem_flags_tree, hf_jxta_element2_flag_sigOfEncoded, tvb, tree_offset, 1, flags); - tree_offset += (int)sizeof(guint8); + proto_tree_add_bitmask(jxta_elem_tree, tvb, tree_offset, hf_jxta_element_flags, ett_jxta_elem_2_flags, element_flags, ENC_NA); + tree_offset += 1; /* Namespace */ namespaceID = tvb_get_ntohs(tvb, tree_offset); namespace_ti = - proto_tree_add_uint(jxta_elem_tree, hf_jxta_element2_namespaceid, tvb, tree_offset, (int)sizeof(guint16), namespaceID); + proto_tree_add_uint(jxta_elem_tree, hf_jxta_element2_namespaceid, tvb, tree_offset, 2, namespaceID); if (namespaceID < names_count) { proto_item_append_text(namespace_ti, " (%s)", names_table[namespaceID]); } else { proto_item_append_text(namespace_ti, " * BAD *"); } - tree_offset += (int)sizeof(guint16); + tree_offset += 2; /* Name */ if ((flags & JXTAMSG2_ELMFLAG_NAME_LITERAL) == 0) { nameID = tvb_get_ntohs(tvb, tree_offset); name_ti = - proto_tree_add_uint(jxta_elem_tree, hf_jxta_element2_nameid, tvb, tree_offset, (int)sizeof(guint16), nameID); + proto_tree_add_uint(jxta_elem_tree, hf_jxta_element2_nameid, tvb, tree_offset, 2, nameID); if (namespaceID < names_count) { proto_item_append_text(name_ti, " (%s)", names_table[nameID]); } else { proto_item_append_text(name_ti, " * BAD *"); } - tree_offset += (int)sizeof(guint16); + tree_offset += 2; } else { /* literal name */ guint16 name_len = tvb_get_ntohs(tvb, tree_offset); - proto_item_append_text(jxta_elem_tree_item, " \"%s\"", tvb_format_text(tvb, tree_offset + (int)sizeof(guint16), name_len)); - proto_tree_add_item(jxta_elem_tree, hf_jxta_element_name, tvb, tree_offset, (int)sizeof(guint16), ENC_ASCII|ENC_BIG_ENDIAN); - tree_offset += (int)sizeof(guint16) + name_len; + proto_item_append_text(jxta_elem_tree_item, " \"%s\"", tvb_format_text(tvb, tree_offset + 2, name_len)); + proto_tree_add_item(jxta_elem_tree, hf_jxta_element_name, tvb, tree_offset, 2, ENC_ASCII|ENC_BIG_ENDIAN); + tree_offset += 2 + name_len; } /* process type */ if ((flags & JXTAMSG2_ELMFLAG_TYPE) != 0) { guint16 mimeID = tvb_get_ntohs(tvb, tree_offset); proto_item *mime_ti = - proto_tree_add_uint(jxta_elem_tree, hf_jxta_element2_mimeid, tvb, tree_offset, (int)sizeof(guint16), mimeID); + proto_tree_add_uint(jxta_elem_tree, hf_jxta_element2_mimeid, tvb, tree_offset, 2, mimeID); if (mimeID < names_count) { proto_item_append_text(mime_ti, " (%s)", names_table[mimeID]); @@ -1972,7 +1972,7 @@ static int dissect_jxta_message_element_2(tvbuff_t * tvb, packet_info * pinfo, p proto_item_append_text(mime_ti, " * BAD *"); } - tree_offset += (int)sizeof(guint16); + tree_offset += 2; } else { mediatype = "application/octet-stream"; } @@ -1981,7 +1981,7 @@ static int dissect_jxta_message_element_2(tvbuff_t * tvb, packet_info * pinfo, p if ((flags & JXTAMSG2_ELMFLAG_ENCODINGS) != 0) { guint16 encodingID = tvb_get_ntohs(tvb, tree_offset); proto_item *encoding_ti = - proto_tree_add_uint(jxta_elem_tree, hf_jxta_element2_encodingid, tvb, tree_offset, (int)sizeof(guint16), encodingID); + proto_tree_add_uint(jxta_elem_tree, hf_jxta_element2_encodingid, tvb, tree_offset, 2, encodingID); if (encodingID < names_count) { proto_item_append_text(encoding_ti, " (%s)", names_table[encodingID]); @@ -1989,18 +1989,18 @@ static int dissect_jxta_message_element_2(tvbuff_t * tvb, packet_info * pinfo, p proto_item_append_text(encoding_ti, " * BAD *"); } - tree_offset += (int)sizeof(guint16); + tree_offset += 2; } if ((flags & JXTAMSG2_ELMFLAG_UINT64_LENS) != 0) { content_len = tvb_get_ntoh64(tvb, tree_offset); - proto_tree_add_item(jxta_elem_tree, hf_jxta_element_content_len64, tvb, tree_offset, (int)sizeof(guint64), ENC_BIG_ENDIAN); - tree_offset += (int)sizeof(guint64); + proto_tree_add_item(jxta_elem_tree, hf_jxta_element_content_len64, tvb, tree_offset, 8, ENC_BIG_ENDIAN); + tree_offset += 8; } else { content_len = tvb_get_ntohl(tvb, tree_offset); - proto_tree_add_item(jxta_elem_tree, hf_jxta_element_content_len, tvb, tree_offset, (int)sizeof(guint32), ENC_BIG_ENDIAN); - tree_offset += (int)sizeof(guint32); + proto_tree_add_item(jxta_elem_tree, hf_jxta_element_content_len, tvb, tree_offset, 4, ENC_BIG_ENDIAN); + tree_offset += 4; } /* content */ diff --git a/epan/dissectors/packet-lwapp.c b/epan/dissectors/packet-lwapp.c index e01542f9f3..5d927408ac 100644 --- a/epan/dissectors/packet-lwapp.c +++ b/epan/dissectors/packet-lwapp.c @@ -49,6 +49,7 @@ static gint ett_lwapp_control = -1; static gint hf_lwapp_version = -1; static gint hf_lwapp_slotid = -1; +static gint hf_lwapp_flags = -1; static gint hf_lwapp_flags_type = -1; static gint hf_lwapp_flags_fragment = -1; static gint hf_lwapp_flags_fragment_type = -1; @@ -356,10 +357,15 @@ dissect_lwapp(tvbuff_t *tvb, packet_info *pinfo, guint8 slotId; guint8 version; proto_tree *lwapp_tree; - proto_tree *flags_tree; tvbuff_t *next_client; guint8 dest_mac[6]; guint8 have_destmac=0; + static const int * flags[] = { + &hf_lwapp_flags_type, + &hf_lwapp_flags_fragment, + &hf_lwapp_flags_fragment_type, + NULL + }; /* Set up structures needed to add the protocol subtree and manage it */ proto_item *ti; @@ -419,13 +425,7 @@ dissect_lwapp(tvbuff_t *tvb, packet_info *pinfo, proto_tree_add_uint(lwapp_tree, hf_lwapp_slotid, tvb, offset, 1, slotId); - flags_tree = proto_item_add_subtree(lwapp_tree, ett_lwapp_flags); - proto_tree_add_boolean(flags_tree, hf_lwapp_flags_type, - tvb, offset, 1, header.flags); - proto_tree_add_boolean(flags_tree, hf_lwapp_flags_fragment, - tvb, offset, 1, header.flags); - proto_tree_add_boolean(flags_tree, hf_lwapp_flags_fragment_type, - tvb, offset, 1, header.flags); + proto_tree_add_bitmask(lwapp_tree, tvb, offset, hf_lwapp_flags, ett_lwapp_flags, flags, ENC_NA); offset++; proto_tree_add_uint(lwapp_tree, hf_lwapp_fragment_id, @@ -468,6 +468,9 @@ proto_register_lwapp(void) { &hf_lwapp_slotid, { "slotId","lwapp.slotId", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_lwapp_flags, + { "Flags", "lwapp.flags", FT_UINT8, BASE_HEX, + NULL, 0x0, NULL, HFILL }}, { &hf_lwapp_flags_type, { "Type", "lwapp.flags.type", FT_BOOLEAN, 8, TFS(&lwapp_flags_type), LWAPP_FLAGS_T, NULL, HFILL }}, diff --git a/epan/dissectors/packet-mip.c b/epan/dissectors/packet-mip.c index 38df585303..0e81d72910 100644 --- a/epan/dissectors/packet-mip.c +++ b/epan/dissectors/packet-mip.c @@ -503,14 +503,11 @@ dissect_mip_extensions( tvbuff_t *tvb, int offset, proto_tree *tree, packet_info { proto_tree *exts_tree=NULL; proto_tree *ext_tree; - proto_tree *tf; - proto_tree *ext_flags_tree; proto_tree *pmipv4_tree; gint ext_len; guint8 ext_type; guint8 ext_subtype=0; guint8 pmipv4skipext_subscriberid_type; - guint16 flags; gint hdrLen; guint32 cvse_vendor_id; guint16 cvse_3gpp2_type; @@ -594,17 +591,20 @@ dissect_mip_extensions( tvbuff_t *tvb, int offset, proto_tree *tree, packet_info ext_len - 4, ENC_NA); break; - case REV_SUPP_EXT: /* RFC 3543 */ + case REV_SUPP_EXT: /* RFC 3543 */ + { /* flags */ - flags = tvb_get_ntohs(tvb, offset); - tf = proto_tree_add_uint(ext_tree, hf_mip_rext_flags, tvb, offset, 2, flags); - ext_flags_tree = proto_item_add_subtree(tf, ett_mip_flags); - proto_tree_add_boolean(ext_flags_tree, hf_mip_rext_i, tvb, offset, 2, flags); + static const int * flags[] = { + &hf_mip_rext_i, + &hf_mip_rext_reserved, + NULL + }; + + proto_tree_add_bitmask(ext_tree, tvb, offset, hf_mip_rext_flags, ett_mip_flags, flags, ENC_BIG_ENDIAN); - /* reserved */ - proto_tree_add_uint(ext_flags_tree, hf_mip_rext_reserved, tvb, offset, 2, flags); /* registration revocation timestamp */ proto_tree_add_item(ext_tree, hf_mip_rext_tstamp, tvb, offset + 2, 4, ENC_BIG_ENDIAN); + } break; case DYN_HA_EXT: /* RFC 4433 */ /* subtype */ @@ -620,6 +620,14 @@ dissect_mip_extensions( tvbuff_t *tvb, int offset, proto_tree *tree, packet_info proto_tree_add_item(ext_tree, hf_mip_mstrext_text, tvb, offset + 1, ext_len-1, ENC_ASCII|ENC_NA); break; case UDP_TUN_REQ_EXT: /* RFC 3519 */ + { + static const int * flags[] = { + &hf_mip_utrqext_f, + &hf_mip_utrqext_r, + &hf_mip_utrqext_reserved2, + NULL + }; + /* sub-type */ proto_tree_add_item(ext_tree, hf_mip_utrqext_stype, tvb, offset, 1, ENC_BIG_ENDIAN); @@ -627,21 +635,22 @@ dissect_mip_extensions( tvbuff_t *tvb, int offset, proto_tree *tree, packet_info proto_tree_add_item(ext_tree, hf_mip_utrqext_reserved1, tvb, offset + 1, 1, ENC_BIG_ENDIAN); /* flags */ - flags = tvb_get_guint8(tvb, offset + 2); - tf = proto_tree_add_uint(ext_tree, hf_mip_utrqext_flags, tvb, offset + 2, 1, flags); - ext_flags_tree = proto_item_add_subtree(tf, ett_mip_flags); - proto_tree_add_boolean(ext_flags_tree, hf_mip_utrqext_f, tvb, offset + 2, 1, flags); - proto_tree_add_boolean(ext_flags_tree, hf_mip_utrqext_r, tvb, offset + 2, 1, flags); - - /* reserved 2 */ - proto_tree_add_uint(ext_flags_tree, hf_mip_utrqext_reserved2, tvb, offset + 2, 1, flags); + proto_tree_add_bitmask(ext_tree, tvb, offset + 2, hf_mip_utrqext_flags, ett_mip_flags, flags, ENC_BIG_ENDIAN); + /* encapsulation */ proto_tree_add_item(ext_tree, hf_mip_utrqext_encap_type, tvb, offset + 3, 1, ENC_BIG_ENDIAN); /* reserved 3 */ proto_tree_add_item(ext_tree, hf_mip_utrqext_reserved3, tvb, offset + 4, 2, ENC_BIG_ENDIAN); + } break; case UDP_TUN_REP_EXT: /* RFC 3519 */ + { + static const int * flags[] = { + &hf_mip_utrpext_f, + &hf_mip_utrpext_reserved, + NULL + }; /* sub-type */ proto_tree_add_item(ext_tree, hf_mip_utrpext_stype, tvb, offset, 1, ENC_BIG_ENDIAN); @@ -649,16 +658,11 @@ dissect_mip_extensions( tvbuff_t *tvb, int offset, proto_tree *tree, packet_info proto_tree_add_item(ext_tree, hf_mip_utrpext_code, tvb, offset + 1, 1, ENC_BIG_ENDIAN); /* flags */ - flags = tvb_get_ntohs(tvb, offset+2); - tf = proto_tree_add_uint(ext_tree, hf_mip_utrpext_flags, tvb, offset + 2, 2, flags); - ext_flags_tree = proto_item_add_subtree(tf, ett_mip_flags); - proto_tree_add_boolean(ext_flags_tree, hf_mip_utrpext_f, tvb, offset + 2, 2, flags); - - /* reserved */ - proto_tree_add_uint(ext_flags_tree, hf_mip_utrpext_reserved, tvb, offset + 2, 2, flags); + proto_tree_add_bitmask(ext_tree, tvb, offset + 2, hf_mip_utrpext_flags, ett_mip_flags, flags, ENC_BIG_ENDIAN); /* keepalive interval */ proto_tree_add_item(ext_tree, hf_mip_utrpext_keepalive, tvb, offset + 4, 2, ENC_BIG_ENDIAN); + } break; case PMIPv4_NON_SKIP_EXT: /* draft-leung-mip4-proxy-mode */ /* sub-type */ @@ -778,10 +782,7 @@ dissect_mip( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* Set up structures we will need to add the protocol subtree and manage it */ proto_item *ti; proto_tree *mip_tree=NULL; - proto_item *tf; - proto_tree *flags_tree; guint8 type; - guint16 flags; gint offset=0; tvbuff_t *next_tvb; @@ -800,6 +801,18 @@ dissect_mip( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) tvb_ip_to_str(tvb, 12)); if (tree) { + static const int * flags[] = { + &hf_mip_s, + &hf_mip_b, + &hf_mip_d, + &hf_mip_m, + &hf_mip_g, + &hf_mip_v, + &hf_mip_t, + &hf_mip_x, + NULL + }; + ti = proto_tree_add_item(tree, proto_mip, tvb, offset, -1, ENC_NA); mip_tree = proto_item_add_subtree(ti, ett_mip); @@ -808,17 +821,7 @@ dissect_mip( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) offset++; /* flags */ - flags = tvb_get_guint8(tvb, offset); - tf = proto_tree_add_uint(mip_tree, hf_mip_flags, tvb, offset, 1, flags); - flags_tree = proto_item_add_subtree(tf, ett_mip_flags); - proto_tree_add_boolean(flags_tree, hf_mip_s, tvb, offset, 1, flags); - proto_tree_add_boolean(flags_tree, hf_mip_b, tvb, offset, 1, flags); - proto_tree_add_boolean(flags_tree, hf_mip_d, tvb, offset, 1, flags); - proto_tree_add_boolean(flags_tree, hf_mip_m, tvb, offset, 1, flags); - proto_tree_add_boolean(flags_tree, hf_mip_g, tvb, offset, 1, flags); - proto_tree_add_boolean(flags_tree, hf_mip_v, tvb, offset, 1, flags); - proto_tree_add_boolean(flags_tree, hf_mip_t, tvb, offset, 1, flags); - proto_tree_add_boolean(flags_tree, hf_mip_x, tvb, offset, 1, flags); + proto_tree_add_bitmask(mip_tree, tvb, offset, hf_mip_flags, ett_mip_flags, flags, ENC_BIG_ENDIAN); offset++; /* lifetime */ @@ -917,6 +920,13 @@ dissect_mip( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) tvb_ip_to_str(tvb, 12)); if (tree) { + static const int * mip_flags[] = { + &hf_mip_rev_a, + &hf_mip_rev_i, + &hf_mip_rev_reserved, + NULL + }; + ti = proto_tree_add_item(tree, proto_mip, tvb, offset, -1, ENC_NA); mip_tree = proto_item_add_subtree(ti, ett_mip); @@ -929,14 +939,7 @@ dissect_mip( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) offset++; /* flags */ - flags = tvb_get_ntohs(tvb, offset); - tf = proto_tree_add_uint(mip_tree, hf_mip_flags, tvb, offset, 2, flags); - flags_tree = proto_item_add_subtree(tf, ett_mip_flags); - proto_tree_add_boolean(flags_tree, hf_mip_rev_a, tvb, offset, 2, flags); - proto_tree_add_boolean(flags_tree, hf_mip_rev_i, tvb, offset, 2, flags); - - /* reserved */ - proto_tree_add_uint(flags_tree, hf_mip_rev_reserved, tvb, offset, 2, flags); + proto_tree_add_bitmask(mip_tree, tvb, offset, hf_mip_flags, ett_mip_flags, mip_flags, ENC_BIG_ENDIAN); offset += 2; /* home address */ @@ -961,6 +964,12 @@ dissect_mip( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) tvb_ip_to_str(tvb, 4)); if (tree) { + static const int * mip_flags[] = { + &hf_mip_ack_i, + &hf_mip_ack_reserved, + NULL + }; + ti = proto_tree_add_item(tree, proto_mip, tvb, offset, -1, ENC_NA); mip_tree = proto_item_add_subtree(ti, ett_mip); @@ -973,13 +982,7 @@ dissect_mip( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) offset++; /* flags */ - flags = tvb_get_ntohs(tvb, offset); - tf = proto_tree_add_uint(mip_tree, hf_mip_flags, tvb, offset, 2, flags); - flags_tree = proto_item_add_subtree(tf, ett_mip_flags); - proto_tree_add_boolean(flags_tree, hf_mip_ack_i, tvb, offset, 2, flags); - - /* reserved */ - proto_tree_add_uint(flags_tree, hf_mip_ack_reserved, tvb, offset, 2, flags); + proto_tree_add_bitmask(mip_tree, tvb, offset, hf_mip_flags, ett_mip_flags, mip_flags, ENC_BIG_ENDIAN); offset += 2; /* home address */ diff --git a/epan/dissectors/packet-mount.c b/epan/dissectors/packet-mount.c index 1270c899ef..50e5df613f 100644 --- a/epan/dissectors/packet-mount.c +++ b/epan/dissectors/packet-mount.c @@ -410,8 +410,19 @@ static int dissect_mount_pathconf_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, void* data _U_) { guint32 pc_mask; - proto_item *lock_item; - proto_tree *lock_tree; + static const int * flags[] = { + &hf_mount_pathconf_error_all, + &hf_mount_pathconf_error_link_max, + &hf_mount_pathconf_error_max_canon, + &hf_mount_pathconf_error_max_input, + &hf_mount_pathconf_error_name_max, + &hf_mount_pathconf_error_path_max, + &hf_mount_pathconf_error_pipe_buf, + &hf_mount_pathconf_chown_restricted, + &hf_mount_pathconf_no_trunc, + &hf_mount_pathconf_error_vdisable, + NULL + }; /* * Extract the mask first, so we know which other fields the @@ -419,96 +430,55 @@ dissect_mount_pathconf_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, */ pc_mask = tvb_get_ntohl(tvb, offset+OFFS_MASK) & 0xffff; if (!(pc_mask & (PC_ERROR_LINK_MAX|PC_ERROR_ALL))) { - if (tree) { - dissect_rpc_uint32(tvb,tree,hf_mount_pathconf_link_max,offset); - } + dissect_rpc_uint32(tvb,tree,hf_mount_pathconf_link_max,offset); } offset += 4; if (!(pc_mask & (PC_ERROR_MAX_CANON|PC_ERROR_ALL))) { - if (tree) { - proto_tree_add_item(tree, + proto_tree_add_item(tree, hf_mount_pathconf_max_canon,tvb,offset+2,2, tvb_get_ntohs(tvb,offset)&0xffff); - } } offset += 4; if (!(pc_mask & (PC_ERROR_MAX_INPUT|PC_ERROR_ALL))) { - if (tree) { - proto_tree_add_item(tree, + proto_tree_add_item(tree, hf_mount_pathconf_max_input,tvb,offset+2,2, tvb_get_ntohs(tvb,offset)&0xffff); - } } offset += 4; if (!(pc_mask & (PC_ERROR_NAME_MAX|PC_ERROR_ALL))) { - if (tree) { - proto_tree_add_item(tree, + proto_tree_add_item(tree, hf_mount_pathconf_name_max,tvb,offset+2,2, tvb_get_ntohs(tvb,offset)&0xffff); - } } offset += 4; if (!(pc_mask & (PC_ERROR_PATH_MAX|PC_ERROR_ALL))) { - if (tree) { - proto_tree_add_item(tree, + proto_tree_add_item(tree, hf_mount_pathconf_path_max,tvb,offset+2,2, tvb_get_ntohs(tvb,offset)&0xffff); - } } offset += 4; if (!(pc_mask & (PC_ERROR_PIPE_BUF|PC_ERROR_ALL))) { - if (tree) { - proto_tree_add_item(tree, + proto_tree_add_item(tree, hf_mount_pathconf_pipe_buf,tvb,offset+2,2, tvb_get_ntohs(tvb,offset)&0xffff); - } } offset += 4; offset += 4; /* skip "pc_xxx" pad field */ if (!(pc_mask & (PC_ERROR_VDISABLE|PC_ERROR_ALL))) { - if (tree) { - proto_tree_add_item(tree, + proto_tree_add_item(tree, hf_mount_pathconf_vdisable,tvb,offset+3,1, tvb_get_ntohs(tvb,offset)&0xffff); - } } offset += 4; - - if (tree) { - lock_item = proto_tree_add_item(tree, hf_mount_pathconf_mask, tvb, - offset+2, 2, ENC_BIG_ENDIAN); - - lock_tree = proto_item_add_subtree(lock_item, ett_mount_pathconf_mask); - proto_tree_add_boolean(lock_tree, hf_mount_pathconf_error_all, tvb, - offset + 2, 2, pc_mask); - - proto_tree_add_boolean(lock_tree, hf_mount_pathconf_error_link_max, tvb, - offset + 2, 2, pc_mask); - proto_tree_add_boolean(lock_tree, hf_mount_pathconf_error_max_canon, tvb, - offset + 2, 2, pc_mask); - proto_tree_add_boolean(lock_tree, hf_mount_pathconf_error_max_input, tvb, - offset + 2, 2, pc_mask); - proto_tree_add_boolean(lock_tree, hf_mount_pathconf_error_name_max, tvb, - offset + 2, 2, pc_mask); - proto_tree_add_boolean(lock_tree, hf_mount_pathconf_error_path_max, tvb, - offset + 2, 2, pc_mask); - proto_tree_add_boolean(lock_tree, hf_mount_pathconf_error_pipe_buf, tvb, - offset + 2, 2, pc_mask); - proto_tree_add_boolean(lock_tree, hf_mount_pathconf_chown_restricted, tvb, - offset + 2, 2, pc_mask); - proto_tree_add_boolean(lock_tree, hf_mount_pathconf_no_trunc, tvb, - offset + 2, 2, pc_mask); - proto_tree_add_boolean(lock_tree, hf_mount_pathconf_error_vdisable, tvb, - offset + 2, 2, pc_mask); - } + proto_tree_add_bitmask(tree, tvb, offset+2, hf_mount_pathconf_mask, ett_mount_pathconf_mask, flags, ENC_BIG_ENDIAN); offset += 8; return offset; @@ -654,89 +624,54 @@ static const true_false_string tos_st_local = { static int dissect_mount_statvfs_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, void* data _U_) { - proto_item *flag_item; - proto_tree *flag_tree; - guint32 statvfs_flags; + static const int * flags[] = { + &hf_mount_statvfs_flag_rdonly, + &hf_mount_statvfs_flag_nosuid, + &hf_mount_statvfs_flag_notrunc, + &hf_mount_statvfs_flag_nodev, + &hf_mount_statvfs_flag_grpid, + &hf_mount_statvfs_flag_local, + NULL + }; - statvfs_flags = tvb_get_ntohl(tvb, offset+52); - if (tree) { - dissect_rpc_uint32(tvb, tree, hf_mount_statvfs_bsize, offset); - } + dissect_rpc_uint32(tvb, tree, hf_mount_statvfs_bsize, offset); offset += 4; - if (tree) { - dissect_rpc_uint32(tvb, tree, hf_mount_statvfs_frsize, offset); - } + + dissect_rpc_uint32(tvb, tree, hf_mount_statvfs_frsize, offset); offset += 4; - if (tree) { - dissect_rpc_uint32(tvb, tree, hf_mount_statvfs_blocks, offset); - } + + dissect_rpc_uint32(tvb, tree, hf_mount_statvfs_blocks, offset); offset += 4; - if (tree) { - dissect_rpc_uint32(tvb, tree, hf_mount_statvfs_bfree, offset); - } + + dissect_rpc_uint32(tvb, tree, hf_mount_statvfs_bfree, offset); offset += 4; - if (tree) { - dissect_rpc_uint32(tvb, tree, hf_mount_statvfs_bavail, offset); - } + + dissect_rpc_uint32(tvb, tree, hf_mount_statvfs_bavail, offset); offset += 4; - if (tree) { - dissect_rpc_uint32(tvb, tree, hf_mount_statvfs_files, offset); - } + + dissect_rpc_uint32(tvb, tree, hf_mount_statvfs_files, offset); offset += 4; - if (tree) { - dissect_rpc_uint32(tvb, tree, hf_mount_statvfs_ffree, offset); - } + + dissect_rpc_uint32(tvb, tree, hf_mount_statvfs_ffree, offset); offset += 4; - if (tree) { - dissect_rpc_uint32(tvb, tree, hf_mount_statvfs_favail, offset); - } + + dissect_rpc_uint32(tvb, tree, hf_mount_statvfs_favail, offset); offset += 4; - if (tree) { - dissect_rpc_bytes(tvb, tree, hf_mount_statvfs_basetype, offset, + + dissect_rpc_bytes(tvb, tree, hf_mount_statvfs_basetype, offset, 16, TRUE, NULL); - } offset += 16; - if (tree) { - dissect_rpc_bytes(tvb, tree, hf_mount_statvfs_fstr, offset, - 32, FALSE, NULL); - } + + dissect_rpc_bytes(tvb, tree, hf_mount_statvfs_fstr, offset, 32, FALSE, NULL); offset += 32; - if (tree) { - dissect_rpc_uint32(tvb, tree, hf_mount_statvfs_fsid, offset); - } - offset += 4; - if (tree) { - flag_item = proto_tree_add_item(tree, hf_mount_statvfs_flag, - tvb, offset, 4, ENC_BIG_ENDIAN); - if (flag_item) { - flag_tree = proto_item_add_subtree(flag_item, - ett_mount_statvfs_flag); - proto_tree_add_boolean(flag_tree, - hf_mount_statvfs_flag_rdonly, tvb, offset, 4, - statvfs_flags); - proto_tree_add_boolean(flag_tree, - hf_mount_statvfs_flag_nosuid, tvb, offset, 4, - statvfs_flags); - proto_tree_add_boolean(flag_tree, - hf_mount_statvfs_flag_notrunc, tvb, offset, 4, - statvfs_flags); - proto_tree_add_boolean(flag_tree, - hf_mount_statvfs_flag_nodev, tvb, offset, 4, - statvfs_flags); - proto_tree_add_boolean(flag_tree, - hf_mount_statvfs_flag_grpid, tvb, offset, 4, - statvfs_flags); - proto_tree_add_boolean(flag_tree, - hf_mount_statvfs_flag_local, tvb, offset, 4, - statvfs_flags); - } - } + dissect_rpc_uint32(tvb, tree, hf_mount_statvfs_fsid, offset); + offset += 4; + proto_tree_add_bitmask(tree, tvb, offset, hf_mount_statvfs_flag, ett_mount_statvfs_flag, flags, ENC_BIG_ENDIAN); offset += 4; - if (tree) { - dissect_rpc_uint32(tvb, tree, hf_mount_statvfs_namemax, offset); - } + + dissect_rpc_uint32(tvb, tree, hf_mount_statvfs_namemax, offset); offset += 4; return offset; diff --git a/epan/dissectors/packet-nfs.c b/epan/dissectors/packet-nfs.c index db9a94185d..489105c6a6 100644 --- a/epan/dissectors/packet-nfs.c +++ b/epan/dissectors/packet-nfs.c @@ -1306,8 +1306,7 @@ dissect_fhandle_data_SVR4(tvbuff_t* tvb, packet_info *pinfo _U_, proto_tree *tre } } - if (tree) - proto_tree_add_boolean(tree, hf_nfs_fh_endianness, tvb, 0, fhlen, little_endian); + proto_tree_add_boolean(tree, hf_nfs_fh_endianness, tvb, 0, fhlen, little_endian); /* We are fairly sure, that when found == FALSE, the following code will throw an exception. */ @@ -1844,7 +1843,30 @@ dissect_fhandle_data_NETAPP_GX_v3(tvbuff_t* tvb, packet_info *pinfo _U_, proto_t guint32 spinfile_uid; guint8 utility; guint8 volcnt; - guint32 offset = 0; + guint32 offset = 0; + static const int * fh_flags[] = { + &hf_nfs3_gxfh_sfhflags_resv1, + &hf_nfs3_gxfh_sfhflags_resv2, + &hf_nfs3_gxfh_sfhflags_ontapGX, + &hf_nfs3_gxfh_sfhflags_striped, + &hf_nfs3_gxfh_sfhflags_empty, + &hf_nfs3_gxfh_sfhflags_snapdirent, + &hf_nfs3_gxfh_sfhflags_snapdir, + &hf_nfs3_gxfh_sfhflags_streamdir, + NULL + }; + + static const int * fh_flags_ontap[] = { + &hf_nfs3_gxfh_sfhflags_resv1, + &hf_nfs3_gxfh_sfhflags_resv2, + &hf_nfs3_gxfh_sfhflags_ontap7G, + &hf_nfs3_gxfh_sfhflags_striped, + &hf_nfs3_gxfh_sfhflags_empty, + &hf_nfs3_gxfh_sfhflags_snapdirent, + &hf_nfs3_gxfh_sfhflags_snapdir, + &hf_nfs3_gxfh_sfhflags_streamdir, + NULL + }; /* = utility = */ utility = tvb_get_guint8(tvb, offset); @@ -1890,33 +1912,13 @@ dissect_fhandle_data_NETAPP_GX_v3(tvbuff_t* tvb, packet_info *pinfo _U_, proto_t proto_tree_add_item(field_tree, hf_nfs3_gxfh_cid, tvb, offset+8, 2, ENC_BIG_ENDIAN); proto_tree_add_item(field_tree, hf_nfs3_gxfh_resv, tvb, offset+10, 1, ENC_BIG_ENDIAN); - tf = proto_tree_add_uint_format(field_tree, hf_nfs3_gxfh_sfhflags, tvb, - offset+11, 1, utility, - " flags: 0x%02x", flags); - field_tree = proto_item_add_subtree(tf, ett_nfs3_gxfh_sfhflags); - proto_tree_add_uint(field_tree, hf_nfs3_gxfh_sfhflags_resv1, tvb, - offset+11, 1, flags); - proto_tree_add_uint(field_tree, hf_nfs3_gxfh_sfhflags_resv2, tvb, - offset+11, 1, flags); - if (flags & SPINNP_FH_FLAG_ONTAP_MASK) { - proto_tree_add_uint(field_tree, hf_nfs3_gxfh_sfhflags_ontap7G, tvb, - offset+11, 1, flags); + proto_tree_add_bitmask(field_tree, tvb, offset+11, hf_nfs3_gxfh_sfhflags, ett_nfs3_gxfh_sfhflags, fh_flags_ontap, ENC_NA); } else { - proto_tree_add_uint(field_tree, hf_nfs3_gxfh_sfhflags_ontapGX, tvb, - offset+11, 1, flags); + proto_tree_add_bitmask(field_tree, tvb, offset+11, hf_nfs3_gxfh_sfhflags, ett_nfs3_gxfh_sfhflags, fh_flags, ENC_NA); } - proto_tree_add_boolean(field_tree, hf_nfs3_gxfh_sfhflags_striped, tvb, - offset+11, 1, flags); - proto_tree_add_boolean(field_tree, hf_nfs3_gxfh_sfhflags_empty, tvb, - offset+11, 1, flags); - proto_tree_add_boolean(field_tree, hf_nfs3_gxfh_sfhflags_snapdirent, tvb, - offset+11, 1, flags); - proto_tree_add_boolean(field_tree, hf_nfs3_gxfh_sfhflags_snapdir, tvb, - offset+11, 1, flags); - proto_tree_add_boolean(field_tree, hf_nfs3_gxfh_sfhflags_streamdir, tvb, - offset+11, 1, flags); + proto_tree_add_uint(field_tree, hf_nfs3_gxfh_spinfid, tvb, offset+12, 4, spinfile_id); proto_tree_add_uint(field_tree, hf_nfs3_gxfh_spinfuid, tvb, @@ -1934,33 +1936,13 @@ dissect_fhandle_data_NETAPP_GX_v3(tvbuff_t* tvb, packet_info *pinfo _U_, proto_t proto_tree_add_item(field_tree, hf_nfs3_gxfh_cid, tvb, offset+24, 2, ENC_BIG_ENDIAN); proto_tree_add_item(field_tree, hf_nfs3_gxfh_resv, tvb, offset+26, 1, ENC_BIG_ENDIAN); - tf = proto_tree_add_uint_format(field_tree, hf_nfs3_gxfh_sfhflags, tvb, - offset+27, 1, utility, - " flags: 0x%02x", flags); - field_tree = proto_item_add_subtree(tf, ett_nfs3_gxfh_sfhflags); - proto_tree_add_uint(field_tree, hf_nfs3_gxfh_sfhflags_resv1, tvb, - offset+27, 1, flags); - proto_tree_add_uint(field_tree, hf_nfs3_gxfh_sfhflags_resv2, tvb, - offset+27, 1, flags); - if (flags & SPINNP_FH_FLAG_ONTAP_MASK) { - proto_tree_add_uint(field_tree, hf_nfs3_gxfh_sfhflags_ontap7G, tvb, - offset+27, 1, flags); + proto_tree_add_bitmask(field_tree, tvb, offset+27, hf_nfs3_gxfh_sfhflags, ett_nfs3_gxfh_sfhflags, fh_flags_ontap, ENC_NA); } else { - proto_tree_add_uint(field_tree, hf_nfs3_gxfh_sfhflags_ontapGX, tvb, - offset+27, 1, flags); + proto_tree_add_bitmask(field_tree, tvb, offset+27, hf_nfs3_gxfh_sfhflags, ett_nfs3_gxfh_sfhflags, fh_flags, ENC_NA); } - proto_tree_add_boolean(field_tree, hf_nfs3_gxfh_sfhflags_striped, tvb, - offset+27, 1, flags); - proto_tree_add_boolean(field_tree, hf_nfs3_gxfh_sfhflags_empty, tvb, - offset+27, 1, flags); - proto_tree_add_boolean(field_tree, hf_nfs3_gxfh_sfhflags_snapdirent, tvb, - offset+27, 1, flags); - proto_tree_add_boolean(field_tree, hf_nfs3_gxfh_sfhflags_snapdir, tvb, - offset+27, 1, flags); - proto_tree_add_boolean(field_tree, hf_nfs3_gxfh_sfhflags_streamdir, tvb, - offset+27, 1, flags); + proto_tree_add_uint(field_tree, hf_nfs3_gxfh_spinfid, tvb, offset+28, 4, spinfile_id); proto_tree_add_uint(field_tree, hf_nfs3_gxfh_spinfuid, tvb, @@ -7780,8 +7762,7 @@ dissect_nfs4_dirlist(tvbuff_t *tvb, int offset, packet_info *pinfo, entry_tree = proto_item_add_subtree(eitem, ett_nfs4_dir_entry); /* Value Follows: <Yes|No> */ - if (entry_tree) - proto_tree_add_boolean(entry_tree, hf_nfs4_value_follows, tvb, offset, 4, val_follows); + proto_tree_add_boolean(entry_tree, hf_nfs4_value_follows, tvb, offset, 4, val_follows); offset += 4; /* Directory entry cookie */ diff --git a/epan/dissectors/packet-nhrp.c b/epan/dissectors/packet-nhrp.c index bf12a75e28..5f507a2941 100644 --- a/epan/dissectors/packet-nhrp.c +++ b/epan/dissectors/packet-nhrp.c @@ -575,7 +575,6 @@ static void dissect_nhrp_mand(tvbuff_t *tvb, gint offset = *pOffset; gint mandEnd = offset + mandLen; guint8 ssl, shl; - guint16 flags; guint dstLen; gboolean isReq = FALSE; gboolean isErr = FALSE; @@ -613,34 +612,56 @@ static void dissect_nhrp_mand(tvbuff_t *tvb, offset += 1; if (!isInd) { - proto_item *flag_item; - proto_tree *flag_tree; - flags = tvb_get_ntohs(tvb, offset); - flag_item = proto_tree_add_uint(nhrp_tree, hf_nhrp_flags, tvb, offset, 2, flags); - flag_tree = proto_item_add_subtree(flag_item, ett_nhrp_mand_flag); - switch (hdr->ar_op_type) { case NHRP_RESOLUTION_REQ: case NHRP_RESOLUTION_REPLY: - proto_tree_add_boolean(flag_tree, hf_nhrp_flag_Q, tvb, offset, 2, flags); - proto_tree_add_boolean(flag_tree, hf_nhrp_flag_A, tvb, offset, 2, flags); - proto_tree_add_boolean(flag_tree, hf_nhrp_flag_D, tvb, offset, 2, flags); - proto_tree_add_boolean(flag_tree, hf_nhrp_flag_U1, tvb, offset, 2, flags); - proto_tree_add_boolean(flag_tree, hf_nhrp_flag_S, tvb, offset, 2, flags); + { + static const int * flags[] = { + &hf_nhrp_flag_Q, + &hf_nhrp_flag_A, + &hf_nhrp_flag_D, + &hf_nhrp_flag_U1, + &hf_nhrp_flag_S, + &hf_nhrp_flag_NAT, + NULL + }; + proto_tree_add_bitmask(nhrp_tree, tvb, offset, hf_nhrp_flags, ett_nhrp_mand_flag, flags, ENC_BIG_ENDIAN); + } break; case NHRP_REGISTRATION_REQ: case NHRP_REGISTRATION_REPLY: - proto_tree_add_boolean(flag_tree, hf_nhrp_flag_U2, tvb, offset, 2, flags); + { + static const int * flags[] = { + &hf_nhrp_flag_U2, + &hf_nhrp_flag_NAT, + NULL + }; + proto_tree_add_bitmask(nhrp_tree, tvb, offset, hf_nhrp_flags, ett_nhrp_mand_flag, flags, ENC_BIG_ENDIAN); + } break; case NHRP_PURGE_REQ: case NHRP_PURGE_REPLY: - proto_tree_add_boolean(flag_tree, hf_nhrp_flag_N, tvb, offset, 2, flags); + { + static const int * flags[] = { + &hf_nhrp_flag_N, + &hf_nhrp_flag_NAT, + NULL + }; + proto_tree_add_bitmask(nhrp_tree, tvb, offset, hf_nhrp_flags, ett_nhrp_mand_flag, flags, ENC_BIG_ENDIAN); + } + break; + default: + { + static const int * flags[] = { + &hf_nhrp_flag_NAT, + NULL + }; + proto_tree_add_bitmask(nhrp_tree, tvb, offset, hf_nhrp_flags, ett_nhrp_mand_flag, flags, ENC_BIG_ENDIAN); + } break; } - proto_tree_add_boolean(flag_tree, hf_nhrp_flag_NAT, tvb, offset, 2, flags); - offset += 2; col_append_fstr(pinfo->cinfo, COL_INFO, ", ID=%u", tvb_get_ntohl(tvb, offset)); diff --git a/epan/dissectors/packet-nisplus.c b/epan/dissectors/packet-nisplus.c index 069ecd6815..833527dd4b 100644 --- a/epan/dissectors/packet-nisplus.c +++ b/epan/dissectors/packet-nisplus.c @@ -312,31 +312,27 @@ dissect_group_obj(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tre static int dissect_access_rights(tvbuff_t *tvb, int offset, proto_tree *tree) { - proto_item* mask_item = NULL; - proto_tree* mask_tree = NULL; - guint32 mask; - - mask_item = proto_tree_add_item(tree, hf_nisplus_access_mask, - tvb, offset, 4, ENC_NA); - - mask_tree = proto_item_add_subtree(mask_item, ett_nisplus_access_mask); - mask = tvb_get_ntohl(tvb, offset); - proto_tree_add_boolean(mask_tree, hf_nisplus_mask_world_read, tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_mask_world_modify, tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_mask_world_create, tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_mask_world_destroy, tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_mask_group_read, tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_mask_group_modify, tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_mask_group_create, tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_mask_group_destroy, tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_mask_owner_read, tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_mask_owner_modify, tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_mask_owner_create, tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_mask_owner_destroy, tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_mask_nobody_read, tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_mask_nobody_modify, tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_mask_nobody_create, tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_mask_nobody_destroy, tvb, offset, 4, mask); + static const int * flags[] = { + &hf_nisplus_mask_world_read, + &hf_nisplus_mask_world_modify, + &hf_nisplus_mask_world_create, + &hf_nisplus_mask_world_destroy, + &hf_nisplus_mask_group_read, + &hf_nisplus_mask_group_modify, + &hf_nisplus_mask_group_create, + &hf_nisplus_mask_group_destroy, + &hf_nisplus_mask_owner_read, + &hf_nisplus_mask_owner_modify, + &hf_nisplus_mask_owner_create, + &hf_nisplus_mask_owner_destroy, + &hf_nisplus_mask_nobody_read, + &hf_nisplus_mask_nobody_modify, + &hf_nisplus_mask_nobody_create, + &hf_nisplus_mask_nobody_destroy, + NULL + }; + + proto_tree_add_bitmask(tree, tvb, offset, hf_nisplus_access_mask, ett_nisplus_access_mask, flags, ENC_BIG_ENDIAN); offset += 4; return offset; @@ -345,12 +341,19 @@ dissect_access_rights(tvbuff_t *tvb, int offset, proto_tree *tree) static int dissect_table(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, void* data _U_) { - proto_item* lock_item = NULL; - proto_tree* lock_tree = NULL; - proto_item* mask_item = NULL; - proto_tree* mask_tree = NULL; - guint32 mask; + proto_item* lock_item; + proto_tree* lock_tree; int old_offset = offset; + static const int * flags[] = { + &hf_nisplus_table_col_mask_binary, + &hf_nisplus_table_col_mask_encrypted, + &hf_nisplus_table_col_mask_xdr, + &hf_nisplus_table_col_mask_searchable, + &hf_nisplus_table_col_mask_casesensitive, + &hf_nisplus_table_col_mask_modified, + &hf_nisplus_table_col_mask_asn, + NULL + }; lock_item = proto_tree_add_item(tree, hf_nisplus_table_col, tvb, offset, -1, ENC_NA); @@ -360,26 +363,7 @@ dissect_table(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tre offset = dissect_rpc_string(tvb, lock_tree, hf_nisplus_table_col_name, offset, NULL); - - mask_item = proto_tree_add_item(lock_tree, hf_nisplus_table_col_mask, - tvb, offset, 4, - ENC_NA); - mask_tree = proto_item_add_subtree(mask_item, ett_nisplus_table_col_mask); - mask = tvb_get_ntohl(tvb, offset); - proto_tree_add_boolean(mask_tree, hf_nisplus_table_col_mask_binary, - tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_table_col_mask_encrypted, - tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_table_col_mask_xdr, - tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_table_col_mask_searchable, - tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_table_col_mask_casesensitive, - tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_table_col_mask_modified, - tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_table_col_mask_asn, - tvb, offset, 4, mask); + proto_tree_add_bitmask(lock_tree, tvb, offset, hf_nisplus_table_col_mask, ett_nisplus_table_col_mask, flags, ENC_BIG_ENDIAN); offset += 4; offset = dissect_access_rights(tvb, offset, lock_tree); @@ -422,29 +406,24 @@ dissect_table_obj(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tre static int dissect_entry(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, void* data _U_) { - proto_item* lock_item = NULL; - proto_tree* lock_tree = NULL; - proto_item* mask_item = NULL; - proto_tree* mask_tree = NULL; - guint32 mask; + proto_item* lock_item; + proto_tree* lock_tree; int old_offset = offset; + static const int * flags[] = { + &hf_nisplus_entry_mask_binary, + &hf_nisplus_entry_mask_crypt, + &hf_nisplus_entry_mask_xdr, + &hf_nisplus_entry_mask_modified, + &hf_nisplus_entry_mask_asn, + NULL + }; lock_item = proto_tree_add_item(tree, hf_nisplus_entry_col, tvb, offset, -1, ENC_NA); lock_tree = proto_item_add_subtree(lock_item, ett_nisplus_entry_col); - mask_item = proto_tree_add_item(lock_tree, hf_nisplus_entry_mask, - tvb, offset, 4, - ENC_NA); - - mask_tree = proto_item_add_subtree(mask_item, ett_nisplus_entry_mask); - mask = tvb_get_ntohl(tvb, offset); - proto_tree_add_boolean(mask_tree, hf_nisplus_entry_mask_binary, tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_entry_mask_crypt, tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_entry_mask_xdr, tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_entry_mask_modified, tvb, offset, 4, mask); - proto_tree_add_boolean(mask_tree, hf_nisplus_entry_mask_asn, tvb, offset, 4, mask); + proto_tree_add_bitmask(lock_tree, tvb, offset, hf_nisplus_entry_mask, ett_nisplus_entry_mask, flags, ENC_BIG_ENDIAN); offset += 4; offset = dissect_rpc_string(tvb, lock_tree, @@ -1476,7 +1455,7 @@ proto_register_nis(void) NIS_MASK_NOBODY_DESTROY, "Nobody Destroy Flag", HFILL }}, { &hf_nisplus_access_mask, { - "access mask", "nisplus.access.mask", FT_NONE, BASE_NONE, + "access mask", "nisplus.access.mask", FT_UINT32, BASE_HEX, NULL, 0, "NIS Access Mask", HFILL }}, { &hf_nisplus_object_type, { @@ -1635,7 +1614,7 @@ proto_register_nis(void) NULL, 0, NULL, HFILL }}, { &hf_nisplus_table_col_mask, { - "flags", "nisplus.table.col.flags", FT_NONE, BASE_NONE, + "flags", "nisplus.table.col.flags", FT_UINT32, BASE_HEX, NULL, 0, "Flags For This Column", HFILL }}, { &hf_nisplus_table_col_mask_binary, { diff --git a/epan/dissectors/packet-nsip.c b/epan/dissectors/packet-nsip.c index 88377863c8..0aca414b2b 100644 --- a/epan/dissectors/packet-nsip.c +++ b/epan/dissectors/packet-nsip.c @@ -59,6 +59,7 @@ static int hf_nsip_ip_address_ipv4 = -1; static int hf_nsip_ip_address_ipv6 = -1; static int hf_nsip_end_flag = -1; static int hf_nsip_end_flag_spare = -1; +static int hf_nsip_control_bits = -1; static int hf_nsip_control_bits_r = -1; static int hf_nsip_control_bits_c = -1; static int hf_nsip_control_bits_spare = -1; @@ -594,27 +595,18 @@ decode_iei_end_flag(nsip_ie_t *ie, build_info_t *bi, int ie_start_offset) { } static void -decode_iei_control_bits(nsip_ie_t *ie, build_info_t *bi, int ie_start_offset) { +decode_iei_control_bits(nsip_ie_t *ie _U_, build_info_t *bi, int ie_start_offset) { guint8 control_bits; - proto_tree *field_tree; + static const int * flags[] = { + &hf_nsip_control_bits_r, + &hf_nsip_control_bits_c, + &hf_nsip_control_bits_spare, + NULL + }; control_bits = tvb_get_guint8(bi->tvb, bi->offset); - - if (bi->nsip_tree) { - field_tree = proto_tree_add_subtree_format(bi->nsip_tree, bi->tvb, ie_start_offset, - ie->total_length, ett_nsip_control_bits, NULL, - "NS SDU Control bits: %#02x", control_bits); - - proto_tree_add_boolean(field_tree, hf_nsip_control_bits_r, bi->tvb, - bi->offset, 1, - control_bits & NSIP_MASK_CONTROL_BITS_R); - proto_tree_add_boolean(field_tree, hf_nsip_control_bits_c, bi->tvb, - bi->offset, 1, - control_bits & NSIP_MASK_CONTROL_BITS_C); - proto_tree_add_uint(field_tree, hf_nsip_control_bits_spare, - bi->tvb, bi->offset, 1, - control_bits & NSIP_MASK_CONTROL_BITS_SPARE); - } + proto_tree_add_bitmask(bi->nsip_tree, bi->tvb, ie_start_offset, hf_nsip_control_bits, + ett_nsip_control_bits, flags, ENC_NA); bi->offset++; if (control_bits & NSIP_MASK_CONTROL_BITS_R) { @@ -1080,6 +1072,11 @@ proto_register_nsip(void) FT_UINT8, BASE_HEX, NULL, NSIP_MASK_END_FLAG_SPARE, NULL, HFILL } }, + { &hf_nsip_control_bits, + { "NS SDU Control bits", "nsip.control_bits", + FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL } + }, { &hf_nsip_control_bits_r, { "Request change flow", "nsip.control_bits.r", FT_BOOLEAN, 8, TFS(&tfs_set_notset), NSIP_MASK_CONTROL_BITS_R, diff --git a/epan/dissectors/packet-ntlmssp.c b/epan/dissectors/packet-ntlmssp.c index b1e242fedd..94597cd309 100644 --- a/epan/dissectors/packet-ntlmssp.c +++ b/epan/dissectors/packet-ntlmssp.c @@ -1019,120 +1019,41 @@ dissect_ntlmssp_blob (tvbuff_t *tvb, packet_info *pinfo, return offset; } -static int -dissect_ntlmssp_negotiate_flags (tvbuff_t *tvb, int offset, - proto_tree *ntlmssp_tree, - guint32 negotiate_flags) -{ - proto_tree *negotiate_flags_tree = NULL; - proto_item *tf = NULL; - - if (ntlmssp_tree) { - tf = proto_tree_add_uint (ntlmssp_tree, - hf_ntlmssp_negotiate_flags, - tvb, offset, 4, negotiate_flags); - negotiate_flags_tree = proto_item_add_subtree (tf, ett_ntlmssp_negotiate_flags); - } - - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_80000000, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_40000000, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_20000000, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_10000000, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_8000000, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_4000000, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_2000000, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_1000000, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_800000, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_400000, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_200000, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_100000, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_80000, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_40000, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_20000, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_10000, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_8000, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_4000, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_2000, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_1000, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_800, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_400, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_200, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_100, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_80, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_40, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_20, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_10, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_08, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_04, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_02, - tvb, offset, 4, negotiate_flags); - proto_tree_add_boolean (negotiate_flags_tree, - hf_ntlmssp_negotiate_flags_01, - tvb, offset, 4, negotiate_flags); - - return (offset + 4); -} +static const int * ntlmssp_negotiate_flags[] = { + &hf_ntlmssp_negotiate_flags_80000000, + &hf_ntlmssp_negotiate_flags_40000000, + &hf_ntlmssp_negotiate_flags_20000000, + &hf_ntlmssp_negotiate_flags_10000000, + &hf_ntlmssp_negotiate_flags_8000000, + &hf_ntlmssp_negotiate_flags_4000000, + &hf_ntlmssp_negotiate_flags_2000000, + &hf_ntlmssp_negotiate_flags_1000000, + &hf_ntlmssp_negotiate_flags_800000, + &hf_ntlmssp_negotiate_flags_400000, + &hf_ntlmssp_negotiate_flags_200000, + &hf_ntlmssp_negotiate_flags_100000, + &hf_ntlmssp_negotiate_flags_80000, + &hf_ntlmssp_negotiate_flags_40000, + &hf_ntlmssp_negotiate_flags_20000, + &hf_ntlmssp_negotiate_flags_10000, + &hf_ntlmssp_negotiate_flags_8000, + &hf_ntlmssp_negotiate_flags_4000, + &hf_ntlmssp_negotiate_flags_2000, + &hf_ntlmssp_negotiate_flags_1000, + &hf_ntlmssp_negotiate_flags_800, + &hf_ntlmssp_negotiate_flags_400, + &hf_ntlmssp_negotiate_flags_200, + &hf_ntlmssp_negotiate_flags_100, + &hf_ntlmssp_negotiate_flags_80, + &hf_ntlmssp_negotiate_flags_40, + &hf_ntlmssp_negotiate_flags_20, + &hf_ntlmssp_negotiate_flags_10, + &hf_ntlmssp_negotiate_flags_08, + &hf_ntlmssp_negotiate_flags_04, + &hf_ntlmssp_negotiate_flags_02, + &hf_ntlmssp_negotiate_flags_01, + NULL +}; /* Dissect "version" */ @@ -1406,8 +1327,8 @@ dissect_ntlmssp_negotiate (tvbuff_t *tvb, int offset, proto_tree *ntlmssp_tree, /* NTLMSSP Negotiate Flags */ negotiate_flags = tvb_get_letohl (tvb, offset); - offset = dissect_ntlmssp_negotiate_flags (tvb, offset, ntlmssp_tree, - negotiate_flags); + proto_tree_add_bitmask(ntlmssp_tree, tvb, offset, hf_ntlmssp_negotiate_flags, ett_ntlmssp_negotiate_flags, ntlmssp_negotiate_flags, ENC_LITTLE_ENDIAN); + offset += 4; /* * XXX - the davenport document says that these might not be @@ -1511,8 +1432,8 @@ dissect_ntlmssp_challenge (tvbuff_t *tvb, packet_info *pinfo, int offset, data_end = item_end; /* NTLMSSP Negotiate Flags */ - offset = dissect_ntlmssp_negotiate_flags (tvb, offset, ntlmssp_tree, - negotiate_flags); + proto_tree_add_bitmask(ntlmssp_tree, tvb, offset, hf_ntlmssp_negotiate_flags, ett_ntlmssp_negotiate_flags, ntlmssp_negotiate_flags, ENC_LITTLE_ENDIAN); + offset += 4; /* NTLMSSP NT Lan Manager Challenge */ proto_tree_add_item (ntlmssp_tree, @@ -1788,8 +1709,9 @@ dissect_ntlmssp_auth (tvbuff_t *tvb, packet_info *pinfo, int offset, if (offset < data_start) { /* NTLMSSP Negotiate Flags */ negotiate_flags = tvb_get_letohl (tvb, offset); - offset = dissect_ntlmssp_negotiate_flags (tvb, offset, ntlmssp_tree, - negotiate_flags); + proto_tree_add_bitmask(ntlmssp_tree, tvb, offset, hf_ntlmssp_negotiate_flags, ett_ntlmssp_negotiate_flags, ntlmssp_negotiate_flags, ENC_LITTLE_ENDIAN); + offset += 4; + /* If no previous flags seen (ie: no previous CHALLENGE) use flags from the AUTHENTICATE message). Assumption: (flags == 0) means flags not previously seen */ |