2 * Routines for LCS-AP packet dissembly.
4 * Copyright (c) 2011 by Spenser Sheng <spenser.sheng@ericsson.com>
6 * $Id: packet-lcsap.c 28770 2011-06-18 21:30:42Z stig Spenser Sheng$
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1999 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 * ETSI TS 129 171 V9.2.0 (2010-10)
34 #include <epan/packet.h>
39 #include <epan/strutil.h>
40 #include <epan/asn1.h>
41 #include <epan/prefs.h>
42 #include <epan/sctpppids.h>
44 #include "packet-ber.h"
45 #include "packet-per.h"
46 #include "packet-e212.h"
47 #include "packet-sccp.h"
50 /* disable: "warning C4146: unary minus operator applied to unsigned type, result still unsigned" */
51 #pragma warning(disable:4146)
54 #define PNAME "LCS Application Protocol"
55 #define PSNAME "LCSAP"
56 #define PFNAME "lcsap"
58 #define SCTP_PORT_LCSAP 9082
59 #include "packet-lcsap-val.h"
60 /* Strcture to hold ProcedureCode */
65 /* Initialize the protocol and registered fields */
66 static int proto_lcsap = -1;
67 #include "packet-lcsap-hf.c"
69 /* Initialize the subtree pointers */
70 static int ett_lcsap = -1;
72 #include "packet-lcsap-ett.c"
74 /* Global variables */
75 static guint32 ProcedureCode;
76 static guint32 ProtocolIE_ID;
77 static guint32 ProtocolExtensionID;
78 static guint gbl_lcsapSctpPort=SCTP_PORT_LCSAP;
80 /* Dissector tables */
81 static dissector_table_t lcsap_ies_dissector_table;
83 static dissector_table_t lcsap_extension_dissector_table;
84 static dissector_table_t lcsap_proc_imsg_dissector_table;
85 static dissector_table_t lcsap_proc_sout_dissector_table;
86 static dissector_table_t lcsap_proc_uout_dissector_table;
88 static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
90 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
91 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
92 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
93 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
95 #include "packet-lcsap-fn.c"
97 static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
99 return (dissector_try_uint(lcsap_ies_dissector_table, ProtocolIE_ID, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
103 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
105 return (dissector_try_uint(lcsap_extension_dissector_table, ProtocolExtensionID, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
108 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
110 return (dissector_try_uint(lcsap_proc_imsg_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
113 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
115 return (dissector_try_uint(lcsap_proc_sout_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
118 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
120 return (dissector_try_uint(lcsap_proc_uout_dissector_table, ProcedureCode, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
125 dissect_lcsap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
127 proto_item *lcsap_item = NULL;
128 proto_tree *lcsap_tree = NULL;
130 /* make entry in the Protocol column on summary display */
131 if (check_col(pinfo->cinfo, COL_PROTOCOL))
132 col_set_str(pinfo->cinfo, COL_PROTOCOL, "LCSAP");
134 /* create the lcsap protocol tree */
135 lcsap_item = proto_tree_add_item(tree, proto_lcsap, tvb, 0, -1, ENC_NA);
136 lcsap_tree = proto_item_add_subtree(lcsap_item, ett_lcsap);
138 dissect_LCS_AP_PDU_PDU(tvb, pinfo, lcsap_tree);
141 /*--- proto_reg_handoff_lcsap ---------------------------------------*/
143 proto_reg_handoff_lcsap(void)
145 static gboolean Initialized=FALSE;
146 static dissector_handle_t lcsap_handle;
147 static guint SctpPort;
150 lcsap_handle = find_dissector("lcsap");
152 dissector_add_handle("sctp.port", lcsap_handle); /* for "decode-as" */
153 dissector_add_uint("sctp.ppi", LCS_AP_PAYLOAD_PROTOCOL_ID, lcsap_handle);
155 #include "packet-lcsap-dis-tab.c"
158 dissector_delete_uint("sctp.port", SctpPort, lcsap_handle);
162 SctpPort=gbl_lcsapSctpPort;
164 dissector_add_uint("sctp.port", SctpPort, lcsap_handle);
168 /*--- proto_register_lcsap -------------------------------------------*/
169 void proto_register_lcsap(void) {
172 static hf_register_info hf[] = {
173 #include "packet-lcsap-hfarr.c"
176 /* List of subtrees */
177 static gint *ett[] = {
179 #include "packet-lcsap-ettarr.c"
182 module_t *lcsap_module;
184 /* Register protocol */
185 proto_lcsap = proto_register_protocol(PNAME, PSNAME, PFNAME);
187 /* Register fields and subtrees */
188 proto_register_field_array(proto_lcsap, hf, array_length(hf));
189 proto_register_subtree_array(ett, array_length(ett));
190 register_dissector("lcsap", dissect_lcsap, proto_lcsap);
192 /* Register dissector tables */
193 lcsap_ies_dissector_table = register_dissector_table("lcsap.ies", "LCS-AP-PROTOCOL-IES", FT_UINT32, BASE_DEC);
196 lcsap_extension_dissector_table = register_dissector_table("lcsap.extension", "LCS-AP-PROTOCOL-EXTENSION", FT_UINT32, BASE_DEC);
197 lcsap_proc_imsg_dissector_table = register_dissector_table("lcsap.proc.imsg", "LCS-AP-ELEMENTARY-PROCEDURE InitiatingMessage", FT_UINT32, BASE_DEC);
198 lcsap_proc_sout_dissector_table = register_dissector_table("lcsap.proc.sout", "LCS-AP-ELEMENTARY-PROCEDURE SuccessfulOutcome", FT_UINT32, BASE_DEC);
199 lcsap_proc_uout_dissector_table = register_dissector_table("lcsap.proc.uout", "LCS-AP-ELEMENTARY-PROCEDURE UnsuccessfulOutcome", FT_UINT32, BASE_DEC);
201 /* Register configuration options for ports */
202 lcsap_module = prefs_register_protocol(proto_lcsap, proto_reg_handoff_lcsap);
204 prefs_register_uint_preference(lcsap_module, "sctp.port",
206 "Set the SCTP port for LCSAP messages",