From 4f9707469dc6edb8792ec811fecebb0f377fc58b Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Tue, 25 Sep 2012 01:00:41 +0000 Subject: [PATCH] replaced decode_boolean_bitfield calls with itemized filters added tfs_no_yes to tfs.[ch] svn path=/trunk/; revision=45115 --- epan/dissectors/packet-bgp.c | 190 +++++++++++--------- epan/dissectors/packet-cups.c | 157 ++++++++++------- epan/dissectors/packet-dlsw.c | 9 +- epan/dissectors/packet-netbios.c | 24 +-- epan/dissectors/packet-nlsp.c | 30 ++-- epan/dissectors/packet-pcep.c | 29 +-- epan/dissectors/packet-pim.c | 61 +++++-- epan/dissectors/packet-ppp.c | 46 +++-- epan/dissectors/packet-quake.c | 83 +++++---- epan/dissectors/packet-skinny.c | 80 +++++++-- epan/dissectors/packet-tacacs.c | 39 +++-- epan/dissectors/packet-v120.c | 291 ++++++++++++++++++------------- epan/tfs.c | 1 + epan/tfs.h | 1 + 14 files changed, 646 insertions(+), 395 deletions(-) diff --git a/epan/dissectors/packet-bgp.c b/epan/dissectors/packet-bgp.c index 9c2c960463..a90b435529 100644 --- a/epan/dissectors/packet-bgp.c +++ b/epan/dissectors/packet-bgp.c @@ -97,11 +97,8 @@ struct bgp_route_refresh { guint8 bgpr_safi; }; -/* path attribute */ -struct bgp_attr { - guint8 bgpa_flags; - guint8 bgpa_type; -}; +#define BGP_SIZE_OF_PATH_ATTRIBUTE 2 + /* attribute flags, from RFC1771 */ #define BGP_ATTR_FLAG_OPTIONAL 0x80 @@ -593,6 +590,11 @@ static const value_string mcast_vpn_route_type[] = { { 0, NULL } }; +static const true_false_string tfs_optional_wellknown = { "Optional", "Well-known" }; +static const true_false_string tfs_transitive_non_transitive = { "Transitive", "Non-transitive" }; +static const true_false_string tfs_partial_complete = { "Partial", "Complete" }; +static const true_false_string tfs_extended_regular_length = { "Extended length", "Regular length" }; + /* Maximal size of an IP address string */ #define MAX_SIZE_OF_IP_ADDR_STRING 16 @@ -695,7 +697,19 @@ static int hf_bgp_encaps_tunnel_subtlv_type = -1; static int hf_bgp_mdt_safi_rd = -1; static int hf_bgp_mdt_safi_ipv4_addr = -1; static int hf_bgp_mdt_safi_group_addr = -1; - +static int hf_bgp_flags_optional = -1; +static int hf_bgp_flags_transitive = -1; +static int hf_bgp_flags_partial = -1; +static int hf_bgp_flags_extended_length = -1; +static int hf_bgp_ext_com_qos_flags = -1; +static int hf_bgp_ext_com_qos_flags_remarking = -1; +static int hf_bgp_ext_com_qos_flags_ignore_remarking = -1; +static int hf_bgp_ext_com_qos_flags_agg_marking = -1; +static int hf_bgp_ext_com_cos_flags = -1; +static int hf_bgp_ext_com_cos_flags_be = -1; +static int hf_bgp_ext_com_cos_flags_ef = -1; +static int hf_bgp_ext_com_cos_flags_af = -1; +static int hf_bgp_ext_com_cos_flags_le = -1; static gint ett_bgp = -1; static gint ett_bgp_prefix = -1; @@ -2319,7 +2333,8 @@ dissect_bgp_open(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo) static void dissect_bgp_update(tvbuff_t *tvb, proto_tree *tree) { - struct bgp_attr bgpa; /* path attributes */ + guint8 bgpa_flags; /* path attributes */ + guint8 bgpa_type; guint16 hlen; /* message length */ gint o; /* packet offset */ gint q; /* tmp */ @@ -2424,28 +2439,30 @@ dissect_bgp_update(tvbuff_t *tvb, proto_tree *tree) guint8 nexthop_len; guint8 asn_len = 0; - tvb_memcpy(tvb, (guint8 *)&bgpa, o + i, sizeof(bgpa)); + bgpa_flags = tvb_get_guint8(tvb, o + i); + bgpa_type = tvb_get_guint8(tvb, o + i+1); + /* check for the Extended Length bit */ - if (bgpa.bgpa_flags & BGP_ATTR_FLAG_EXTENDED_LENGTH) { - alen = tvb_get_ntohs(tvb, o + i + sizeof(bgpa)); - aoff = sizeof(bgpa) + 2; + if (bgpa_flags & BGP_ATTR_FLAG_EXTENDED_LENGTH) { + alen = tvb_get_ntohs(tvb, o + i + BGP_SIZE_OF_PATH_ATTRIBUTE); + aoff = BGP_SIZE_OF_PATH_ATTRIBUTE+2; } else { - alen = tvb_get_guint8(tvb, o + i + sizeof(bgpa)); - aoff = sizeof(bgpa) + 1; + alen = tvb_get_guint8(tvb, o + i + BGP_SIZE_OF_PATH_ATTRIBUTE); + aoff = BGP_SIZE_OF_PATH_ATTRIBUTE+1; } tlen = alen; /* This is kind of ugly - similar code appears twice, but it helps browsing attrs. */ /* the first switch prints things in the title of the subtree */ - switch (bgpa.bgpa_type) { + switch (bgpa_type) { case BGPTYPE_ORIGIN: if (tlen != 1) goto default_attribute_top; msg = val_to_str_const(tvb_get_guint8(tvb, o + i + aoff), bgpattr_origin, "Unknown"); ti = proto_tree_add_text(subtree, tvb, o + i, tlen + aoff, "%s: %s (%u byte%s)", - val_to_str_const(bgpa.bgpa_type, bgpattr_type, "Unknown"), + val_to_str_const(bgpa_type, bgpattr_type, "Unknown"), msg, tlen + aoff, plurality(tlen + aoff, "", "s")); break; case BGPTYPE_AS_PATH: @@ -2462,7 +2479,7 @@ dissect_bgp_update(tvbuff_t *tvb, proto_tree *tree) ep_strbuf_truncate(as_path_emstr, 0); /* estimate the length of the AS number */ - if (bgpa.bgpa_type == BGPTYPE_NEW_AS_PATH) + if (bgpa_type == BGPTYPE_NEW_AS_PATH) asn_len = 4; else { if (bgp_asn_len == 0) { @@ -2551,7 +2568,7 @@ dissect_bgp_update(tvbuff_t *tvb, proto_tree *tree) ti = proto_tree_add_text(subtree, tvb, o + i, tlen + aoff, "%s: %s (%u byte%s)", - val_to_str_const(bgpa.bgpa_type, bgpattr_type, "Unknown"), + val_to_str_const(bgpa_type, bgpattr_type, "Unknown"), as_path_emstr->str, tlen + aoff, plurality(tlen + aoff, "", "s")); break; @@ -2561,7 +2578,7 @@ dissect_bgp_update(tvbuff_t *tvb, proto_tree *tree) ipaddr = tvb_get_ipv4(tvb, o + i + aoff); ti = proto_tree_add_text(subtree, tvb, o + i, tlen + aoff, "%s: %s (%u byte%s)", - val_to_str_const(bgpa.bgpa_type, bgpattr_type, "Unknown"), + val_to_str_const(bgpa_type, bgpattr_type, "Unknown"), ip_to_str((guint8 *)&ipaddr), tlen + aoff, plurality(tlen + aoff, "", "s")); break; @@ -2570,7 +2587,7 @@ dissect_bgp_update(tvbuff_t *tvb, proto_tree *tree) goto default_attribute_top; ti = proto_tree_add_text(subtree, tvb, o + i, tlen + aoff, "%s: %u (%u byte%s)", - val_to_str_const(bgpa.bgpa_type, bgpattr_type, "Unknown"), + val_to_str_const(bgpa_type, bgpattr_type, "Unknown"), tvb_get_ntohl(tvb, o + i + aoff), tlen + aoff, plurality(tlen + aoff, "", "s")); break; @@ -2579,7 +2596,7 @@ dissect_bgp_update(tvbuff_t *tvb, proto_tree *tree) goto default_attribute_top; ti = proto_tree_add_text(subtree, tvb, o + i, tlen + aoff, "%s: %u (%u byte%s)", - val_to_str_const(bgpa.bgpa_type, bgpattr_type, "Unknown"), + val_to_str_const(bgpa_type, bgpattr_type, "Unknown"), tvb_get_ntohl(tvb, o + i + aoff), tlen + aoff, plurality(tlen + aoff, "", "s")); break; @@ -2588,20 +2605,20 @@ dissect_bgp_update(tvbuff_t *tvb, proto_tree *tree) goto default_attribute_top; ti = proto_tree_add_text(subtree, tvb, o + i, tlen + aoff, "%s (%u byte%s)", - val_to_str_const(bgpa.bgpa_type, bgpattr_type, "Unknown"), + val_to_str_const(bgpa_type, bgpattr_type, "Unknown"), tlen + aoff, plurality(tlen + aoff, "", "s")); break; case BGPTYPE_AGGREGATOR: if (tlen != 6 && tlen != 8) goto default_attribute_top; case BGPTYPE_NEW_AGGREGATOR: - if (bgpa.bgpa_type == BGPTYPE_NEW_AGGREGATOR && tlen != 8) + if (bgpa_type == BGPTYPE_NEW_AGGREGATOR && tlen != 8) goto default_attribute_top; asn_len = tlen - 4; ipaddr = tvb_get_ipv4(tvb, o + i + aoff + asn_len); ti = proto_tree_add_text(subtree, tvb, o + i, tlen + aoff, "%s: AS: %u origin: %s (%u byte%s)", - val_to_str_const(bgpa.bgpa_type, bgpattr_type, "Unknown"), + val_to_str_const(bgpa_type, bgpattr_type, "Unknown"), (asn_len == 2) ? tvb_get_ntohs(tvb, o + i + aoff) : tvb_get_ntohl(tvb, o + i + aoff), ip_to_str((guint8 *)&ipaddr), @@ -2644,7 +2661,7 @@ dissect_bgp_update(tvbuff_t *tvb, proto_tree *tree) ti = proto_tree_add_text(subtree, tvb, o + i, tlen + aoff, "%s: %s (%u byte%s)", - val_to_str_const(bgpa.bgpa_type, bgpattr_type, "Unknown"), + val_to_str_const(bgpa_type, bgpattr_type, "Unknown"), communities_emstr->str, tlen + aoff, plurality(tlen + aoff, "", "s")); break; @@ -2654,7 +2671,7 @@ dissect_bgp_update(tvbuff_t *tvb, proto_tree *tree) ipaddr = tvb_get_ipv4(tvb, o + i + aoff); ti = proto_tree_add_text(subtree, tvb, o + i, tlen + aoff, "%s: %s (%u byte%s)", - val_to_str_const(bgpa.bgpa_type, bgpattr_type, "Unknown"), + val_to_str_const(bgpa_type, bgpattr_type, "Unknown"), ip_to_str((guint8 *)&ipaddr), tlen + aoff, plurality(tlen + aoff, "", "s")); break; @@ -2685,7 +2702,7 @@ dissect_bgp_update(tvbuff_t *tvb, proto_tree *tree) ti = proto_tree_add_text(subtree, tvb, o + i, tlen + aoff, "%s: %s (%u byte%s)", - val_to_str_const(bgpa.bgpa_type, bgpattr_type, "Unknown"), + val_to_str_const(bgpa_type, bgpattr_type, "Unknown"), cluster_list_emstr->str, tlen + aoff, plurality(tlen + aoff, "", "s")); break; @@ -2694,14 +2711,14 @@ dissect_bgp_update(tvbuff_t *tvb, proto_tree *tree) break; ti = proto_tree_add_text(subtree,tvb,o+i,tlen+aoff, "%s: (%u byte%s)", - val_to_str_const(bgpa.bgpa_type,bgpattr_type,"Unknown"), + val_to_str_const(bgpa_type,bgpattr_type,"Unknown"), tlen + aoff, plurality(tlen + aoff, "", "s")); break; case BGPTYPE_SAFI_SPECIFIC_ATTR: ti = proto_tree_add_text(subtree,tvb,o+i,tlen+aoff, "%s: (%u byte%s)", - val_to_str_const(bgpa.bgpa_type,bgpattr_type,"Unknown"), + val_to_str_const(bgpa_type,bgpattr_type,"Unknown"), tlen + aoff, plurality(tlen + aoff, "", "s")); break; @@ -2709,72 +2726,57 @@ dissect_bgp_update(tvbuff_t *tvb, proto_tree *tree) default_attribute_top: ti = proto_tree_add_text(subtree, tvb, o + i, tlen + aoff, "%s (%u byte%s)", - val_to_str_const(bgpa.bgpa_type, bgpattr_type, "Unknown"), + val_to_str_const(bgpa_type, bgpattr_type, "Unknown"), tlen + aoff, plurality(tlen + aoff, "", "s")); } /* switch (bgpa.bgpa_type) */ /* end of first switch */ subtree2 = proto_item_add_subtree(ti, ett_bgp_attr); /* figure out flags */ ep_strbuf_truncate(junk_emstr, 0); - if (bgpa.bgpa_flags & BGP_ATTR_FLAG_OPTIONAL) { + if (bgpa_flags & BGP_ATTR_FLAG_OPTIONAL) { ep_strbuf_append(junk_emstr, "Optional, "); } else { ep_strbuf_append(junk_emstr, "Well-known, "); } - if (bgpa.bgpa_flags & BGP_ATTR_FLAG_TRANSITIVE) { + if (bgpa_flags & BGP_ATTR_FLAG_TRANSITIVE) { ep_strbuf_append(junk_emstr, "Transitive, "); } else { ep_strbuf_append(junk_emstr, "Non-transitive, "); } - if (bgpa.bgpa_flags & BGP_ATTR_FLAG_PARTIAL) { + if (bgpa_flags & BGP_ATTR_FLAG_PARTIAL) { ep_strbuf_append(junk_emstr, "Partial"); } else { ep_strbuf_append(junk_emstr, "Complete"); } - if (bgpa.bgpa_flags & BGP_ATTR_FLAG_EXTENDED_LENGTH) { + if (bgpa_flags & BGP_ATTR_FLAG_EXTENDED_LENGTH) { ep_strbuf_append(junk_emstr, ", Extended Length"); } - ti = proto_tree_add_text(subtree2, tvb, - o + i + offsetof(struct bgp_attr, bgpa_flags), 1, - "Flags: 0x%02x (%s)", bgpa.bgpa_flags, junk_emstr->str); + ti = proto_tree_add_text(subtree2, tvb, o + i, 1, + "Flags: 0x%02x (%s)", bgpa_flags, junk_emstr->str); subtree3 = proto_item_add_subtree(ti, ett_bgp_attr_flags); /* add flag bitfield subtrees */ - proto_tree_add_text(subtree3, tvb, - o + i + offsetof(struct bgp_attr, bgpa_flags), 1, - "%s", decode_boolean_bitfield(bgpa.bgpa_flags, - BGP_ATTR_FLAG_OPTIONAL, 8, "Optional", "Well-known")); - proto_tree_add_text(subtree3, tvb, - o + i + offsetof(struct bgp_attr, bgpa_flags), 1, - "%s", decode_boolean_bitfield(bgpa.bgpa_flags, - BGP_ATTR_FLAG_TRANSITIVE, 8, "Transitive", - "Non-transitive")); - proto_tree_add_text(subtree3, tvb, - o + i + offsetof(struct bgp_attr, bgpa_flags), 1, - "%s", decode_boolean_bitfield(bgpa.bgpa_flags, - BGP_ATTR_FLAG_PARTIAL, 8, "Partial", "Complete")); - proto_tree_add_text(subtree3, tvb, - o + i + offsetof(struct bgp_attr, bgpa_flags), 1, - "%s", decode_boolean_bitfield(bgpa.bgpa_flags, - BGP_ATTR_FLAG_EXTENDED_LENGTH, 8, "Extended length", - "Regular length")); + proto_tree_add_item(subtree3, hf_bgp_flags_optional, tvb, o + i, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(subtree3, hf_bgp_flags_transitive, tvb, o + i, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(subtree3, hf_bgp_flags_partial, tvb, o + i, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(subtree3, hf_bgp_flags_extended_length, tvb, o + i, 1, ENC_BIG_ENDIAN); proto_tree_add_text(subtree2, tvb, - o + i + offsetof(struct bgp_attr, bgpa_type), 1, + o + i + 1, 1, "Type code: %s (%u)", - val_to_str_const(bgpa.bgpa_type, bgpattr_type, "Unknown"), - bgpa.bgpa_type); + val_to_str_const(bgpa_type, bgpattr_type, "Unknown"), + bgpa_type); - proto_tree_add_text(subtree2, tvb, o + i + sizeof(bgpa), - aoff - sizeof(bgpa), "Length: %d byte%s", tlen, + proto_tree_add_text(subtree2, tvb, o + i + BGP_SIZE_OF_PATH_ATTRIBUTE, + aoff - BGP_SIZE_OF_PATH_ATTRIBUTE, "Length: %d byte%s", tlen, plurality(tlen, "", "s")); /* the second switch prints things in the actual subtree of each attribute */ - switch (bgpa.bgpa_type) { + switch (bgpa_type) { case BGPTYPE_ORIGIN: if (tlen != 1) { proto_tree_add_text(subtree2, tvb, o + i + aoff, tlen, @@ -2916,7 +2918,7 @@ dissect_bgp_update(tvbuff_t *tvb, proto_tree *tree) break; } case BGPTYPE_NEW_AGGREGATOR: - if (bgpa.bgpa_type == BGPTYPE_NEW_AGGREGATOR && tlen != 8) + if (bgpa_type == BGPTYPE_NEW_AGGREGATOR && tlen != 8) proto_tree_add_text(subtree2, tvb, o + i + aoff, tlen, "Aggregator (invalid): %u byte%s", tlen, plurality(tlen, "", "s")); @@ -3183,16 +3185,12 @@ dissect_bgp_update(tvbuff_t *tvb, proto_tree *tree) subtree4 = proto_item_add_subtree(ti,ett_bgp_extended_communities); proto_tree_add_text(subtree4, tvb, q, 1, "Type: 0x%02x", tvb_get_guint8(tvb,q)); - ti = proto_tree_add_text(subtree4, tvb, q+1, 1, - "Flags: 0x%02x", tvb_get_guint8(tvb,q+1)); + ti = proto_tree_add_item(subtree4, hf_bgp_ext_com_qos_flags, tvb, q+1, 1, ENC_BIG_ENDIAN); subtree5 = proto_item_add_subtree(ti,ett_bgp_ext_com_flags); /* add flag bitfield */ - proto_tree_add_text(subtree5, tvb, q+1, 1, "%s", decode_boolean_bitfield(tvb_get_guint8(tvb,q+1), - 0x10, 8, "Remarking", "No Remarking")); - proto_tree_add_text(subtree5, tvb, q+1, 1, "%s", decode_boolean_bitfield(tvb_get_guint8(tvb,q+1), - 0x08, 8, "Ignored marking", "No Ignored marking")); - proto_tree_add_text(subtree5, tvb, q+1, 1, "%s", decode_boolean_bitfield(tvb_get_guint8(tvb,q+1), - 0x04, 8, "Aggregation of markings", "No Aggregation of markings")); + proto_tree_add_item(subtree5, hf_bgp_ext_com_qos_flags_remarking, tvb, q+1, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(subtree5, hf_bgp_ext_com_qos_flags_ignore_remarking, tvb, q+1, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(subtree5, hf_bgp_ext_com_qos_flags_agg_marking, tvb, q+1, 1, ENC_BIG_ENDIAN); proto_tree_add_text(subtree4, tvb, q+2, 1, "QoS Set Number: 0x%02x", tvb_get_guint8(tvb,q+2)); @@ -3215,18 +3213,13 @@ dissect_bgp_update(tvbuff_t *tvb, proto_tree *tree) subtree4 = proto_item_add_subtree(ti,ett_bgp_extended_communities); proto_tree_add_text(subtree4, tvb, q, 1, "Type: 0x%02x", tvb_get_guint8(tvb,q)); - ti = proto_tree_add_text(subtree4, tvb, q+1, 1, - "Flags byte 1 : 0x%02x", tvb_get_guint8(tvb,q+1)); + ti = proto_tree_add_item(subtree4, hf_bgp_ext_com_cos_flags, tvb, q+1, 1, ENC_BIG_ENDIAN); subtree5 = proto_item_add_subtree(ti,ett_bgp_ext_com_flags); /* add flag bitfield */ - proto_tree_add_text(subtree5, tvb, q+1, 1, "%s", decode_boolean_bitfield(tvb_get_guint8(tvb,q+1), - 0x80, 8, "BE class supported", "BE class NOT supported")); - proto_tree_add_text(subtree5, tvb, q+1, 1, "%s", decode_boolean_bitfield(tvb_get_guint8(tvb,q+1), - 0x40, 8, "EF class supported", "EF class NOT supported")); - proto_tree_add_text(subtree5, tvb, q+1, 1, "%s", decode_boolean_bitfield(tvb_get_guint8(tvb,q+1), - 0x20, 8, "AF class supported", "AF class NOT supported")); - proto_tree_add_text(subtree5, tvb, q+1, 1, "%s", decode_boolean_bitfield(tvb_get_guint8(tvb,q+1), - 0x10, 8, "LE class supported", "LE class NOT supported")); + proto_tree_add_item(subtree5, hf_bgp_ext_com_cos_flags_be, tvb, q+1, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(subtree5, hf_bgp_ext_com_cos_flags_ef, tvb, q+1, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(subtree5, hf_bgp_ext_com_cos_flags_af, tvb, q+1, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(subtree5, hf_bgp_ext_com_cos_flags_le, tvb, q+1, 1, ENC_BIG_ENDIAN); proto_tree_add_text(subtree4, tvb, q+2, 1, "Flags byte 2..7 : 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x", tvb_get_guint8(tvb,q+2),tvb_get_guint8(tvb,q+3),tvb_get_guint8(tvb,q+4), @@ -4299,6 +4292,45 @@ proto_register_bgp(void) { &hf_bgp_mdt_safi_group_addr, { "Group Address", "bgp.mdt_safi_group_addr", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL}}, + { &hf_bgp_flags_optional, + { "Optional", "bgp.flags.optional", FT_BOOLEAN, 8, + TFS(&tfs_optional_wellknown), BGP_ATTR_FLAG_OPTIONAL, NULL, HFILL}}, + { &hf_bgp_flags_transitive, + { "Transitive", "bgp.flags.transitive", FT_BOOLEAN, 8, + TFS(&tfs_transitive_non_transitive), BGP_ATTR_FLAG_TRANSITIVE, NULL, HFILL}}, + { &hf_bgp_flags_partial, + { "Partial", "bgp.flags.partial", FT_BOOLEAN, 8, + TFS(&tfs_partial_complete), BGP_ATTR_FLAG_PARTIAL, NULL, HFILL}}, + { &hf_bgp_flags_extended_length, + { "Length", "bgp.flags.extended_length", FT_BOOLEAN, 8, + TFS(&tfs_extended_regular_length), BGP_ATTR_FLAG_EXTENDED_LENGTH, NULL, HFILL}}, + { &hf_bgp_ext_com_qos_flags, + { "Flags", "bgp.ext_com_qos.flags", FT_UINT8, BASE_HEX, + NULL, 0, NULL, HFILL}}, + { &hf_bgp_ext_com_qos_flags_remarking, + { "Remarking", "bgp.ext_com_qos.flags.remarking", FT_BOOLEAN, 8, + TFS(&tfs_yes_no), 0x10, NULL, HFILL}}, + { &hf_bgp_ext_com_qos_flags_ignore_remarking, + { "Ignore remarking", "bgp.ext_com_qos.flags.ignore_remarking", FT_BOOLEAN, 8, + TFS(&tfs_yes_no), 0x08, NULL, HFILL}}, + { &hf_bgp_ext_com_qos_flags_agg_marking, + { "Aggegation of markins", "bgp.ext_com_qos.flags.agg_marking", FT_BOOLEAN, 8, + TFS(&tfs_yes_no), 0x04, NULL, HFILL}}, + { &hf_bgp_ext_com_cos_flags, + { "Flags byte 1", "bgp.ext_com_cos.flags", FT_UINT8, BASE_HEX, + NULL, 0, NULL, HFILL}}, + { &hf_bgp_ext_com_cos_flags_be, + { "BE class", "bgp.ext_com_cos.flags.be", FT_BOOLEAN, 8, + TFS(&tfs_supported_not_supported), 0x80, NULL, HFILL}}, + { &hf_bgp_ext_com_cos_flags_ef, + { "EF class", "bgp.ext_com_cos.flags.ef", FT_BOOLEAN, 8, + TFS(&tfs_supported_not_supported), 0x40, NULL, HFILL}}, + { &hf_bgp_ext_com_cos_flags_af, + { "AF class", "bgp.ext_com_cos.flags.af", FT_BOOLEAN, 8, + TFS(&tfs_supported_not_supported), 0x20, NULL, HFILL}}, + { &hf_bgp_ext_com_cos_flags_le, + { "LE class", "bgp.ext_com_cos.flags.le", FT_BOOLEAN, 8, + TFS(&tfs_supported_not_supported), 0x10, NULL, HFILL}}, }; static gint *ett[] = { diff --git a/epan/dissectors/packet-cups.c b/epan/dissectors/packet-cups.c index 1761d0ed30..88de476b05 100644 --- a/epan/dissectors/packet-cups.c +++ b/epan/dissectors/packet-cups.c @@ -60,53 +60,6 @@ enum /* Not a typedef'd enum so we can OR */ }; /* End insert from cups/cups.h */ -typedef struct { - guint32 bit; - const char *on_string; - const char *off_string; -} cups_ptype_bit_info; - -static const cups_ptype_bit_info cups_ptype_bits[] = { - { CUPS_PRINTER_DEFAULT, - "Default printer on network", "Not default printer" }, - { CUPS_PRINTER_IMPLICIT, - "Implicit class", "Explicit class" }, - { CUPS_PRINTER_VARIABLE, - "Can print variable sizes", "Cannot print variable sizes" }, - { CUPS_PRINTER_LARGE, - "Can print up to 36x48 inches", "Cannot print up to 36x48 inches" }, - { CUPS_PRINTER_MEDIUM, - "Can print up to 18x24 inches", "Cannot print up to 18x24 inches" }, - { CUPS_PRINTER_SMALL, - "Can print up to 9x14 inches", "Cannot print up to 9x14 inches" }, - { CUPS_PRINTER_SORT, - "Can sort", "Cannot sort" }, - { CUPS_PRINTER_BIND, - "Can bind", "Cannot bind" }, - { CUPS_PRINTER_COVER, - "Can cover", "Cannot cover" }, - { CUPS_PRINTER_PUNCH, - "Can punch holes", "Cannot punch holes" }, - { CUPS_PRINTER_COLLATE, - "Can do fast collating", "Cannot do fast collating" }, - { CUPS_PRINTER_COPIES, - "Can do fast copies", "Cannot do fast copies" }, - { CUPS_PRINTER_STAPLE, - "Can staple", "Cannot staple" }, - { CUPS_PRINTER_DUPLEX, - "Can duplex", "Cannot duplex" }, - { CUPS_PRINTER_COLOR, - "Can print color", "Cannot print color" }, - { CUPS_PRINTER_BW, - "Can print black", "Cannot print black" }, - { CUPS_PRINTER_REMOTE, - "Remote", "Local (illegal)" }, - { CUPS_PRINTER_CLASS, - "Printer class", "Single printer" } -}; - -#define N_CUPS_PTYPE_BITS (sizeof cups_ptype_bits / sizeof cups_ptype_bits[0]) - typedef enum _cups_state { CUPS_IDLE = 3, CUPS_PROCESSING, @@ -120,8 +73,29 @@ static const value_string cups_state_values[] = { { 0, NULL } }; +static const true_false_string tfs_implicit_explicit = { "Implicit class", "Explicit class" }; +static const true_false_string tfs_printer_class = { "Printer class", "Single printer" }; + static int proto_cups = -1; static int hf_cups_ptype = -1; +static int hf_cups_ptype_default = -1; +static int hf_cups_ptype_implicit = -1; +static int hf_cups_ptype_variable = -1; +static int hf_cups_ptype_large = -1; +static int hf_cups_ptype_medium = -1; +static int hf_cups_ptype_small = -1; +static int hf_cups_ptype_sort = -1; +static int hf_cups_ptype_bind = -1; +static int hf_cups_ptype_cover = -1; +static int hf_cups_ptype_punch = -1; +static int hf_cups_ptype_collate = -1; +static int hf_cups_ptype_copies = -1; +static int hf_cups_ptype_staple = -1; +static int hf_cups_ptype_duplex = -1; +static int hf_cups_ptype_color = -1; +static int hf_cups_ptype_bw = -1; +static int hf_cups_ptype_remote = -1; +static int hf_cups_ptype_class = -1; static int hf_cups_state = -1; static gint ett_cups = -1; @@ -152,7 +126,6 @@ dissect_cups(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) gint offset = 0; gint next_offset; guint len; - unsigned int u; const guint8 *str; cups_ptype_t ptype; unsigned int state; @@ -173,18 +146,26 @@ dissect_cups(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) len = next_offset - offset; if (len != 0) { if (cups_tree) { - ti = proto_tree_add_uint(cups_tree, hf_cups_ptype, - tvb, offset, len, ptype); - ptype_subtree = proto_item_add_subtree(ti, - ett_cups_ptype); - for (u = 0; u < N_CUPS_PTYPE_BITS; u++) { - proto_tree_add_text(ptype_subtree, tvb, - offset, len, "%s", - decode_boolean_bitfield(ptype, - cups_ptype_bits[u].bit, sizeof (ptype)*8, - cups_ptype_bits[u].on_string, - cups_ptype_bits[u].off_string)); - } + ti = proto_tree_add_uint(cups_tree, hf_cups_ptype, tvb, offset, len, ptype); + ptype_subtree = proto_item_add_subtree(ti, ett_cups_ptype); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_default, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_implicit, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_variable, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_large, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_medium, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_small, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_sort, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_bind, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_cover, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_punch, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_collate, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_copies, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_staple, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_duplex, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_color, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_bw, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_remote, tvb, offset, len, ENC_BIG_ENDIAN); + proto_tree_add_item(ptype_subtree, hf_cups_ptype_class, tvb, offset, len, ENC_BIG_ENDIAN); } } offset = next_offset; @@ -353,11 +334,63 @@ void proto_register_cups(void) { static hf_register_info hf[] = { - /* This one could be split in separate fields. */ { &hf_cups_ptype, { "Type", "cups.ptype", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }}, - + { &hf_cups_ptype_default, + { "Default printer on network", "cups.ptype.default", FT_BOOLEAN, 32, + TFS(&tfs_yes_no), CUPS_PRINTER_DEFAULT, NULL, HFILL }}, + { &hf_cups_ptype_implicit, + { "Class", "cups.ptype.implicit", FT_BOOLEAN, 32, + TFS(&tfs_implicit_explicit), CUPS_PRINTER_IMPLICIT, NULL, HFILL }}, + { &hf_cups_ptype_variable, + { "Can print variable sizes", "cups.ptype.variable", FT_BOOLEAN, 32, + TFS(&tfs_yes_no), CUPS_PRINTER_VARIABLE, NULL, HFILL }}, + { &hf_cups_ptype_large, + { "Can print up to 36x48 inches", "cups.ptype.large", FT_BOOLEAN, 32, + TFS(&tfs_yes_no), CUPS_PRINTER_LARGE, NULL, HFILL }}, + { &hf_cups_ptype_medium, + { "Can print up to 18x24 inches", "cups.ptype.medium", FT_BOOLEAN, 32, + TFS(&tfs_yes_no), CUPS_PRINTER_MEDIUM, NULL, HFILL }}, + { &hf_cups_ptype_small, + { "Can print up to 9x14 inches", "cups.ptype.small", FT_BOOLEAN, 32, + TFS(&tfs_yes_no), CUPS_PRINTER_SMALL, NULL, HFILL }}, + { &hf_cups_ptype_sort, + { "Can sort", "cups.ptype.sort", FT_BOOLEAN, 32, + TFS(&tfs_yes_no), CUPS_PRINTER_SORT, NULL, HFILL }}, + { &hf_cups_ptype_bind, + { "Can bind", "cups.ptype.bind", FT_BOOLEAN, 32, + TFS(&tfs_yes_no), CUPS_PRINTER_BIND, NULL, HFILL }}, + { &hf_cups_ptype_cover, + { "Can cover", "cups.ptype.cover", FT_BOOLEAN, 32, + TFS(&tfs_yes_no), CUPS_PRINTER_COVER, NULL, HFILL }}, + { &hf_cups_ptype_punch, + { "Can punch holes", "cups.ptype.punch", FT_BOOLEAN, 32, + TFS(&tfs_yes_no), CUPS_PRINTER_PUNCH, NULL, HFILL }}, + { &hf_cups_ptype_collate, + { "Can do fast collating", "cups.ptype.collate", FT_BOOLEAN, 32, + TFS(&tfs_yes_no), CUPS_PRINTER_COLLATE, NULL, HFILL }}, + { &hf_cups_ptype_copies, + { "Can do fast copies", "cups.ptype.copies", FT_BOOLEAN, 32, + TFS(&tfs_yes_no), CUPS_PRINTER_COPIES, NULL, HFILL }}, + { &hf_cups_ptype_staple, + { "Can staple", "cups.ptype.staple", FT_BOOLEAN, 32, + TFS(&tfs_yes_no), CUPS_PRINTER_STAPLE, NULL, HFILL }}, + { &hf_cups_ptype_duplex, + { "Can duplex", "cups.ptype.duplex", FT_BOOLEAN, 32, + TFS(&tfs_yes_no), CUPS_PRINTER_DUPLEX, NULL, HFILL }}, + { &hf_cups_ptype_color, + { "Can print color", "cups.ptype.color", FT_BOOLEAN, 32, + TFS(&tfs_yes_no), CUPS_PRINTER_COLOR, NULL, HFILL }}, + { &hf_cups_ptype_bw, + { "Can print black", "cups.ptype.bw", FT_BOOLEAN, 32, + TFS(&tfs_yes_no), CUPS_PRINTER_BW, NULL, HFILL }}, + { &hf_cups_ptype_remote, + { "Remote", "cups.ptype.remote", FT_BOOLEAN, 32, + TFS(&tfs_yes_no), CUPS_PRINTER_REMOTE, NULL, HFILL }}, + { &hf_cups_ptype_class, + { "Class", "cups.ptype.class", FT_BOOLEAN, 32, + TFS(&tfs_printer_class), CUPS_PRINTER_CLASS, NULL, HFILL }}, { &hf_cups_state, { "State", "cups.state", FT_UINT8, BASE_HEX, VALS(cups_state_values), 0x0, NULL, HFILL }} diff --git a/epan/dissectors/packet-dlsw.c b/epan/dissectors/packet-dlsw.c index 86022a0259..8059c422be 100644 --- a/epan/dissectors/packet-dlsw.c +++ b/epan/dissectors/packet-dlsw.c @@ -35,6 +35,7 @@ static int proto_dlsw = -1; static int hf_dlsw_flow_control_indication = -1; static int hf_dlsw_flow_control_ack = -1; static int hf_dlsw_flow_control_operator = -1; +static int hf_dlsw_flags_explorer_msg = -1; static gint ett_dlsw = -1; static gint ett_dlsw_header = -1; @@ -297,10 +298,7 @@ dissect_dlsw_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) flags = tvb_get_guint8(tvb,21); ti2 = proto_tree_add_text (dlsw_header_tree,tvb, 21,1,"SSP Flags = 0x%02x",flags) ; dlsw_flags_tree = proto_item_add_subtree(ti2, ett_dlsw_sspflags); - proto_tree_add_text (dlsw_flags_tree, tvb, 21, 1, "%s", - decode_boolean_bitfield(flags, 0x80, 8, - "Explorer message: yes", - "Explorer message: no")); + proto_tree_add_item (dlsw_flags_tree, hf_dlsw_flags_explorer_msg, tvb, 21, 1, ENC_BIG_ENDIAN); proto_tree_add_text (dlsw_header_tree,tvb, 22,1,"Circuit priority = %s", val_to_str((tvb_get_guint8(tvb,22)&7),dlsw_pri_vals, "Unknown (%d)")) ; proto_tree_add_text (dlsw_header_tree,tvb, 23,1,"Old message type = %s (0x%02x)", @@ -525,6 +523,9 @@ proto_register_dlsw(void) {&hf_dlsw_flow_control_operator, {"Flow Control Operator", "dlsw.flow_control_operator", FT_UINT8, BASE_DEC, VALS(dlsw_fc_cmd_vals), 0x07, NULL, HFILL}}, + {&hf_dlsw_flags_explorer_msg, + {"Explorer message", "dlsw.flags.explorer_msg", FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x80, + NULL, HFILL}}, }; static gint *ett[] = { diff --git a/epan/dissectors/packet-netbios.c b/epan/dissectors/packet-netbios.c index f597e3e30d..f0acf1b56e 100644 --- a/epan/dissectors/packet-netbios.c +++ b/epan/dissectors/packet-netbios.c @@ -89,6 +89,8 @@ static int hf_netb_ack_expected = -1; static int hf_netb_recv_cont_req = -1; static int hf_netb_send_no_ack = -1; static int hf_netb_version = -1; +static int hf_netbios_no_receive_flags = -1; +static int hf_netbios_no_receive_flags_send_no_ack = -1; static int hf_netb_largest_frame = -1; static int hf_netb_nb_name = -1; static int hf_netb_nb_name_type = -1; @@ -448,19 +450,11 @@ static void netbios_no_receive_flags( tvbuff_t *tvb, proto_tree *tree, { proto_tree *field_tree; proto_item *tf; - guint flags = tvb_get_guint8( tvb, offset); /* decode the flag field for No Receive packet*/ - - tf = proto_tree_add_text(tree, tvb, offset, 1, - "Flags: 0x%02x", flags); - - if (flags & 0x02) { - field_tree = proto_item_add_subtree(tf, ett_netb_flags); - proto_tree_add_text(field_tree, tvb, offset, 1, "%s", - decode_boolean_bitfield(flags, 0x02, 8, - "SEND.NO.ACK data not received", NULL)); - } + tf = proto_tree_add_item(tree, hf_netbios_no_receive_flags, tvb, offset, 1, ENC_LITTLE_ENDIAN); + field_tree = proto_item_add_subtree(tf, ett_netb_flags); + proto_tree_add_item(field_tree, hf_netbios_no_receive_flags_send_no_ack, tvb, offset, 1, ENC_LITTLE_ENDIAN); } @@ -1326,6 +1320,14 @@ void proto_register_netbios(void) { "NetBIOS Version", "netbios.version", FT_BOOLEAN, 8, TFS( &netb_version_str), 0x01, NULL, HFILL }}, + { &hf_netbios_no_receive_flags, + { "Flags", "netbios.no_receive_flags", FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_netbios_no_receive_flags_send_no_ack, + { "SEND.NO.ACK data received", "netbios.no_receive_flags.send_no_ack", FT_BOOLEAN, 8, + TFS( &tfs_no_yes), 0x02, NULL, HFILL }}, + { &hf_netb_largest_frame, { "Largest Frame", "netbios.largest_frame", FT_UINT8, BASE_DEC, VALS(max_frame_size_vals), 0x0E, NULL, HFILL }}, diff --git a/epan/dissectors/packet-nlsp.c b/epan/dissectors/packet-nlsp.c index 6eeb8b0a8d..5e9f8cdd72 100644 --- a/epan/dissectors/packet-nlsp.c +++ b/epan/dissectors/packet-nlsp.c @@ -51,6 +51,9 @@ static int hf_nlsp_lsp_p = -1; static int hf_nlsp_lsp_attached_flag = -1; static int hf_nlsp_lsp_lspdbol = -1; static int hf_nlsp_lsp_router_type = -1; +static int hf_nlsp_lsp_link_info_clv_flags_cost_present = -1; +static int hf_nlsp_lsp_link_info_clv_flags_cost_metric = -1; +static int hf_nlsp_lsp_link_info_clv_flags_cost = -1; static gint ett_nlsp = -1; static gint ett_nlsp_hello_clv_area_addr = -1; @@ -108,6 +111,8 @@ static const value_string nlsp_router_type_vals[] = { { 0, NULL} }; +static const true_false_string tfs_internal_external = { "Internal", "External" }; + /* * Our sub-packet dismantle structure for CLV's */ @@ -671,20 +676,13 @@ dissect_lsp_link_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset, } if (tree) { flags_cost = tvb_get_guint8(tvb, offset); - proto_tree_add_text(tree, tvb, offset, 1, "%s", - decode_boolean_bitfield(flags_cost, 0x80, 1*8, - "Cost not present", "Cost present")); + proto_tree_add_item(tree, hf_nlsp_lsp_link_info_clv_flags_cost_present, tvb, offset, 1, ENC_BIG_ENDIAN); if (!(flags_cost & 0x80)) { /* * 0x80 clear => cost present. */ - proto_tree_add_text(tree, tvb, offset, 1, "%s", - decode_boolean_bitfield(flags_cost, 0x40, 1*8, - "Cost is internal metric", - "Cost is external metric")); - proto_tree_add_text(tree, tvb, offset, 1, "%s", - decode_numeric_bitfield(flags_cost, 0x3F, 1*8, - "Cost = %u")); + proto_tree_add_item(tree, hf_nlsp_lsp_link_info_clv_flags_cost_metric, tvb, offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(tree, hf_nlsp_lsp_link_info_clv_flags_cost, tvb, offset, 1, ENC_BIG_ENDIAN); } } offset += 1; @@ -1622,6 +1620,18 @@ proto_register_nlsp(void) { "Router Type", "nlsp.lsp.router_type", FT_UINT8, BASE_DEC, VALS(nlsp_router_type_vals), NLSP_LSP_ROUTER_TYPE_MASK, NULL, HFILL }}, + + { &hf_nlsp_lsp_link_info_clv_flags_cost_present, + { "Cost present", "nlsp.lsp.link_info_clv.flags.cost_present", FT_BOOLEAN, 8, + TFS(&tfs_no_yes), 0x80, NULL, HFILL }}, + + { &hf_nlsp_lsp_link_info_clv_flags_cost_metric, + { "Cost metric", "nlsp.lsp.link_info_clv.flags.cost_metric", FT_BOOLEAN, 8, + TFS(&tfs_internal_external), 0x40, NULL, HFILL }}, + + { &hf_nlsp_lsp_link_info_clv_flags_cost, + { "Cost", "nlsp.lsp.link_info_clv.flags.cost", FT_UINT8, BASE_DEC, + NULL, 0x3F, NULL, HFILL }}, }; static gint *ett[] = { &ett_nlsp, diff --git a/epan/dissectors/packet-pcep.c b/epan/dissectors/packet-pcep.c index cc66129645..83df428c09 100644 --- a/epan/dissectors/packet-pcep.c +++ b/epan/dissectors/packet-pcep.c @@ -287,6 +287,9 @@ static gint pcep_subobj_flags_lpa= -1; static gint pcep_subobj_flags_lpu= -1; static gint pcep_subobj_label_flags_gl= -1; static gint ett_pcep_obj_unknown = -1; +static gint hf_pcep_no_path_tlvs_pce = -1; +static gint hf_pcep_no_path_tlvs_unk_dest = -1; +static gint hf_pcep_no_path_tlvs_unk_src = -1; /* PCEP message types.*/ typedef enum { @@ -699,27 +702,24 @@ dissect_pcep_tlvs(proto_tree *pcep_obj, tvbuff_t *tvb, int offset, gint length, proto_tree_add_text(tlv, tvb, offset + 2 + j, 2, "Length: %u", tlv_length); switch (tlv_type) { - case 1: /* NO-PATH TLV */ - proto_tree_add_text(tlv, tvb, offset+4+j, tlv_length, "%s", - decode_boolean_bitfield(tvb_get_ntohl(tvb, offset+4+j), 0x0001, 32, "PCE currently unavailable", "")); - proto_tree_add_text(tlv, tvb, offset+4+j, tlv_length, "%s", - decode_boolean_bitfield(tvb_get_ntohl(tvb, offset+4+j), 0x0002, 32, "Unknown destination", "")); - proto_tree_add_text(tlv, tvb, offset+4+j, tlv_length, "%s", - decode_boolean_bitfield(tvb_get_ntohl(tvb, offset+4+j), 0x0004, 32, "Unknown source", "")); + case 1: /* NO-PATH TLV */ + proto_tree_add_item(tlv, hf_pcep_no_path_tlvs_pce, tvb, offset+4+j, tlv_length, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv, hf_pcep_no_path_tlvs_unk_dest, tvb, offset+4+j, tlv_length, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv, hf_pcep_no_path_tlvs_unk_src, tvb, offset+4+j, tlv_length, ENC_BIG_ENDIAN); break; - case 3: /* REQ-MISSING TLV */ + case 3: /* REQ-MISSING TLV */ proto_tree_add_text(tlv, tvb, offset+4+j, tlv_length, "Request-ID: %u", tvb_get_ntohl(tvb, offset+4+j)); break; - case 4: /* OF TLV */ + case 4: /* OF TLV */ for (i=0; icinfo, COL_PROTOCOL, "QUAKE"); col_clear(pinfo->cinfo, COL_INFO); - length = tvb_get_ntohl(tvb, 0); - flags = length & (~NETFLAG_LENGTH_MASK); - length &= NETFLAG_LENGTH_MASK; + flags = tvb_get_ntohs(tvb, 2); if (tree) { proto_item *quake_item; @@ -452,30 +453,18 @@ dissect_quake(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item* flags_item; proto_tree* flags_tree; - flags_item = proto_tree_add_uint(quake_tree, hf_quake_header_flags, - tvb, 0, 2, flags); + flags_item = proto_tree_add_item(quake_tree, hf_quake_header_flags, + tvb, 2, 2, ENC_BIG_ENDIAN); flags_tree = proto_item_add_subtree(flags_item, ett_quake_flags); + proto_tree_add_item(flags_tree, hf_quake_header_flags_data, tvb, 2, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(flags_tree, hf_quake_header_flags_ack, tvb, 2, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(flags_tree, hf_quake_header_flags_no_ack, tvb, 2, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(flags_tree, hf_quake_header_flags_endmsg, tvb, 2, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(flags_tree, hf_quake_header_flags_unreliable, tvb, 2, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(flags_tree, hf_quake_header_flags_control, tvb, 2, 2, ENC_BIG_ENDIAN); - proto_tree_add_text(flags_tree, tvb, 0, 2, "%s", - decode_boolean_bitfield(flags, NETFLAG_DATA, 32, - "Data","-")); - proto_tree_add_text(flags_tree, tvb, 0, 2, "%s", - decode_boolean_bitfield(flags, NETFLAG_ACK, 32, - "Acknowledgment","-")); - proto_tree_add_text(flags_tree, tvb, 0, 2, "%s", - decode_boolean_bitfield(flags, NETFLAG_NAK, 32, - "No Acknowledgment","-")); - proto_tree_add_text(flags_tree, tvb, 0, 2, "%s", - decode_boolean_bitfield(flags, NETFLAG_EOM, 32, - "End Of Message","-")); - proto_tree_add_text(flags_tree, tvb, 0, 2, "%s", - decode_boolean_bitfield(flags, NETFLAG_UNRELIABLE, 32, - "Unreliable","-")); - proto_tree_add_text(flags_tree, tvb, 0, 2, "%s", - decode_boolean_bitfield(flags, NETFLAG_CTL, 32, - "Control","-")); - proto_tree_add_uint(quake_tree, hf_quake_header_length, - tvb, 2, 2, length); + proto_tree_add_item(quake_tree, hf_quake_header_length, + tvb, 0, 2, ENC_BIG_ENDIAN); } if (flags == NETFLAG_CTL) { @@ -510,6 +499,30 @@ proto_register_quake(void) { "Flags", "quake.header.flags", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}, + { &hf_quake_header_flags_data, + { "Data", "quake.header.flags.data", + FT_BOOLEAN, 16, TFS(&tfs_set_notset), NETFLAG_DATA, + NULL, HFILL }}, + { &hf_quake_header_flags_ack, + { "Acknowledgment", "quake.header.flags.ack", + FT_BOOLEAN, 16, TFS(&tfs_set_notset), NETFLAG_ACK, + NULL, HFILL }}, + { &hf_quake_header_flags_no_ack, + { "No Acknowledgment", "quake.header.flags.no_ack", + FT_BOOLEAN, 16, TFS(&tfs_set_notset), NETFLAG_NAK, + NULL, HFILL }}, + { &hf_quake_header_flags_endmsg, + { "End Of Message", "quake.header.flags.endmsg", + FT_BOOLEAN, 16, TFS(&tfs_set_notset), NETFLAG_EOM, + NULL, HFILL }}, + { &hf_quake_header_flags_unreliable, + { "Unreliable", "quake.header.flags.unreliable", + FT_BOOLEAN, 16, TFS(&tfs_set_notset), NETFLAG_UNRELIABLE, + NULL, HFILL }}, + { &hf_quake_header_flags_control, + { "Control", "quake.header.flags.control", + FT_BOOLEAN, 16, TFS(&tfs_set_notset), NETFLAG_CTL, + NULL, HFILL }}, { &hf_quake_header_length, { "Length", "quake.header.length", FT_UINT16, BASE_DEC, NULL, 0x0, diff --git a/epan/dissectors/packet-skinny.c b/epan/dissectors/packet-skinny.c index 5edbfad503..b4277c2fe8 100644 --- a/epan/dissectors/packet-skinny.c +++ b/epan/dissectors/packet-skinny.c @@ -1209,6 +1209,14 @@ static int hf_cast_originalCdpnRedirectReason = -1; static int hf_cast_lastRedirectingReason = -1; static int hf_cast_callInstance = -1; static int hf_cast_callSecurityStatus = -1; +static int hf_cast_partyPIRestrictionBits_CallingPartyName = -1; +static int hf_cast_partyPIRestrictionBits_CallingPartyNumber = -1; +static int hf_cast_partyPIRestrictionBits_CalledPartyName = -1; +static int hf_cast_partyPIRestrictionBits_CalledPartyNumber = -1; +static int hf_cast_partyPIRestrictionBits_OriginalCalledPartyName = -1; +static int hf_cast_partyPIRestrictionBits_OriginalCalledPartyNumber = -1; +static int hf_cast_partyPIRestrictionBits_LastRedirectPartyName = -1; +static int hf_cast_partyPIRestrictionBits_LastRedirectPartyNumber = -1; static int hf_skinny_directoryIndex = -1; static int hf_skinny_directoryPhoneNumber = -1; @@ -2046,22 +2054,14 @@ dissect_skinny_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) val = tvb_get_letohl( tvb, i); ti_sub = proto_tree_add_text(skinny_tree, tvb, i, 8, "partyPIRestrictionBits"); skinny_sub_tree = proto_item_add_subtree(ti_sub, ett_skinny_tree); - proto_tree_add_text(skinny_sub_tree, tvb, i, 4, "%s", - decode_boolean_bitfield( val, 0x01, 4*8, "Does RestrictCallingPartyName", "Doesn't RestrictCallingPartyName")); - proto_tree_add_text(skinny_sub_tree, tvb, i, 4, "%s", - decode_boolean_bitfield( val, 0x02, 4*8, "Does RestrictCallingPartyNumber", "Doesn't RestrictCallingPartyNumber")); - proto_tree_add_text(skinny_sub_tree, tvb, i, 4, "%s", - decode_boolean_bitfield( val, 0x04, 4*8, "Does RestrictCalledPartyName", "Doesn't RestrictCalledPartyName")); - proto_tree_add_text(skinny_sub_tree, tvb, i, 4, "%s", - decode_boolean_bitfield( val, 0x08, 4*8, "Does RestrictCalledPartyNumber", "Doesn't RestrictCalledPartyNumber")); - proto_tree_add_text(skinny_sub_tree, tvb, i, 4, "%s", - decode_boolean_bitfield( val, 0x10, 4*8, "Does RestrictOriginalCalledPartyName", "Doesn't RestrictOriginalCalledPartyName")); - proto_tree_add_text(skinny_sub_tree, tvb, i, 4, "%s", - decode_boolean_bitfield( val, 0x20, 4*8, "Does RestrictOriginalCalledPartyNumber", "Doesn't RestrictOriginalCalledPartyNumber")); - proto_tree_add_text(skinny_sub_tree, tvb, i, 4, "%s", - decode_boolean_bitfield( val, 0x40, 4*8, "Does RestrictLastRedirectPartyName", "Doesn't RestrictLastRedirectPartyName")); - proto_tree_add_text(skinny_sub_tree, tvb, i, 4, "%s", - decode_boolean_bitfield( val, 0x80, 4*8, "Does RestrictLastRedirectPartyNumber", "Doesn't RestrictLastRedirectPartyNumber")); + proto_tree_add_item(skinny_sub_tree, hf_cast_partyPIRestrictionBits_CallingPartyName, tvb, i, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(skinny_sub_tree, hf_cast_partyPIRestrictionBits_CallingPartyNumber, tvb, i, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(skinny_sub_tree, hf_cast_partyPIRestrictionBits_CalledPartyName, tvb, i, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(skinny_sub_tree, hf_cast_partyPIRestrictionBits_CalledPartyNumber, tvb, i, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(skinny_sub_tree, hf_cast_partyPIRestrictionBits_OriginalCalledPartyName, tvb, i, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(skinny_sub_tree, hf_cast_partyPIRestrictionBits_OriginalCalledPartyNumber, tvb, i, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(skinny_sub_tree, hf_cast_partyPIRestrictionBits_LastRedirectPartyName, tvb, i, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(skinny_sub_tree, hf_cast_partyPIRestrictionBits_LastRedirectPartyNumber, tvb, i, 4, ENC_LITTLE_ENDIAN); break; case 0x0090: /* ForwardStatMessage */ @@ -4659,6 +4659,54 @@ proto_register_skinny(void) HFILL } }, + { &hf_cast_partyPIRestrictionBits_CallingPartyName, + { "RestrictCallingPartyName", "cast.partyPIRestrictionBits.CallingPartyName", + FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x01, + NULL, HFILL } + }, + + { &hf_cast_partyPIRestrictionBits_CallingPartyNumber, + { "RestrictCallingPartyNumber", "cast.partyPIRestrictionBits.CallingPartyNumber", + FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x02, + NULL, HFILL } + }, + + { &hf_cast_partyPIRestrictionBits_CalledPartyName, + { "RestrictCalledPartyName", "cast.partyPIRestrictionBits.CalledPartyName", + FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x04, + NULL, HFILL } + }, + + { &hf_cast_partyPIRestrictionBits_CalledPartyNumber, + { "RestrictCalledPartyNumber", "cast.partyPIRestrictionBits.CalledPartyNumber", + FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x08, + NULL, HFILL } + }, + + { &hf_cast_partyPIRestrictionBits_OriginalCalledPartyName, + { "RestrictOriginalCalledPartyName", "cast.partyPIRestrictionBits.OriginalCalledPartyName", + FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x10, + NULL, HFILL } + }, + + { &hf_cast_partyPIRestrictionBits_OriginalCalledPartyNumber, + { "RestrictOriginalCalledPartyNumber", "cast.partyPIRestrictionBits.OriginalCalledPartyNumber", + FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x20, + NULL, HFILL } + }, + + { &hf_cast_partyPIRestrictionBits_LastRedirectPartyName, + { "RestrictLastRedirectPartyName", "cast.partyPIRestrictionBits.LastRedirectPartyName", + FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x40, + NULL, HFILL } + }, + + { &hf_cast_partyPIRestrictionBits_LastRedirectPartyNumber, + { "RestrictLastRedirectPartyNumber", "cast.partyPIRestrictionBits.LastRedirectPartyNumber", + FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x80, + NULL, HFILL } + }, + { &hf_skinny_directoryIndex, { "Directory index", "skinny.directoryIndex", FT_UINT32, BASE_DEC, NULL, 0x0, diff --git a/epan/dissectors/packet-tacacs.c b/epan/dissectors/packet-tacacs.c index eb1fabc9b5..bdc49c7850 100644 --- a/epan/dissectors/packet-tacacs.c +++ b/epan/dissectors/packet-tacacs.c @@ -325,6 +325,10 @@ static int hf_tacplus_flags = -1; static int hf_tacplus_flags_payload_type = -1; static int hf_tacplus_flags_connection_type = -1; static int hf_tacplus_acct_flags = -1; +static int hf_tacplus_acct_flags_more = -1; +static int hf_tacplus_acct_flags_start = -1; +static int hf_tacplus_acct_flags_stop = -1; +static int hf_tacplus_acct_flags_watchdog = -1; static int hf_tacplus_session_id = -1; static int hf_tacplus_packet_len = -1; @@ -673,22 +677,13 @@ dissect_tacplus_body_acct_req( tvbuff_t* tvb, proto_tree *tree ) proto_item *tf; proto_tree *flags_tree; - val=tvb_get_guint8( tvb, ACCT_Q_FLAGS_OFF ); - tf = proto_tree_add_uint( tree, hf_tacplus_acct_flags, tvb, ACCT_Q_FLAGS_OFF, 1, val ); + tf = proto_tree_add_item( tree, hf_tacplus_acct_flags, tvb, ACCT_Q_FLAGS_OFF, 1, ENC_BIG_ENDIAN); flags_tree = proto_item_add_subtree( tf, ett_tacplus_acct_flags ); - proto_tree_add_text( flags_tree, tvb, ACCT_Q_FLAGS_OFF, 1, "%s", - decode_boolean_bitfield( val, TAC_PLUS_ACCT_FLAG_MORE, 8, - "More: Set", "More: Not set" ) ); - proto_tree_add_text( flags_tree, tvb, ACCT_Q_FLAGS_OFF, 1, "%s", - decode_boolean_bitfield( val, TAC_PLUS_ACCT_FLAG_START, 8, - "Start: Set", "Start: Not set" ) ); - proto_tree_add_text( flags_tree, tvb, ACCT_Q_FLAGS_OFF, 1, "%s", - decode_boolean_bitfield( val, TAC_PLUS_ACCT_FLAG_STOP, 8, - "Stop: Set", "Stop: Not set" ) ); - proto_tree_add_text( flags_tree, tvb, ACCT_Q_FLAGS_OFF, 1, "%s", - decode_boolean_bitfield( val, TAC_PLUS_ACCT_FLAG_WATCHDOG, 8, - "Watchdog: Set", "Watchdog: Not set" ) ); + proto_tree_add_item(flags_tree, hf_tacplus_acct_flags_more, tvb, ACCT_Q_FLAGS_OFF, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(flags_tree, hf_tacplus_acct_flags_start, tvb, ACCT_Q_FLAGS_OFF, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(flags_tree, hf_tacplus_acct_flags_stop, tvb, ACCT_Q_FLAGS_OFF, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(flags_tree, hf_tacplus_acct_flags_watchdog, tvb, ACCT_Q_FLAGS_OFF, 1, ENC_BIG_ENDIAN); val=tvb_get_guint8( tvb, ACCT_Q_METHOD_OFF ); proto_tree_add_text( tree, tvb, ACCT_Q_METHOD_OFF, 1, @@ -1073,6 +1068,22 @@ proto_register_tacplus(void) { "Flags", "tacplus.acct.flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }}, + { &hf_tacplus_acct_flags_more, + { "More", "tacplus.acct.flags.more", + FT_BOOLEAN, 8, TFS(&tfs_set_notset), TAC_PLUS_ACCT_FLAG_MORE, + NULL, HFILL }}, + { &hf_tacplus_acct_flags_start, + { "Start", "tacplus.acct.flags.start", + FT_BOOLEAN, 8, TFS(&tfs_set_notset), TAC_PLUS_ACCT_FLAG_START, + NULL, HFILL }}, + { &hf_tacplus_acct_flags_stop, + { "Stop", "tacplus.acct.flags.stop", + FT_BOOLEAN, 8, TFS(&tfs_set_notset), TAC_PLUS_ACCT_FLAG_STOP, + NULL, HFILL }}, + { &hf_tacplus_acct_flags_watchdog, + { "Watchdog", "tacplus.acct.flags.watchdog", + FT_BOOLEAN, 8, TFS(&tfs_set_notset), TAC_PLUS_ACCT_FLAG_WATCHDOG, + NULL, HFILL }}, { &hf_tacplus_session_id, { "Session ID", "tacplus.session_id", FT_UINT32, BASE_DEC, NULL, 0x0, diff --git a/epan/dissectors/packet-v120.c b/epan/dissectors/packet-v120.c index f4390ad7ca..de57c9ba67 100644 --- a/epan/dissectors/packet-v120.c +++ b/epan/dissectors/packet-v120.c @@ -32,6 +32,10 @@ static int proto_v120 = -1; static int hf_v120_address = -1; +static int hf_v120_rc = -1; +static int hf_v120_lli = -1; +static int hf_v120_ea0 = -1; +static int hf_v120_ea1 = -1; static int hf_v120_control = -1; static int hf_v120_n_r = -1; static int hf_v120_n_s = -1; @@ -45,7 +49,22 @@ static int hf_v120_u_modifier_resp = -1; static int hf_v120_ftype_i = -1; static int hf_v120_ftype_s_u = -1; static int hf_v120_ftype_s_u_ext = -1; -static int hf_v120_header = -1; +static int hf_v120_header8 = -1; +static int hf_v120_header_ext8 = -1; +static int hf_v120_header_break8 = -1; +static int hf_v120_header_error_control8 = -1; +static int hf_v120_header_segb8 = -1; +static int hf_v120_header_segf8 = -1; +static int hf_v120_header16 = -1; +static int hf_v120_header_ext16 = -1; +static int hf_v120_header_break16 = -1; +static int hf_v120_header_error_control16 = -1; +static int hf_v120_header_segb16 = -1; +static int hf_v120_header_segf16 = -1; +static int hf_v120_header_e = -1; +static int hf_v120_header_dr = -1; +static int hf_v120_header_sr = -1; +static int hf_v120_header_rr = -1; static gint ett_v120 = -1; static gint ett_v120_address = -1; @@ -54,6 +73,9 @@ static gint ett_v120_header = -1; static dissector_handle_t data_handle; +static const true_false_string tfs_response_command = { "Response", "Command" }; +static const true_false_string tfs_segmentation_no_segmentation = { "Segmentation", "No segmentation" }; + static int dissect_v120_header(tvbuff_t *tvb, int offset, proto_tree *tree); /* Used only for U frames */ @@ -85,143 +107,113 @@ static const xdlc_cf_items v120_cf_items_ext = { static void dissect_v120(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - proto_tree *v120_tree, *tc, *address_tree; - proto_item *ti; - int is_response; - int addr; - char *info; - int v120len; - guint8 byte0, byte1; - guint16 control; - tvbuff_t *next_tvb; + proto_tree *v120_tree, *address_tree; + proto_item *ti, *tc; + int is_response; + int v120len; + guint8 byte0, byte1; + guint16 control; + tvbuff_t *next_tvb; - info=ep_alloc(80); - col_set_str(pinfo->cinfo, COL_PROTOCOL, "V.120"); - col_clear(pinfo->cinfo, COL_INFO); + col_set_str(pinfo->cinfo, COL_PROTOCOL, "V.120"); + col_clear(pinfo->cinfo, COL_INFO); - byte0 = tvb_get_guint8(tvb, 0); + byte0 = tvb_get_guint8(tvb, 0); - if(check_col(pinfo->cinfo, COL_RES_DL_SRC)) - col_add_fstr(pinfo->cinfo, COL_RES_DL_SRC, "0x%02X", byte0); + if(check_col(pinfo->cinfo, COL_RES_DL_SRC)) + col_add_fstr(pinfo->cinfo, COL_RES_DL_SRC, "0x%02X", byte0); - byte1 = tvb_get_guint8(tvb, 1); + byte1 = tvb_get_guint8(tvb, 1); - if ( ((byte0 & 0x01) != 0x00) && ((byte1 & 0x01) != 0x01) ) - { - col_set_str(pinfo->cinfo, COL_INFO, "Invalid V.120 frame"); - if (tree) - proto_tree_add_protocol_format(tree, proto_v120, tvb, 0, -1, - "Invalid V.120 frame"); - return; - } + if ( ((byte0 & 0x01) != 0x00) && ((byte1 & 0x01) != 0x01) ) + { + col_set_str(pinfo->cinfo, COL_INFO, "Invalid V.120 frame"); + if (tree) + proto_tree_add_protocol_format(tree, proto_v120, tvb, 0, -1, + "Invalid V.120 frame"); + return; + } - if (pinfo->p2p_dir == P2P_DIR_SENT) { - is_response = (byte0 & 0x02) ? FALSE: TRUE; - col_set_str(pinfo->cinfo, COL_RES_DL_DST, "DCE"); - col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "DTE"); - } else { - /* XXX - what if the direction is unknown? */ - is_response = (byte0 & 0x02) ? TRUE : FALSE; - col_set_str(pinfo->cinfo, COL_RES_DL_DST, "DTE"); - col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "DCE"); - } + if (pinfo->p2p_dir == P2P_DIR_SENT) { + is_response = (byte0 & 0x02) ? FALSE: TRUE; + col_set_str(pinfo->cinfo, COL_RES_DL_DST, "DCE"); + col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "DTE"); + } else { + /* XXX - what if the direction is unknown? */ + is_response = (byte0 & 0x02) ? TRUE : FALSE; + col_set_str(pinfo->cinfo, COL_RES_DL_DST, "DTE"); + col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "DCE"); + } - if (tree) { - ti = proto_tree_add_protocol_format(tree, proto_v120, tvb, 0, -1, "V.120"); - v120_tree = proto_item_add_subtree(ti, ett_v120); - addr = byte1 << 8 | byte0; - g_snprintf(info, 80, "LLI: %d C/R: %s", - ((byte0 & 0xfc) << 5) | ((byte1 & 0xfe) >> 1), - byte0 & 0x02 ? "R" : "C"); - tc = proto_tree_add_text(v120_tree, tvb, - 0, 2, - "Address field: %s", info); - address_tree = proto_item_add_subtree(tc, ett_v120_address); - proto_tree_add_text(address_tree, tvb, 0, 2, "%s", - decode_boolean_bitfield(addr, 0x0002, 2*8, - "Response", "Command")); - g_snprintf(info, 80, "LLI: %d", ((byte0 & 0xfc) << 5) | ((byte1 & 0xfe) >> 1)); - proto_tree_add_text(address_tree, tvb, 0, 2, "%s", - decode_numeric_bitfield(addr, 0xfefc, 2*8, info)); - proto_tree_add_text(address_tree, tvb, 0, 2, "%s", - decode_boolean_bitfield(addr, 0x0001, 2*8, - "EA0 = 1 (Error)", "EA0 = 0")); - proto_tree_add_text(address_tree, tvb, 0, 2, "%s", - decode_boolean_bitfield(addr, 0x0100, 2*8, - "EA1 = 1", "EA1 = 0 (Error)")); - } - else { - v120_tree = NULL; - ti = NULL; - } - control = dissect_xdlc_control(tvb, 2, pinfo, v120_tree, hf_v120_control, - ett_v120_control, &v120_cf_items, &v120_cf_items_ext, - NULL, NULL, is_response, TRUE, FALSE); - if (tree) { - v120len = 2 + XDLC_CONTROL_LEN(control, TRUE); - if (tvb_bytes_exist(tvb, v120len, 1)) - v120len += dissect_v120_header(tvb, v120len, v120_tree); - proto_item_set_len(ti, v120len); - next_tvb = tvb_new_subset_remaining(tvb, v120len); - call_dissector(data_handle,next_tvb, pinfo, v120_tree); - } + if (tree) { + ti = proto_tree_add_protocol_format(tree, proto_v120, tvb, 0, -1, "V.120"); + v120_tree = proto_item_add_subtree(ti, ett_v120); + tc = proto_tree_add_item(v120_tree, hf_v120_address, tvb, 0, 2, ENC_BIG_ENDIAN); + proto_item_append_text(tc, "LLI: %d C/R: %s", + ((byte0 & 0xfc) << 5) | ((byte1 & 0xfe) >> 1), + byte0 & 0x02 ? "R" : "C"); + address_tree = proto_item_add_subtree(tc, ett_v120_address); + + proto_tree_add_item(address_tree, hf_v120_rc, tvb, 0, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(address_tree, hf_v120_lli, tvb, 0, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(address_tree, hf_v120_ea0, tvb, 0, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(address_tree, hf_v120_ea1, tvb, 0, 2, ENC_BIG_ENDIAN); + } + else { + v120_tree = NULL; + ti = NULL; + } + control = dissect_xdlc_control(tvb, 2, pinfo, v120_tree, hf_v120_control, + ett_v120_control, &v120_cf_items, &v120_cf_items_ext, + NULL, NULL, is_response, TRUE, FALSE); + if (tree) { + v120len = 2 + XDLC_CONTROL_LEN(control, TRUE); + + if (tvb_bytes_exist(tvb, v120len, 1)) + v120len += dissect_v120_header(tvb, v120len, v120_tree); + proto_item_set_len(ti, v120len); + next_tvb = tvb_new_subset_remaining(tvb, v120len); + call_dissector(data_handle,next_tvb, pinfo, v120_tree); + } } static int dissect_v120_header(tvbuff_t *tvb, int offset, proto_tree *tree) { - char *info; - int header_len, nbits; - int header; - proto_tree *h_tree, *tc; - guint8 byte0; + int header_len; + guint8 byte0; + proto_tree *h_tree; + proto_item *tc; - info=ep_alloc(80); byte0 = tvb_get_guint8(tvb, offset); - if (byte0 & 0x80) { header_len = 1; - header = byte0; + tc = proto_tree_add_item(tree, hf_v120_header8, tvb, 0, 1, ENC_NA); + + h_tree = proto_item_add_subtree(tc, ett_v120_header); + proto_tree_add_item(h_tree, hf_v120_header_ext8, tvb, 0, 1, ENC_NA); + proto_tree_add_item(h_tree, hf_v120_header_break8, tvb, 0, 1, ENC_NA); + proto_tree_add_item(h_tree, hf_v120_header_error_control8, tvb, 0, 1, ENC_NA); + proto_tree_add_item(h_tree, hf_v120_header_segb8, tvb, 0, 1, ENC_NA); + proto_tree_add_item(h_tree, hf_v120_header_segf8, tvb, 0, 1, ENC_NA); } else { header_len = 2; - header = byte0 | tvb_get_guint8(tvb, offset + 1) << 8; - } - nbits = header_len * 8; - g_snprintf(info, 80, "Header: B: %d F: %d", byte0 & 0x02 ? 1:0, - byte0 & 0x01 ? 1:0); - tc = proto_tree_add_text(tree, tvb, - offset, header_len, - "Header octet: %s (0x%02X)", info, byte0); - h_tree = proto_item_add_subtree(tc, ett_v120_header); - proto_tree_add_text(h_tree, tvb, offset, header_len, "%s", - decode_boolean_bitfield(header, 0x80, nbits, - "No extension octet", "Extension octet follows")); - proto_tree_add_text(h_tree, tvb, offset, header_len, "%s", - decode_boolean_bitfield(header, 0x40, nbits, - "Break condition", "No break condition")); - g_snprintf(info, 80, "Error control C1/C2: %d", (header & 0x0c) >> 2); - proto_tree_add_text(h_tree, tvb, offset, header_len, "%s", - decode_numeric_bitfield(header, 0x0c, nbits, info)); - proto_tree_add_text(h_tree, tvb, offset, header_len, "%s", - decode_boolean_bitfield(header, 0x02, nbits, - "Segmentation bit B", "No segmentation bit B")); - proto_tree_add_text(h_tree, tvb, offset, header_len, "%s", - decode_boolean_bitfield(header, 0x01, nbits, - "Segmentation bit F", "No segmentation bit F")); - if (header_len == 2) { - proto_tree_add_text(h_tree, tvb, offset, header_len, - decode_boolean_bitfield(header, 0x8000, nbits, - "E", "E bit not set (Error)"), NULL); - proto_tree_add_text(h_tree, tvb, offset, header_len, - decode_boolean_bitfield(header, 0x4000, nbits, - "DR", "No DR"), NULL); - proto_tree_add_text(h_tree, tvb, offset, header_len, - decode_boolean_bitfield(header, 0x2000, nbits, - "SR", "No SR"), NULL); - proto_tree_add_text(h_tree, tvb, offset, header_len, - decode_boolean_bitfield(header, 0x1000, nbits, - "RR", "No RR"), NULL); + tc = proto_tree_add_item(tree, hf_v120_header16, tvb, 0, 2, ENC_BIG_ENDIAN); + h_tree = proto_item_add_subtree(tc, ett_v120_header); + proto_tree_add_item(h_tree, hf_v120_header_ext16, tvb, 0, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(h_tree, hf_v120_header_break16, tvb, 0, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(h_tree, hf_v120_header_error_control16, tvb, 0, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(h_tree, hf_v120_header_segb16, tvb, 0, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(h_tree, hf_v120_header_segf16, tvb, 0, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(h_tree, hf_v120_header_e, tvb, 0, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(h_tree, hf_v120_header_dr, tvb, 0, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(h_tree, hf_v120_header_sr, tvb, 0, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(h_tree, hf_v120_header_rr, tvb, 0, 2, ENC_BIG_ENDIAN); } + + proto_item_append_text(tc, " B: %d F: %d", + byte0 & 0x02 ? 1:0, byte0 & 0x01 ? 1:0); + return header_len; } @@ -232,6 +224,18 @@ proto_register_v120(void) { &hf_v120_address, { "Link Address", "v120.address", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}, + { &hf_v120_rc, + { "R/C", "v120.rc", FT_BOOLEAN, 16, TFS(&tfs_response_command), + 0x0002, NULL, HFILL }}, + { &hf_v120_lli, + { "LLI", "v120.lli", FT_UINT16, BASE_HEX, NULL, + 0xfefc, NULL, HFILL }}, + { &hf_v120_ea0, + { "EA0", "v120.ea0", FT_BOOLEAN, 16, TFS(&tfs_error_ok), + 0x0001, NULL, HFILL }}, + { &hf_v120_ea1, + { "EA1", "v120.ea1", FT_BOOLEAN, 16, TFS(&tfs_ok_error), + 0x0100, NULL, HFILL }}, { &hf_v120_control, { "Control Field", "v120.control", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}, @@ -271,8 +275,53 @@ proto_register_v120(void) { &hf_v120_ftype_s_u_ext, { "Frame type", "v120.control.ftype", FT_UINT16, BASE_HEX, VALS(ftype_vals), XDLC_S_U_MASK, NULL, HFILL }}, - { &hf_v120_header, - { "Header Field", "v120.header", FT_STRING, BASE_NONE, NULL, 0x0, + { &hf_v120_header8, + { "Header", "v120.header", FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + { &hf_v120_header_ext8, + { "Extension octet", "v120.header.ext", FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x80, + NULL, HFILL }}, + { &hf_v120_header_break8, + { "Break condition", "v120.header.break", FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x40, + NULL, HFILL }}, + { &hf_v120_header_error_control8, + { "Error control C1/C2", "v120.error_control", FT_UINT8, BASE_HEX, NULL, 0x0C, + NULL, HFILL }}, + { &hf_v120_header_segb8, + { "Bit B", "v120.header.segb", FT_BOOLEAN, 8, TFS(&tfs_segmentation_no_segmentation), 0x02, + NULL, HFILL }}, + { &hf_v120_header_segf8, + { "Bit F", "v120.header.segf", FT_BOOLEAN, 8, TFS(&tfs_segmentation_no_segmentation), 0x01, + NULL, HFILL }}, + { &hf_v120_header16, + { "Header", "v120.header", FT_UINT16, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + { &hf_v120_header_ext16, + { "Extension octet", "v120.header.ext", FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x80, + NULL, HFILL }}, + { &hf_v120_header_break16, + { "Break condition", "v120.header.break", FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x40, + NULL, HFILL }}, + { &hf_v120_header_error_control16, + { "Error control C1/C2", "v120.error_control", FT_UINT16, BASE_HEX, NULL, 0x0C, + NULL, HFILL }}, + { &hf_v120_header_segb16, + { "Bit B", "v120.header.segb", FT_BOOLEAN, 16, TFS(&tfs_segmentation_no_segmentation), 0x02, + NULL, HFILL }}, + { &hf_v120_header_segf16, + { "Bit F", "v120.header.segf", FT_BOOLEAN, 16, TFS(&tfs_segmentation_no_segmentation), 0x01, + NULL, HFILL }}, + { &hf_v120_header_e, + { "E", "v120.header.e", FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x8000, + NULL, HFILL }}, + { &hf_v120_header_dr, + { "DR", "v120.header.dr", FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x4000, + NULL, HFILL }}, + { &hf_v120_header_sr, + { "SR", "v120.header.sr", FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x2000, + NULL, HFILL }}, + { &hf_v120_header_rr, + { "RR", "v120.header.rr", FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x1000, NULL, HFILL }}, }; static gint *ett[] = { diff --git a/epan/tfs.c b/epan/tfs.c index 772d80f662..50ecf05dbd 100644 --- a/epan/tfs.c +++ b/epan/tfs.c @@ -33,6 +33,7 @@ */ const true_false_string tfs_true_false = { "True", "False" }; const true_false_string tfs_yes_no = { "Yes", "No" }; +const true_false_string tfs_no_yes = { "No", "Yes" }; const true_false_string tfs_set_notset = { "Set", "Not set" }; const true_false_string tfs_enabled_disabled = { "Enabled", "Disabled" }; const true_false_string tfs_disabled_enabled = { "Disabled", "Enabled" }; diff --git a/epan/tfs.h b/epan/tfs.h index 4c3766fede..fed79acee5 100644 --- a/epan/tfs.h +++ b/epan/tfs.h @@ -42,6 +42,7 @@ typedef struct true_false_string { */ WS_VAR_IMPORT const true_false_string tfs_true_false; WS_VAR_IMPORT const true_false_string tfs_yes_no; +WS_VAR_IMPORT const true_false_string tfs_no_yes; WS_VAR_IMPORT const true_false_string tfs_set_notset; WS_VAR_IMPORT const true_false_string tfs_enabled_disabled; WS_VAR_IMPORT const true_false_string tfs_disabled_enabled;