aboutsummaryrefslogtreecommitdiffstats
path: root/packet-ip.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2000-12-29 04:16:57 +0000
committerGuy Harris <guy@alum.mit.edu>2000-12-29 04:16:57 +0000
commit5bcb17c724b7c1958a0f36d2a421fa7e6da9345e (patch)
treee462fe7b56e8626dcfee449e8761a52e236906a1 /packet-ip.c
parent00828b3f2bfe8523886257e54e37d34f18155f7d (diff)
If we get an exception when dissecting a packet, append "[Short Frame]"
or "[Malformed Frame]" to the Info column. Make some dissectors set the Protocol column and clear the Info column before fetching anything from the tvbuff they were handed, so that if the frame is short or malformed, it'll be marked as being the right top-level protocol, and the Info column won't have cruft left over from the previous protocol. svn path=/trunk/; revision=2800
Diffstat (limited to 'packet-ip.c')
-rw-r--r--packet-ip.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/packet-ip.c b/packet-ip.c
index 888d1b2683..5ed582f86c 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.114 2000/12/14 21:44:01 guy Exp $
+ * $Id: packet-ip.c,v 1.115 2000/12/29 04:16:57 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -797,6 +797,11 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
pinfo->current_proto = "IP";
+ if (check_col(pinfo->fd, COL_PROTOCOL))
+ col_set_str(pinfo->fd, COL_PROTOCOL, "IP");
+ if (check_col(pinfo->fd, COL_INFO))
+ col_clear(pinfo->fd, COL_INFO);
+
/* Avoids alignment problems on many architectures. */
tvb_memcpy(tvb, (guint8 *)&iph, offset, sizeof(e_ip));
iph.ip_len = ntohs(iph.ip_len);
@@ -922,8 +927,6 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
nxt = iph.ip_p;
if (iph.ip_off & IP_OFFSET) {
/* fragmented */
- if (check_col(pinfo->fd, COL_PROTOCOL))
- col_set_str(pinfo->fd, COL_PROTOCOL, "IP");
if (check_col(pinfo->fd, COL_INFO))
col_add_fstr(pinfo->fd, COL_INFO, "Fragmented IP protocol (proto=%s 0x%02x, off=%u)",
ipprotostr(iph.ip_p), iph.ip_p, (iph.ip_off & IP_OFFSET) * 8);
@@ -950,8 +953,6 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
next_tvb = tvb_new_subset(tvb, offset, -1, -1);
if (!dissector_try_port(ip_dissector_table, nxt, next_tvb, pinfo, tree)) {
/* Unknown protocol */
- if (check_col(pinfo->fd, COL_PROTOCOL))
- col_set_str(pinfo->fd, COL_PROTOCOL, "IP");
if (check_col(pinfo->fd, COL_INFO))
col_add_fstr(pinfo->fd, COL_INFO, "%s (0x%02x)", ipprotostr(iph.ip_p), iph.ip_p);
dissect_data(next_tvb, 0, pinfo, tree);
@@ -1012,6 +1013,11 @@ dissect_icmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
pinfo->current_proto = "ICMP";
+ if (check_col(pinfo->fd, COL_PROTOCOL))
+ col_set_str(pinfo->fd, COL_PROTOCOL, "ICMP");
+ if (check_col(pinfo->fd, COL_INFO))
+ col_clear(pinfo->fd, COL_INFO);
+
/* To do: check for runts, errs, etc. */
icmp_type = tvb_get_guint8(tvb, 0);
icmp_code = tvb_get_guint8(tvb, 1);
@@ -1087,8 +1093,6 @@ dissect_icmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
strcpy(type_str, "Unknown ICMP (obsolete or malformed?)");
}
- if (check_col(pinfo->fd, COL_PROTOCOL))
- col_set_str(pinfo->fd, COL_PROTOCOL, "ICMP");
if (check_col(pinfo->fd, COL_INFO))
col_add_str(pinfo->fd, COL_INFO, type_str);
@@ -1236,8 +1240,11 @@ dissect_igmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
CHECK_DISPLAY_AS_DATA(proto_igmp, tvb, pinfo, tree);
pinfo->current_proto = "IGMP";
+
if (check_col(pinfo->fd, COL_PROTOCOL))
col_set_str(pinfo->fd, COL_PROTOCOL, "IGMP");
+ if (check_col(pinfo->fd, COL_INFO))
+ col_clear(pinfo->fd, COL_INFO);
/* Avoids alignment problems on many architectures. */
memcpy(&ih, tvb_get_ptr(tvb, 0, sizeof(e_igmp)), sizeof(e_igmp));