Update Kari Tiirikainen's e-mail address.
[obnox/wireshark/wip.git] / packet-pop.c
index 7ef52d47aa6afe0cb14c0f21d9ba930226a5b297..5b6a4b6f2d5eface3077f32a1a41d90598d2c845 100644 (file)
@@ -2,10 +2,10 @@
  * Routines for pop packet dissection
  * Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
  *
- * $Id: packet-pop.c,v 1.20 2000/11/16 07:35:38 guy Exp $
+ * $Id: packet-pop.c,v 1.30 2002/01/24 09:20:50 guy Exp $
  *
  * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
  * Copyright 1998 Gerald Combs
  *
  * Copied from packet-tftp.c
@@ -41,8 +41,8 @@
 
 #include <string.h>
 #include <glib.h>
-#include "packet.h"
-#include "strutil.h"
+#include <epan/packet.h>
+#include <epan/strutil.h>
 
 static int proto_pop = -1;
 static int hf_pop_response = -1;
@@ -50,6 +50,8 @@ static int hf_pop_request = -1;
 
 static gint ett_pop = -1;
 
+static dissector_handle_t data_handle;
+
 #define TCP_PORT_POP                   110
 
 static gboolean response_is_continuation(const u_char *data);
@@ -68,15 +70,15 @@ dissect_pop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        int             tokenlen;
        const u_char    *next_token;
 
-       CHECK_DISPLAY_AS_DATA(proto_pop, tvb, pinfo, tree);
-
-       pinfo->current_proto = "POP";
-
-       if (check_col(pinfo->fd, COL_PROTOCOL))
-               col_add_str(pinfo->fd, COL_PROTOCOL, "POP");
+       if (check_col(pinfo->cinfo, COL_PROTOCOL))
+               col_set_str(pinfo->cinfo, COL_PROTOCOL, "POP");
 
        /*
         * Find the end of the first line.
+        *
+        * Note that "tvb_find_line_end()" will return a value that is
+        * not longer than what's in the buffer, so the "tvb_get_ptr()"
+        * call won't throw an exception.
         */
        linelen = tvb_find_line_end(tvb, offset, -1, &next_offset);
        line = tvb_get_ptr(tvb, offset, linelen);
@@ -89,7 +91,7 @@ dissect_pop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                is_continuation = response_is_continuation(line);
        }
 
-       if (check_col(pinfo->fd, COL_INFO)) {
+       if (check_col(pinfo->cinfo, COL_INFO)) {
                /*
                 * Put the first line from the buffer into the summary
                 * if it's a POP request or reply (but leave out the
@@ -97,23 +99,23 @@ dissect_pop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                 * Otherwise, just call it a continuation.
                 */
                if (is_continuation)
-                       col_add_str(pinfo->fd, COL_INFO, "Continuation");
+                       col_set_str(pinfo->cinfo, COL_INFO, "Continuation");
                else
-                       col_add_fstr(pinfo->fd, COL_INFO, "%s: %s",
+                       col_add_fstr(pinfo->cinfo, COL_INFO, "%s: %s",
                            is_request ? "Request" : "Response",
                            format_text(line, linelen));
        }
 
        if (tree) {
-               ti = proto_tree_add_item(tree, proto_pop, tvb, offset,
-                   tvb_length_remaining(tvb, offset), FALSE);
+               ti = proto_tree_add_item(tree, proto_pop, tvb, offset, -1,
+                   FALSE);
                pop_tree = proto_item_add_subtree(ti, ett_pop);
 
                if (is_continuation) {
                        /*
                         * Put the whole packet into the tree as data.
                         */
-                       dissect_data(tvb, 0, pinfo, pop_tree);
+                       call_dissector(data_handle,tvb, pinfo, pop_tree);
                        return;
                }
 
@@ -203,18 +205,18 @@ proto_register_pop(void)
     { &hf_pop_response,
       { "Response",           "pop.response",
        FT_BOOLEAN, BASE_NONE, NULL, 0x0,
-       "TRUE if POP response" }},
+       "TRUE if POP response", HFILL }},
 
     { &hf_pop_request,
       { "Request",            "pop.request",
        FT_BOOLEAN, BASE_NONE, NULL, 0x0,
-       "TRUE if POP request" }}
+       "TRUE if POP request", HFILL }}
   };
   static gint *ett[] = {
     &ett_pop,
   };
 
-  proto_pop = proto_register_protocol("Post Office Protocol", "pop");
+  proto_pop = proto_register_protocol("Post Office Protocol", "POP", "pop");
   proto_register_field_array(proto_pop, hf, array_length(hf));
   proto_register_subtree_array(ett, array_length(ett));
 }
@@ -222,5 +224,9 @@ proto_register_pop(void)
 void
 proto_reg_handoff_pop(void)
 {
-  dissector_add("tcp.port", TCP_PORT_POP, dissect_pop);
+  dissector_handle_t pop_handle;
+
+  pop_handle = create_dissector_handle(dissect_pop, proto_pop);
+  dissector_add("tcp.port", TCP_PORT_POP, pop_handle);
+  data_handle = find_dissector("data");
 }