aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2001-05-23 03:33:59 +0000
committerGerald Combs <gerald@wireshark.org>2001-05-23 03:33:59 +0000
commit5500c0992334db778eb27584f9e659e4e60f1830 (patch)
treec8a83b5254c94d04fe3a567078187310ae70ff9e
parentec962d8cbde501432666dd45ab3b42beaec6184d (diff)
Add tree summary information similar to what's in packet-tcp.c.
svn path=/trunk/; revision=3436
-rw-r--r--packet-ip.c20
-rw-r--r--packet-udp.c22
2 files changed, 37 insertions, 5 deletions
diff --git a/packet-ip.c b/packet-ip.c
index 173c0ea8a0..2181a9e25a 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.132 2001/05/20 22:20:33 guy Exp $
+ * $Id: packet-ip.c,v 1.133 2001/05/23 03:33:58 gerald Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -65,6 +65,9 @@ static gboolean g_ip_dscp_actif = TRUE;
/* Defragment fragmented IP datagrams */
static gboolean ip_defragment = FALSE;
+/* Place IP summary in proto tree */
+static gboolean ip_summary_in_tree = TRUE;
+
static int proto_ip = -1;
static int hf_ip_version = -1;
static int hf_ip_hdr_len = -1;
@@ -1147,7 +1150,14 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
hlen = lo_nibble(iph.ip_v_hl) * 4; /* IP header length, in bytes */
if (tree) {
- ti = proto_tree_add_item(tree, proto_ip, tvb, offset, hlen, FALSE);
+ if (ip_summary_in_tree && hlen >= IPH_MIN_LEN) {
+ ti = proto_tree_add_protocol_format(tree, proto_ip, tvb, offset, hlen,
+ "Internet Protocol, Src Addr: %s (%s), Dst Addr: %s (%s)",
+ get_hostname(iph.ip_src), ip_to_str((guint8 *) &iph.ip_src),
+ get_hostname(iph.ip_dst), ip_to_str((guint8 *) &iph.ip_dst));
+ } else {
+ ti = proto_tree_add_item(tree, proto_ip, tvb, offset, hlen, FALSE);
+ }
ip_tree = proto_item_add_subtree(ti, ett_ip);
}
@@ -1859,12 +1869,16 @@ proto_register_ip(void)
ip_module = prefs_register_protocol(proto_ip, NULL);
prefs_register_bool_preference(ip_module, "decode_tos_as_diffserv",
"Decode IPv4 TOS field as DiffServ field",
-"Whether the IPv4 type-of-service field should be decoded as a Differentiated Services field",
+ "Whether the IPv4 type-of-service field should be decoded as a Differentiated Services field",
&g_ip_dscp_actif);
prefs_register_bool_preference(ip_module, "defragment",
"Reassemble fragmented IP datagrams",
"Whether fragmented IP datagrams should be reassembled",
&ip_defragment);
+ prefs_register_bool_preference(ip_module, "ip_summary_in_tree",
+ "Show IP summary in protocol tree",
+ "Whether the IP summary line should be shown in the protocol tree",
+ &ip_summary_in_tree);
register_dissector("ip", dissect_ip, proto_ip);
register_init_routine(ip_defragment_init);
diff --git a/packet-udp.c b/packet-udp.c
index e6a91ebcc2..b26db5cd78 100644
--- a/packet-udp.c
+++ b/packet-udp.c
@@ -1,7 +1,7 @@
/* packet-udp.c
* Routines for UDP packet disassembly
*
- * $Id: packet-udp.c,v 1.91 2001/04/23 17:56:42 guy Exp $
+ * $Id: packet-udp.c,v 1.92 2001/05/23 03:33:59 gerald Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -46,6 +46,7 @@
#include "resolv.h"
#include "ipproto.h"
#include "in_cksum.h"
+#include "prefs.h"
#include "packet-udp.h"
@@ -62,6 +63,9 @@ static int hf_udp_checksum_bad = -1;
static gint ett_udp = -1;
+/* Place UDP summary in proto tree */
+static gboolean udp_summary_in_tree = TRUE;
+
/* UDP structs and definitions */
typedef struct _e_udphdr {
@@ -138,7 +142,13 @@ dissect_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
get_udp_port(uh_sport), get_udp_port(uh_dport));
if (tree) {
- ti = proto_tree_add_item(tree, proto_udp, tvb, offset, 8, FALSE);
+ if (udp_summary_in_tree) {
+ ti = proto_tree_add_protocol_format(tree, proto_udp, tvb, offset, 8,
+ "User Datagram Protocol, Src Port: %s (%u), Dst Port: %s (%u)",
+ get_udp_port(uh_sport), uh_sport, get_udp_port(uh_dport), uh_dport);
+ } else {
+ ti = proto_tree_add_item(tree, proto_udp, tvb, offset, 8, FALSE);
+ }
udp_tree = proto_item_add_subtree(ti, ett_udp);
proto_tree_add_uint_format(udp_tree, hf_udp_srcport, tvb, offset, 2, uh_sport,
@@ -221,6 +231,7 @@ dissect_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
void
proto_register_udp(void)
{
+ module_t *udp_module;
static hf_register_info hf[] = {
{ &hf_udp_srcport,
{ "Source Port", "udp.srcport", FT_UINT16, BASE_DEC, NULL, 0x0,
@@ -259,6 +270,13 @@ proto_register_udp(void)
udp_dissector_table = register_dissector_table("udp.port");
register_heur_dissector_list("udp", &heur_subdissector_list);
register_conv_dissector_list("udp", &conv_subdissector_list);
+
+ /* Register configuration preferences */
+ udp_module = prefs_register_protocol(proto_udp, NULL);
+ prefs_register_bool_preference(udp_module, "udp_summary_in_tree",
+ "Show UDP summary in protocol treee",
+ "Whether the UDP summary line should be shown in the protocol tree",
+ &udp_summary_in_tree);
}
void