81
72
* Put the first line from the buffer into the summary
82
73
* (but leave out the line terminator).
75
linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
76
line = tvb_get_ptr(tvb, offset, linelen);
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));
90
84
ti = proto_tree_add_item(tree, proto_imap, tvb, offset, -1,
92
86
imap_tree = proto_item_add_subtree(ti, ett_imap);
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);
98
92
proto_tree_add_boolean_hidden(imap_tree,
99
hf_imap_response, tvb, 0, 0, TRUE);
103
* Put the line into the protocol tree.
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);
111
* Show the first line as tags + requests or replies.
115
* Extract the first token, and, if there is a first
116
* token, add it as the request or reply tag.
118
tokenlen = get_token_len(line, line + linelen, &next_token);
121
proto_tree_add_text(reqresp_tree, tvb, offset,
122
tokenlen, "Request Tag: %s",
123
format_text(line, tokenlen));
125
proto_tree_add_text(reqresp_tree, tvb, offset,
126
tokenlen, "Response Tag: %s",
127
format_text(line, tokenlen));
129
offset += next_token - line;
130
linelen -= next_token - line;
135
* Add the rest of the line as request or reply data.
139
proto_tree_add_text(reqresp_tree, tvb, offset,
140
linelen, "Request: %s",
141
format_text(line, linelen));
143
proto_tree_add_text(reqresp_tree, tvb, offset,
144
linelen, "Response: %s",
145
format_text(line, linelen));
150
* XXX - show the rest of the frame; this requires that
151
* we handle literals, quoted strings, continuation
154
* This involves a state machine, and attaching
155
* state information to the packets.
93
hf_imap_response, tvb, 0, 0, TRUE);
96
while(tvb_length_remaining(tvb, offset) > 2) {
99
* Find the end of each line
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.
105
linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
106
line = tvb_get_ptr(tvb, offset, linelen);
109
* Put the line into the protocol tree.
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);
117
* Show each line as tags + requests or replies.
121
* Extract the first token, and, if there is a first
122
* token, add it as the request or reply tag.
124
tokenlen = get_token_len(line, line + linelen, &next_token);
127
proto_tree_add_text(reqresp_tree, tvb, offset,
128
tokenlen, "Request Tag: %s",
129
format_text(line, tokenlen));
131
proto_tree_add_text(reqresp_tree, tvb, offset,
132
tokenlen, "Response Tag: %s",
133
format_text(line, tokenlen));
135
offset += next_token - line;
136
linelen -= next_token - line;
141
* Add the rest of the line as request or reply data.
145
proto_tree_add_text(reqresp_tree, tvb, offset,
146
linelen, "Request: %s",
147
format_text(line, linelen));
149
proto_tree_add_text(reqresp_tree, tvb, offset,
150
linelen, "Response: %s",
151
format_text(line, linelen));
155
offset += linelen+2; /* Skip over last line and \r\n at the end of it */