Heikki Vatiainen's patch to add a flag to control whether to interpret

the IPv4 TOS field as a TOS field or as a DiffServ field, and allow that
field to be controlled by a command-line option or an option in the
"Display:Options" dialog box.

svn path=/trunk/; revision=1532
This commit is contained in:
Guy Harris 2000-01-24 04:44:58 +00:00
parent 930d95c0b0
commit f393a19883
8 changed files with 151 additions and 24 deletions

View File

@ -183,6 +183,8 @@ Heikki Vatiainen <hessu@cs.tut.fi> {
SAP (Session Announcement Protocol) support
VRRP (Virtual Router Redundancy)
HSRP (Hot Standby Router Protocol)
option to control whether to interpret the IPv4 TOS field as
such or as the DiffServ field
}
Greg Hankins <gregh@twoguys.org> {

View File

@ -9,6 +9,7 @@ B<ethereal>
S<[ B<-B> byte view height ]>
S<[ B<-b> bold font ]>
S<[ B<-c> count ]>
S<[ B<-D> ]>
S<[ B<-f> filter expression ]>
S<[ B<-h> ]>
S<[ B<-i> interface ]>
@ -84,6 +85,11 @@ pane that corresponds to the field selected in the protocol tree pane.
Sets the default number of packets to read when capturing live
data.
=item -D
Turns off treating the original IPv4 TOS field as the Differentiated
Services Field. The structure of the DS Field is defined in RFC 2474.
=item -f
Sets the capture filter expression.
@ -245,10 +251,12 @@ system-dependent, but is likely either /var/tmp or /tmp.
=item Display:Options
Sets the format of the packet timestamp displayed in the packet list
window to relative, absolute, or delta.
Allows you to enable the automatic scrolling of the packet list while a
live capture is in progress.
Allows you to sets the format of the packet timestamp displayed in the
packet list window to relative, absolute, or delta, to enable or disable
the automatic scrolling of the packet list while a live capture is in
progress, to enable or disable translation of addresses to names in the
display, or to enable or disable interpretation of the IPv4 TOS field as
the Differentiated Services field.
=item Display:Match Selected
@ -500,7 +508,9 @@ in the packet list. You can select "Time of day" for absolute time stamps,
"Seconds since previous frame" for delta time stamps. You can also
specify whether, when the display is updated as packets are captured,
the list should automatically scroll to show the most recently captured
packets or not.
packets or not, whether addresses should be translated to names in the
display, and whether IPv4 TOS field should be treated as the
Differentiated Services field.
=item Plugins
@ -509,7 +519,7 @@ on your system.
The I<Plugins List> shows the name, description, version and state
(enabled or not) of each plugin found on your system. The plugins are
searched in the following directories : B</usr/share/ethereal/plugins>,
searched in the following directories: B</usr/share/ethereal/plugins>,
B</usr/local/share/ethereal/plugins> and B<~/.ethereal/plugins>
A plugin must be activated using the I<Enable> button in order to use it

View File

@ -7,6 +7,7 @@ Tethereal - Dump and analyze network traffic
B<tethereal>
S<[ B<-c> count ]>
S<[ B<-D> ]>
S<[ B<-f> filter expression ]>
S<[ B<-F> file format ]>
S<[ B<-h> ]>
@ -91,6 +92,11 @@ be unable to read compressed files.
Sets the default number of packets to read when capturing live
data.
=item -D
Turns off treating the original IPv4 TOS field as the Differentiated
Services Field. The structure of the DS Field is defined in RFC 2474.
=item -f
Sets the capture filter expression.

View File

@ -1,7 +1,7 @@
/* globals.h
* Global defines, etc.
*
* $Id: globals.h,v 1.14 2000/01/06 06:28:54 guy Exp $
* $Id: globals.h,v 1.15 2000/01/24 04:44:35 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -85,6 +85,7 @@ extern gchar *bold_font;
extern gchar *last_open_dir;
extern gboolean auto_scroll_live;
extern int g_resolving_actif;
extern gboolean g_ip_dscp_actif;
extern field_info *finfo_selected;
extern ts_type timestamp_type;

View File

@ -1,7 +1,7 @@
/* display_opts.c
* Routines for packet display windows
*
* $Id: display_opts.c,v 1.1 1999/10/18 12:48:13 gram Exp $
* $Id: display_opts.c,v 1.2 2000/01/24 04:44:58 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -92,6 +92,7 @@ extern GtkWidget *packet_list;
#define E_DISPLAY_TIME_DELTA_KEY "display_time_delta"
#define E_DISPLAY_AUTO_SCROLL_KEY "display_auto_scroll"
#define E_DISPLAY_NAME_RESOLUTION_KEY "display_name_resolution"
#define E_DISPLAY_IP_DSCP_KEY "display_ip_dscp"
static void display_opt_ok_cb(GtkWidget *, gpointer);
static void display_opt_apply_cb(GtkWidget *, gpointer);
@ -172,6 +173,13 @@ display_opt_cb(GtkWidget *w, gpointer d) {
gtk_box_pack_start(GTK_BOX(main_vb), button, TRUE, TRUE, 0);
gtk_widget_show(button);
button = gtk_check_button_new_with_label("Decode IPv4 TOS field as DiffServ Field");
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), g_ip_dscp_actif);
gtk_object_set_data(GTK_OBJECT(display_opt_w), E_DISPLAY_IP_DSCP_KEY,
button);
gtk_box_pack_start(GTK_BOX(main_vb), button, TRUE, TRUE, 0);
gtk_widget_show(button);
/* Button row: OK, Apply, and Cancel buttons */
bbox = gtk_hbutton_box_new();
gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_END);
@ -232,6 +240,10 @@ display_opt_ok_cb(GtkWidget *ok_bt, gpointer parent_w) {
E_DISPLAY_NAME_RESOLUTION_KEY);
g_resolving_actif = (GTK_TOGGLE_BUTTON (button)->active);
button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(parent_w),
E_DISPLAY_IP_DSCP_KEY);
g_ip_dscp_actif = (GTK_TOGGLE_BUTTON (button)->active);
gtk_widget_destroy(GTK_WIDGET(parent_w));
display_opt_window_active = FALSE;
@ -265,6 +277,10 @@ display_opt_apply_cb(GtkWidget *ok_bt, gpointer parent_w) {
E_DISPLAY_NAME_RESOLUTION_KEY);
g_resolving_actif = (GTK_TOGGLE_BUTTON (button)->active);
button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(parent_w),
E_DISPLAY_IP_DSCP_KEY);
g_ip_dscp_actif = (GTK_TOGGLE_BUTTON (button)->active);
change_time_formats(&cf);
}

