forked from osmocom/wireshark
Create dscp_vals_ext value_str_ext (based upon dscp_vals); Use it as appropriate.
Also: - use val_to_str_const() [instead of val_to_str()] in a few cases; - do some trivial formatting cleanup. svn path=/trunk/; revision=43204
This commit is contained in:
parent
a923c28ede
commit
df07bfeba4
|
@ -286,8 +286,10 @@ static dissector_handle_t tapa_handle;
|
|||
#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
|
||||
|
@ -309,6 +311,7 @@ static dissector_handle_t tapa_handle;
|
|||
#define IPDSFIELD_DSCP_AF42 0x24
|
||||
#define IPDSFIELD_DSCP_AF43 0x26
|
||||
#define IPDSFIELD_DSCP_EF 0x2E
|
||||
|
||||
#define IPDSFIELD_ECT_NOT 0x00
|
||||
#define IPDSFIELD_ECT_1 0x01
|
||||
#define IPDSFIELD_ECT_0 0x02
|
||||
|
@ -1826,6 +1829,7 @@ const value_string dscp_vals[] = {
|
|||
{ IPDSFIELD_DSCP_AF43, "Assured Forwarding 43" },
|
||||
{ IPDSFIELD_DSCP_EF, "Expedited Forwarding" },
|
||||
{ 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)" },
|
||||
|
@ -1977,10 +1981,10 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
|
|||
tf = proto_tree_add_uint_format(ip_tree, hf_ip_dsfield, tvb, offset + 1,
|
||||
1, iph->ip_tos, "Differentiated Services Field: 0x%02x "
|
||||
"(DSCP 0x%02x: %s; ECN: 0x%02x: %s)", iph->ip_tos,
|
||||
IPDSFIELD_DSCP(iph->ip_tos), val_to_str(IPDSFIELD_DSCP(iph->ip_tos),
|
||||
dscp_vals, "Unknown DSCP"),
|
||||
IPDSFIELD_ECN(iph->ip_tos), val_to_str(IPDSFIELD_ECN(iph->ip_tos),
|
||||
ecn_vals, "Unknown ECN"));
|
||||
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"));
|
||||
|
||||
field_tree = proto_item_add_subtree(tf, ett_ip_dsfield);
|
||||
/* Add DSCP using bit offset to be able to use the same hf field in IPv6 */
|
||||
|
@ -1991,8 +1995,8 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
|
|||
iph->ip_tos,
|
||||
"Type of service: 0x%02x (%s)",
|
||||
iph->ip_tos,
|
||||
val_to_str(IPTOS_TOS(iph->ip_tos),
|
||||
iptos_vals, "Unknown"));
|
||||
val_to_str_const(IPTOS_TOS(iph->ip_tos),
|
||||
iptos_vals, "Unknown"));
|
||||
|
||||
field_tree = proto_item_add_subtree(tf, ett_ip_tos);
|
||||
proto_tree_add_item(field_tree, hf_ip_tos_precedence, tvb, offset + 1, 1, ENC_NA);
|
||||
|
@ -2412,8 +2416,8 @@ proto_register_ip(void)
|
|||
NULL, 0x0, NULL, HFILL }},
|
||||
|
||||
{ &hf_ip_dsfield_dscp,
|
||||
{ "Differentiated Services Codepoint", "ip.dsfield.dscp", FT_UINT8, BASE_HEX,
|
||||
VALS(dscp_vals), 0, NULL, HFILL }},
|
||||
{ "Differentiated Services Codepoint", "ip.dsfield.dscp", FT_UINT8, BASE_HEX | BASE_EXT_STRING,
|
||||
&dscp_vals_ext, 0, NULL, HFILL }},
|
||||
|
||||
{ &hf_ip_dsfield_ecn,
|
||||
{ "Explicit Congestion Notification", "ip.dsfield.ecn", FT_UINT8, BASE_HEX,
|
||||
|
@ -2570,8 +2574,8 @@ proto_register_ip(void)
|
|||
NULL, 0x0, NULL, HFILL }},
|
||||
|
||||
{ &hf_ip_proto,
|
||||
{ "Protocol", "ip.proto", FT_UINT8, BASE_DEC|BASE_EXT_STRING,
|
||||
(&ipproto_val_ext), 0x0, NULL, HFILL }},
|
||||
{ "Protocol", "ip.proto", FT_UINT8, BASE_DEC | BASE_EXT_STRING,
|
||||
&ipproto_val_ext, 0x0, NULL, HFILL }},
|
||||
|
||||
{ &hf_ip_checksum,
|
||||
{ "Header checksum", "ip.checksum", FT_UINT16, BASE_HEX,
|
||||
|
@ -2652,7 +2656,7 @@ proto_register_ip(void)
|
|||
|
||||
{ &hf_ip_opt_qs_rate,
|
||||
{ "Rate", "ip.opt.qs_rate", FT_UINT8, BASE_DEC | BASE_EXT_STRING,
|
||||
&(qs_rate_vals_ext), QS_RATE_MASK, NULL, HFILL }},
|
||||
&qs_rate_vals_ext, QS_RATE_MASK, NULL, HFILL }},
|
||||
|
||||
{ &hf_ip_opt_qs_ttl,
|
||||
{ "QS TTL", "ip.opt.qs_ttl", FT_UINT8, BASE_DEC,
|
||||
|
|
|
@ -45,6 +45,7 @@ guint16 ip_checksum(const guint8 *ptr, int len);
|
|||
|
||||
/* Export the DSCP value-string table for other protocols */
|
||||
WS_VAR_IMPORT const value_string dscp_vals[];
|
||||
WS_VAR_IMPORT value_string_ext dscp_vals_ext;
|
||||
|
||||
proto_item *add_ip_version_to_tree(proto_tree *tree, tvbuff_t *tvb, int offset);
|
||||
proto_item *add_ip_dscp_to_tree(proto_tree *tree, tvbuff_t *tvb, int offset);
|
||||
|
|
Loading…
Reference in New Issue