diff options
author | João Valverde <joao.valverde@tecnico.ulisboa.pt> | 2015-09-02 01:28:18 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2015-09-18 04:12:45 +0000 |
commit | 9162177db968f1310d867c32d2920298302f01b5 (patch) | |
tree | 191d643053f8fb73f29362d0b83e2da2b149fc16 /epan | |
parent | 69d2d585aa5a96e6ab5b1ead049a7ee79f50060e (diff) | |
download | wireshark-9162177db968f1310d867c32d2920298302f01b5.tar.gz |
Make IPv4/IPv6 DiffServ fields uniform
Replace DSCP/ECT/CE with DSCP/ECN for IPv6.
Introduce short descriptions for DSCP/ECN values.
Formating changes:
- Make IPv4 and IPv6 as similar as possible.
- Display short abbreviations only for "Differentiated Services Field".
- Display DiffServ field as hex for IPv4.
- Elide leading zeros from hex representation from DiffServ field for IPv6.
- Display DSCP/ECN as decimal in subtree (same as "IP DSCP" column format).
Change-Id: Ia69d11dc9c1d752eb2e269314287c885506b5353
Reviewed-on: https://code.wireshark.org/review/10360
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/packet-ip.c | 74 | ||||
-rw-r--r-- | epan/dissectors/packet-ip.h | 15 | ||||
-rw-r--r-- | epan/dissectors/packet-ipv6.c | 90 |
3 files changed, 90 insertions, 89 deletions
diff --git a/epan/dissectors/packet-ip.c b/epan/dissectors/packet-ip.c index 1c289cdc2d..47debe5809 100644 --- a/epan/dissectors/packet-ip.c +++ b/epan/dissectors/packet-ip.c @@ -317,14 +317,7 @@ static dissector_handle_t data_handle; #define IP_MF 0x2000 /* Flag: "More Fragments" */ #define IP_OFFSET 0x1FFF /* "Fragment Offset" part */ -/* Differentiated Services Field. See RFCs 2474, 2597 and 2598. */ -#define IPDSFIELD_DSCP_MASK 0xFC -#define IPDSFIELD_ECN_MASK 0x03 -#define IPDSFIELD_DSCP_SHIFT 2 - -#define IPDSFIELD_DSCP(dsfield) (((dsfield)&IPDSFIELD_DSCP_MASK)>>IPDSFIELD_DSCP_SHIFT) -#define IPDSFIELD_ECN(dsfield) ((dsfield)&IPDSFIELD_ECN_MASK) - +/* Differentiated Services Field. See RFCs 2474, 2597, 2598 and 3168. */ #define IPDSFIELD_DSCP_DEFAULT 0x00 #define IPDSFIELD_DSCP_CS1 0x08 #define IPDSFIELD_DSCP_AF11 0x0A @@ -1890,6 +1883,32 @@ local_network_control_block_addr_valid_ttl(guint32 addr) return IPLOCAL_NETWRK_CTRL_BLK_DEFAULT_TTL; } +static const value_string dscp_short_vals[] = { + { IPDSFIELD_DSCP_DEFAULT, "CS0" }, + { IPDSFIELD_DSCP_CS1, "CS1" }, + { IPDSFIELD_DSCP_AF11, "AF11" }, + { IPDSFIELD_DSCP_AF12, "AF12" }, + { IPDSFIELD_DSCP_AF13, "AF13" }, + { IPDSFIELD_DSCP_CS2, "CS2" }, + { IPDSFIELD_DSCP_AF21, "AF21" }, + { IPDSFIELD_DSCP_AF22, "AF22" }, + { IPDSFIELD_DSCP_AF23, "AF23" }, + { IPDSFIELD_DSCP_CS3, "CS3" }, + { IPDSFIELD_DSCP_AF31, "AF31" }, + { IPDSFIELD_DSCP_AF32, "AF32" }, + { IPDSFIELD_DSCP_AF33, "AF33" }, + { IPDSFIELD_DSCP_CS4, "CS4" }, + { IPDSFIELD_DSCP_AF41, "AF41" }, + { IPDSFIELD_DSCP_AF42, "AF42" }, + { IPDSFIELD_DSCP_AF43, "AF43" }, + { IPDSFIELD_DSCP_CS5, "CS5" }, + { IPDSFIELD_DSCP_EF, "EF PHB" }, + { IPDSFIELD_DSCP_CS6, "CS6" }, + { IPDSFIELD_DSCP_CS7, "CS7" }, + { 0, NULL }}; +value_string_ext dscp_short_vals_ext = VALUE_STRING_EXT_INIT(dscp_short_vals); + + static const value_string dscp_vals[] = { { IPDSFIELD_DSCP_DEFAULT, "Default" }, { IPDSFIELD_DSCP_CS1, "Class Selector 1" }, @@ -1915,12 +1934,21 @@ static const value_string dscp_vals[] = { { 0, NULL }}; value_string_ext dscp_vals_ext = VALUE_STRING_EXT_INIT(dscp_vals); -const value_string ecn_vals[] = { - { IPDSFIELD_ECT_NOT, "Not-ECT (Not ECN-Capable Transport)" }, - { IPDSFIELD_ECT_1, "ECT(1) (ECN-Capable Transport)" }, - { IPDSFIELD_ECT_0, "ECT(0) (ECN-Capable Transport)" }, - { IPDSFIELD_CE, "CE (Congestion Experienced)" }, - { 0, NULL }}; +static const value_string ecn_short_vals[] = { + { IPDSFIELD_ECT_NOT, "Not-ECT" }, + { IPDSFIELD_ECT_1, "ECT(1)" }, + { IPDSFIELD_ECT_0, "ECT(0)" }, + { IPDSFIELD_CE, "CE" }, + { 0, NULL }}; +value_string_ext ecn_short_vals_ext = VALUE_STRING_EXT_INIT(ecn_short_vals); + +static const value_string ecn_vals[] = { + { IPDSFIELD_ECT_NOT, "Not ECN-Capable Transport" }, + { IPDSFIELD_ECT_1, "ECN-Capable Transport codepoint '01'" }, + { IPDSFIELD_ECT_0, "ECN-Capable Transport codepoint '10'" }, + { IPDSFIELD_CE, "Congestion Experienced" }, + { 0, NULL }}; +value_string_ext ecn_vals_ext = VALUE_STRING_EXT_INIT(ecn_vals); static const value_string precedence_vals[] = { { IPTOS_PREC_ROUTINE, "routine" }, @@ -2058,12 +2086,10 @@ dissect_ip_v4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) if (tree) { if (g_ip_dscp_actif) { - tf = proto_tree_add_uint_format_value(ip_tree, hf_ip_dsfield, tvb, offset + 1, - 1, iph->ip_tos, "0x%02x (DSCP 0x%02x: %s; ECN 0x%02x: %s)", iph->ip_tos, - IPDSFIELD_DSCP(iph->ip_tos), val_to_str_ext_const(IPDSFIELD_DSCP(iph->ip_tos), - &dscp_vals_ext, "Unknown DSCP"), - IPDSFIELD_ECN(iph->ip_tos), val_to_str_const(IPDSFIELD_ECN(iph->ip_tos), - ecn_vals, "Unknown ECN")); + tf = proto_tree_add_item(ip_tree, hf_ip_dsfield, tvb, offset + 1, 1, ENC_NA); + proto_item_append_text(tf, " (DSCP: %s, ECN: %s)", + val_to_str_ext_const(IPDSFIELD_DSCP(iph->ip_tos), &dscp_short_vals_ext, "Unknown"), + val_to_str_ext_const(IPDSFIELD_ECN(iph->ip_tos), &ecn_short_vals_ext, "Unknown")); field_tree = proto_item_add_subtree(tf, ett_ip_dsfield); proto_tree_add_item(field_tree, hf_ip_dsfield_dscp, tvb, offset + 1, 1, ENC_NA); @@ -2608,16 +2634,16 @@ proto_register_ip(void) NULL, 0x0F, NULL, HFILL }}, { &hf_ip_dsfield, - { "Differentiated Services Field", "ip.dsfield", FT_UINT8, BASE_DEC, + { "Differentiated Services Field", "ip.dsfield", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }}, { &hf_ip_dsfield_dscp, - { "Differentiated Services Codepoint", "ip.dsfield.dscp", FT_UINT8, BASE_HEX | BASE_EXT_STRING, + { "Differentiated Services Codepoint", "ip.dsfield.dscp", FT_UINT8, BASE_DEC | BASE_EXT_STRING, &dscp_vals_ext, IPDSFIELD_DSCP_MASK, NULL, HFILL }}, { &hf_ip_dsfield_ecn, - { "Explicit Congestion Notification", "ip.dsfield.ecn", FT_UINT8, BASE_HEX, - VALS(ecn_vals), IPDSFIELD_ECN_MASK, NULL, HFILL }}, + { "Explicit Congestion Notification", "ip.dsfield.ecn", FT_UINT8, BASE_DEC | BASE_EXT_STRING, + &ecn_vals_ext, IPDSFIELD_ECN_MASK, NULL, HFILL }}, { &hf_ip_tos, { "Type of Service", "ip.tos", FT_UINT8, BASE_DEC, diff --git a/epan/dissectors/packet-ip.h b/epan/dissectors/packet-ip.h index 7456e134e1..698e5047e0 100644 --- a/epan/dissectors/packet-ip.h +++ b/epan/dissectors/packet-ip.h @@ -42,15 +42,26 @@ typedef struct _ws_ip address ip_dst; } ws_ip; +/* Differentiated Services Codepoint */ +#define IPDSFIELD_DSCP_MASK 0xFC +#define IPDSFIELD_DSCP(dsfield) (((dsfield) & IPDSFIELD_DSCP_MASK) >> 2) + +/* Explicit Congestion Notification */ +#define IPDSFIELD_ECN_MASK 0x03 +#define IPDSFIELD_ECN(dsfield) ((dsfield) & IPDSFIELD_ECN_MASK) + void capture_ip(const guchar *, int, int, packet_counts *); gboolean ip_try_dissect(gboolean heur_first, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ws_ip *iph); -/* Export the DSCP extended value-string table for other protocols */ +/* Export the DSCP/ECN extended value-string table for other protocols */ WS_DLL_PUBLIC value_string_ext dscp_vals_ext; +WS_DLL_PUBLIC value_string_ext ecn_vals_ext; +WS_DLL_PUBLIC value_string_ext dscp_short_vals_ext; +WS_DLL_PUBLIC value_string_ext ecn_short_vals_ext; -#endif +#endif /* __PACKET_IP_H__ */ /* * Editor modelines - http://www.wireshark.org/tools/modelines.html diff --git a/epan/dissectors/packet-ipv6.c b/epan/dissectors/packet-ipv6.c index b9aa008251..330b26bb79 100644 --- a/epan/dissectors/packet-ipv6.c +++ b/epan/dissectors/packet-ipv6.c @@ -86,36 +86,6 @@ void proto_reg_handoff_ipv6(void); #define IP6OPT_RTALERT_RSVP 1 /* Datagram contains RSVP msg */ #define IP6OPT_RTALERT_ACTNET 2 /* Datagram contains ACTNET msg */ -/* Differentiated Services Field. See RFCs 2474, 2597 and 2598. */ -#define IPDSFIELD_DSCP_MASK 0xFC -#define IPDSFIELD_ECN_MASK 0x03 -#define IPDSFIELD_DSCP_SHIFT 2 -#define IPDSFIELD_DSCP(dsfield) (((dsfield)&IPDSFIELD_DSCP_MASK)>>IPDSFIELD_DSCP_SHIFT) -#define IPDSFIELD_ECN(dsfield) ((dsfield)&IPDSFIELD_ECN_MASK) -#define IPDSFIELD_DSCP_DEFAULT 0x00 -#define IPDSFIELD_DSCP_CS1 0x08 -#define IPDSFIELD_DSCP_CS2 0x10 -#define IPDSFIELD_DSCP_CS3 0x18 -#define IPDSFIELD_DSCP_CS4 0x20 -#define IPDSFIELD_DSCP_CS5 0x28 -#define IPDSFIELD_DSCP_CS6 0x30 -#define IPDSFIELD_DSCP_CS7 0x38 -#define IPDSFIELD_DSCP_AF11 0x0A -#define IPDSFIELD_DSCP_AF12 0x0C -#define IPDSFIELD_DSCP_AF13 0x0E -#define IPDSFIELD_DSCP_AF21 0x12 -#define IPDSFIELD_DSCP_AF22 0x14 -#define IPDSFIELD_DSCP_AF23 0x16 -#define IPDSFIELD_DSCP_AF31 0x1A -#define IPDSFIELD_DSCP_AF32 0x1C -#define IPDSFIELD_DSCP_AF33 0x1E -#define IPDSFIELD_DSCP_AF41 0x22 -#define IPDSFIELD_DSCP_AF42 0x24 -#define IPDSFIELD_DSCP_AF43 0x26 -#define IPDSFIELD_DSCP_EF 0x2E -#define IPDSFIELD_ECT_MASK 0x02 -#define IPDSFIELD_CE_MASK 0x01 - /* RPL Routing header */ #define IP6RRPL_BITMASK_CMPRI 0xF0000000 #define IP6RRPL_BITMASK_CMPRE 0x0F000000 @@ -145,7 +115,9 @@ static int proto_ipv6_dstopts = -1; static int hf_ipv6_version = -1; static int hf_ip_version = -1; -static int hf_ipv6_class = -1; +static int hf_ipv6_tclass = -1; +static int hf_ipv6_tclass_dscp = -1; +static int hf_ipv6_tclass_ecn = -1; static int hf_ipv6_flow = -1; static int hf_ipv6_plen = -1; static int hf_ipv6_nxt = -1; @@ -292,9 +264,6 @@ static int hf_ipv6_shim6_opt_fii = -1; static int hf_ipv6_shim6_validator = -1; static int hf_ipv6_shim6_cga_parameter_data_structure = -1; static int hf_ipv6_shim6_cga_signature = -1; -static int hf_ipv6_traffic_class_dscp = -1; -static int hf_ipv6_traffic_class_ect = -1; -static int hf_ipv6_traffic_class_ce = -1; #ifdef HAVE_GEOIP_V6 static int hf_geoip_country = -1; @@ -1971,10 +1940,10 @@ dissect_shim6(tvbuff_t *tvb, packet_info * pinfo, proto_tree *tree, void* data _ static void dissect_ipv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - proto_tree *ipv6_tree, *ipv6_tc_tree; - proto_item *ipv6_item, *ipv6_tc, *ti, *pi; + proto_tree *ipv6_tree, *pt; + proto_item *ipv6_item, *ti, *pi; proto_item *ti_ipv6_plen = NULL, *ti_ipv6_version; - guint8 nxt; + guint8 nxt, tfc; int advance; guint32 plen; gboolean frag; @@ -2031,7 +2000,8 @@ dissect_ipv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) return; } - col_add_fstr(pinfo->cinfo, COL_DSCP_VALUE, "%u", IPDSFIELD_DSCP(IPv6_HDR_TCLS(ipv6))); + tfc = IPv6_HDR_TCLS(ipv6); + col_add_fstr(pinfo->cinfo, COL_DSCP_VALUE, "%u", IPDSFIELD_DSCP(tfc)); /* Get extension header and payload length */ plen = g_ntohs(ipv6->ip6_plen); @@ -2045,18 +2015,18 @@ dissect_ipv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) p_add_proto_data(pinfo->pool, pinfo, proto_ipv6, IPV6_PROTO_META, ipv6_info); if (tree) { - /* !!! warning: (4-bit) version, (6-bit) DSCP, (1-bit) ECN-ECT, (1-bit) ECN-CE and (20-bit) Flow */ - ipv6_tc = proto_tree_add_item(ipv6_tree, hf_ipv6_class, tvb, - offset + IP6H_CTL_FLOW, 4, ENC_BIG_ENDIAN); - - ipv6_tc_tree = proto_item_add_subtree(ipv6_tc, ett_ipv6_traffic_class); - - proto_tree_add_item(ipv6_tc_tree, hf_ipv6_traffic_class_dscp, tvb, - offset + IP6H_CTL_FLOW, 4, ENC_BIG_ENDIAN); - proto_tree_add_item(ipv6_tc_tree, hf_ipv6_traffic_class_ect, tvb, + /* !!! warning: (4-bit) version, (6-bit) DSCP, (2-bit) ECN and (20-bit) Flow */ + + /* _format_value() used to elide leading zeros from hex representation for IPv6 Traffic Class */ + ti = proto_tree_add_uint_format_value(ipv6_tree, hf_ipv6_tclass, tvb, + offset + IP6H_CTL_FLOW, 4, g_ntohl(ipv6->ip6_flow), "0x%02x", tfc); + proto_item_append_text(ti, " (DSCP: %s, ECN: %s)", + val_to_str_ext_const(IPDSFIELD_DSCP(tfc), &dscp_short_vals_ext, "Unknown"), + val_to_str_ext_const(IPDSFIELD_ECN(tfc), &ecn_short_vals_ext, "Unknown")); + pt = proto_item_add_subtree(ti, ett_ipv6_traffic_class); + proto_tree_add_item(pt, hf_ipv6_tclass_dscp, tvb, offset + IP6H_CTL_FLOW, 4, ENC_BIG_ENDIAN); - - proto_tree_add_item(ipv6_tc_tree, hf_ipv6_traffic_class_ce, tvb, + proto_tree_add_item(pt, hf_ipv6_tclass_ecn, tvb, offset + IP6H_CTL_FLOW, 4, ENC_BIG_ENDIAN); proto_tree_add_item(ipv6_tree, hf_ipv6_flow, tvb, @@ -2430,9 +2400,15 @@ proto_register_ipv6(void) { &hf_ip_version, { "Version", "ip.version", FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL }}, - { &hf_ipv6_class, - { "Traffic class", "ipv6.class", + { &hf_ipv6_tclass, + { "Traffic class", "ipv6.tclass", FT_UINT32, BASE_HEX, NULL, 0x0FF00000, NULL, HFILL }}, + { &hf_ipv6_tclass_dscp, + { "Differentiated Services Codepoint", "ipv6.tclass.dscp", + FT_UINT32, BASE_DEC | BASE_EXT_STRING, &dscp_vals_ext, 0x0FC00000, NULL, HFILL }}, + { &hf_ipv6_tclass_ecn, + { "Explicit Congestion Notification", "ipv6.tclass.ecn", + FT_UINT32, BASE_DEC | BASE_EXT_STRING, &ecn_vals_ext, 0x00300000, NULL, HFILL }}, { &hf_ipv6_flow, { "Flowlabel", "ipv6.flow", FT_UINT32, BASE_HEX, NULL, 0x000FFFFF, NULL, HFILL }}, @@ -3150,18 +3126,6 @@ proto_register_ipv6(void) { "CGA Signature", "ipv6.shim6.cga_signature", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - - { &hf_ipv6_traffic_class_dscp, - { "Differentiated Services Field", "ipv6.traffic_class.dscp", - FT_UINT32, BASE_HEX | BASE_EXT_STRING, &dscp_vals_ext, 0x0FC00000, NULL, HFILL }}, - - { &hf_ipv6_traffic_class_ect, - { "ECN-Capable Transport (ECT)", "ipv6.traffic_class.ect", - FT_BOOLEAN, 32, TFS(&tfs_set_notset), 0x0200000, NULL, HFILL }}, - - { &hf_ipv6_traffic_class_ce, - { "ECN-CE", "ipv6.traffic_class.ce", - FT_BOOLEAN, 32, TFS(&tfs_set_notset), 0x0100000, NULL, HFILL }}, }; static gint *ett[] = { &ett_ipv6, |