Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-sipfrag.c
blob5a82e9f01142d6f5b7f852583adb965fe5428783
1 /* Routines for sipfrag packet disassembly (RFC 3420)
3 * Martin Mathieson
4 * Based on packet-sdp.c
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
13 #include "config.h"
15 #include <epan/packet.h>
18 * Doesn't do a detailed dissection of the lines of the message, just treat as text.
21 void proto_register_sipfrag(void);
23 /* Initialize the protocol and registered fields. */
24 static int proto_sipfrag;
25 static int hf_sipfrag_line;
27 /* Protocol subtree. */
28 static int ett_sipfrag;
30 void proto_reg_handoff_sipfrag(void);
32 static dissector_handle_t sipfrag_handle;
34 /* Main dissection function. */
35 static int dissect_sipfrag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
37 proto_tree *sipfrag_tree;
38 proto_item *ti;
39 int offset = 0;
40 int next_offset;
41 int linelen;
42 char *string;
43 int lines = 0;
45 /* Append this protocol name rather than replace. */
46 col_append_str(pinfo->cinfo, COL_PROTOCOL, "/sipfrag");
48 /* Add mention of this protocol to info column */
49 col_append_str(pinfo->cinfo, COL_INFO, ", with Sipfrag");
51 /* Create sipfrag tree. */
52 ti = proto_tree_add_item(tree, proto_sipfrag, tvb, offset, -1, ENC_NA);
53 sipfrag_tree = proto_item_add_subtree(ti, ett_sipfrag);
55 /* Show the sipfrag message a line at a time. */
56 while (tvb_offset_exists(tvb, offset))
58 /* Find the end of the line. */
59 linelen = tvb_find_line_end_unquoted(tvb, offset, -1, &next_offset);
61 /* For now, add all lines as unparsed strings */
63 /* Extract & add the string. */
64 string = (char*)tvb_get_string_enc(pinfo->pool, tvb, offset, linelen, ENC_ASCII);
65 proto_tree_add_string_format(sipfrag_tree, hf_sipfrag_line,
66 tvb, offset,
67 linelen, string,
68 "%s", string);
69 lines++;
71 /* Show first line in info column */
72 if (lines == 1) {
73 col_append_fstr(pinfo->cinfo, COL_INFO, "(%s", string);
76 /* Move onto next line. */
77 offset = next_offset;
80 /* Close off summary of sipfrag in info column */
81 col_append_str(pinfo->cinfo, COL_INFO, (lines > 1) ? "...)" : ")");
82 return tvb_captured_length(tvb);
85 void proto_register_sipfrag(void)
87 static hf_register_info hf[] =
89 { &hf_sipfrag_line,
90 { "Line",
91 "sipfrag.line",FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL
96 static int *ett[] =
98 &ett_sipfrag
101 /* Register protocol. */
102 proto_sipfrag = proto_register_protocol("Sipfrag", "SIPFRAG", "sipfrag");
103 proto_register_field_array(proto_sipfrag, hf, array_length(hf));
104 proto_register_subtree_array(ett, array_length(ett));
106 /* Allow other dissectors to find this one by name. */
107 sipfrag_handle = register_dissector("sipfrag", dissect_sipfrag, proto_sipfrag);
110 void proto_reg_handoff_sipfrag(void)
112 dissector_add_string("media_type", "message/sipfrag", sipfrag_handle);
116 * Editor modelines - https://www.wireshark.org/tools/modelines.html
118 * Local variables:
119 * c-basic-offset: 4
120 * tab-width: 8
121 * indent-tabs-mode: nil
122 * End:
124 * vi: set shiftwidth=4 tabstop=8 expandtab:
125 * :indentSize=4:tabSize=8:noTabs=true: