Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-ipsi-ctl.c
blob8f71b6574a2a7fa0fc91529f6e799838ba8d9c21
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
6 * Copyright 2008, Randy McEoin <rmceoin@ahbelo.com>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include "config.h"
17 #include <epan/packet.h>
19 void proto_register_ipsictl(void);
20 void proto_reg_handoff_ipsictl(void);
22 static dissector_handle_t ipsictl_handle;
24 #define IPSICTL_PORT 5010 /* Not IANA registered */
25 #define IPSICTL_PDU_MAGIC 0x0300
27 static int proto_ipsictl;
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;
37 static int ett_ipsictl;
38 static int ett_ipsictl_pdu;
40 static int dissect_ipsictl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
43 proto_tree *ipsictl_tree;
44 proto_tree *pdu_tree;
45 proto_item *ti;
46 int offset = 0;
47 int loffset = 0;
48 int llength = 0;
49 int remaining_length;
50 uint16_t magic;
51 uint16_t length;
52 uint16_t type=0;
53 uint16_t sequence=0;
54 int first_sequence=-1;
55 int last_sequence=-1;
56 uint16_t field1=0;
57 uint16_t pdu=0;
58 int haspdus=0;
60 remaining_length=tvb_reported_length_remaining(tvb, offset);
62 ti = proto_tree_add_item(tree, proto_ipsictl, tvb, offset, remaining_length, ENC_NA);
63 ipsictl_tree = proto_item_add_subtree(ti, ett_ipsictl);
65 magic = tvb_get_ntohs(tvb, offset);
66 if (magic == IPSICTL_PDU_MAGIC)
68 haspdus=1;
71 while (haspdus &&
72 ((remaining_length=tvb_reported_length_remaining(tvb, offset)) > 6))
74 loffset = offset;
76 magic = tvb_get_ntohs(tvb, loffset); loffset+=2;
77 length = tvb_get_ntohs(tvb, loffset); loffset+=2;
78 llength=length;
79 remaining_length-=4;
80 if (remaining_length>=2)
82 type = tvb_get_ntohs(tvb, loffset); loffset+=2;
83 remaining_length-=2;
84 llength-=2;
86 if (remaining_length>=2)
88 sequence = tvb_get_ntohs(tvb, loffset); loffset+=2;
89 remaining_length-=2;
90 llength-=2;
91 if (first_sequence==-1)
93 first_sequence=sequence;
94 }else{
95 last_sequence=sequence;
98 if (remaining_length>=2)
100 field1 = tvb_get_ntohs(tvb, loffset);
101 llength-=2;
104 ti = proto_tree_add_uint(ipsictl_tree, hf_ipsictl_pdu, tvb,
105 offset, (length+4), pdu);
106 pdu_tree = proto_item_add_subtree(ti, ett_ipsictl_pdu);
108 loffset=offset;
109 remaining_length=tvb_reported_length_remaining(tvb, offset);
111 if (tree) {
112 proto_tree_add_uint(pdu_tree, hf_ipsictl_magic, tvb, loffset, 2, magic);
114 loffset+=2; remaining_length-=2;
115 if (tree) {
116 proto_tree_add_uint(pdu_tree, hf_ipsictl_length, tvb, loffset, 2, length);
118 loffset+=2; remaining_length-=2;
120 if (remaining_length>=2)
122 if (tree) {
123 proto_tree_add_uint(pdu_tree, hf_ipsictl_type, tvb, loffset, 2, type);
125 loffset+=2; remaining_length-=2;
127 if (remaining_length>=2)
129 if (tree) {
130 proto_tree_add_uint(pdu_tree, hf_ipsictl_sequence, tvb, loffset, 2, sequence);
132 loffset+=2; remaining_length-=2;
134 if (remaining_length>=2)
136 if (tree) {
137 proto_tree_add_uint(pdu_tree, hf_ipsictl_field1, tvb, loffset, 2, field1);
139 loffset+=2; remaining_length-=2;
141 if (remaining_length>=2)
143 if (tree) {
144 proto_tree_add_item(pdu_tree, hf_ipsictl_data, tvb, loffset, llength, ENC_NA);
146 loffset+=llength;
149 offset=loffset;
150 pdu++;
153 if (!haspdus)
155 proto_tree_add_item(ipsictl_tree, hf_ipsictl_data, tvb, offset, -1, ENC_NA);
158 col_set_str(pinfo->cinfo, COL_PROTOCOL, "IPSICTL");
160 if (haspdus)
162 if (last_sequence==-1)
164 col_add_fstr(pinfo->cinfo, COL_INFO, "PDUS=%d, Seq=0x%04x",
165 pdu,first_sequence);
166 }else{
167 col_add_fstr(pinfo->cinfo, COL_INFO, "PDUS=%d, Seq=0x%04x-0x%04x",
168 pdu,first_sequence,last_sequence);
170 }else{
171 col_set_str(pinfo->cinfo, COL_INFO, "Initialization");
174 return tvb_captured_length(tvb);
176 } /* dissect_ipsictl */
178 void proto_register_ipsictl(void)
181 static hf_register_info hf[] = {
182 { &hf_ipsictl_pdu,
183 { "PDU", "ipsictl.pdu",
184 FT_UINT16, BASE_DEC, NULL, 0x0,
185 "IPSICTL PDU", HFILL }},
186 { &hf_ipsictl_magic,
187 { "Magic", "ipsictl.magic",
188 FT_UINT16, BASE_HEX, NULL, 0x0,
189 "IPSICTL Magic", HFILL }},
190 { &hf_ipsictl_length,
191 { "Length", "ipsictl.length",
192 FT_UINT16, BASE_HEX, NULL, 0x0,
193 "IPSICTL Length", HFILL }},
194 { &hf_ipsictl_type,
195 { "Type", "ipsictl.type",
196 FT_UINT16, BASE_HEX, NULL, 0x0,
197 "IPSICTL Type", HFILL }},
198 { &hf_ipsictl_sequence,
199 { "Sequence", "ipsictl.sequence",
200 FT_UINT16, BASE_HEX, NULL, 0x0,
201 "IPSICTL Sequence", HFILL }},
202 { &hf_ipsictl_field1,
203 { "Field1", "ipsictl.field1",
204 FT_UINT16, BASE_HEX, NULL, 0x0,
205 "IPSICTL Field1", HFILL }},
206 { &hf_ipsictl_data,
207 { "Data", "ipsictl.data",
208 FT_BYTES, BASE_NONE, NULL, 0x0,
209 "IPSICTL data", HFILL }},
212 static int *ett[] = {
213 &ett_ipsictl,
214 &ett_ipsictl_pdu
217 proto_ipsictl = proto_register_protocol("IPSICTL", "IPSICTL", "ipsictl");
218 proto_register_field_array(proto_ipsictl, hf, array_length(hf));
219 proto_register_subtree_array(ett, array_length(ett));
221 ipsictl_handle = register_dissector("ipsictl", dissect_ipsictl, proto_ipsictl);
224 void proto_reg_handoff_ipsictl(void)
227 dissector_add_uint_with_preference("tcp.port", IPSICTL_PORT, ipsictl_handle);
232 * Editor modelines - https://www.wireshark.org/tools/modelines.html
234 * Local Variables:
235 * c-basic-offset: 2
236 * tab-width: 8
237 * indent-tabs-mode: nil
238 * End:
240 * ex: set shiftwidth=2 tabstop=8 expandtab:
241 * :indentSize=2:tabSize=8:noTabs=true: