~ubuntu-branches/ubuntu/gutsy/wireshark/gutsy-security

« back to all changes in this revision

Viewing changes to epan/dissectors/packet-imap.c

  • Committer: Bazaar Package Importer
  • Author(s): Frederic Peters
  • Date: 2007-04-01 08:58:40 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070401085840-or3qhrpv8alt1bwg
Tags: 0.99.5-1
* New upstream release.
* debian/patches/09_idl2wrs.dpatch: updated to patch idl2wrs.sh.in.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * Routines for imap packet dissection
3
3
 * Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
4
4
 *
5
 
 * $Id: packet-imap.c 18608 2006-06-29 08:31:38Z sahlberg $
 
5
 * $Id: packet-imap.c 19698 2006-10-26 07:45:01Z sahlberg $
6
6
 *
7
7
 * Wireshark - Network traffic analyzer
8
8
 * By Gerald Combs <gerald@wireshark.org>
61
61
        if (check_col(pinfo->cinfo, COL_PROTOCOL))
62
62
                col_set_str(pinfo->cinfo, COL_PROTOCOL, "IMAP");
63
63
 
64
 
        /*
65
 
         * Find the end of the first line.
66
 
         *
67
 
         * Note that "tvb_find_line_end()" will return a value that is
68
 
         * not longer than what's in the buffer, so the "tvb_get_ptr()"
69
 
         * call won't throw an exception.
70
 
         */
71
 
        linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
72
 
        line = tvb_get_ptr(tvb, offset, linelen);
73
64
 
74
65
        if (pinfo->match_port == pinfo->destport)
75
66
                is_request = TRUE;
81
72
                 * Put the first line from the buffer into the summary
82
73
                 * (but leave out the line terminator).
83
74
                 */
 
75
                linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
 
76
                line = tvb_get_ptr(tvb, offset, linelen);
 
77
 
84
78
                col_add_fstr(pinfo->cinfo, COL_INFO, "%s: %s",
85
 
                    is_request ? "Request" : "Response",
86
 
                    format_text(line, linelen));
 
79
                             is_request ? "Request" : "Response",
 
80
                             format_text(line, linelen));
87
81
        }
88
82
 
89
83
        if (tree) {
90
84
                ti = proto_tree_add_item(tree, proto_imap, tvb, offset, -1,
91
 
                    FALSE);
 
85
                                         FALSE);
92
86
                imap_tree = proto_item_add_subtree(ti, ett_imap);
93
87
 
94
88
                if (is_request) {
95
89
                        proto_tree_add_boolean_hidden(imap_tree,
96
 
                            hf_imap_request, tvb, 0, 0, TRUE);
 
90
                                                      hf_imap_request, tvb, 0, 0, TRUE);
97
91
                } else {
98
92
                        proto_tree_add_boolean_hidden(imap_tree,
99
 
                            hf_imap_response, tvb, 0, 0, TRUE);
100
 
                }
101
 
 
102
 
                /*
103
 
                 * Put the line into the protocol tree.
104
 
                 */
105
 
                ti = proto_tree_add_text(imap_tree, tvb, offset,
106
 
                    next_offset - offset, "%s",
107
 
                    tvb_format_text(tvb, offset, next_offset - offset));
108
 
                reqresp_tree = proto_item_add_subtree(ti, ett_imap_reqresp);
109
 
 
110
 
                /*
111
 
                 * Show the first line as tags + requests or replies.
112
 
                 */
113
 
 
114
 
                /*
115
 
                 * Extract the first token, and, if there is a first
116
 
                 * token, add it as the request or reply tag.
117
 
                 */
118
 
                tokenlen = get_token_len(line, line + linelen, &next_token);
119
 
                if (tokenlen != 0) {
120
 
                        if (is_request) {
121
 
                                proto_tree_add_text(reqresp_tree, tvb, offset,
122
 
                                    tokenlen, "Request Tag: %s",
123
 
                                    format_text(line, tokenlen));
124
 
                        } else {
125
 
                                proto_tree_add_text(reqresp_tree, tvb, offset,
126
 
                                    tokenlen, "Response Tag: %s",
127
 
                                    format_text(line, tokenlen));
128
 
                        }
129
 
                        offset += next_token - line;
130
 
                        linelen -= next_token - line;
131
 
                        line = next_token;
132
 
                }
