[-Wmissing-prototypes]
[metze/wireshark/wip.git] / asn1 / rnsap / packet-rnsap-template.c
1 /* packet-rnsap.c
2  * Routines for dissecting Universal Mobile Telecommunications System (UMTS);
3  * UTRAN Iur interface Radio Network Subsystem
4  * Application Part (RNSAP) signalling
5  * (3GPP TS 25.423 version 6.7.0 Release 6) packet dissection
6  * Copyright 2005 - 2006, Anders Broman <anders.broman@ericsson.com>
7  *
8  * $Id$
9  *
10  * Wireshark - Network traffic analyzer
11  * By Gerald Combs <gerald@wireshark.org>
12  * Copyright 1998 Gerald Combs
13  *
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.
18  *
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.
23  *
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.
27  *
28  * Ref: 3GPP TS 25.423 version 6.7.0 Release 6
29  */
30
31 #include "config.h"
32
33 #include <glib.h>
34 #include <epan/packet.h>
35
36 #include <epan/asn1.h>
37
38 #include "packet-per.h"
39 #include "packet-ber.h"
40
41 #ifdef _MSC_VER
42 /* disable: "warning C4146: unary minus operator applied to unsigned type, result still unsigned" */
43 #pragma warning(disable:4146)
44 #endif
45
46 #define PNAME  "UTRAN Iur interface Radio Network Subsystem Application Part"
47 #define PSNAME "RNSAP"
48 #define PFNAME "rnsap"
49
50 #define SCCP_SSN_RNSAP 143
51
52 #include "packet-rnsap-val.h"
53
54 static dissector_handle_t rrc_dl_dcch_handle = NULL;
55
56 /* Initialize the protocol and registered fields */
57 static int proto_rnsap = -1;
58
59 #include "packet-rnsap-hf.c"
60
61 /* Initialize the subtree pointers */
62 static int ett_rnsap = -1;
63
64 #include "packet-rnsap-ett.c"
65
66 /* Global variables */
67 static guint32 ProcedureCode;
68 static guint32 ProtocolIE_ID;
69 static guint32 ddMode;
70 static const gchar *ProcedureID;
71 static const char *obj_id = NULL;
72
73
74 /* Dissector tables */
75 static dissector_table_t rnsap_ies_dissector_table;
76 static dissector_table_t rnsap_extension_dissector_table;
77 static dissector_table_t rnsap_proc_imsg_dissector_table;
78 static dissector_table_t rnsap_proc_sout_dissector_table;
79 static dissector_table_t rnsap_proc_uout_dissector_table;
80
81 static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
82 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
83 static int dissect_PrivateIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
84 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
85 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
86 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *);
87
88 #include "packet-rnsap-fn.c"
89
90 static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
91 {
92   return (dissector_try_uint(rnsap_ies_dissector_table, ProtocolIE_ID, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
93 }
94
95 static int dissect_ProtocolExtensionFieldExtensionValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
96 {
97   return (dissector_try_uint(rnsap_extension_dissector_table, ProtocolIE_ID, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
98 }
99
100 static int dissect_PrivateIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
101 {
102   return (call_ber_oid_callback(obj_id, tvb, 0, pinfo, tree)) ? tvb_length(tvb) : 0;
103 }
104
105 static int dissect_InitiatingMessageValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
106 {
107   if (!ProcedureID) return 0;
108   return (dissector_try_string(rnsap_proc_imsg_dissector_table, ProcedureID, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
109 }
110
111 static int dissect_SuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
112 {
113   if (!ProcedureID) return 0;
114   return (dissector_try_string(rnsap_proc_sout_dissector_table, ProcedureID, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
115 }
116
117 static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
118 {
119   if (!ProcedureID) return 0;
120   return (dissector_try_string(rnsap_proc_uout_dissector_table, ProcedureID, tvb, pinfo, tree)) ? tvb_length(tvb) : 0;
121 }
122
123 static void
124 dissect_rnsap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
125 {
126         proto_item      *rnsap_item = NULL;
127         proto_tree      *rnsap_tree = NULL;
128
129         /* make entry in the Protocol column on summary display */
130         col_set_str(pinfo->cinfo, COL_PROTOCOL, "RNSAP");
131
132         /* create the rnsap protocol tree */
133         rnsap_item = proto_tree_add_item(tree, proto_rnsap, tvb, 0, -1, ENC_NA);
134         rnsap_tree = proto_item_add_subtree(rnsap_item, ett_rnsap);
135         
136         dissect_RNSAP_PDU_PDU(tvb, pinfo, rnsap_tree);
137 }
138
139 /*--- proto_register_rnsap -------------------------------------------*/
140 void proto_register_rnsap(void) {
141
142   /* List of fields */
143
144   static hf_register_info hf[] = {
145 #include "packet-rnsap-hfarr.c"
146   };
147
148   /* List of subtrees */
149   static gint *ett[] = {
150                   &ett_rnsap,
151 #include "packet-rnsap-ettarr.c"
152   };
153
154
155   /* Register protocol */
156   proto_rnsap = proto_register_protocol(PNAME, PSNAME, PFNAME);
157   /* Register fields and subtrees */
158   proto_register_field_array(proto_rnsap, hf, array_length(hf));
159   proto_register_subtree_array(ett, array_length(ett));
160  
161   /* Register dissector */
162   register_dissector("rnsap", dissect_rnsap, proto_rnsap);
163
164   /* Register dissector tables */
165   rnsap_ies_dissector_table = register_dissector_table("rnsap.ies", "RNSAP-PROTOCOL-IES", FT_UINT32, BASE_DEC);
166   rnsap_extension_dissector_table = register_dissector_table("rnsap.extension", "RNSAP-PROTOCOL-EXTENSION", FT_UINT32, BASE_DEC);
167   rnsap_proc_imsg_dissector_table = register_dissector_table("rnsap.proc.imsg", "RNSAP-ELEMENTARY-PROCEDURE InitiatingMessage", FT_STRING, BASE_NONE);
168   rnsap_proc_sout_dissector_table = register_dissector_table("rnsap.proc.sout", "RNSAP-ELEMENTARY-PROCEDURE SuccessfulOutcome", FT_STRING, BASE_NONE);
169   rnsap_proc_uout_dissector_table = register_dissector_table("rnsap.proc.uout", "RNSAP-ELEMENTARY-PROCEDURE UnsuccessfulOutcome", FT_STRING, BASE_NONE);
170
171 }
172
173
174 /*--- proto_reg_handoff_rnsap ---------------------------------------*/
175 void
176 proto_reg_handoff_rnsap(void)
177 {
178         dissector_handle_t rnsap_handle;
179
180         rnsap_handle = find_dissector("rnsap");
181         rrc_dl_dcch_handle = find_dissector("rrc.dl.dcch");
182
183         dissector_add_uint("sccp.ssn", SCCP_SSN_RNSAP, rnsap_handle);
184         /* Add heuristic dissector
185          * Perhaps we want a preference whether the heuristic dissector
186          * is or isn't enabled
187          */
188         /*heur_dissector_add("sccp", dissect_sccp_rnsap_heur, proto_rnsap); */
189
190 #include "packet-rnsap-dis-tab.c"
191 }
192
193