MSWSP: fix dissect_mswsp_smb()
[wireshark-wip.git] / epan / dissectors / packet-ipsi-ctl.c
blob884a961a3c24addd062faee447f91c9f61ca913d
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 * $Id$
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 1998 Gerald Combs
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include "config.h"
31 #include <glib.h>
32 #include <epan/packet.h>
34 #define IPSICTL_PORT 5010
35 #define IPSICTL_PDU_MAGIC 0x0300
37 static int proto_ipsictl = -1;
39 static int hf_ipsictl_pdu = -1;
40 static int hf_ipsictl_magic = -1;
41 static int hf_ipsictl_length = -1;
42 static int hf_ipsictl_type = -1;
43 static int hf_ipsictl_sequence = -1;
44 static int hf_ipsictl_field1 = -1;
45 static int hf_ipsictl_data = -1;
47 static gint ett_ipsictl = -1;
48 static gint ett_ipsictl_pdu = -1;
50 static void dissect_ipsictl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
53 proto_tree *ipsictl_tree = NULL;
54 proto_tree *pdu_tree = NULL;
55 proto_item *ti;
56 int offset = 0;
57 int loffset = 0;
58 int llength = 0;
59 int remaining_length;
60 guint16 magic;
61 guint16 length;
62 guint16 type=0;
63 guint16 sequence=0;
64 int first_sequence=-1;
65 int last_sequence=-1;
66 guint16 field1=0;
67 guint16 pdu=0;
68 int haspdus=0;
70 remaining_length=tvb_reported_length_remaining(tvb, offset);
72 if (tree) {
74 ti = proto_tree_add_item(tree, proto_ipsictl, tvb, offset, remaining_length, ENC_NA);
75 ipsictl_tree = proto_item_add_subtree(ti, ett_ipsictl);
79 magic = tvb_get_ntohs(tvb, offset);
80 if (magic == IPSICTL_PDU_MAGIC)
82 haspdus=1;
85 while (haspdus &&
86 ((remaining_length=tvb_reported_length_remaining(tvb, offset)) > 6))
88 loffset = offset;
90 magic = tvb_get_ntohs(tvb, loffset); loffset+=2;
91 length = tvb_get_ntohs(tvb, loffset); loffset+=2;
92 llength=length;
93 remaining_length-=4;
94 if (remaining_length>=2)
96 type = tvb_get_ntohs(tvb, loffset); loffset+=2;
97 remaining_length-=2;
98 llength-=2;
100 if (remaining_length>=2)
102 sequence = tvb_get_ntohs(tvb, loffset); loffset+=2;
103 remaining_length-=2;
104 llength-=2;
105 if (first_sequence==-1)
107 first_sequence=sequence;
108 }else{
109 last_sequence=sequence;
112 if (remaining_length>=2)
114 field1 = tvb_get_ntohs(tvb, loffset);
115 llength-=2;
118 if (tree) {
120 ti = proto_tree_add_uint(ipsictl_tree, hf_ipsictl_pdu, tvb,
121 offset, (length+4), pdu);
123 pdu_tree = proto_item_add_subtree(ti, ett_ipsictl_pdu);
126 loffset=offset;
127 remaining_length=tvb_reported_length_remaining(tvb, offset);
129 if (tree) {
130 proto_tree_add_uint(pdu_tree, hf_ipsictl_magic, tvb, loffset, 2, magic);
132 loffset+=2; remaining_length-=2;
133 if (tree) {
134 proto_tree_add_uint(pdu_tree, hf_ipsictl_length, tvb, loffset, 2, length);
136 loffset+=2; remaining_length-=2;
138 if (remaining_length>=2)
140 if (tree) {
141 proto_tree_add_uint(pdu_tree, hf_ipsictl_type, tvb, loffset, 2, type);
143 loffset+=2; remaining_length-=2;
145 if (remaining_length>=2)
147 if (tree) {
148 proto_tree_add_uint(pdu_tree, hf_ipsictl_sequence, tvb, loffset, 2, sequence);
150 loffset+=2; remaining_length-=2;
152 if (remaining_length>=2)
154 if (tree) {
155 proto_tree_add_uint(pdu_tree, hf_ipsictl_field1, tvb, loffset, 2, field1);
157 loffset+=2; remaining_length-=2;
159 if (remaining_length>=2)
161 if (tree) {
162 proto_tree_add_item(pdu_tree, hf_ipsictl_data, tvb, loffset, llength, ENC_NA);
164 loffset+=llength;
167 offset=loffset;
168 pdu++;
171 if (!haspdus)
173 if (tree) {
174 proto_tree_add_item(ipsictl_tree, hf_ipsictl_data, tvb, offset, -1, ENC_NA);
178 col_set_str(pinfo->cinfo, COL_PROTOCOL, "IPSICTL");
180 if (haspdus)
182 if (last_sequence==-1)
184 col_add_fstr(pinfo->cinfo, COL_INFO, "PDUS=%d, Seq=0x%04x",
185 pdu,first_sequence);
186 }else{
187 col_add_fstr(pinfo->cinfo, COL_INFO, "PDUS=%d, Seq=0x%04x-0x%04x",
188 pdu,first_sequence,last_sequence);
190 }else{
191 col_set_str(pinfo->cinfo, COL_INFO, "Initialization");
195 } /* dissect_ipsictl */
197 void proto_register_ipsictl(void)
200 static hf_register_info hf[] = {
201 { &hf_ipsictl_pdu,
202 { "PDU", "ipsictl.pdu",
203 FT_UINT16, BASE_DEC, NULL, 0x0,
204 "IPSICTL PDU", HFILL }},
205 { &hf_ipsictl_magic,
206 { "Magic", "ipsictl.magic",
207 FT_UINT16, BASE_HEX, NULL, 0x0,
208 "IPSICTL Magic", HFILL }},
209 { &hf_ipsictl_length,
210 { "Length", "ipsictl.length",
211 FT_UINT16, BASE_HEX, NULL, 0x0,
212 "IPSICTL Length", HFILL }},
213 { &hf_ipsictl_type,
214 { "Type", "ipsictl.type",
215 FT_UINT16, BASE_HEX, NULL, 0x0,
216 "IPSICTL Type", HFILL }},
217 { &hf_ipsictl_sequence,
218 { "Sequence", "ipsictl.sequence",
219 FT_UINT16, BASE_HEX, NULL, 0x0,
220 "IPSICTL Sequence", HFILL }},
221 { &hf_ipsictl_field1,
222 { "Field1", "ipsictl.field1",
223 FT_UINT16, BASE_HEX, NULL, 0x0,
224 "IPSICTL Field1", HFILL }},
225 { &hf_ipsictl_data,
226 { "Data", "ipsictl.data",
227 FT_BYTES, BASE_NONE, NULL, 0x0,
228 "IPSICTL data", HFILL }},
231 static gint *ett[] = {
232 &ett_ipsictl,
233 &ett_ipsictl_pdu
236 proto_ipsictl = proto_register_protocol("IPSICTL", "IPSICTL", "ipsictl");
237 proto_register_field_array(proto_ipsictl, hf, array_length(hf));
238 proto_register_subtree_array(ett, array_length(ett));
242 void proto_reg_handoff_ipsictl(void)
245 dissector_handle_t ipsictl_handle = NULL;
247 ipsictl_handle = create_dissector_handle(dissect_ipsictl, proto_ipsictl);
249 dissector_add_uint("tcp.port", IPSICTL_PORT, ipsictl_handle);