View File

@ -1,6 +1,6 @@
/* main.c
*
* $Id: main.c,v 1.92 2000/01/18 08:38:16 guy Exp $
* $Id: main.c,v 1.93 2000/01/24 04:44:58 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -1157,7 +1157,7 @@ main(int argc, char *argv[])
#ifndef WIN32
/* Now get our args */
while ((opt = getopt(argc, argv, "b:B:c:f:hi:km:nP:Qr:R:Ss:t:T:w:W:v")) != EOF) {
while ((opt = getopt(argc, argv, "b:B:c:Df:hi:km:nP:Qr:R:Ss:t:T:w:W:v")) != EOF) {
switch (opt) {
case 'b': /* Bold font */
bold_font = g_strdup(optarg);
@ -1173,6 +1173,9 @@ main(int argc, char *argv[])
arg_error = TRUE;
#endif
break;
case 'D': /* Turn off DSCP printing */
g_ip_dscp_actif = FALSE;
break;
case 'f':
#ifdef HAVE_LIBPCAP
if (cf.cfilter)

View File

@ -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,

View File

@ -1,6 +1,6 @@
/* tethereal.c
*
* $Id: tethereal.c,v 1.12 2000/01/22 07:19:26 guy Exp $
* $Id: tethereal.c,v 1.13 2000/01/24 04:44:36 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -144,8 +144,8 @@ print_usage(void)
fprintf(stderr, "This is GNU t%s %s, compiled with %s\n", PACKAGE,
VERSION, comp_info_str);
fprintf(stderr, "t%s [ -vVh ] [ -c count ] [ -f <filter expression> ] [ -F <capture type> ]\n", PACKAGE);
fprintf(stderr, "\t[ -i iface ] [ -r infile ] [ -R <filter expression> ]\n");
fprintf(stderr, "t%s [ -vVh ] [ -c count ] [ -D ] [ -f <filter expression> ] [ -F <capture type> ]\n", PACKAGE);
fprintf(stderr, "\t[ -i iface ] [ -n ] [ -r infile ] [ -R <filter expression> ]\n");
fprintf(stderr, "\t[ -s snaplen ] [ -t <time stamp format> ] [ -w savefile ] [ -x ]\n");
fprintf(stderr, "Valid file type arguments to the \"-F\" flag:\n");
for (i = 0; i < WTAP_NUM_FILE_TYPES; i++) {
@ -266,7 +266,7 @@ main(int argc, char *argv[])
);
/* Now get our args */
while ((opt = getopt(argc, argv, "c:f:F:hi:nr:R:s:t:vw:Vx")) != EOF) {
while ((opt = getopt(argc, argv, "c:Df:F:hi:nr:R:s:t:vw:Vx")) != EOF) {
switch (opt) {
case 'c': /* Capture xxx packets */
#ifdef HAVE_LIBPCAP
@ -276,6 +276,9 @@ main(int argc, char *argv[])
arg_error = TRUE;
#endif
break;
case 'D': /* Turn off DSCP printing */
g_ip_dscp_actif = FALSE;
break;
case 'f':
#ifdef HAVE_LIBPCAP
cf.cfilter = g_strdup(optarg);