MSWSP: add two more Property Sets
[wireshark-wip.git] / epan / dissectors / packet-sipfrag.c
blob16924470699b9859628e159b06539455c536b94f
1 /* Routines for sipfrag packet disassembly (RFC 3420)
3 * Martin Mathieson
4 * Based on packet-sdp.c
6 * $Id$
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include "config.h"
29 #include <epan/packet.h>
32 * Doesn't do a detailed dissection of the lines of the message, just treat as text.
36 /* Initialize the protocol and registered fields. */
37 static int proto_sipfrag = -1;
38 static int hf_sipfrag_line = -1;
40 /* Protocol subtree. */
41 static int ett_sipfrag = -1;
43 void proto_reg_handoff_sipfrag(void);
44 static void dissect_sipfrag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
47 /* Main dissection function. */
48 static void dissect_sipfrag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
50 proto_tree *sipfrag_tree;
51 proto_item *ti;
52 gint offset = 0;
53 gint next_offset;
54 int linelen;
55 char *string;
56 gint lines = 0;
58 /* Append this protocol name rather than replace. */
59 col_append_str(pinfo->cinfo, COL_PROTOCOL, "/sipfrag");
61 /* Add mention of this protocol to info column */
62 col_append_str(pinfo->cinfo, COL_INFO, ", with Sipfrag");
64 /* Create sipfrag tree. */
65 ti = proto_tree_add_item(tree, proto_sipfrag, tvb, offset, -1, ENC_NA);
66 sipfrag_tree = proto_item_add_subtree(ti, ett_sipfrag);
68 /* Show the sipfrag message a line at a time. */
69 while (tvb_reported_length_remaining(tvb, offset) > 0)
71 /* Find the end of the line. */
72 linelen = tvb_find_line_end_unquoted(tvb, offset, -1, &next_offset);
74 /* For now, add all lines as unparsed strings */
76 /* Extract & add the string. */
77 string = (char*)tvb_get_string(wmem_packet_scope(), tvb, offset, linelen);
78 proto_tree_add_string_format(sipfrag_tree, hf_sipfrag_line,
79 tvb, offset,
80 linelen, string,
81 "%s", string);
82 lines++;
84 /* Show first line in info column */
85 if (lines == 1) {
86 col_append_fstr(pinfo->cinfo, COL_INFO, "(%s", string);
89 /* Move onto next line. */
90 offset = next_offset;
93 /* Close off summary of sipfrag in info column */
94 col_append_str(pinfo->cinfo, COL_INFO, (lines > 1) ? "...)" : ")");
97 void proto_register_sipfrag(void)
99 static hf_register_info hf[] =
101 { &hf_sipfrag_line,
102 { "Line",
103 "sipfrag.line",FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL
108 static gint *ett[] =
110 &ett_sipfrag
113 /* Register protocol. */
114 proto_sipfrag = proto_register_protocol("Sipfrag", "SIPFRAG", "sipfrag");
115 proto_register_field_array(proto_sipfrag, hf, array_length(hf));
116 proto_register_subtree_array(ett, array_length(ett));
118 /* Allow other dissectors to find this one by name. */
119 register_dissector("sipfrag", dissect_sipfrag, proto_sipfrag);
122 void proto_reg_handoff_sipfrag(void)
124 dissector_handle_t sipfrag_handle = find_dissector("sipfrag");
125 dissector_add_string("media_type", "message/sipfrag", sipfrag_handle);