This patch adds two things to Post Office Protocol (POP) packet
parsing. First, packets that come from the POP server and do not
start with "+OK" or "-ERR" are tagged as "Continuation", similarily
as the HTTP parser does. The packet contents are then passed to
dissect_data() in the tree view.
Second, if the request or response did not contain an argument, the
argument line in the tree display is not shown.
// Heikki
Index: ethereal/packet-pop.c
===================================================================
RCS file: /cvsroot/ethereal/packet-pop.c,v
retrieving revision 1.10
diff -u -r1.10 packet-pop.c
--- packet-pop.c 1999/11/16 11:42:46 1.10
+++ packet-pop.c 1999/11/20 16:03:38
@@ -49,6 +49,8 @@
static gint ett_pop = -1;
+static gboolean is_continuation(const u_char *data);
+
void
dissect_pop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
@@ -80,11 +82,19 @@
}
if (check_col(fd, COL_PROTOCOL))
- col_add_str(fd, COL_PROTOCOL, "POP");
+ col_add_str(fd, COL_PROTOCOL, "POP");
if (check_col(fd, COL_INFO)) {
-
- col_add_fstr(fd, COL_INFO, "%s: %s %s", (pi.match_port == pi.destport)? "Request" : "Response", rr, rd);
+ /*
+ * Do it like HTTP does.
+ * Put the first line from the buffer into the summary,
+ * if it's an POP request or reply.
+ * Otherwise, just call it a continuation.
+ */
+ if (pi.match_port == pi.srcport && is_continuation(pd+offset))
+ col_add_str(fd, COL_INFO, "Continuation");
+ else
+ col_add_fstr(fd, COL_INFO, "%s: %s %s", (pi.match_port == pi.destport)? "Request" : "Response", rr, rd);
}
if (tree) {
@@ -96,14 +106,21 @@
proto_tree_add_item_hidden(pop_tree, hf_pop_request, offset, i1, TRUE);
proto_tree_add_text(pop_tree, offset, i1, "Request: %s", rr);
- proto_tree_add_text(pop_tree, offset + i1 + 1, END_OF_FRAME, "Request Arg: %s", rd);
+ if (strlen(rd) != 0)
+ proto_tree_add_text(pop_tree, offset + i1 + 1, END_OF_FRAME, "Request Arg: %s", rd);
}
else {
proto_tree_add_item_hidden(pop_tree, hf_pop_response, offset, i1, TRUE);
- proto_tree_add_text(pop_tree, offset, i1, "Response: %s", rr);
- proto_tree_add_text(pop_tree, offset + i1 + 1, END_OF_FRAME, "Response Arg: %s", rd);
+ if (is_continuation(pd+offset))
+ dissect_data(pd, offset, fd, pop_tree);
+ else {
+ proto_tree_add_text(pop_tree, offset, i1, "Response: %s", rr);
+
+ if (strlen(rd) != 0)
+ proto_tree_add_text(pop_tree, offset + i1 + 1, END_OF_FRAME, "Response Arg: %s", rd);
+ }
}
}
@@ -131,4 +148,15 @@
proto_pop = proto_register_protocol("Post Office Protocol", "pop");
proto_register_field_array(proto_pop, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
+}
+
+static gboolean is_continuation(const u_char *data)
+{
+ if (strncmp(data, "+OK", strlen("+OK")) == 0)
+ return FALSE;
+
+ if (strncmp(data, "-ERR", strlen("-ERR")) == 0)
+ return FALSE;
+
+ return TRUE;
}