name change
[obnox/wireshark/wip.git] / asn1 / gsm_ss / packet-gsm_ss-template.c
1 /* packet-gsm_ss-template.c
2  * Routines for GSM Supplementary Services dissection
3  * Copyright 2005, Anders Broman <anders.broman@ericsson.com>
4  * Based on the dissector by:
5  * Michael Lum <mlum [AT] telostech.com>
6  * In association with Telos Technology Inc.
7  *
8  * Title                3GPP                    Other
9  *
10  *   Reference [1]
11  *   Mobile radio Layer 3 supplementary service specification;
12  *   Formats and coding
13  *   (3GPP TS 24.080 version )
14  * $Id$
15  *
16  * Wireshark - Network traffic analyzer
17  * By Gerald Combs <gerald@wireshark.org>
18  * Copyright 1998 Gerald Combs
19  *
20  * This program is free software; you can redistribute it and/or
21  * modify it under the terms of the GNU General Public License
22  * as published by the Free Software Foundation; either version 2
23  * of the License, or (at your option) any later version.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28  * GNU General Public License for more details.
29  *
30  * You should have received a copy of the GNU General Public License
31  * along with this program; if not, write to the Free Software
32  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
33  * References: ETSI TS 129 002
34  */
35
36 #ifdef HAVE_CONFIG_H
37 # include "config.h"
38 #endif
39
40 #include <glib.h>
41 #include <epan/packet.h>
42 #include <epan/prefs.h>
43 #include <epan/conversation.h>
44 #include <epan/tap.h>
45
46 #include <stdio.h>
47 #include <string.h>
48
49 #include "packet-ber.h"
50 #include "packet-gsm_ss.h"
51 #include "packet-gsm_map.h"
52
53 #define PNAME  "GSM_SS"
54 #define PSNAME "GSM_SS"
55 #define PFNAME "gsm_ss"
56
57 const value_string gsm_ss_err_code_strings[] = {
58     { 1,        "Unknown Subscriber" },
59     { 3,        "Unknown MSC" },
60     { 5,        "Unidentified Subscriber" },
61     { 6,        "Absent Subscriber SM" },
62     { 7,        "Unknown Equipment" },
63     { 8,        "Roaming Not Allowed" },
64     { 9,        "Illegal Subscriber" },
65     { 10,       "Bearer Service Not Provisioned" },
66     { 11,       "Teleservice Not Provisioned" },
67     { 12,       "Illegal Equipment" },
68     { 13,       "Call Barred" },
69     { 14,       "Forwarding Violation" },
70     { 15,       "CUG Reject" },
71     { 16,       "Illegal SS Operation" },
72     { 17,       "SS Error Status" },
73     { 18,       "SS Not Available" },
74     { 19,       "SS Subscription Violation" },
75     { 20,       "SS Incompatibility" },
76     { 21,       "Facility Not Supported" },
77     { 25,       "No Handover Number Available" },
78     { 26,       "Subsequent Handover Failure" },
79     { 27,       "Absent Subscriber" },
80     { 28,       "Incompatible Terminal" },
81     { 29,       "Short Term Denial" },
82     { 30,       "Long Term Denial" },
83     { 31,       "Subscriber Busy For MT SMS" },
84     { 32,       "SM Delivery Failure" },
85     { 33,       "Message Waiting List Full" },
86     { 34,       "System Failure" },
87     { 35,       "Data Missing" },
88     { 36,       "Unexpected Data Value" },
89     { 37,       "PW Registration Failure" },
90     { 38,       "Negative PW Check" },
91     { 39,       "No Roaming Number Available" },
92     { 40,       "Tracing Buffer Full" },
93     { 42,       "Target Cell Outside Group Call Area" },
94     { 43,       "Number Of PW Attempts Violation" },
95     { 44,       "Number Changed" },
96     { 45,       "Busy Subscriber" },
97     { 46,       "No Subscriber Reply" },
98     { 47,       "Forwarding Failed" },
99     { 48,       "OR Not Allowed" },
100     { 49,       "ATI Not Allowed" },
101     { 50,       "No Group Call Number Available" },
102     { 51,       "Resource Limitation" },
103     { 52,       "Unauthorized Requesting Network" },
104     { 53,       "Unauthorized LCS Client" },
105     { 54,       "Position Method Failure" },
106     { 58,       "Unknown Or Unreachable LCS Client" },
107     { 59,       "MM Event Not Supported" },
108     { 60,       "ATSI Not Allowed" },
109     { 61,       "ATM Not Allowed" },
110     { 62,       "Information Not Available" },
111     { 71,       "Unknown Alphabet" },
112     { 72,       "USSD Busy" },
113     { 120,      "Nbr Sb Exceeded" },
114     { 121,      "Rejected By User" },
115     { 122,      "Rejected By Network" },
116     { 123,      "Deflection To Served Subscriber" },
117     { 124,      "Special Service Code" },
118     { 125,      "Invalid Deflected To Number" },
119     { 126,      "Max Number Of MPTY Participants Exceeded" },
120     { 127,      "Resources Not Available" },
121     { 0, NULL }
122 };
123
124 const value_string gsm_ss_opr_code_strings[] = {
125     { 10,       "Register SS" },
126     { 11,       "Erase SS" },
127     { 12,       "Activate SS" },
128     { 13,       "Deactivate SS" },
129     { 14,       "Interrogate SS" },
130     { 16,       "Notify SS" },
131     { 17,       "Register Password" },
132     { 18,       "Get Password" },
133     { 19,       "Process Unstructured SS Data" },
134     { 38,       "Forward Check SS Indication" },
135     { 59,       "Process Unstructured SS Request" },
136     { 60,       "Unstructured SS Request" },
137     { 61,       "Unstructured SS Notify" },
138     { 77,       "Erase CC Entry" },
139     { 112,      "lcs-AreaEventCancellation" },
140     { 113,      "lcs-AreaEventReport" },
141     { 114,      "LCS-AreaEventRequest" },
142     { 115,      "LCS MOLR" },
143     { 116,      "LCS Location Notification" },
144     { 117,      "Call Deflection" },
145     { 118,      "User User Service" },
146     { 119,      "Access Register CC Entry" },
147     { 120,      "Forward CUG Info" },
148     { 121,      "Split MPTY" },
149     { 122,      "Retrieve MPTY" },
150     { 123,      "Hold MPTY" },
151     { 124,      "Build MPTY" },
152     { 125,      "Forward Charge Advice" },
153     { 126,      "Explicit CT" },
154
155     { 0, NULL }
156 };
157
158 /* Initialize the protocol and registered fields */
159 int proto_gsm_ss = -1;
160
161 static int hf_gsm_ss_getPassword = -1;
162 static int hf_gsm_ss_currentPassword = -1;
163 static int hf_gsm_ss_SS_Code = -1;
164 #include "packet-gsm_ss-hf.c"
165
166 /* Initialize the subtree pointers */
167 #include "packet-gsm_ss-ett.c"
168
169 static dissector_table_t        sms_dissector_table;    /* SMS TPDU */
170
171 #include "packet-gsm_ss-fn.c"
172
173
174 int
175 gsm_ss_dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset,guint32 opcode, gint comp_type_tag)
176 {
177         switch (comp_type_tag){
178                 case 1: /* invoke */
179                         switch (opcode){
180                                 case 10: /* Register SS -- imports operations from MAP-SupplementaryServiceOperations*/
181                                         offset=dissect_gsm_map_RegisterSS_Arg(FALSE, tvb, offset, pinfo, tree, -1);
182                                         break;
183                                 case 11: /* Erase SS -- imports operations from MAP-SupplementaryServiceOperations*/
184                                         offset=dissect_gsm_map_SS_ForBS_Code(FALSE, tvb, offset, pinfo, tree, -1);
185                                         break;
186                                 case 12: /* Activate SS -- imports operations from MAP-SupplementaryServiceOperations*/
187                                         offset=dissect_gsm_map_SS_ForBS_Code(FALSE, tvb, offset, pinfo, tree, -1);
188                                         break;
189                                 case 13: /*Deactivate SS -- imports operations from MAP-SupplementaryServiceOperations*/
190                                         offset=dissect_gsm_map_SS_ForBS_Code(FALSE, tvb, offset, pinfo, tree, -1);
191                                         break;
192                                 case 14: /*Interrogate SS -- imports operations from MAP-SupplementaryServiceOperations*/
193                                         offset=dissect_gsm_map_SS_ForBS_Code(FALSE, tvb, offset, pinfo, tree, -1);
194                                         break;
195                                 case 16: /*Notify SS */
196                                         offset = dissect_notifySS(pinfo, tree, tvb, offset);
197                                         break;
198                                 case 17: /*Register Password -- imports operations from MAP-SupplementaryServiceOperations*/
199                                         offset=dissect_gsm_map_SS_Code(FALSE, tvb, offset, pinfo, tree, -1);
200                                         break;
201                                 case 18: /*Get Password -- imports operations from MAP-SupplementaryServiceOperations*/
202                                          offset=dissect_gsm_map_GetPasswordArg(FALSE, tvb, offset, pinfo, tree, hf_gsm_ss_getPassword);
203                                         break;
204                                 case 19: /*Process Unstructured SS Data */
205                                         offset = dissect_processUnstructuredSS_Data(pinfo, tree, tvb, offset);
206                                         break;
207                                 case 38: /*Forward Check SS Indication -- imports operation from MAP-MobileServiceOperations*/
208                                         break;
209                                 case 59: /*Process Unstructured SS Request -- imports operations from MAP-SupplementaryServiceOperations*/
210                                          offset=dissect_gsm_map_Ussd_Arg(FALSE, tvb, offset, pinfo, tree, -1);
211                                         break;
212                                 case 60: /*Unstructured SS Request -- imports operations from MAP-SupplementaryServiceOperations*/
213                                         offset=dissect_gsm_map_Ussd_Arg(FALSE, tvb, offset, pinfo, tree, -1);
214                                         break;
215                                 case 61: /*Unstructured SS Notify -- imports operations from MAP-SupplementaryServiceOperations*/
216                                         offset=dissect_gsm_map_Ussd_Arg(FALSE, tvb, offset, pinfo, tree, -1);
217                                         break;
218                                 case 77: /*Erase CC Entry -- imports operations from MAP-SupplementaryServiceOperations*/
219                                         offset=dissect_gsm_map_EraseCC_EntryArg(FALSE, tvb, offset, pinfo, tree, -1);
220                                         break;
221                                 case 112: /*lcs-AreaEventCancellation */
222                                         offset = dissect_lcs_AreaEventCancellation(pinfo, tree, tvb, offset);
223                                         break;
224                                 case 113: /*lcs-AreaEventReport */
225                                         offset = dissect_lcs_AreaEventReport(pinfo, tree, tvb, offset);
226                                         break;
227                                 case 114: /*LCS-AreaEventRequest */
228                                         offset = dissect_lcs_AreaEventRequest(pinfo, tree, tvb, offset);
229                                         break;
230                                 case 115: /*LCS MOLR */
231                                         offset = dissect_lcs_MOLR(pinfo, tree, tvb, offset);
232                                         break;
233                                 case 116: /*LCS Location Notification */
234                                         offset = dissect_lcs_LocationNotification(pinfo, tree, tvb,offset);
235                                         break;
236                                 case 117: /*Call Deflection */
237                                         offset = dissect_callDeflection(pinfo, tree, tvb,offset);
238                                         break;
239                                 case 118: /*User User Service */
240                                         offset = dissect_gsm_ss_UserUserServiceArg(FALSE, tvb, offset, pinfo, tree, -1);
241                                         break;
242                                 case 119: /* Access Register CC Entry */
243                                         offset = dissect_gsm_ss_AccessRegisterCCEntryArg(FALSE, tvb, offset, pinfo, tree, -1);
244                                         break;
245                                 case 120: /*Forward CUG Info */
246                                         offset = dissect_forwardCUG_Info(pinfo, tree, tvb,offset);
247                                         break;
248                                 case 121: /*Split MPTY */
249                                         break;
250                                 case 122: /*Retrieve MPTY */
251                                         break;
252                                 case 123: /*Hold MPTY */
253                                         break;
254                                 case 124: /*Build MPTY */
255                                         break;
256                                 case 125: /*Forward Charge Advice */
257                                         dissect_forwardChargeAdvice(pinfo, tree, tvb,offset);
258                                         break;
259                                 case 126: /*Explicit CT */
260                                         break;
261                                 default:
262                                         break;
263                                 }
264                         break;
265                 case 2: /* returnResultLast */
266                         switch (opcode){
267                                 case  10: /*registerSS*/
268                                     offset=dissect_gsm_map_SS_Info(FALSE, tvb, offset, pinfo, tree, -1);
269                                     break;
270                                 case  11: /*eraseSS*/
271                                         offset=dissect_gsm_map_SS_Info(FALSE, tvb, offset, pinfo, tree, -1);
272                                         break;
273                                 case 12: /*activateSS*/
274                                         offset=dissect_gsm_map_SS_Info(FALSE, tvb, offset, pinfo, tree, -1);
275                                         break;
276                                 case 13: /*deactivateSS*/
277                                         offset=dissect_gsm_map_SS_Info(FALSE, tvb, offset, pinfo, tree, -1);
278                                         break;
279                                 case 14: /*interrogateSS*/
280                                         offset=dissect_gsm_map_InterrogateSS_Res(FALSE, tvb, offset, pinfo, tree, -1);
281                                         break;
282                                 case 16: /*Notify SS */
283                                         break;
284                                 case 17: /*Register Password -- imports operations from MAP-SupplementaryServiceOperations*/
285                                     offset=dissect_gsm_map_NewPassword(FALSE, tvb, offset, pinfo, tree, hf_gsm_ss_SS_Code);
286                                         break;
287                                 case 18: /*Get Password -- imports operations from MAP-SupplementaryServiceOperations*/
288                                         offset=dissect_gsm_map_CurrentPassword(FALSE, tvb, offset, pinfo, tree, hf_gsm_ss_currentPassword);
289                                         break;
290                                 case 19: /*Process Unstructured SS Data */
291                                         offset=dissect_gsm_ss_SS_UserData(FALSE, tvb, offset, pinfo, tree, -1);
292                                         break;
293                                 case 38: /*Forward Check SS Indication -- imports operation from MAP-MobileServiceOperations*/
294                                         break;
295                                 case 59: /*Process Unstructured SS Request -- imports operations from MAP-SupplementaryServiceOperations*/
296                                          offset=dissect_gsm_map_Ussd_Res(FALSE, tvb, offset, pinfo, tree, -1);
297                                         break;
298                                 case 60: /*Unstructured SS Request -- imports operations from MAP-SupplementaryServiceOperations*/
299                                         offset=dissect_gsm_map_Ussd_Res(FALSE, tvb, offset, pinfo, tree, -1);
300                                         break;
301                                 case 61: /*Unstructured SS Notify -- imports operations from MAP-SupplementaryServiceOperations*/
302                                         offset=dissect_gsm_map_Ussd_Res(FALSE, tvb, offset, pinfo, tree, -1);
303                                         break;
304                                 case 77: /*Erase CC Entry -- imports operations from MAP-SupplementaryServiceOperations*/
305                                         offset=dissect_gsm_map_EraseCC_EntryRes(FALSE, tvb, offset, pinfo, tree, -1);
306                                         break;
307                                 case 112: /*lcs-AreaEventCancellation */
308                                         break;
309                                 case 113: /*lcs-AreaEventReport */
310                                         break;
311                                 case 114: /*LCS-AreaEventRequest */
312                                         break;
313                                 case 115: /*LCS MOLR */
314                                         offset=dissect_gsm_ss_LCS_MOLRRes(FALSE, tvb, offset, pinfo, tree, -1);
315                                         break;
316                                 case 116: /*LCS Location Notification */
317                                         offset=dissect_gsm_ss_LocationNotificationRes(FALSE, tvb, offset, pinfo, tree, -1);
318                                         break;
319                                 case 117: /*Call Deflection */
320                                         break;
321                                 case 118: /*User User Service */
322                                         break;
323                                 case 119: /* Access Register CC Entry */
324                                     offset=dissect_gsm_map_RegisterCC_EntryRes(FALSE, tvb, offset, pinfo, tree, -1);
325                                         break;
326                                 case 120: /*Forward CUG Info */
327                                         break;
328                                 case 121: /*Split MPTY */
329                                         break;
330                                 case 122: /*Retrieve MPTY */
331                                         break;
332                                 case 123: /*Hold MPTY */
333                                         break;
334                                 case 124: /*Build MPTY */
335                                         break;
336                                 case 125: /*Forward Charge Advice */
337                                         break;
338                                 case 126: /*Explicit CT */
339                                         break;
340                                 default:
341                                         break;
342                         }
343                         break;
344                 case 3: /* returnError */
345                         break;
346                 case 4: /* reject */
347                         break;
348                 default:
349                         break;
350         }
351         return offset;
352 }
353
354 static void
355 dissect_gsm_ss(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
356 {
357
358 }
359
360 /*--- proto_reg_handoff_gsm_ss ---------------------------------------
361 This proto is called directly from packet-gsm_a and needs to know component type */
362 void proto_reg_handoff_gsm_ss(void) {
363     dissector_handle_t  gsm_ss_handle;
364
365     gsm_ss_handle = create_dissector_handle(dissect_gsm_ss, proto_gsm_ss);
366
367
368 }
369
370 /*--- proto_register_gsm_ss -------------------------------------------*/
371 void proto_register_gsm_ss(void) {
372
373   /* List of fields */
374   static hf_register_info hf[] = {
375     { &hf_gsm_ss_getPassword,
376       { "Password", "gsm_ss.password",
377         FT_UINT8, BASE_DEC, VALS(gsm_map_GetPasswordArg_vals), 0,
378         "Password", HFILL }},
379     { &hf_gsm_ss_currentPassword,
380       { "currentPassword", "gsm_ss.currentPassword",
381         FT_STRING, BASE_NONE, NULL, 0,
382         "", HFILL }},
383     { &hf_gsm_ss_SS_Code,
384       { "ss-Code", "gsm_ss.ss_Code",
385         FT_UINT8, BASE_DEC, VALS(ssCode_vals), 0,
386         "", HFILL }},
387
388 #include "packet-gsm_ss-hfarr.c"
389   };
390
391   /* List of subtrees */
392   static gint *ett[] = {
393 #include "packet-gsm_ss-ettarr.c"
394   };
395
396   /* Register protocol */
397   proto_gsm_ss = proto_register_protocol(PNAME, PSNAME, PFNAME); 
398 /*XXX  register_dissector("gsm_ss", dissect_gsm_ss, proto_gsm_ss);*/
399   /* Register fields and subtrees */
400   proto_register_field_array(proto_gsm_ss, hf, array_length(hf));
401   proto_register_subtree_array(ett, array_length(ett));
402
403
404 }
405
406