2 * Routines for pop packet dissection
3 * Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
5 * $Id: packet-pop.c,v 1.4 1999/07/07 22:51:50 gram Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@unicom.net>
9 * Copyright 1998 Gerald Combs
11 * Copied from packet-tftp.c
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 #ifdef HAVE_SYS_TYPES_H
35 # include <sys/types.h>
38 #ifdef HAVE_NETINET_IN_H
39 # include <netinet/in.h>
47 extern packet_info pi;
50 dissect_pop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int max_data)
52 proto_tree *pop_tree, *ti;
53 gchar rr[50], rd[1500];
54 int i1 = (u_char *)strchr(pd + offset, ' ') - (pd + offset); /* Where is that space */
57 memset(rr, '\0', sizeof(rr));
58 memset(rd, '\0', sizeof(rd));
60 if ((i1 > max_data) || (i1 <= 0)) {
63 strncpy(rr, pd + offset, MIN(max_data - 2, sizeof(rr) - 1));
68 strncpy(rr, pd + offset, MIN(i1, sizeof(rr) - 1));
69 i2 = ((u_char *)strchr(pd + offset + i1 + 1, '\r') - (pd + offset)) - i1 - 1;
70 strncpy(rd, pd + offset + i1 + 1, MIN(i2, sizeof(rd) - 1));
73 if (check_col(fd, COL_PROTOCOL))
74 col_add_str(fd, COL_PROTOCOL, "POP");
76 if (check_col(fd, COL_INFO)) {
78 col_add_fstr(fd, COL_INFO, "%s: %s %s", (pi.match_port == pi.destport)? "Request" : "Response", rr, rd);
84 ti = proto_tree_add_text(tree, offset, END_OF_FRAME,
85 "Post Office Protocol");
86 pop_tree = proto_item_add_subtree(ti, ETT_POP);
88 if (pi.match_port == pi.destport) { /* Request */
90 proto_tree_add_text(pop_tree, offset, i1, "Request: %s", rr);
92 proto_tree_add_text(pop_tree, offset + i1 + 1, END_OF_FRAME, "Request Arg: %s", rd);
97 proto_tree_add_text(pop_tree, offset, i1, "Response: %s", rr);
99 proto_tree_add_text(pop_tree, offset + i1 + 1, END_OF_FRAME, "Response Arg: %s", rd);