1 /* Routines for sipfrag packet disassembly (RFC 3420)
4 * Based on packet-sdp.c
8 * Ethereal - Network traffic analyzer
9 * By Gerald Combs <gerald@ethereal.com>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #include <epan/packet.h>
35 * Doesn't currently dissect the lines of the message.
36 * Need to refactor SIP dissector and make its functionality available here
40 /* Initialize the protocol and registered fields. */
41 static int proto_sipfrag = -1;
42 static int hf_line = -1;
44 /* Protocol subtree. */
45 static int ett_sipfrag = -1;
48 /* Main dissection function. */
50 dissect_sipfrag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
52 proto_tree *sipfrag_tree;
60 /* Append this protocol name rather than replace. */
61 if (check_col(pinfo->cinfo, COL_PROTOCOL))
62 col_append_str(pinfo->cinfo, COL_PROTOCOL, "/sipfrag");
64 /* Add mention of this protocol to info column */
65 if (check_col(pinfo->cinfo, COL_INFO)) {
66 col_append_str(pinfo->cinfo, COL_INFO, ", with Sipfrag");
69 /* Create sipfrag tree. */
70 ti = proto_tree_add_item(tree, proto_sipfrag, tvb, offset, -1, FALSE);
71 sipfrag_tree = proto_item_add_subtree(ti, ett_sipfrag);
73 /* Show the sipfrag message a line at a time. */
74 while (tvb_reported_length_remaining(tvb, offset) > 0)
76 /* Find the end of the line. */
77 linelen = tvb_find_line_end_unquoted(tvb, offset, -1, &next_offset);
79 /* For now, add all lines as unparsed strings */
81 /* Extract & add the string. */
82 string = tvb_get_string(tvb, offset, linelen);
83 proto_tree_add_string_format(sipfrag_tree, hf_line,
89 /* Show first line in info column */
90 if (lines == 1 && check_col(pinfo->cinfo, COL_INFO)) {
91 col_append_fstr(pinfo->cinfo, COL_INFO, "(%s", string);
94 /* Finished with this string now. */
97 /* Move onto next line. */
101 /* Close off summary of sipfrag in info column */
102 if (check_col(pinfo->cinfo, COL_INFO)) {
103 col_append_str(pinfo->cinfo, COL_INFO, (lines > 1) ? "...)" : ")");
108 proto_register_sipfrag(void)
110 static hf_register_info hf[] =
114 "sipfrag.line",FT_STRING, BASE_NONE, NULL, 0x0, "Line", HFILL
124 /* Register protocol. */
125 proto_sipfrag = proto_register_protocol("Sipfrag", "SIPFRAG", "sipfrag");
126 proto_register_field_array(proto_sipfrag, hf, array_length(hf));
127 proto_register_subtree_array(ett, array_length(ett));
129 /* Allow other dissectors to find this one by name. */
130 register_dissector("sipfrag", dissect_sipfrag, proto_sipfrag);
134 proto_reg_handoff_sipfrag(void)
136 dissector_handle_t sipfrag_handle = find_dissector("sipfrag");
137 dissector_add_string("media_type", "message/sipfrag", sipfrag_handle);