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