aboutsummaryrefslogtreecommitdiffstats
path: root/packet-ip.c
diff options
context:
space:
mode:
Diffstat (limited to 'packet-ip.c')
-rw-r--r--packet-ip.c108
1 files changed, 97 insertions, 11 deletions
diff --git a/packet-ip.c b/packet-ip.c
index c1bb7e69a2..df68f17871 100644
--- a/packet-ip.c
+++ b/packet-ip.c
@@ -1,7 +1,7 @@
/* packet-ip.c
* Routines for IP and miscellaneous IP protocol packet disassembly
*
- * $Id: packet-ip.c,v 1.70 2000/01/23 08:55:32 guy Exp $
+ * $Id: packet-ip.c,v 1.71 2000/01/24 04:44:35 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -54,9 +54,15 @@
#include "packet-ip.h"
#endif
+/* Decode the old IPv4 TOS field as the DiffServ DS Field */
+gboolean g_ip_dscp_actif = TRUE;
+
static int proto_ip = -1;
static int hf_ip_version = -1;
static int hf_ip_hdr_len = -1;
+static int hf_ip_dsfield = -1;
+static int hf_ip_dsfield_dscp = -1;
+static int hf_ip_dsfield_cu = -1;
static int hf_ip_tos = -1;
static int hf_ip_tos_precedence = -1;
static int hf_ip_tos_delay = -1;
@@ -77,6 +83,7 @@ static int hf_ip_proto = -1;
static int hf_ip_checksum = -1;
static gint ett_ip = -1;
+static gint ett_ip_dsfield = -1;
static gint ett_ip_tos = -1;
static gint ett_ip_off = -1;
static gint ett_ip_options = -1;
@@ -242,6 +249,34 @@ typedef struct _e_ip
#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_DSCP_SHIFT 2
+#define IPDSFIELD_DSCP(dsfield) (((dsfield)&IPDSFIELD_DSCP_MASK)>>IPDSFIELD_DSCP_SHIFT)
+#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_CU_MASK 0x03
+
+/* IP TOS, superseded by the DS Field, RFC 2474. */
#define IPTOS_TOS_MASK 0x1E
#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
#define IPTOS_NONE 0x00
@@ -720,6 +755,30 @@ static const value_string proto_vals[] = { {IP_PROTO_ICMP, "ICMP"},
{IP_PROTO_VINES,"VINES"},
{0, NULL } };
+static const value_string dscp_vals[] = {
+ { IPDSFIELD_DSCP_DEFAULT, "Default" },
+ { IPDSFIELD_DSCP_CS1, "Class Selector 1" },
+ { IPDSFIELD_DSCP_CS2, "Class Selector 2" },
+ { IPDSFIELD_DSCP_CS3, "Class Selector 3" },
+ { IPDSFIELD_DSCP_CS4, "Class Selector 4" },
+ { IPDSFIELD_DSCP_CS5, "Class Selector 5" },
+ { IPDSFIELD_DSCP_CS6, "Class Selector 6" },
+ { IPDSFIELD_DSCP_CS7, "Class Selector 7" },
+ { IPDSFIELD_DSCP_AF11, "Assured Forwarding 11" },
+ { IPDSFIELD_DSCP_AF12, "Assured Forwarding 12" },
+ { IPDSFIELD_DSCP_AF13, "Assured Forwarding 13" },
+ { IPDSFIELD_DSCP_AF21, "Assured Forwarding 21" },
+ { IPDSFIELD_DSCP_AF22, "Assured Forwarding 22" },
+ { IPDSFIELD_DSCP_AF23, "Assured Forwarding 23" },
+ { IPDSFIELD_DSCP_AF31, "Assured Forwarding 31" },
+ { IPDSFIELD_DSCP_AF32, "Assured Forwarding 32" },
+ { IPDSFIELD_DSCP_AF33, "Assured Forwarding 33" },
+ { IPDSFIELD_DSCP_AF41, "Assured Forwarding 41" },
+ { IPDSFIELD_DSCP_AF42, "Assured Forwarding 42" },
+ { IPDSFIELD_DSCP_AF43, "Assured Forwarding 43" },
+ { IPDSFIELD_DSCP_EF, "Expedited Forwarding" },
+ { 0, NULL } };
+
static const value_string precedence_vals[] = {
{ IPTOS_PREC_ROUTINE, "routine" },
{ IPTOS_PREC_PRIORITY, "priority" },
@@ -870,16 +929,28 @@ dissect_ip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
proto_tree_add_item(ip_tree, hf_ip_version, offset, 1, hi_nibble(iph.ip_v_hl));
proto_tree_add_item_format(ip_tree, hf_ip_hdr_len, offset, 1, hlen,
"Header length: %u bytes", hlen);
- tf = proto_tree_add_item_format(ip_tree, hf_ip_tos, offset + 1, 1, iph.ip_tos,
- "Type of service: 0x%02x (%s)", iph.ip_tos,
- val_to_str( 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, offset + 1, 1, iph.ip_tos);
- proto_tree_add_item(field_tree, hf_ip_tos_delay, offset + 1, 1, iph.ip_tos);
- proto_tree_add_item(field_tree, hf_ip_tos_throughput, offset + 1, 1, iph.ip_tos);
- proto_tree_add_item(field_tree, hf_ip_tos_reliability, offset + 1, 1, iph.ip_tos);
- proto_tree_add_item(field_tree, hf_ip_tos_cost, offset + 1, 1, iph.ip_tos);
+
+ if (g_ip_dscp_actif) {
+ tf = proto_tree_add_item_format(ip_tree, hf_ip_dsfield, offset + 1, 1, iph.ip_tos,
+ "Differentiated Services Field: 0x%02x (DSCP 0x%02x: %s)", iph.ip_tos,
+ IPDSFIELD_DSCP(iph.ip_tos), val_to_str(IPDSFIELD_DSCP(iph.ip_tos), dscp_vals,
+ "Unknown DSCP"));
+
+ field_tree = proto_item_add_subtree(tf, ett_ip_dsfield);
+ proto_tree_add_item(field_tree, hf_ip_dsfield_dscp, offset + 1, 1, iph.ip_tos);
+ proto_tree_add_item(field_tree, hf_ip_dsfield_cu, offset + 1, 1, iph.ip_tos);
+ } else {
+ tf = proto_tree_add_item_format(ip_tree, hf_ip_tos, offset + 1, 1, iph.ip_tos,
+ "Type of service: 0x%02x (%s)", iph.ip_tos,
+ val_to_str( 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, offset + 1, 1, iph.ip_tos);
+ proto_tree_add_item(field_tree, hf_ip_tos_delay, offset + 1, 1, iph.ip_tos);
+ proto_tree_add_item(field_tree, hf_ip_tos_throughput, offset + 1, 1, iph.ip_tos);
+ proto_tree_add_item(field_tree, hf_ip_tos_reliability, offset + 1, 1, iph.ip_tos);
+ proto_tree_add_item(field_tree, hf_ip_tos_cost, offset + 1, 1, iph.ip_tos);
+ }
proto_tree_add_item(ip_tree, hf_ip_len, offset + 2, 2, iph.ip_len);
proto_tree_add_item(ip_tree, hf_ip_id, offset + 4, 2, iph.ip_id);
@@ -1344,6 +1415,20 @@ proto_register_ip(void)
{ "Header Length", "ip.hdr_len", FT_UINT8, BASE_DEC, NULL, 0x0,
"" }},
+ { &hf_ip_dsfield,
+ { "Differentiated Services field", "ip.dsfield", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
+ { &hf_ip_dsfield_dscp,
+ { "Differentiated Services Codepoint", "ip.dsfield.dscp", FT_UINT8, BASE_HEX,
+ VALS(dscp_vals), IPDSFIELD_DSCP_MASK,
+ "" }},
+
+ { &hf_ip_dsfield_cu,
+ { "Currently Unused", "ip.dsfield.cu", FT_UINT8, BASE_DEC, NULL,
+ IPDSFIELD_CU_MASK,
+ "" }},
+
{ &hf_ip_tos,
{ "Type of Service", "ip.tos", FT_UINT8, BASE_DEC, NULL, 0x0,
"" }},
@@ -1423,6 +1508,7 @@ proto_register_ip(void)
};
static gint *ett[] = {
&ett_ip,
+ &ett_ip_dsfield,
&ett_ip_tos,
&ett_ip_off,
&ett_ip_options,