133
 
 
134
 
                /*
135
 
                 * Add the rest of the line as request or reply data.
136
 
                 */
137
 
                if (linelen != 0) {
138
 
                        if (is_request) {
139
 
                                proto_tree_add_text(reqresp_tree, tvb, offset,
140
 
                                    linelen, "Request: %s",
141
 
                                    format_text(line, linelen));
142
 
                        } else {
143
 
                                proto_tree_add_text(reqresp_tree, tvb, offset,
144
 
                                    linelen, "Response: %s",
145
 
                                    format_text(line, linelen));
146
 
                        }
147
 
                }
148
 
 
149
 
                /*
150
 
                 * XXX - show the rest of the frame; this requires that
151
 
                 * we handle literals, quoted strings, continuation
152
 
                 * responses, etc..
153
 
                 *
154
 
                 * This involves a state machine, and attaching
155
 
                 * state information to the packets.
156
 
                 */
 
93
                                                      hf_imap_response, tvb, 0, 0, TRUE);
 
94
                }
 
95
 
 
96
                while(tvb_length_remaining(tvb, offset) > 2) {
 
97
 
 
98
                        /*
 
99
                         * Find the end of each line
 
100
                         *
 
101
                         * Note that "tvb_find_line_end()" will return a value that is
 
102
                         * not longer than what's in the buffer, so the "tvb_get_ptr()"
 
103
                         * call won't throw an exception.
 
104
                         */
 
105
                        linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
 
106
                        line = tvb_get_ptr(tvb, offset, linelen);
 
107
 
 
108
                        /*
 
109
                         * Put the line into the protocol tree.
 
110
                         */
 
111
                        ti = proto_tree_add_text(imap_tree, tvb, offset,
 
112
                                                 next_offset - offset, "%s",
 
113
                                                 tvb_format_text(tvb, offset, next_offset - offset));
 
114
                        reqresp_tree = proto_item_add_subtree(ti, ett_imap_reqresp);
 
115
 
 
116
                        /*
 
117
                         * Show each line as tags + requests or replies.
 
118
                         */
 
119
 
 
120
                        /*
 
121
                         * Extract the first token, and, if there is a first
 
122
                         * token, add it as the request or reply tag.
 
123
                         */
 
124
                        tokenlen = get_token_len(line, line + linelen, &next_token);
 
125
                        if (tokenlen != 0) {
 
126
                                if (is_request) {
 
127
                                        proto_tree_add_text(reqresp_tree, tvb, offset,
 
128
                                                            tokenlen, "Request Tag: %s",
 
129
                                                            format_text(line, tokenlen));
 
130
                                } else {
 
131
                                        proto_tree_add_text(reqresp_tree, tvb, offset,
 
132
                                                            tokenlen, "Response Tag: %s",
 
133
                                                            format_text(line, tokenlen));
 
134
                                }
 
135
                                offset += next_token - line;
 
136
                                linelen -= next_token - line;
 
137
                                line = next_token;
 
138
                        }
 
139
 
 
140
                        /*
 
141
                         * Add the rest of the line as request or reply data.
 
142
                         */
 
143
                        if (linelen != 0) {
 
144
                                if (is_request) {
 
145
                                        proto_tree_add_text(reqresp_tree, tvb, offset,
 
146
                                                            linelen, "Request: %s",
 
147
                                                            format_text(line, linelen));
 
148
                                } else {
 
149
                                        proto_tree_add_text(reqresp_tree, tvb, offset,
 
150
                                                            linelen, "Response: %s",
 
151
                                                            format_text(line, linelen));
 
152
                                }
 
153
                        }
 
154
 
 
155
                        offset += linelen+2; /* Skip over last line and \r\n at the end of it */
 
156
 
 
157
                }
157
158
        }
158
159
}
159
160