/src/wireshark/epan/dissectors/packet-ipsi-ctl.c
Line | Count | Source |
1 | | /* packet-ipsi-ctl.c |
2 | | * Routines for Avaya IPSI Control packet disassembly |
3 | | * Traffic is encapsulated Avaya proprietary CCMS |
4 | | * (Control Channel Message Set) between PCD and SIM |
5 | | * |
6 | | * Copyright 2008, Randy McEoin <rmceoin@ahbelo.com> |
7 | | * |
8 | | * Wireshark - Network traffic analyzer |
9 | | * By Gerald Combs <gerald@wireshark.org> |
10 | | * Copyright 1998 Gerald Combs |
11 | | * |
12 | | * SPDX-License-Identifier: GPL-2.0-or-later |
13 | | */ |
14 | | |
15 | | #include "config.h" |
16 | | |
17 | | #include <epan/packet.h> |
18 | | |
19 | | void proto_register_ipsictl(void); |
20 | | void proto_reg_handoff_ipsictl(void); |
21 | | |
22 | | static dissector_handle_t ipsictl_handle; |
23 | | |
24 | 14 | #define IPSICTL_PORT 5010 /* Not IANA registered */ |
25 | 0 | #define IPSICTL_PDU_MAGIC 0x0300 |
26 | | |
27 | | static int proto_ipsictl; |
28 | | |
29 | | static int hf_ipsictl_pdu; |
30 | | static int hf_ipsictl_magic; |
31 | | static int hf_ipsictl_length; |
32 | | static int hf_ipsictl_type; |
33 | | static int hf_ipsictl_sequence; |
34 | | static int hf_ipsictl_field1; |
35 | | static int hf_ipsictl_data; |
36 | | |
37 | | static int ett_ipsictl; |
38 | | static int ett_ipsictl_pdu; |
39 | | |
40 | | static int dissect_ipsictl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
41 | 0 | { |
42 | |
|
43 | 0 | proto_tree *ipsictl_tree; |
44 | 0 | proto_tree *pdu_tree; |
45 | 0 | proto_item *ti; |
46 | 0 | int offset = 0; |
47 | 0 | int loffset = 0; |
48 | 0 | int llength = 0; |
49 | 0 | int remaining_length; |
50 | 0 | uint16_t magic; |
51 | 0 | uint16_t length; |
52 | 0 | uint16_t type=0; |
53 | 0 | uint16_t sequence=0; |
54 | 0 | int first_sequence=-1; |
55 | 0 | int last_sequence=-1; |
56 | 0 | uint16_t field1=0; |
57 | 0 | uint16_t pdu=0; |
58 | 0 | int haspdus=0; |
59 | |
|
60 | 0 | remaining_length=tvb_reported_length_remaining(tvb, offset); |
61 | |
|
62 | 0 | ti = proto_tree_add_item(tree, proto_ipsictl, tvb, offset, remaining_length, ENC_NA); |
63 | 0 | ipsictl_tree = proto_item_add_subtree(ti, ett_ipsictl); |
64 | |
|
65 | 0 | magic = tvb_get_ntohs(tvb, offset); |
66 | 0 | if (magic == IPSICTL_PDU_MAGIC) |
67 | 0 | { |
68 | 0 | haspdus=1; |
69 | 0 | } |
70 | |
|
71 | 0 | while (haspdus && |
72 | 0 | ((remaining_length=tvb_reported_length_remaining(tvb, offset)) > 6)) |
73 | 0 | { |
74 | 0 | loffset = offset; |
75 | |
|
76 | 0 | magic = tvb_get_ntohs(tvb, loffset); loffset+=2; |
77 | 0 | length = tvb_get_ntohs(tvb, loffset); loffset+=2; |
78 | 0 | llength=length; |
79 | 0 | remaining_length-=4; |
80 | 0 | if (remaining_length>=2) |
81 | 0 | { |
82 | 0 | type = tvb_get_ntohs(tvb, loffset); loffset+=2; |
83 | 0 | remaining_length-=2; |
84 | 0 | llength-=2; |
85 | 0 | } |
86 | 0 | if (remaining_length>=2) |
87 | 0 | { |
88 | 0 | sequence = tvb_get_ntohs(tvb, loffset); loffset+=2; |
89 | 0 | remaining_length-=2; |
90 | 0 | llength-=2; |
91 | 0 | if (first_sequence==-1) |
92 | 0 | { |
93 | 0 | first_sequence=sequence; |
94 | 0 | }else{ |
95 | 0 | last_sequence=sequence; |
96 | 0 | } |
97 | 0 | } |
98 | 0 | if (remaining_length>=2) |
99 | 0 | { |
100 | 0 | field1 = tvb_get_ntohs(tvb, loffset); |
101 | 0 | llength-=2; |
102 | 0 | } |
103 | |
|
104 | 0 | ti = proto_tree_add_uint(ipsictl_tree, hf_ipsictl_pdu, tvb, |
105 | 0 | offset, (length+4), pdu); |
106 | 0 | pdu_tree = proto_item_add_subtree(ti, ett_ipsictl_pdu); |
107 | |
|
108 | 0 | loffset=offset; |
109 | 0 | remaining_length=tvb_reported_length_remaining(tvb, offset); |
110 | |
|
111 | 0 | if (tree) { |
112 | 0 | proto_tree_add_uint(pdu_tree, hf_ipsictl_magic, tvb, loffset, 2, magic); |
113 | 0 | } |
114 | 0 | loffset+=2; remaining_length-=2; |
115 | 0 | if (tree) { |
116 | 0 | proto_tree_add_uint(pdu_tree, hf_ipsictl_length, tvb, loffset, 2, length); |
117 | 0 | } |
118 | 0 | loffset+=2; remaining_length-=2; |
119 | |
|
120 | 0 | if (remaining_length>=2) |
121 | 0 | { |
122 | 0 | if (tree) { |
123 | 0 | proto_tree_add_uint(pdu_tree, hf_ipsictl_type, tvb, loffset, 2, type); |
124 | 0 | } |
125 | 0 | loffset+=2; remaining_length-=2; |
126 | 0 | } |
127 | 0 | if (remaining_length>=2) |
128 | 0 | { |
129 | 0 | if (tree) { |
130 | 0 | proto_tree_add_uint(pdu_tree, hf_ipsictl_sequence, tvb, loffset, 2, sequence); |
131 | 0 | } |
132 | 0 | loffset+=2; remaining_length-=2; |
133 | 0 | } |
134 | 0 | if (remaining_length>=2) |
135 | 0 | { |
136 | 0 | if (tree) { |
137 | 0 | proto_tree_add_uint(pdu_tree, hf_ipsictl_field1, tvb, loffset, 2, field1); |
138 | 0 | } |
139 | 0 | loffset+=2; remaining_length-=2; |
140 | 0 | } |
141 | 0 | if (remaining_length>=2) |
142 | 0 | { |
143 | 0 | if (tree) { |
144 | 0 | proto_tree_add_item(pdu_tree, hf_ipsictl_data, tvb, loffset, llength, ENC_NA); |
145 | 0 | } |
146 | 0 | loffset+=llength; |
147 | 0 | } |
148 | |
|
149 | 0 | offset=loffset; |
150 | 0 | pdu++; |
151 | 0 | } |
152 | |
|
153 | 0 | if (!haspdus) |
154 | 0 | { |
155 | 0 | proto_tree_add_item(ipsictl_tree, hf_ipsictl_data, tvb, offset, -1, ENC_NA); |
156 | 0 | } |
157 | |
|
158 | 0 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "IPSICTL"); |
159 | |
|
160 | 0 | if (haspdus) |
161 | 0 | { |
162 | 0 | if (last_sequence==-1) |
163 | 0 | { |
164 | 0 | col_add_fstr(pinfo->cinfo, COL_INFO, "PDUS=%d, Seq=0x%04x", |
165 | 0 | pdu,first_sequence); |
166 | 0 | }else{ |
167 | 0 | col_add_fstr(pinfo->cinfo, COL_INFO, "PDUS=%d, Seq=0x%04x-0x%04x", |
168 | 0 | pdu,first_sequence,last_sequence); |
169 | 0 | } |
170 | 0 | }else{ |
171 | 0 | col_set_str(pinfo->cinfo, COL_INFO, "Initialization"); |
172 | 0 | } |
173 | |
|
174 | 0 | return tvb_captured_length(tvb); |
175 | |
|
176 | 0 | } /* dissect_ipsictl */ |
177 | | |
178 | | void proto_register_ipsictl(void) |
179 | 14 | { |
180 | | |
181 | 14 | static hf_register_info hf[] = { |
182 | 14 | { &hf_ipsictl_pdu, |
183 | 14 | { "PDU", "ipsictl.pdu", |
184 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, |
185 | 14 | "IPSICTL PDU", HFILL }}, |
186 | 14 | { &hf_ipsictl_magic, |
187 | 14 | { "Magic", "ipsictl.magic", |
188 | 14 | FT_UINT16, BASE_HEX, NULL, 0x0, |
189 | 14 | "IPSICTL Magic", HFILL }}, |
190 | 14 | { &hf_ipsictl_length, |
191 | 14 | { "Length", "ipsictl.length", |
192 | 14 | FT_UINT16, BASE_HEX, NULL, 0x0, |
193 | 14 | "IPSICTL Length", HFILL }}, |
194 | 14 | { &hf_ipsictl_type, |
195 | 14 | { "Type", "ipsictl.type", |
196 | 14 | FT_UINT16, BASE_HEX, NULL, 0x0, |
197 | 14 | "IPSICTL Type", HFILL }}, |
198 | 14 | { &hf_ipsictl_sequence, |
199 | 14 | { "Sequence", "ipsictl.sequence", |
200 | 14 | FT_UINT16, BASE_HEX, NULL, 0x0, |
201 | 14 | "IPSICTL Sequence", HFILL }}, |
202 | 14 | { &hf_ipsictl_field1, |
203 | 14 | { "Field1", "ipsictl.field1", |
204 | 14 | FT_UINT16, BASE_HEX, NULL, 0x0, |
205 | 14 | "IPSICTL Field1", HFILL }}, |
206 | 14 | { &hf_ipsictl_data, |
207 | 14 | { "Data", "ipsictl.data", |
208 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
209 | 14 | "IPSICTL data", HFILL }}, |
210 | 14 | }; |
211 | | |
212 | 14 | static int *ett[] = { |
213 | 14 | &ett_ipsictl, |
214 | 14 | &ett_ipsictl_pdu |
215 | 14 | }; |
216 | | |
217 | 14 | proto_ipsictl = proto_register_protocol("IPSICTL", "IPSICTL", "ipsictl"); |
218 | 14 | proto_register_field_array(proto_ipsictl, hf, array_length(hf)); |
219 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
220 | | |
221 | 14 | ipsictl_handle = register_dissector("ipsictl", dissect_ipsictl, proto_ipsictl); |
222 | 14 | } |
223 | | |
224 | | void proto_reg_handoff_ipsictl(void) |
225 | 14 | { |
226 | | |
227 | 14 | dissector_add_uint_with_preference("tcp.port", IPSICTL_PORT, ipsictl_handle); |
228 | | |
229 | 14 | } |
230 | | |
231 | | /* |
232 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
233 | | * |
234 | | * Local Variables: |
235 | | * c-basic-offset: 2 |
236 | | * tab-width: 8 |
237 | | * indent-tabs-mode: nil |
238 | | * End: |
239 | | * |
240 | | * ex: set shiftwidth=2 tabstop=8 expandtab: |
241 | | * :indentSize=2:tabSize=8:noTabs=true: |
242 | | */ |