1 /* Routines for sipfrag packet disassembly (RFC 3420)
4 * Based on packet-sdp.c
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include <epan/packet.h>
30 * Doesn't do a detailed dissection of the lines of the message, just treat as text.
33 void proto_register_sipfrag(void);
35 /* Initialize the protocol and registered fields. */
36 static int proto_sipfrag = -1;
37 static int hf_sipfrag_line = -1;
39 /* Protocol subtree. */
40 static int ett_sipfrag = -1;
42 void proto_reg_handoff_sipfrag(void);
43 static void dissect_sipfrag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
46 /* Main dissection function. */
47 static void dissect_sipfrag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
49 proto_tree *sipfrag_tree;
57 /* Append this protocol name rather than replace. */
58 col_append_str(pinfo->cinfo, COL_PROTOCOL, "/sipfrag");
60 /* Add mention of this protocol to info column */
61 col_append_str(pinfo->cinfo, COL_INFO, ", with Sipfrag");
63 /* Create sipfrag tree. */
64 ti = proto_tree_add_item(tree, proto_sipfrag, tvb, offset, -1, ENC_NA);
65 sipfrag_tree = proto_item_add_subtree(ti, ett_sipfrag);
67 /* Show the sipfrag message a line at a time. */
68 while (tvb_reported_length_remaining(tvb, offset) > 0)
70 /* Find the end of the line. */
71 linelen = tvb_find_line_end_unquoted(tvb, offset, -1, &next_offset);
73 /* For now, add all lines as unparsed strings */
75 /* Extract & add the string. */
76 string = (char*)tvb_get_string_enc(wmem_packet_scope(), tvb, offset, linelen, ENC_ASCII);
77 proto_tree_add_string_format(sipfrag_tree, hf_sipfrag_line,
83 /* Show first line in info column */
85 col_append_fstr(pinfo->cinfo, COL_INFO, "(%s", string);
88 /* Move onto next line. */
92 /* Close off summary of sipfrag in info column */
93 col_append_str(pinfo->cinfo, COL_INFO, (lines > 1) ? "...)" : ")");
96 void proto_register_sipfrag(void)
98 static hf_register_info hf[] =
102 "sipfrag.line",FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL
112 /* Register protocol. */
113 proto_sipfrag = proto_register_protocol("Sipfrag", "SIPFRAG", "sipfrag");
114 proto_register_field_array(proto_sipfrag, hf, array_length(hf));
115 proto_register_subtree_array(ett, array_length(ett));
117 /* Allow other dissectors to find this one by name. */
118 register_dissector("sipfrag", dissect_sipfrag, proto_sipfrag);
121 void proto_reg_handoff_sipfrag(void)
123 dissector_handle_t sipfrag_handle = find_dissector("sipfrag");
124 dissector_add_string("media_type", "message/sipfrag", sipfrag_handle);