Return FALSE from the configure event handler, so that anybody else
[obnox/wireshark/wip.git] / packet-ranap.c
1 /* packet-ranap.c
2  * Routines for Radio Access Network Application Part Protocol dissection
3  * Based on 3GPP TS 25.413 V3.4.0
4  * Copyright 2001, Martin Held <Martin.Held@icn.siemens.de>
5  *
6  * $Id: packet-ranap.c,v 1.20 2003/10/06 08:35:30 guy Exp $
7  *
8  * Ethereal - Network traffic analyzer
9  * By Gerald Combs <gerald@ethereal.com>
10  * Copyright 1998 Gerald Combs
11  *
12  * Copied from README.developer
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27  */
28
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32
33 #include <stdio.h>
34 #include <stdlib.h>
35
36
37 #include <string.h>
38 #include <glib.h>
39
40 #include <epan/packet.h>
41
42
43 #define SCCP_SSN_RANAP 0x8E
44
45 /* description of PDU header */
46 #define PDU_NUMBER_OF_OCTETS_OFFSET 3
47
48 /* PDU Index Values */
49 #define InitiatingMessage 0
50 #define SuccessfulOutcome 1
51 #define UnsuccessfulOutcome 2
52 #define Outcome 3
53
54 static const value_string   ranap_pdu_index_values[] = {
55   {InitiatingMessage,           "InitiatingMessage"},
56   {SuccessfulOutcome,           "SuccessfulOutcome"},
57   {UnsuccessfulOutcome,         "UnsuccessfulOutcome"},
58   {Outcome,                     "Outcome"},
59   { 0,                          NULL}
60 };
61
62
63 /* Procedure Code Values */
64 #define PC_RAB_Assignment 0
65 #define PC_Iu_Release 1
66 #define PC_RelocationPreparation 2
67 #define PC_RelocationResourceAllocation 3
68 #define PC_RelocationCancel 4
69 #define PC_SRNS_ContextTransfer 5
70 #define PC_SecurityModeControl 6
71 #define PC_DataVolumeReport 7
72 #define PC_CN_InformationBroadcast 8
73 #define PC_Reset 9
74 #define PC_RAB_ReleaseRequest 10
75 #define PC_Iu_ReleaseRequest 11
76 #define PC_RelocationDetect 12
77 #define PC_RelocationComplete 13
78 #define PC_Paging 14
79 #define PC_CommonID 15
80 #define PC_CN_InvokeTrace 16
81 #define PC_LocationReportingControl 17
82 #define PC_LocationReport 18
83 #define PC_InitialUE_Message 19
84 #define PC_DirectTransfer 20
85 #define PC_OverloadControl 21
86 #define PC_ErrorIndication 22
87 #define PC_SRNS_DataForward 23
88 #define PC_ForwardSRNS_Context 24
89 #define PC_privateMessage 25
90 #define PC_CN_DeactivateTrace 26
91 #define PC_ResetResource 27
92 #define PC_RANAP_Relocation 28
93 #define PC_max 28
94
95 static const value_string   ranap_procedure_code_values[] = {
96   {PC_RAB_Assignment,                   "RAB-Assignment"},
97   {PC_Iu_Release,                       "IU-Release"},
98   {PC_RelocationPreparation,            "RelocationPreparation"},
99   {PC_RelocationResourceAllocation,     "RelocationResourceAllocation"},
100   {PC_RelocationCancel,                 "RelocationCancel"},
101   {PC_SRNS_ContextTransfer,             "SRNS-ContextTransfer"},
102   {PC_SecurityModeControl,              "SecurityModeControl"},
103   {PC_DataVolumeReport,                 "DataVolumeReport"},
104   {PC_CN_InformationBroadcast,          "CN-InformationBroadcast"},
105   {PC_Reset,                            "Reset"},
106   {PC_RAB_ReleaseRequest,               "RAB-ReleaseRequest"},
107   {PC_Iu_ReleaseRequest,                "Iu-ReleaseRequest"},
108   {PC_RelocationDetect,                 "RelocationDetect"},
109   {PC_RelocationComplete,               "RelocationComplete"},
110   {PC_Paging,                           "Paging"},
111   {PC_CommonID,                         "CommonID"},
112   {PC_CN_InvokeTrace,                   "CN-InvokeTrace"},
113   {PC_LocationReportingControl,         "LocationReportingControl"},
114   {PC_LocationReport,                   "LocationReport"},
115   {PC_InitialUE_Message,                "InitialUE_Message"},
116   {PC_DirectTransfer,                   "DirectTransfer"},
117   {PC_OverloadControl,                  "OverloadControl"},
118   {PC_ErrorIndication,                  "ErrorIndication"},
119   {PC_SRNS_DataForward,                 "SRNS-DataForward"},
120   {PC_ForwardSRNS_Context,              "ForwardSRNS-Context"},
121   {PC_privateMessage,                   "privateMessage"},
122   {PC_CN_DeactivateTrace,               "CN-DeactivateTrace"},
123   {PC_ResetResource,                    "ResetResource"},
124   {PC_RANAP_Relocation,                 "RANAP-Relocation"},
125   {0,                                   NULL}
126 };
127
128
129 static const value_string  ranap_message_names[][5] = {
130   {/* PC_RAB_Assignment */
131      { InitiatingMessage,               "RAB-AssignmentRequest"},
132      { SuccessfulOutcome,               "undefined message"},
133      { UnsuccessfulOutcome,             "undefined message"},
134      { Outcome,                         "RAB-AssignmentResponse"},
135      { 0,                               NULL}, },
136   { /* PC_Iu_Release */
137      { InitiatingMessage,               "Iu-ReleaseCommand"},
138      { SuccessfulOutcome,               "Iu-ReleaseComplete"},
139      { UnsuccessfulOutcome,             NULL},
140      { Outcome,                         NULL},
141      { 0,                               NULL}, },
142   { /* PC_RelocationPreparation */
143      { InitiatingMessage,               "RelocationRequired"},
144      { SuccessfulOutcome,               "RelocationCommand"},
145      { UnsuccessfulOutcome,             "RelocationPreparationFailure"},
146      { Outcome,                         NULL},
147      { 0,                               NULL}, },
148   { /* PC_RelocationResourceAllocation */
149      { InitiatingMessage,               "RelocationRequest"},
150      { SuccessfulOutcome,               "RelocationRequestAcknowledge"},
151      { UnsuccessfulOutcome,             "RelocationFailure"},
152      { Outcome,                         NULL},
153      { 0,                               NULL}, },
154   { /* PC_RelocationCancel */
155      { InitiatingMessage,               "RelocationCancel"},
156      { SuccessfulOutcome,               "RelocationCancelAcknowledge"},
157      { UnsuccessfulOutcome,             NULL},
158      { Outcome,                         NULL},
159      { 0,                               NULL}, },
160   { /* PC_SRNS_ContextTransfer */
161      { InitiatingMessage,               "SRNS-ContextRequest"},
162      { SuccessfulOutcome,               "SRNS-ContextResponse"},
163      { UnsuccessfulOutcome,             NULL},
164      { Outcome,                         NULL},
165      { 0,                               NULL}, },
166   { /* PC_SecurityModeControl */
167      { InitiatingMessage,               "SecurityModeCommand"},
168      { SuccessfulOutcome,               "SecurityModeComplete"},
169      { UnsuccessfulOutcome,             "SecurityModeReject"},
170      { Outcome,                         NULL},
171      { 0,                               NULL}, },
172   { /* PC_DataVolumeReport */
173      { InitiatingMessage,               "DataVolumeReportRequest"},
174      { SuccessfulOutcome,               "DataVolumeReport"},
175      { UnsuccessfulOutcome,             NULL},
176      { Outcome,                         NULL},
177      { 0,                               NULL}, },
178   { /* PC_CN_InformationBroadcast */
179      { InitiatingMessage,               "CN-InformationBroadcastRequest"},
180      { SuccessfulOutcome,               "CN-InformationBroadcastConfirm"},
181      { UnsuccessfulOutcome,             "CN-InformationBroadcastReject"},
182      { Outcome,                         NULL},
183      { 0,                               NULL}, },
184  { /* PC_Reset */
185      { InitiatingMessage,               "Reset"},
186      { SuccessfulOutcome,               "ResetAcknowledge"},
187      { UnsuccessfulOutcome,             NULL},
188      { Outcome,                         NULL},
189      { 0,                               NULL}, },
190   { /* PC_RAB_ReleaseRequest */
191      { InitiatingMessage,               "RAB-ReleaseRequest"},
192      { SuccessfulOutcome,               NULL},
193      { UnsuccessfulOutcome,             NULL},
194      { Outcome,                         NULL},
195      { 0,                               NULL}, },
196   { /* PC_Iu_ReleaseRequest */
197      { InitiatingMessage,               "Iu-ReleaseRequest"},
198      { SuccessfulOutcome,               NULL},
199      { UnsuccessfulOutcome,             NULL},
200      { Outcome,                         NULL},
201      { 0,                               NULL}, },
202   { /* PC_RelocationDetect */
203      { InitiatingMessage,               "RelocationDetect"},
204      { SuccessfulOutcome,               NULL},
205      { UnsuccessfulOutcome,             NULL},
206      { Outcome,                         NULL},
207      { 0,                               NULL}, },
208   { /* PC_RelocationComplete */
209      { InitiatingMessage,               "RelocationComplete"},
210      { SuccessfulOutcome,               NULL},
211      { UnsuccessfulOutcome,             NULL},
212      { Outcome,                         NULL},
213      { 0,                               NULL}, },
214   { /* PC_Paging */
215      { InitiatingMessage,               "Paging"},
216      { SuccessfulOutcome,               NULL},
217      { UnsuccessfulOutcome,             NULL},
218      { Outcome,                         NULL},
219      { 0,                               NULL}, },
220   { /* PC_CommonID */
221      { InitiatingMessage,               "CommonID"},
222      { SuccessfulOutcome,               NULL},
223      { UnsuccessfulOutcome,             NULL},
224      { Outcome,                         NULL},
225      { 0,                               NULL}, },
226   { /* PC_CN_InvokeTrace */
227      { InitiatingMessage,               "CN-InvokeTrace"},
228      { SuccessfulOutcome,               NULL},
229      { UnsuccessfulOutcome,             NULL},
230      { Outcome,                         NULL},
231      { 0,                               NULL}, },
232   {/* PC_LocationReportingControl */
233      { InitiatingMessage,               "LocationReportingControl"},
234      { SuccessfulOutcome,               NULL},
235      { UnsuccessfulOutcome,             NULL},
236      { Outcome,                         NULL},
237      { 0,                               NULL}, },
238   { /* PC_LocationReport */
239      { InitiatingMessage,               "LocationReport"},
240      { SuccessfulOutcome,               NULL},
241      { UnsuccessfulOutcome,             NULL},
242      { Outcome,                         NULL},
243      { 0,                               NULL}, },
244   { /* PC_InitialUE_Message */
245      { InitiatingMessage,               "InitialUE-Message"},
246      { SuccessfulOutcome,               NULL},
247      { UnsuccessfulOutcome,             NULL},
248      { Outcome,                         NULL},
249      { 0,                               NULL}, },
250   { /* PC_DirectTransfer */
251      { InitiatingMessage,               "DirectTransfer"},
252      { SuccessfulOutcome,               NULL},
253      { UnsuccessfulOutcome,             NULL},
254      { Outcome,                         NULL},
255      { 0,                               NULL}, },
256   { /* PC_OverloadControl */
257      { InitiatingMessage,               "Overload"},
258      { SuccessfulOutcome,               NULL},
259      { UnsuccessfulOutcome,             NULL},
260      { Outcome,                         NULL},
261      { 0,                               NULL}, },
262   { /* PC_ErrorIndication */
263      { InitiatingMessage,               "ErrorIndication"},
264      { SuccessfulOutcome,               NULL},
265      { UnsuccessfulOutcome,             NULL},
266      { Outcome,                         NULL},
267      { 0,                               NULL}, },
268   { /* PC_SRNS_DataForward */
269      { InitiatingMessage,               "SRNS-DataForwardCommand"},
270      { SuccessfulOutcome,               NULL},
271      { UnsuccessfulOutcome,             NULL},
272      { Outcome,                         NULL},
273      { 0,                               NULL}, },
274   { /* PC_ForwardSRNS_Context */
275      { InitiatingMessage,               "ForwardSRNS-Context"},
276      { SuccessfulOutcome,               NULL},
277      { UnsuccessfulOutcome,             NULL},
278      { Outcome,                         NULL},
279      { 0,                               NULL}, },
280   { /* PC_privateMessage */
281      { InitiatingMessage,               "PrivateMessage"},
282      { SuccessfulOutcome,               NULL},
283      { UnsuccessfulOutcome,             NULL},
284      { Outcome,                         NULL},
285      { 0,                               NULL}, },
286   { /* PC_CN_DeactivateTrace */
287      { InitiatingMessage,               "CN-DeactivateTrace"},
288      { SuccessfulOutcome,               NULL},
289      { UnsuccessfulOutcome,             NULL},
290      { Outcome,                         NULL},
291      { 0,                               NULL}, },
292   { /* PC_ResetResource */
293      { InitiatingMessage,               "ResetResource"},
294      { SuccessfulOutcome,               "ResetResourceAcknowledge"},
295      { UnsuccessfulOutcome,             NULL},
296      { Outcome,                         NULL},
297      { 0,                               NULL}, },
298   { /* PC_RANAP_Relocation */
299      { InitiatingMessage,               "RANAP-RelocationInformation"},
300      { SuccessfulOutcome,               NULL},
301      { UnsuccessfulOutcome,             NULL},
302      { Outcome,                         NULL},
303      { 0,                               NULL}, }
304 };
305
306
307 /* Criticality Values */
308 #define CR_reject 0
309 #define CR_ignore 1
310 #define CR_notify 2
311
312 static const value_string   ranap_criticality_values[] = {
313   {CR_reject,                   "reject"},
314   {CR_ignore,                   "ignore"},
315   {CR_notify,                   "notify"},
316   {0,                         NULL}};
317
318
319 /* presence values for optional components */
320 #define PR_not_present 0
321 #define PR_present 1
322
323 static const value_string ranap_presence_values[] = {
324    {PR_not_present,             "not present"},
325    {PR_present,                 "present"},
326    {0,                          NULL}};
327
328
329 /* description of IE Header */
330 #define IE_ID_LENGTH 2
331 #define IE_CRITICALITY_LENGTH 1
332
333
334 /* description of IE-ID values */
335 #define IE_AreaIdentity 0
336 #define IE_CN_BroadcastInformationPiece 1
337 #define IE_CN_BroadcastInformationPieceList 2
338 #define IE_CN_DomainIndicator 3
339 #define IE_Cause 4
340 #define IE_ChosenEncryptionAlgorithm 5
341 #define IE_ChosenIntegrityProtectionAlgorithm 6
342 #define IE_ClassmarkInformation2 7
343 #define IE_ClassmarkInformation3 8
344 #define IE_CriticalityDiagnostics 9
345 #define IE_DL_GTP_PDU_SequenceNumber 10
346 #define IE_EncryptionInformation 11
347 #define IE_IntegrityProtectionInformation 12
348 #define IE_IuTransportAssociation 13
349 #define IE_L3_Information 14
350 #define IE_LAI 15
351 #define IE_NAS_PDU 16
352 #define IE_NonSearchingIndication 17
353 #define IE_NumberOfSteps 18
354 #define IE_OMC_ID 19
355 #define IE_OldBSS_ToNewBSS_Information 20
356 #define IE_PagingAreaID 21
357 #define IE_PagingCause 22
358 #define IE_PermanentNAS_UE_ID 23
359 #define IE_RAB_ContextItem 24
360 #define IE_RAB_ContextList 25
361 #define IE_RAB_DataForwardingItem 26
362 #define IE_RAB_DataForwardingItem_SRNS_CtxReq 27
363 #define IE_RAB_DataForwardingList 28
364 #define IE_RAB_DataForwardingList_SRNS_CtxReq 29
365 #define IE_RAB_DataVolumeReportItem 30
366 #define IE_RAB_DataVolumeReportList 31
367 #define IE_RAB_DataVolumeReportRequestItem 32
368 #define IE_RAB_DataVolumeReportRequestList 33
369 #define IE_RAB_FailedItem 34
370 #define IE_RAB_FailedList 35
371 #define IE_RAB_ID 36
372 #define IE_RAB_QueuedItem 37
373 #define IE_RAB_QueuedList 38
374 #define IE_RAB_ReleaseFailedList 39
375 #define IE_RAB_ReleaseItem 40
376 #define IE_RAB_ReleaseList 41
377 #define IE_RAB_ReleasedItem 42
378 #define IE_RAB_ReleasedList 43
379 #define IE_RAB_ReleasedList_IuRelComp 44
380 #define IE_RAB_RelocationReleaseItem 45
381 #define IE_RAB_RelocationReleaseList 46
382 #define IE_RAB_SetupItem_RelocReq 47
383 #define IE_RAB_SetupItem_RelocReqAck 48
384 #define IE_RAB_SetupList_RelocReq 49
385 #define IE_RAB_SetupList_RelocReqAck 50
386 #define IE_RAB_SetupOrModifiedItem 51
387 #define IE_RAB_SetupOrModifiedList 52
388 #define IE_RAB_SetupOrModifyItem 53
389 #define IE_RAB_SetupOrModifyList 54
390 #define IE_RAC 55
391 #define IE_RelocationType 56
392 #define IE_RequestType 57
393 #define IE_SAI 58
394 #define IE_SAPI 59
395 #define IE_SourceID 60
396 #define IE_SourceRNC_ToTargetRNC_TransparentContainer 61
397 #define IE_TargetID 62
398 #define IE_TargetRNC_ToSourceRNC_TransparentContainer 63
399 #define IE_TemporaryUE_ID 64
400 #define IE_TraceReference 65
401 #define IE_TraceType 66
402 #define IE_TransportLayerAddress 67
403 #define IE_TriggerID 68
404 #define IE_UE_ID 69
405 #define IE_UL_GTP_PDU_SequenceNumber 70
406 #define IE_RAB_FailedtoReportItem 71
407 #define IE_RAB_FailedtoReportList 72
408 #define IE_KeyStatus 75
409 #define IE_DRX_CycleLengthCoefficient 76
410 #define IE_IuSigConIdList 77
411 #define IE_IuSigConIdItem 78
412 #define IE_IuSigConId 79
413 #define IE_DirectTransferInformationItem_RANAP_RelocInf 80
414 #define IE_DirectTransferInformationList_RANAP_RelocInf 81
415 #define IE_RAB_ContextItem_RANAP_RelocInf 82
416 #define IE_RAB_ContextList_RANAP_RelocInf 83
417 #define IE_RAB_ContextFailedtoTransferItem 84
418 #define IE_RAB_ContextFailedtoTransferList 85
419 #define IE_GlobalRNC_ID 86
420 #define IE_RAB_ReleasedItem_IuRelComp 87
421
422 static const value_string   ranap_ie_id_values[] = {
423   {IE_AreaIdentity,                             "AreaIdentity"},
424   {IE_CN_BroadcastInformationPiece,             "CN_BroadcastInformationPiece"},
425   {IE_CN_BroadcastInformationPieceList,         "CN_BroadcastInformationPieceList"},
426   {IE_CN_DomainIndicator,                       "CN_DomainIndicator"},
427   {IE_Cause,                                    "Cause"},
428   {IE_ChosenEncryptionAlgorithm,                "ChosenEncryptionAlgorithm"},
429   {IE_ChosenIntegrityProtectionAlgorithm,       "ChosenIntegrityProtectionAlgorithm"},
430   {IE_ClassmarkInformation2,                    "ClassmarkInformation2"},
431   {IE_ClassmarkInformation3,                    "ClassmarkInformation3"},
432   {IE_CriticalityDiagnostics,                   "CriticalityDiagnostics"},
433   {IE_DL_GTP_PDU_SequenceNumber,                "DL_GTP_PDU_SequenceNumber"},
434   {IE_EncryptionInformation,                    "EncryptionInformation"},
435   {IE_IntegrityProtectionInformation,           "IntegrityProtectionInformation"},
436   {IE_IuTransportAssociation,                   "IuTransportAssociation"},
437   {IE_L3_Information,                           "L3_Information"},
438   {IE_LAI,                                      "LAI"},
439   {IE_NAS_PDU,                                  "NAS_PDU"},
440   {IE_NonSearchingIndication,                   "NonSearchingIndication"},
441   {IE_NumberOfSteps,                            "NumberOfSteps"},
442   {IE_OMC_ID,                                   "OMC_ID"},
443   {IE_OldBSS_ToNewBSS_Information,              "OldBSS_ToNewBSS_Information"},
444   {IE_PagingAreaID,                             "PagingAreaID"},
445   {IE_PagingCause,                              "PagingCause"},
446   {IE_PermanentNAS_UE_ID,                       "PermanentNAS_UE_ID"},
447   {IE_RAB_ContextItem,                          "RAB_ContextItem"},
448   {IE_RAB_ContextList,                          "RAB_ContextList"},
449   {IE_RAB_DataForwardingItem,                   "RAB_DataForwardingItem"},
450   {IE_RAB_DataForwardingItem_SRNS_CtxReq,       "RAB_DataForwardingItem_SRNS_CtxReq"},
451   {IE_RAB_DataForwardingList,                   "RAB_DataForwardingList"},
452   {IE_RAB_DataForwardingList_SRNS_CtxReq,       "RAB_DataForwardingList_SRNS_CtxReq"},
453   {IE_RAB_DataVolumeReportItem,                 "RAB_DataVolumeReportItem"},
454   {IE_RAB_DataVolumeReportList,                 "RAB_DataVolumeReportList"},
455   {IE_RAB_DataVolumeReportRequestItem,          "RAB_DataVolumeReportRequestItem"},
456   {IE_RAB_DataVolumeReportRequestList,          "RAB_DataVolumeReportRequestList"},
457   {IE_RAB_FailedItem,                           "RAB_FailedItem"},
458   {IE_RAB_FailedList,                           "RAB_FailedList"},
459   {IE_RAB_ID,                                   "RAB_ID"},
460   {IE_RAB_QueuedItem,                           "RAB_QueuedItem"},
461   {IE_RAB_QueuedList,                           "RAB_QueuedList"},
462   {IE_RAB_ReleaseFailedList,                    "RAB_ReleaseFailedList"},
463   {IE_RAB_ReleaseItem,                          "RAB_ReleaseItem"},
464   {IE_RAB_ReleaseList,                          "RAB_ReleaseList"},
465   {IE_RAB_ReleasedItem,                         "RAB_ReleasedItem"},
466   {IE_RAB_ReleasedList,                         "RAB_ReleasedList"},
467   {IE_RAB_ReleasedList_IuRelComp,               "RAB_ReleasedList_IuRelComp"},
468   {IE_RAB_RelocationReleaseItem,                "RAB_RelocationReleaseItem"},
469   {IE_RAB_RelocationReleaseList,                "RAB_RelocationReleaseList"},
470   {IE_RAB_SetupItem_RelocReq,                   "RAB_SetupItem_RelocReq"},
471   {IE_RAB_SetupItem_RelocReqAck,                "RAB_SetupItem_RelocReqAck"},
472   {IE_RAB_SetupList_RelocReq,                   "RAB_SetupList_RelocReq"},
473   {IE_RAB_SetupList_RelocReqAck,                "RAB_SetupList_RelocReqAck"},
474   {IE_RAB_SetupOrModifiedItem,                  "RAB_SetupOrModifiedItem"},
475   {IE_RAB_SetupOrModifiedList,                  "RAB_SetupOrModifiedList"},
476   {IE_RAB_SetupOrModifyItem,                    "RAB_SetupOrModifyItem"},
477   {IE_RAB_SetupOrModifyList,                    "RAB_SetupOrModifyList"},
478   {IE_RAC,                                      "RAC"},
479   {IE_RelocationType,                           "RelocationType"},
480   {IE_RequestType,                              "RequestType"},
481   {IE_SAI,                                      "SAI"},
482   {IE_SAPI,                                     "SAPI"},
483   {IE_SourceID,                                 "SourceID"},
484   {IE_SourceRNC_ToTargetRNC_TransparentContainer,
485                                                 "SourceRNC_ToTargetRNC_TransparentContainer"},
486   {IE_TargetID,                                 "TargetID"},
487   {IE_TargetRNC_ToSourceRNC_TransparentContainer,
488                                                 "TargetRNC_ToSourceRNC_TransparentContainer"},
489   {IE_TemporaryUE_ID,                           "TemporaryUE_ID"},
490   {IE_TraceReference,                           "TraceReference"},
491   {IE_TraceType,                                "TraceType"},
492   {IE_TransportLayerAddress,                    "TransportLayerAddress"},
493   {IE_TriggerID,                                "TriggerID"},
494   {IE_UE_ID,                                    "UE_ID"},
495   {IE_UL_GTP_PDU_SequenceNumber,                "UL_GTP_PDU_SequenceNumber"},
496   {IE_RAB_FailedtoReportItem,                   "RAB_FailedtoReportItem"},
497   {IE_RAB_FailedtoReportList,                   "RAB_FailedtoReportList"},
498   {IE_KeyStatus,                                "KeyStatus"},
499   {IE_DRX_CycleLengthCoefficient,               "DRX_CycleLengthCoefficient"},
500   {IE_IuSigConIdList,                           "IuSigConIdList"},
501   {IE_IuSigConIdItem,                           "IuSigConIdItem"},
502   {IE_IuSigConId,                               "IuSigConId"},
503   {IE_DirectTransferInformationItem_RANAP_RelocInf,
504                                                 "DirectTransferInformationItem_RANAP_RelocInf"},
505   {IE_DirectTransferInformationList_RANAP_RelocInf,
506                                                 "DirectTransferInformationList_RANAP_RelocInf"},
507   {IE_RAB_ContextItem_RANAP_RelocInf,           "RAB_ContextItem_RANAP_RelocInf"},
508   {IE_RAB_ContextList_RANAP_RelocInf,           "RAB_ContextList_RANAP_RelocInf"},
509   {IE_RAB_ContextFailedtoTransferItem,          "RAB_ContextFailedtoTransferItem"},
510   {IE_RAB_ContextFailedtoTransferList,          "RAB_ContextFailedtoTransferList"},
511   {IE_GlobalRNC_ID,                             "GlobalRNC_ID"},
512   {IE_RAB_ReleasedItem_IuRelComp,               "RAB_ReleasedItem_IuRelComp"},
513   {0,                                           NULL}
514 };
515
516
517 /* Description of IE-Contents */
518
519 /* Length of fields within IEs */
520 #define RAB_ID_LENGTH 1
521 #define PLMN_ID_LENGTH 3
522 #define LAC_LENGTH 2
523 #define IE_PROTOCOL_EXTENSION_LENGTH 1
524 #define RAC_LENGTH 1
525 #define SAC_LENGTH 2
526 #define NUM_RABS_LENGTH 1
527
528
529 /* Traffic Class values */
530 #define TC_conversational 0
531 #define TC_streaming 1
532 #define TC_interactive 2
533 #define TC_background 3
534
535 static const value_string ranap_trafficClass_values[] = {
536   {TC_conversational,           "conversational"},
537   {TC_streaming,                "streaming"},
538   {TC_interactive,              "interactive"},
539   {TC_background,               "background"},
540   {0,                           NULL}};
541
542
543 /* rAB-AsymmetryIndicator values */
544 #define AI_symmetric_bidirectional 0
545 #define AI_asymmetric_unidirectional_downlink 1
546 #define AI_asymmetric_unidirectional_uplink 2
547 #define AI_asymmetric_bidirectional 3
548
549 static const value_string ranap_rAB_AsymmetryIndicator_values[] = {
550    {AI_symmetric_bidirectional,                 "symmetric-bidirectional"},
551    {AI_asymmetric_unidirectional_downlink,      "asymmetric-unidirectional-downlink"},
552    {AI_asymmetric_unidirectional_uplink,        "asymmetric-unidirectional-uplink"},
553    {AI_asymmetric_bidirectional,                "asymmetric-bidirectional"},
554    {0,                                          NULL}};
555
556
557 /* DeliveryOrder values */
558 #define DO_delivery_order_requested 0
559 #define DO_delivery_order_not_requested 1
560
561 static const value_string ranap_DeliveryOrder_values[] = {
562    {DO_delivery_order_requested,                "delivery-order-requested"},
563    {DO_delivery_order_not_requested,            "delivery-order-not-requested"},
564    {0,                                          NULL}};
565
566 #define maxSDU_Size_LENGTH 2
567
568 /* deliveryOfErroneousSDU values */
569 #define DOES_yes 0
570 #define DOES_no 1
571 #define DOES_no_error_detection_consideration 2
572
573 static const value_string ranap_deliveryOfErroneousSDU_values[] = {
574    {DOES_yes,                                   "yes"},
575    {DOES_no,                                    "no"},
576    {DOES_no_error_detection_consideration,      "no-error-detection-consideration"},
577    {0,                                          NULL}};
578
579
580 #define subflowSDU_Size_LENGTH 2
581 #define transferDelay_LENGTH 2
582
583
584 /* trafficHandlingPriority values */
585 static const value_string ranap_priority_values[] = {
586    {  0,        "spare"},
587    {  1,        "highest"},
588    {  2,        ""},
589    {  3,        ""},
590    {  4,        ""},
591    {  5,        ""},
592    {  6,        ""},
593    {  7,        ""},
594    {  8,        ""},
595    {  9,        ""},
596    { 10,        ""},
597    { 11,        ""},
598    { 12,        ""},
599    { 13,        ""},
600    { 14,        "lowest"},
601    { 15,        "no-priority-used"},
602    {  0,        NULL}};
603
604
605 /* pre-emptionCapability values */
606 static const value_string ranap_pre_emptionCapability_values[] = {
607    {  0,        "shall-not-trigger-pre-emption"},
608    {  1,        "may-trigger-pre-emption"},
609    {  0,        NULL}};
610
611 /* pre-emptionVulnerability values */
612 static const value_string ranap_pre_emptionVulnerability_values[] = {
613    {  0,        "not-pre-emptable"},
614    {  1,        "pre-emptable"},
615    {  0,        NULL}};
616
617
618 /* queuingAllowed values         */
619 static const value_string ranap_queuingAllowed_values[] = {
620    {  0,        "queueing-not-allowed"},
621    {  1,        "queueing-allowed"},
622    {  0,        NULL}};
623
624
625 /* sourceStatisticsDescriptor values */
626 static const value_string ranap_sourceStatisticsDescriptor_values[] = {
627    {  0,        "speech"},
628    {  1,        "unknown"},
629    {  0,        NULL}};
630
631 /* relocationRequirement values */
632 static const value_string ranap_relocationRequirement_values[] = {
633    {  0,        "lossless"},
634    {  1,        "none"},
635    {  0,        NULL}};
636
637 /* userPlaneMode values */
638 static const value_string ranap_userPlaneMode_values[] = {
639    {  0,        "transparent-mode"},
640    {  1,        "support-mode-for-predefined-SDU-sizes"},
641    {  0,        NULL}};
642
643 /* PDP_Type values */
644 static const value_string ranap_PDP_Type_values[] = {
645    {  0,        "empty"},
646    {  1,        "ppp"},
647    {  2,        "osp-ihoss"},
648    {  3,        "ipv4"},
649    {  4,        "ipv6"},
650    {  0,        NULL}};
651
652 /* dataVolumeReportingIndication values */
653 static const value_string ranap_dataVolumeReportingIndication_values[] = {
654    {  0,        "do-report"},
655    {  1,        "do-not-report"},
656    {  0,        NULL}};
657
658
659 /* cause_choice values */
660 #define CC_CauseRadioNetwork            0
661 #define CC_CauseTransmissionNetwork     1
662 #define CC_CauseNAS                     2
663 #define CC_CauseProtocol                3
664 #define CC_CauseMisc                    4
665 #define CC_CauseNon_Standard            5
666
667 static const value_string ranap_cause_choice_values[] = {
668    {  CC_CauseRadioNetwork,             "CauseRadioNetwork"},
669    {  CC_CauseTransmissionNetwork,      "CauseTransmissionNetwork"},
670    {  CC_CauseNAS,                      "CauseNAS"},
671    {  CC_CauseProtocol,                 "CauseProtocol"},
672    {  CC_CauseMisc,                     "CauseMisc"},
673    {  CC_CauseNon_Standard,             "CauseNon-Standard"},
674    {  0,                                NULL}};
675
676
677 /* cause values */
678 static const value_string ranap_cause_value_str[] = {
679 /* CauseRadioNetwork (1..64) */
680    {  1,        "rab-pre-empted"},
681    {  2,        "trelocoverall-expiry"},
682    {  3,        "trelocprep-expiry"},
683    {  4,        "treloccomplete-expiry"},
684    {  5,        "tqueing-expiry"},
685    {  6,        "relocation-triggered"},
686    {  7,        "trellocalloc-expiry"},
687    {  8,        "unable-to-establish-during-relocation"},
688    {  9,        "unknown-target-rnc"},
689    { 10,        "relocation-cancelled"},
690    { 11,        "successful-relocation"},
691    { 12,        "requested-ciphering-and-or-integrity-protection-algorithms-not-supported"},
692    { 13,        "change-of-ciphering-and-or-integrity-protection-is-not-supported"},
693    { 14,        "failure-in-the-radio-interface-procedure"},
694    { 15,        "release-due-to-utran-generated-reason"},
695    { 16,        "user-inactivity"},
696    { 17,        "time-critical-relocation"},
697    { 18,        "requested-traffic-class-not-available"},
698    { 19,        "invalid-rab-parameters-value"},
699    { 20,        "requested-maximum-bit-rate-not-available"},
700    { 21,        "requested-guaranteed-bit-rate-not-available"},
701    { 22,        "requested-transfer-delay-not-achievable"},
702    { 23,        "invalid-rab-parameters-combination"},
703    { 24,        "condition-violation-for-sdu-parameters"},
704    { 25,        "condition-violation-for-traffic-handling-priority"},
705    { 26,        "condition-violation-for-guaranteed-bit-rate"},
706    { 27,        "user-plane-versions-not-supported"},
707    { 28,        "iu-up-failure"},
708    { 29,        "relocation-failure-in-target-CN-RNC-or-target-system"},
709    { 30,        "invalid-RAB-ID"},
710    { 31,        "no-remaining-rab"},
711    { 32,        "interaction-with-other-procedure"},
712    { 33,        "requested-maximum-bit-rate-for-dl-not-available"},
713    { 34,        "requested-maximum-bit-rate-for-ul-not-available"},
714    { 35,        "requested-guaranteed-bit-rate-for-dl-not-available"},
715    { 36,        "requested-guaranteed-bit-rate-for-ul-not-available"},
716    { 37,        "repeated-integrity-checking-failure"},
717    { 38,        "requested-report-type-not-supported"},
718    { 39,        "request-superseded"},
719    { 40,        "release-due-to-UE-generated-signalling-connection-release"},
720    { 41,        "resource-optimisation-relocation"},
721    { 42,        "requested-information-not-available"},
722    { 43,        "relocation-desirable-for-radio-reasons"},
723    { 44,        "relocation-not-supported-in-target-RNC-or-target-system"},
724    { 45,        "directed-retry"},
725    { 46,        "radio-connection-with-UE-Lost"},
726
727 /* CauseTransmissionNetwork (65..80) */
728    { 65,        "logical-error-unknown-iu-transport-association"},
729    { 66,        "iu-transport-connection-failed-to-establish"},
730
731 /* CauseNAS (81..96) */
732    { 81,        "user-restriction-start-indication"},
733    { 82,        "user-restriction-end-indication"},
734    { 83,        "normal-release"},
735
736 /* CauseProtocol (97..112) */
737    { 97,        "transfer-syntax-error"},
738    { 98,        "semantic-error"},
739    { 99,        "message-not-compatible-with-receiver-state"},
740    {100,        "abstract-syntax-error-reject"},
741    {101,        "abstract-syntax-error-ignore-and-notify"},
742    {102,        "abstract-syntax-error-falsely-constructed-message"},
743
744 /* CauseMisc (113..128) */
745    {113,        "om-intervention"},
746    {114,        "no-resource-available"},
747    {115,        "unspecified-failure"},
748    {116,        "network-optimisation"},
749    {  0,        NULL}};
750
751
752 /* CN_DomainIndicator_values */
753 static const value_string ranap_CN_DomainIndicator_values[] = {
754    {  0,        "cs-domain"},
755    {  1,        "ps-domain"},
756    {  0,        NULL}};
757
758
759 /* SAPI_values */
760 static const value_string ranap_SAPI_values[] = {
761    {  0,        "sapi-0"},
762    {  1,        "sapi-3"},
763    {  0,        NULL}};
764
765 /* service_Handover_values */
766 static const value_string ranap_service_Handover_values[] = {
767    {  0,        "handover-to-GSM-should-be-performed"},
768    {  1,        "handover-to-GSM-should-not-be-performed"},
769    {  2,        "handover-to-GSM-shall-not-be-performed"},
770    {  0,        NULL}};
771
772 /* Initialize the protocol and registered fields */
773 /* protocol */
774 static int proto_ranap = -1;
775
776 static dissector_table_t nas_pdu_dissector_table;
777
778 packet_info *g_pinfo = NULL;
779 proto_tree *g_tree = NULL;
780
781 /* pdu header fields */
782 static int hf_ranap_pdu_number_of_octets = -1;
783 static int hf_ranap_pdu_index = -1;
784 static int hf_ranap_procedure_code = -1;
785 static int hf_ranap_pdu_criticality = -1;
786 static int hf_ranap_number_of_ies = -1;
787
788 /* ie header fields */
789 static int hf_ranap_ie_ie_id = -1;
790 static int hf_ranap_ie_criticality = -1;
791 static int hf_ranap_ie_number_of_octets = -1;
792 static int hf_ranap_ie_protocol_extension = -1;
793
794 /*ie contents fields */
795 static int hf_ranap_number_of_ies_in_list = -1;
796 static int hf_ranap_ie_pair_first_criticality = -1;
797 static int hf_ranap_ie_pair_second_criticality = -1;
798 static int hf_ranap_first_value_number_of_octets = -1;
799 static int hf_ranap_second_value_number_of_octets = -1;
800 static int hf_ranap_rab_id = -1;
801 static int hf_ranap_nas_pdu = -1;
802 static int hf_ranap_plmn_id = -1;
803 static int hf_ranap_lac = -1;
804 static int hf_ranap_sac = -1;
805 static int hf_ranap_rac = -1;
806 static int hf_ranap_nAS_SynchronisationIndicator = -1;
807 static int hf_ranap_trafficClass = -1;
808 static int hf_ranap_deliveryOrder = -1;
809 static int hf_ranap_iE_Extensions_present = -1;
810 static int hf_ranap_num_rabs = -1;
811 static int hf_ranap_nAS_SynchronisationIndicator_present = -1;
812 static int hf_ranap_rAB_Parameters_present = -1;
813 static int hf_ranap_userPlaneInformation_present = -1;
814 static int hf_ranap_transportLayerInformation_present = -1;
815 static int hf_ranap_service_Handover_present = -1;
816 static int hf_ranap_guaranteedBitRate_present = -1;
817 static int hf_ranap_transferDelay_present = -1;
818 static int hf_ranap_trafficHandlingPriority_present = -1;
819 static int hf_ranap_allocationOrRetentionPriority_present = -1;
820 static int hf_ranap_sourceStatisticsDescriptor_present = -1;
821 static int hf_ranap_relocationRequirement_present = -1;
822 static int hf_ranap_rAB_AsymmetryIndicator = -1;
823 static int hf_ranap_maxBitrate = -1;
824 static int hf_ranap_guaranteedBitrate = -1;
825 static int hf_ranap_maxSDU_Size = -1;
826 static int hf_ranap_sDU_ErrorRatio_mantissa = -1;
827 static int hf_ranap_sDU_ErrorRatio_exponent = -1;
828 static int hf_ranap_residualBitErrorRatio_mantissa = -1;
829 static int hf_ranap_residualBitErrorRatio_exponent = -1;
830 static int hf_ranap_deliveryOfErroneousSDU = -1;
831 static int hf_ranap_subflowSDU_Size = -1;
832 static int hf_ranap_rAB_SubflowCombinationBitRate = -1;
833 static int hf_ranap_sDU_ErrorRatio_present = -1;
834 static int hf_ranap_sDU_FormatInformationParameters_present = -1;
835 static int hf_ranap_subflowSDU_Size_present = -1;
836 static int hf_ranap_rAB_SubflowCombinationBitRate_present = -1;
837 static int hf_ranap_transferDelay = -1;
838 static int hf_ranap_trafficHandlingPriority = -1;
839 static int hf_ranap_priorityLevel = -1;
840 static int hf_ranap_pre_emptionCapability = -1;
841 static int hf_ranap_pre_emptionVulnerability = -1;
842 static int hf_ranap_queuingAllowed = -1;
843 static int hf_ranap_sourceStatisticsDescriptor = -1;
844 static int hf_ranap_userPlaneMode = -1;
845 static int hf_ranap_uP_ModeVersions = -1;
846 static int hf_ranap_number_of_ProtocolExtensionFields = -1;
847 static int hf_ranap_ext_field_id = -1;
848 static int hf_ranap_ext_field_criticality = -1;
849 static int hf_ranap_ext_field_number_of_octets = -1;
850 static int hf_ranap_transportLayerAddress = -1;
851 static int hf_ranap_transportLayerAddress_length = -1;
852 static int hf_ranap_gTP_TEI = -1;
853 static int hf_ranap_bindingID = -1;
854 static int hf_ranap_pDP_TypeInformation_present = -1;
855 static int hf_ranap_dataVolumeReportingIndication_present = -1;
856 static int hf_ranap_dl_GTP_PDU_SequenceNumber_present = -1;
857 static int hf_ranap_ul_GTP_PDU_SequenceNumber_present = -1;
858 static int hf_ranap_dl_N_PDU_SequenceNumber_present = -1;
859 static int hf_ranap_ul_N_PDU_SequenceNumber_present = -1;
860 static int hf_ranap_PDP_Type = -1;
861 static int hf_ranap_dataVolumeReportingIndication = -1;
862 static int hf_ranap_dl_GTP_PDU_SequenceNumber = -1;
863 static int hf_ranap_ul_GTP_PDU_SequenceNumber = -1;
864 static int hf_ranap_dl_N_PDU_SequenceNumber = -1;
865 static int hf_ranap_ul_N_PDU_SequenceNumber = -1;
866 static int hf_ranap_cause_choice = -1;
867 static int hf_ranap_cause_value = -1;
868 static int hf_ranap_transportLayerAddress_present = -1;
869 static int hf_ranap_iuTransportAssociation_present = -1;
870 static int hf_ranap_dl_dataVolumes_present = -1;
871 static int hf_ranap_dataVolumeReference_present = -1;
872 static int hf_ranap_dl_UnsuccessfullyTransmittedDataVolume = -1;
873 static int hf_ranap_dataVolumeReference = -1;
874 static int hf_ranap_procedureCode_present = -1;
875 static int hf_ranap_triggeringMessage_present = -1;
876 static int hf_ranap_procedureCriticality_present = -1;
877 static int hf_ranap_iEsCriticalityDiagnostics_present = -1;
878 static int hf_ranap_triggeringMessage = -1;
879 static int hf_ranap_iECriticality = -1;
880 static int hf_ranap_procedureCriticality = -1;
881 static int hf_ranap_repetitionNumber = -1;
882 static int hf_ranap_num_of_CriticalityDiagnostics_IEs = -1;
883 static int hf_ranap_repetitionNumber_present = -1;
884 static int hf_ranap_dl_UnsuccessfullyTransmittedDataVolume_present = -1;
885 static int hf_ranap_CN_DomainIndicator = -1;
886 static int hf_ranap_IuSigConId = -1;
887 static int hf_ranap_SAPI = -1;
888 static int hf_ranap_msg_extension_present = -1;
889 static int hf_ranap_ProtocolExtensionContainer_present = -1;
890 static int hf_ranap_nas_pdu_length = -1;
891 static int hf_ranap_relocationRequirement = -1;
892 static int hf_ranap_service_Handover = -1;
893 static int hf_ranap_extension_field = -1;
894 static int hf_ranap_RNC_ID = -1;
895
896
897 /* subtrees */
898 static gint ett_ranap = -1;
899 static gint ett_ranap_optionals = -1;
900 static gint ett_ranap_iE_Extension = -1;
901 static gint ett_ranap_ie = -1;
902 static gint ett_ranap_ie_pair = -1;
903 static gint ett_ranap_rab = -1;
904 static gint ett_ranap_ie_pair_first_value = -1;
905 static gint ett_ranap_ie_pair_second_value = -1;
906 static gint ett_ranap_rAB_Parameters = -1;
907 static gint ett_ranap_sDU = -1;
908 static gint ett_ranap_allocationOrRetentionPriority = -1;
909 static gint ett_ranap_CriticalityDiagnostics_IE = -1;
910
911
912
913 /*****************************************************************************/
914 /*                                                                           */
915 /*  Utility Functions                                                        */
916 /*                                                                           */
917 /*****************************************************************************/
918
919 /* sets *offset and *bitoffset n bits further */
920 static void
921 proceed_nbits(gint *offset, gint *bitoffset, gint n)
922 {
923    *bitoffset += n;
924    *offset += *bitoffset / 8;
925    *bitoffset %= 8;
926 }
927
928 /* sets *offset and *bitoffset to the next byte boundary */
929 static void allign(gint *offset, gint *bitoffset)
930 {
931   if ( *bitoffset != 0 )
932   {
933      (*offset)++;
934      *bitoffset=0;
935   }
936 }
937
938 /* sets *offset and *bitoffset behind the following integer */
939 static void
940 proceed_perint32(gint *offset, gint *bitoffset, gint length)
941 {
942    proceed_nbits(offset, bitoffset, 2);
943    allign(offset, bitoffset);
944    *offset += length;
945 }
946
947
948 /* extract length field found at offset */
949 /* if length field spans more than two bytes -1 is returned and the field is not decoded */
950 static guint8
951 extract_length(tvbuff_t *tvb, gint offset, gint *length, gint *length_size)
952 {
953    guint8       tmp_length8;
954    guint16      tmp_length16;
955
956    tmp_length8 = tvb_get_guint8(tvb, offset);
957    if ((tmp_length8 & 0x80) == 0)
958    {
959         /* length coded in one byte */
960         *length = tmp_length8;
961         *length_size = 1;
962     }
963     else
964     {
965         tmp_length16 = tvb_get_ntohs(tvb, offset);
966         if ( ((tmp_length16 & 0x8000) == 0x8000) &&  ((tmp_length16 & 0x4000) == 0) )
967         {
968             /* length coded in two bytes */
969             *length = tmp_length16 & 0x3FFF;
970             *length_size = 2;
971         }
972         else
973         {   /* length is coded in more than 2 bytes */
974            return (-1);
975         }
976     }
977     return(0);
978 }
979
980 /* extract the next n bits and return them alligned to the LSB */
981 static guint8
982 extract_nbits(tvbuff_t *tvb, gint offset, gint bitoffset, gint n)
983 {
984    guint8       uint_bits;
985    guint16      tmp_2bytes;
986
987    /* extract value */
988    if (bitoffset + n <= 8)
989    {
990       /* all bits contained in one byte */
991       uint_bits = tvb_get_guint8(tvb, offset);
992       uint_bits <<= bitoffset;                          /* remove bitoffset */
993       uint_bits >>= 8-n;                                /* allign to LSB */
994    }
995    else
996    {
997       /* bits contained within 2 bytes */
998       tmp_2bytes = tvb_get_ntohs(tvb, offset);
999       tmp_2bytes <<=  bitoffset;                        /* remove bitoffset */
1000       uint_bits = tmp_2bytes >> ( 8 + (8-n));           /* allign to LSB */
1001    }
1002
1003    return(uint_bits);
1004 }
1005
1006
1007 /* extract an integer with 2bit length field and return the int value*/
1008 static guint32
1009 extract_int32(tvbuff_t *tvb, gint offset, gint bitoffset, gint *length)
1010 {
1011    guint16      tmp_2byte;
1012    guint32      result = 0;
1013
1014    tmp_2byte = tvb_get_ntohs(tvb, offset);
1015
1016    tmp_2byte <<= bitoffset;             /* remove bitoffset */
1017    *length = tmp_2byte >> (6 + 8);      /* allign 2bit length field to LSB */
1018    (*length)++;                         /* now we have the length of the int value */
1019
1020    proceed_nbits(&offset, &bitoffset, 2);
1021    allign(&offset, &bitoffset);
1022
1023    switch (*length)
1024    {
1025       case 1:
1026          result = tvb_get_guint8(tvb, offset);
1027          break;
1028       case 2:
1029          result = tvb_get_ntohs(tvb, offset);
1030          break;
1031       case 3:
1032          result = tvb_get_ntoh24(tvb, offset);
1033          break;
1034       case 4:
1035          result = tvb_get_ntohl(tvb, offset);
1036          break;
1037     }
1038
1039     return(result);
1040 }
1041
1042
1043 /* return bitmask string looking like "..01 0..."  */
1044 static char *
1045 bitmaskstr(guint bitoffset, guint bitlength, guint16 value, guint *length)
1046 {
1047    static char          maskstr[20];
1048    guint                i;
1049
1050
1051    strcpy(maskstr, "                   ");
1052
1053    for (i=0; i<16; i++)
1054    {
1055       if ( i < bitoffset  ||  i > bitoffset+bitlength-1 )
1056       {
1057          /* i is outside extracted bitfield */
1058          maskstr[i + i/4] = '.';
1059       }
1060       else
1061       {  /* i is inside extracted bitfield */
1062          if ( ((0x8000 >> i) & value) != 0x0000 )
1063          {
1064             /* bit is set */
1065             maskstr[i + i/4] = '1';
1066          }
1067          else
1068          {
1069             /* bit is not set */
1070             maskstr[i + i/4] = '0';
1071          }
1072       }
1073    }
1074    if (bitoffset + bitlength <= 8)
1075    {
1076       /* bitfield is located within first byte only */
1077       maskstr[9] = '\0';
1078       *length = 1;
1079    }
1080    else
1081    {
1082       /* bitfield is located within first & second byte */
1083       maskstr[19] = '\0';
1084       *length = 2;
1085    }
1086
1087    return(maskstr);
1088 }
1089
1090 /* add bitstring */
1091 static proto_item *
1092 proto_tree_add_bitstring(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint offset,
1093                          gint bitoffset, gint bitlength)
1094 {
1095    guint16              read_2bytes;
1096    guint16              alligned_2bytes;
1097    guint8               one_byte;
1098    char                 *maskstr;
1099    char                 maskstr_buf[56] = "\0";
1100    guint                length;
1101    int                  i;
1102    guint8               bitstr[128];
1103    char                 buf[256] = "\0";
1104    header_field_info    *hf_info_p;
1105    gint                 byte_span;
1106    gint                 initial_offset = offset;
1107
1108    memset(bitstr, 0, 128);
1109
1110    /* create bitmask string for first byte */
1111    read_2bytes = tvb_get_ntohs(tvb, offset);
1112    maskstr = bitmaskstr(bitoffset, (bitoffset+bitlength >8) ? 8-bitoffset : bitlength, read_2bytes, &length);
1113    if (bitoffset+bitlength > 8)
1114    {
1115       sprintf(maskstr_buf, "%s + %d Bits = ", maskstr, bitlength - (8-bitoffset));
1116    }
1117    else
1118    {
1119       sprintf(maskstr_buf, "%s = ", maskstr);
1120    }
1121
1122
1123    /* print all but the last byte to buf */
1124    byte_span = (bitoffset + bitlength + 7) / 8;
1125    for (i=0; i < byte_span - 1; i++, offset++)
1126    {
1127       read_2bytes = tvb_get_ntohs(tvb, offset);
1128       alligned_2bytes = read_2bytes << bitoffset;       /* remove bitoffset */
1129       one_byte = alligned_2bytes >> 8;                  /* move to low byte */
1130
1131       bitstr[i]=one_byte;
1132       sprintf(&(buf[2*i]), "%02X", one_byte);
1133    }
1134
1135    /* add last byte if it contains bits which have not yet been shifted in */
1136    if ( ((bitlength + 7) / 8 ) == byte_span )
1137    {
1138       read_2bytes = tvb_get_ntohs(tvb, offset);
1139       alligned_2bytes = read_2bytes << bitoffset;       /* remove bitoffset */
1140       one_byte = alligned_2bytes >> 8;                  /* move to low byte */
1141       one_byte >>= (8 - (bitlength%8));                 /*cut off surplus bits */
1142       one_byte <<= (8 - (bitlength%8));                 /* allign to MSB in low byte*/
1143
1144       bitstr[i]=one_byte;
1145       sprintf(&(buf[2*i]), "%02X", one_byte);
1146    }
1147
1148    /* get header field info */
1149    hf_info_p = proto_registrar_get_nth(hfindex);
1150
1151
1152   return ( proto_tree_add_bytes_format(tree, hfindex, tvb, initial_offset,
1153            byte_span , bitstr, "%s %s: %s", maskstr_buf, hf_info_p->name, buf) );
1154
1155 }
1156
1157
1158 /* add unsigned int, 1-8 bits long */
1159 static proto_item *
1160 proto_tree_add_uint_bits(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint offset,
1161                          gint bitoffset, gint bitlength, gint min)
1162 {
1163    guint8               uint_bits;
1164    guint16              read_2bytes, alligned_2bytes;
1165    char                 *maskstr;
1166    guint                length;
1167    header_field_info    *hf_info_p;
1168
1169
1170    /* extract value */
1171    if (bitoffset + bitlength <= 8)
1172    {
1173       /* all bits contained in one byte */
1174       uint_bits = tvb_get_guint8(tvb, offset);
1175       read_2bytes = uint_bits;
1176       read_2bytes <<= 8;
1177    }
1178    else
1179    {
1180       /* bits contained within 2 bytes */
1181       read_2bytes = tvb_get_ntohs(tvb, offset);
1182    }
1183    alligned_2bytes = read_2bytes << bitoffset;                  /* remove bitoffset */
1184    uint_bits = alligned_2bytes >> ( 8 + (8-bitlength));         /* allign to LSB */
1185
1186    uint_bits += min;
1187
1188    /* create bitmask string */
1189    maskstr = bitmaskstr(bitoffset, bitlength, read_2bytes, &length);
1190
1191    /* get header field info */
1192    hf_info_p = proto_registrar_get_nth(hfindex);
1193
1194    if (hf_info_p->strings != NULL)
1195    {
1196       /* string representation for decoded header field present */
1197       return ( proto_tree_add_uint_format(tree, hfindex, tvb, offset,
1198               length, uint_bits, "%s = %s: %s (%d)", maskstr, hf_info_p->name,
1199               val_to_str(uint_bits, hf_info_p->strings, "%d"), uint_bits) );
1200    }
1201    else
1202    {
1203       /* no string representation */
1204       return ( proto_tree_add_uint_format(tree, hfindex, tvb, offset,
1205               length, uint_bits, "%s = %s: %d", maskstr, hf_info_p->name, uint_bits) );
1206    }
1207 }
1208
1209 /* add PER encoded integer (maximum length of value: 4 bytes) */
1210 static proto_item *
1211 proto_tree_add_PERint32(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint offset,
1212                          gint bitoffset, gint *length, gint min)
1213 {
1214     guint32             value;
1215     guint16             tmp_2bytes;
1216     char                *maskstr;
1217     guint               length_size;
1218     header_field_info   *hf_info_p;
1219
1220     /* get value */
1221     value = extract_int32(tvb, offset, bitoffset, length);
1222     value += min;
1223
1224     /* create bitmask string for 2 bit length field */
1225     tmp_2bytes = tvb_get_ntohs(tvb, offset);
1226     maskstr = bitmaskstr(bitoffset, 2, tmp_2bytes, &length_size);
1227
1228     /* get header field info */
1229     hf_info_p = proto_registrar_get_nth(hfindex);
1230
1231     return ( proto_tree_add_uint_format(tree, hfindex, tvb, offset,
1232              (*length) + length_size, value,
1233              "%s + %d Bytes = %s: %d", maskstr, *length, hf_info_p->name, value) );
1234 }
1235
1236
1237
1238 /*****************************************************************************/
1239 /*                                                                           */
1240 /*  Dissecting Functions for single parameters                               */
1241 /*                                                                           */
1242 /*****************************************************************************/
1243 static int
1244 dissect_iE_Extension(tvbuff_t *tvb, proto_tree *tree, gint *offset, gint *bitoffset, char *description)
1245 {
1246   proto_item    *ext_item = NULL;
1247   proto_tree    *ext_tree = NULL;
1248   guint16       number_of_extFields;
1249   gint          number_of_octets = 0;
1250   gint          number_of_octets_size = 0;
1251   int           i;
1252
1253   allign(offset, bitoffset);
1254
1255   /* create subtree for iE_Extension */
1256   if (tree)
1257   {
1258      ext_item = proto_tree_add_text(tree, tvb, *offset, 0, "%s iE-Extensions", description);
1259      ext_tree = proto_item_add_subtree(ext_item, ett_ranap_iE_Extension);
1260   }
1261
1262   /* number of extension fields */
1263   number_of_extFields = tvb_get_ntohs(tvb, *offset) + 1;
1264   if (ext_tree)
1265   {
1266      proto_tree_add_uint(ext_tree, hf_ranap_number_of_ProtocolExtensionFields,
1267                                  tvb, *offset, 2, number_of_extFields);
1268   }
1269
1270   *offset += 2;
1271
1272   /*  for each extension field */
1273   for (i=1; i <= number_of_extFields; i++)
1274   {
1275      /* add fields to ie subtee */
1276      /* Extension Field ID */
1277      if (ext_tree)
1278      {
1279         proto_tree_add_item(ext_tree, hf_ranap_ext_field_id, tvb,
1280                             *offset, IE_ID_LENGTH, FALSE);
1281      }
1282      *offset += IE_ID_LENGTH;
1283
1284      /* criticality */
1285      if (ext_tree)
1286      {
1287         proto_tree_add_uint_bits(ext_tree, hf_ranap_ext_field_criticality, tvb,
1288                                  *offset, *bitoffset, 2, 0);
1289      }
1290      proceed_nbits(offset, bitoffset, 2);
1291
1292      /* number of octets in the IE */
1293      allign(offset, bitoffset);
1294      if (0 == extract_length(tvb, *offset, &number_of_octets, &number_of_octets_size))
1295      {
1296        if (ext_tree)
1297        {
1298           proto_tree_add_uint(ext_tree, hf_ranap_ext_field_number_of_octets, tvb,
1299                               *offset, number_of_octets_size, number_of_octets);
1300        }
1301      }
1302      else
1303      {
1304        /* decoding is not supported */
1305        if (ext_tree)
1306        {
1307           proto_tree_add_text(ext_tree, tvb, *offset, 0,
1308                               "Number of Octets greater than 0x3FFF, dissection not supported");
1309        }
1310        return(-1);
1311      }
1312
1313      *offset += number_of_octets_size;
1314      if (ext_tree)
1315      {
1316         proto_tree_add_item(ext_tree, hf_ranap_extension_field, tvb,
1317                             *offset, number_of_octets, FALSE);
1318
1319      }
1320
1321      *offset +=  number_of_octets;
1322   }
1323
1324   return(0);
1325 }
1326
1327
1328 static int
1329 dissect_userPlaneInformation(tvbuff_t *tvb, proto_tree *tree, gint *offset, gint *bitoffset)
1330 {
1331    int          extension_present;
1332    int          iE_Extensions_present;
1333    int          tmp_extension_present;
1334
1335    /* protocol_extension present ? */
1336    extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1337    proceed_nbits(offset, bitoffset, 1);
1338
1339    /* iE_Extensions present ? */
1340    iE_Extensions_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1341    proceed_nbits(offset, bitoffset, 1);
1342
1343    /* userPlaneMode */
1344    tmp_extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1345    proceed_nbits(offset, bitoffset, 1);
1346
1347    proto_tree_add_uint_bits(tree, hf_ranap_userPlaneMode, tvb, *offset,
1348                             *bitoffset, 1, 0);
1349    proceed_nbits(offset, bitoffset, 1);
1350
1351    /* uP-ModeVersions */
1352    proto_tree_add_bitstring(tree, hf_ranap_uP_ModeVersions, tvb, *offset,
1353                             *bitoffset, 16);
1354    proceed_nbits(offset, bitoffset, 16);
1355
1356    /* iE-Extensions */
1357    if (iE_Extensions_present)
1358    {
1359       return(dissect_iE_Extension(tvb, tree, offset, bitoffset, "UserPlaneInformation"));
1360    }
1361    return(0);
1362 }
1363
1364
1365
1366 static int
1367 dissect_sDU_Parameters(tvbuff_t *tvb, proto_tree *ie_tree, gint *offset, gint *bitoffset)
1368 {
1369    proto_item   *sDU_item = NULL;
1370    proto_tree   *sDU_tree = NULL;
1371    proto_item   *optionals_item = NULL;
1372    proto_tree   *optionals_tree = NULL;
1373    int          ret;
1374    int          extension_present;
1375    int          sDU_ErrorRatio_present;
1376    int          sDU_FormatInformationParameters_present;
1377    int          iE_Extensions_present;
1378    int          sDU_ErrorRatio_iE_Extensions_present;
1379    int          residualBitErrorRatio_iE_Extensions_present;
1380    gint         length;
1381    gint         number_of_sDU_FormatInformationParameters;
1382    int          sDU_FormatInformationParameters_extension_present;
1383    int          subflowSDU_Size_present;
1384    int          rAB_SubflowCombinationBitRate_present;
1385    int          sDU_FormatInformationParameters_iE_Extensions_present;
1386    gint         i;
1387
1388    /* create subtree for sDU_Parameters */
1389    sDU_item = proto_tree_add_text(ie_tree, tvb, *offset, 0,
1390                                       "sDU Parameters");
1391    sDU_tree = proto_item_add_subtree(sDU_item, ett_ranap_sDU);
1392
1393    /* create subtree for extension/optional/default bitmap */
1394    optionals_item = proto_tree_add_text(sDU_tree, tvb, *offset, 1,
1395                                       "sDU_Parameters Extension/Optional/Default bitmap");
1396    optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
1397
1398    /* protocol_extension present ? */
1399    extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1400    proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
1401                             *offset, *bitoffset, 1, 0);
1402    proceed_nbits(offset, bitoffset, 1);
1403
1404    /*  sDU_ErrorRatio present ? */
1405    sDU_ErrorRatio_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1406    proto_tree_add_uint_bits(optionals_tree, hf_ranap_sDU_ErrorRatio_present, tvb,
1407                             *offset, *bitoffset, 1, 0);
1408    proceed_nbits(offset, bitoffset, 1);
1409
1410    /*  sDU_FormatInformationParameters present ? */
1411    sDU_FormatInformationParameters_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1412    proto_tree_add_uint_bits(optionals_tree, hf_ranap_sDU_FormatInformationParameters_present, tvb,
1413                             *offset, *bitoffset, 1, 0);
1414    proceed_nbits(offset, bitoffset, 1);
1415
1416    /* iE_Extensions present ? */
1417    iE_Extensions_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1418    proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present, tvb,
1419                             *offset, *bitoffset, 1, 0);
1420    proceed_nbits(offset, bitoffset, 1);
1421
1422
1423    /* sDU_ErrorRatio */
1424    if (sDU_ErrorRatio_present)
1425    {
1426       sDU_ErrorRatio_iE_Extensions_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1427       proceed_nbits(offset, bitoffset, 1);
1428
1429       proto_tree_add_uint_bits(sDU_tree, hf_ranap_sDU_ErrorRatio_mantissa, tvb, *offset,
1430                                *bitoffset, 4, 1);
1431       proceed_nbits(offset, bitoffset, 4);
1432
1433       proto_tree_add_uint_bits(sDU_tree, hf_ranap_sDU_ErrorRatio_exponent, tvb, *offset,
1434                                *bitoffset, 3, 1);
1435       proceed_nbits(offset, bitoffset, 3);
1436
1437       if (sDU_ErrorRatio_iE_Extensions_present)
1438       {
1439          if ((ret=dissect_iE_Extension(tvb, sDU_tree, offset, bitoffset, "sDU_ErrorRatio")) != 0)
1440              return (ret);
1441       }
1442    }
1443
1444    /* residualBitErrorRatio */
1445    residualBitErrorRatio_iE_Extensions_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1446    proceed_nbits(offset, bitoffset, 1);
1447
1448    proto_tree_add_uint_bits(sDU_tree, hf_ranap_residualBitErrorRatio_mantissa, tvb, *offset,
1449                             *bitoffset, 4, 1);
1450    proceed_nbits(offset, bitoffset, 4);
1451
1452    proto_tree_add_uint_bits(sDU_tree, hf_ranap_sDU_ErrorRatio_exponent, tvb, *offset,
1453                             *bitoffset, 3, 1);
1454    proceed_nbits(offset, bitoffset, 3);
1455
1456
1457    if (residualBitErrorRatio_iE_Extensions_present)
1458    {
1459       if ((ret=dissect_iE_Extension(tvb, sDU_tree, offset, bitoffset, "residualBitErrorRatio")) != 0)
1460            return(ret);
1461    }
1462
1463
1464    /* deliveryOfErroneousSDU */
1465    proto_tree_add_uint_bits(sDU_tree, hf_ranap_deliveryOfErroneousSDU, tvb, *offset,
1466                             *bitoffset, 2, 0);
1467    proceed_nbits(offset, bitoffset, 2);
1468
1469
1470    /* sDU_FormatInformationParameters */
1471    if (sDU_FormatInformationParameters_present)
1472    {
1473       number_of_sDU_FormatInformationParameters = extract_nbits(tvb, *offset, *bitoffset, 6) + 1;
1474       proceed_nbits(offset, bitoffset, 6);
1475
1476       for (i=1; i<= number_of_sDU_FormatInformationParameters; i++)
1477       {
1478           /* create subtree for extension/optional/default bitmap */
1479          optionals_item = proto_tree_add_text(sDU_tree, tvb, *offset, 1,
1480                                       "sDU_FormatInformationParameters Extension/Optional/Default bitmap");
1481          optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
1482
1483          /* protocol extension present ? */
1484          sDU_FormatInformationParameters_extension_present =
1485              extract_nbits(tvb, *offset, *bitoffset, 1);
1486          proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
1487                             *offset, *bitoffset, 1, 0);
1488          proceed_nbits(offset, bitoffset, 1);
1489
1490          /* subflowSDU_Size present ? */
1491          subflowSDU_Size_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1492          proto_tree_add_uint_bits(optionals_tree, hf_ranap_subflowSDU_Size_present, tvb,
1493                             *offset, *bitoffset, 1, 0);
1494          proceed_nbits(offset, bitoffset, 1);
1495
1496          /* rAB_SubflowCombinationBitRate present ? */
1497          rAB_SubflowCombinationBitRate_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1498          proto_tree_add_uint_bits(optionals_tree, hf_ranap_rAB_SubflowCombinationBitRate_present, tvb,
1499                             *offset, *bitoffset, 1, 0);
1500          proceed_nbits(offset, bitoffset, 1);
1501
1502          /* ie_Extension present ? */
1503          sDU_FormatInformationParameters_iE_Extensions_present =
1504              extract_nbits(tvb, *offset, *bitoffset, 1);
1505          proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present, tvb,
1506                             *offset, *bitoffset, 1, 0);
1507          proceed_nbits(offset, bitoffset, 1);
1508
1509          if (subflowSDU_Size_present)
1510          {
1511             allign(offset, bitoffset);
1512             proto_tree_add_item(sDU_tree, hf_ranap_subflowSDU_Size,
1513                         tvb, *offset, subflowSDU_Size_LENGTH, FALSE);
1514             offset += subflowSDU_Size_LENGTH;
1515          }
1516
1517          if (rAB_SubflowCombinationBitRate_present)
1518          {
1519              proto_tree_add_PERint32(sDU_tree, hf_ranap_rAB_SubflowCombinationBitRate,
1520                                      tvb, *offset, *bitoffset, &length, 0);
1521              proceed_perint32(offset, bitoffset, length);
1522          }
1523
1524          if (sDU_FormatInformationParameters_iE_Extensions_present)
1525          {
1526             if ((ret=dissect_iE_Extension(tvb, sDU_tree, offset, bitoffset,
1527                                            "sDU_FormatInformationParameters" )) != 0)
1528                 return (ret);
1529          }
1530       }
1531     }
1532
1533     if (extension_present)
1534     {
1535         /* extended sequence */
1536         /* decoding is not supported */
1537         proto_tree_add_text(ie_tree, tvb, *offset, IE_PROTOCOL_EXTENSION_LENGTH,
1538                           "Protocol extension for sDU_FormatInformationParameters present, dissection not supported");
1539         return(-1);
1540     }
1541
1542   return (0);
1543
1544 }
1545
1546
1547 static int
1548 dissect_rAB_Parameters(tvbuff_t *tvb, proto_tree *ie_tree, gint *offset, gint *bitoffset)
1549 {
1550    guint8       tmp_byte;
1551    proto_item   *rab_item = NULL;
1552    proto_tree   *rab_tree = NULL;
1553    proto_item   *optionals_item = NULL;
1554    proto_tree   *optionals_tree = NULL;
1555    proto_item   *prio_item = NULL;
1556    proto_tree   *prio_tree = NULL;
1557    int          ret;
1558    int          extension_present;
1559    int          tmp_extension_present;
1560    int          guaranteedBitRate_present;
1561    int          transferDelay_present;
1562    int          trafficHandlingPriority_present;
1563    int          allocationOrRetentionPriority_present;
1564    int          sourceStatisticsDescriptor_present;
1565    int          relocationRequirement_present;
1566    int          iE_Extensions_present;
1567    int          tmp_iE_Extensions_present;
1568    int          i;
1569    gint         length;
1570
1571    /* create subtree for rAB_Parameters */
1572    rab_item = proto_tree_add_text(ie_tree, tvb, *offset, 0,
1573                                       "rAB_Parameters");
1574    rab_tree = proto_item_add_subtree(rab_item, ett_ranap_rAB_Parameters);
1575
1576    /* create subtree for extension/optional/default bitmap */
1577    optionals_item = proto_tree_add_text(rab_tree, tvb, *offset, IE_PROTOCOL_EXTENSION_LENGTH,
1578                                       "rAB_Parameters Extension/Optional/Default bitmap");
1579    optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
1580
1581    /* protocol extension present ? */
1582    extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1583    proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
1584                             *offset, *bitoffset, 1, 0);
1585    proceed_nbits(offset, bitoffset, 1);
1586
1587    /* guaranteedBitRate present ? */
1588    guaranteedBitRate_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1589    proto_tree_add_uint_bits(optionals_tree, hf_ranap_guaranteedBitRate_present,
1590                             tvb, *offset, *bitoffset, 1, 0);
1591    proceed_nbits(offset, bitoffset, 1);
1592
1593    /* transferDelay present ? */
1594    transferDelay_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1595    proto_tree_add_uint_bits(optionals_tree, hf_ranap_transferDelay_present,
1596                             tvb, *offset, *bitoffset, 1, 0);
1597    proceed_nbits(offset, bitoffset, 1);
1598
1599    /* trafficHandlingPriority present ? */
1600    trafficHandlingPriority_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1601    proto_tree_add_uint_bits(optionals_tree, hf_ranap_trafficHandlingPriority_present,
1602                             tvb, *offset, *bitoffset, 1, 0);
1603    proceed_nbits(offset, bitoffset, 1);
1604
1605    /* allocationOrRetentionPriority present ? */
1606    allocationOrRetentionPriority_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1607    proto_tree_add_uint_bits(optionals_tree, hf_ranap_allocationOrRetentionPriority_present,
1608                             tvb, *offset, *bitoffset, 1, 0);
1609    proceed_nbits(offset, bitoffset, 1);
1610
1611    /* sourceStatisticsDescriptor present ? */
1612    sourceStatisticsDescriptor_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1613    proto_tree_add_uint_bits(optionals_tree, hf_ranap_sourceStatisticsDescriptor_present,
1614                             tvb, *offset, *bitoffset, 1, 0);
1615    proceed_nbits(offset, bitoffset, 1);
1616
1617    /* relocationRequirement present ? */
1618    relocationRequirement_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1619    proto_tree_add_uint_bits(optionals_tree, hf_ranap_relocationRequirement_present,
1620                             tvb, *offset, *bitoffset, 1, 0);
1621    proceed_nbits(offset, bitoffset, 1);
1622
1623    /* iE-Extensions present ? */
1624    iE_Extensions_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1625    proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present,
1626                             tvb, *offset, *bitoffset, 1, 0);
1627    proceed_nbits(offset, bitoffset, 1);
1628
1629
1630    /* trafficClass */
1631    tmp_extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1632    proceed_nbits(offset, bitoffset, 1);
1633
1634    proto_tree_add_uint_bits(rab_tree, hf_ranap_trafficClass,
1635                             tvb, *offset, *bitoffset, 2, 0);
1636    proceed_nbits(offset, bitoffset, 2);
1637
1638    if (tmp_extension_present)
1639    {
1640       /* decoding is not supported */
1641       proto_tree_add_text(rab_tree, tvb, *offset, IE_PROTOCOL_EXTENSION_LENGTH,
1642                           "Protocol extension for trafficClass present, dissection not supported");
1643       return(-1);
1644    }
1645
1646
1647    /* rAB-AsymmetryIndicator */
1648    tmp_extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1649    proceed_nbits(offset, bitoffset, 1);
1650
1651    proto_tree_add_uint_bits(rab_tree, hf_ranap_rAB_AsymmetryIndicator,
1652                             tvb, *offset, *bitoffset, 2, 0);
1653    proceed_nbits(offset, bitoffset, 2);
1654
1655    if (tmp_extension_present)
1656    {
1657       /* decoding is not supported */
1658       proto_tree_add_text(rab_tree, tvb, *offset, IE_PROTOCOL_EXTENSION_LENGTH,
1659                           "Protocol extension for rAB-AsymmetryIndicator present, dissection not supported");
1660       return(-1);
1661    }
1662
1663
1664    /* maxBitrate */
1665    tmp_byte = extract_nbits(tvb, *offset, *bitoffset, 1) +1 ;  /*sequence 1..2 */
1666    proceed_nbits(offset, bitoffset, 1);
1667
1668    for (i=1; i<= tmp_byte; i++)
1669    {
1670       proto_tree_add_PERint32(rab_tree, hf_ranap_maxBitrate,
1671                               tvb, *offset, *bitoffset, &length, 1);
1672       proceed_perint32(offset, bitoffset, length);
1673    }
1674
1675
1676    /* guaranteedBitRate */
1677    if (guaranteedBitRate_present)
1678    {
1679       tmp_byte = extract_nbits(tvb, *offset, *bitoffset, 1) +1 ;  /*sequence 1..2 */
1680       proceed_nbits(offset, bitoffset, 1);
1681
1682       for (i=1; i<= tmp_byte; i++)
1683       {
1684         proto_tree_add_PERint32(rab_tree, hf_ranap_guaranteedBitrate,
1685                                 tvb, *offset, *bitoffset, &length, 0);
1686         proceed_perint32(offset, bitoffset, length);
1687       }
1688    }
1689
1690    /* deliveryOrder */
1691    proto_tree_add_uint_bits(rab_tree, hf_ranap_deliveryOrder, tvb, *offset,
1692                             *bitoffset, 1, 0);
1693    proceed_nbits(offset, bitoffset, 1);
1694
1695
1696    /* maxSDU-Size */
1697    allign(offset, bitoffset);
1698    proto_tree_add_item(rab_tree, hf_ranap_maxSDU_Size,
1699                         tvb, *offset, maxSDU_Size_LENGTH, FALSE);
1700    *offset += maxSDU_Size_LENGTH;
1701
1702    /* sDU-Parameters */
1703    tmp_byte = extract_nbits(tvb, *offset, *bitoffset, 3) + 1; /*sequence 1..7 */
1704    proceed_nbits(offset, bitoffset, 3);
1705    for (i=1; i<= tmp_byte; i++)
1706    {
1707       if ((ret=dissect_sDU_Parameters(tvb, rab_tree, offset, bitoffset))!=0) return(ret);
1708    }
1709
1710    /* transferDelay  */
1711    if (transferDelay_present)
1712    {
1713       allign(offset, bitoffset);
1714       proto_tree_add_item(rab_tree, hf_ranap_transferDelay,
1715                           tvb, *offset, transferDelay_LENGTH, FALSE);
1716       *offset += transferDelay_LENGTH;
1717    }
1718
1719
1720    /* trafficHandlingPriority */
1721    if (trafficHandlingPriority_present)
1722    {
1723       proto_tree_add_uint_bits(rab_tree, hf_ranap_trafficHandlingPriority, tvb, *offset,
1724                                *bitoffset, 4, 0);
1725       proceed_nbits(offset, bitoffset, 4);
1726    }
1727
1728    /* allocationOrRetentionPriority */
1729    if (allocationOrRetentionPriority_present)
1730    {
1731       /* create subtree for */
1732       prio_item = proto_tree_add_text(rab_tree, tvb, *offset, 0,
1733                                       "allocationOrRetentionPriority");
1734       prio_tree = proto_item_add_subtree(prio_item, ett_ranap_allocationOrRetentionPriority);
1735
1736       /* protocol extension  present ? */
1737       tmp_extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1738       proceed_nbits(offset, bitoffset, 1);
1739
1740       /* iE Extension present ? */
1741       tmp_iE_Extensions_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1742       proceed_nbits(offset, bitoffset, 1);
1743
1744       /* allocationOrRetentionPriority */
1745       proto_tree_add_uint_bits(prio_tree, hf_ranap_priorityLevel, tvb, *offset,
1746                                *bitoffset, 4, 0);
1747       proceed_nbits(offset, bitoffset, 4);
1748
1749       /* pre-emptionCapability */
1750       proto_tree_add_uint_bits(prio_tree, hf_ranap_pre_emptionCapability, tvb, *offset,
1751                                *bitoffset, 1, 0);
1752       proceed_nbits(offset, bitoffset, 1);
1753
1754       /* pre-emptionVulnerability */
1755       proto_tree_add_uint_bits(prio_tree, hf_ranap_pre_emptionVulnerability, tvb, *offset,
1756                                *bitoffset, 1, 0);
1757       proceed_nbits(offset, bitoffset, 1);
1758
1759       /* queuingAllowed */
1760       proto_tree_add_uint_bits(prio_tree, hf_ranap_queuingAllowed, tvb, *offset,
1761                                *bitoffset, 1, 0);
1762       proceed_nbits(offset, bitoffset, 1);
1763
1764       if (tmp_iE_Extensions_present)
1765       {
1766          if ((ret=dissect_iE_Extension(tvb, prio_tree, offset, bitoffset,
1767                                            "AllocationOrRetentionPriority")) != 0)
1768                 return (ret);
1769       }
1770
1771       if (tmp_extension_present)
1772       {
1773          /* decoding is not supported */
1774          proto_tree_add_text(prio_tree, tvb, *offset, IE_PROTOCOL_EXTENSION_LENGTH,
1775                           "Protocol extension for rAB-allocationOrRetentionPriority present, dissection not supported");
1776          return(-1);
1777       }
1778    }
1779
1780    /* sourceStatisticsDescriptor */
1781    if (sourceStatisticsDescriptor_present)
1782    {
1783       /* protocol extension */
1784       tmp_extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1785       proceed_nbits(offset, bitoffset, 1);
1786
1787       if (tmp_extension_present)
1788       {
1789          /* decoding is not supported */
1790          proto_tree_add_text(prio_tree, tvb, *offset, IE_PROTOCOL_EXTENSION_LENGTH,
1791                           "Protocol extension for sourceStatisticsDescriptor present, dissection not supported");
1792          return(-1);
1793       }
1794
1795       proto_tree_add_uint_bits(rab_tree, hf_ranap_sourceStatisticsDescriptor, tvb, *offset,
1796                                *bitoffset, 1, 0);
1797       proceed_nbits(offset, bitoffset, 1);
1798     }
1799
1800     /* relocationRequirement */
1801     if (relocationRequirement_present)
1802     {
1803       /* protocol extension */
1804       tmp_extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1805       proceed_nbits(offset, bitoffset, 1);
1806
1807       if (tmp_extension_present)
1808       {
1809          /* decoding is not supported */
1810          proto_tree_add_text(prio_tree, tvb, *offset, IE_PROTOCOL_EXTENSION_LENGTH,
1811                           "Protocol extension for relocationRequirement present, dissection not supported");
1812          return(-1);
1813       }
1814
1815       proto_tree_add_uint_bits(rab_tree, hf_ranap_relocationRequirement, tvb, *offset,
1816                                *bitoffset, 1, 0);
1817       proceed_nbits(offset, bitoffset, 1);
1818     }
1819
1820
1821    /* iE-Extensions */
1822    if (iE_Extensions_present)
1823    {
1824      if ((ret=dissect_iE_Extension(tvb, rab_tree, offset, bitoffset, "rAB_Parameters" )) != 0 )
1825                 return (ret);
1826    }
1827
1828    /* extended */
1829    if (extension_present)
1830    {
1831       /* decoding is not supported */
1832       proto_tree_add_text(rab_tree, tvb, *offset, IE_PROTOCOL_EXTENSION_LENGTH,
1833                           "Protocol extension for rAB_Parameters present, dissection not supported");
1834       return(-1);
1835    }
1836
1837    return(0);
1838 }
1839
1840
1841
1842 static int
1843 dissect_TransportLayerAddress(tvbuff_t *tvb, proto_tree *ie_tree, gint *offset, gint *bitoffset)
1844 {
1845    gint         extension_present;
1846    gint         str_length;
1847
1848    extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1849    proceed_nbits(offset, bitoffset, 1);
1850    if (extension_present)
1851    {
1852       /* extended integer */
1853       proto_tree_add_text(ie_tree, tvb, *offset, 0,
1854                           "extension present for TransportLayerAddress, dissection not supported");
1855       return (-1);
1856    }
1857
1858    /* extract and add length of transportLayerAddress bitstring */
1859    str_length = extract_nbits(tvb, *offset, *bitoffset, 8) + 1;
1860    proto_tree_add_uint_bits(ie_tree, hf_ranap_transportLayerAddress_length,
1861                              tvb, *offset, *bitoffset, 8, 1);
1862    proceed_nbits(offset, bitoffset, 8);
1863    allign(offset, bitoffset);
1864
1865    /* add transportLayerAddress */
1866    proto_tree_add_bitstring(ie_tree, hf_ranap_transportLayerAddress, tvb, *offset,
1867                             *bitoffset, str_length);
1868    proceed_nbits(offset, bitoffset, str_length);
1869
1870    return (0);
1871 }
1872
1873
1874
1875 static int
1876 dissect_iuTransportAssociation(tvbuff_t *tvb, proto_tree *ie_tree, gint *offset, gint *bitoffset)
1877 {
1878    guint        extension_present;
1879    guint        choice_value;
1880
1881    /* extension present ? */
1882    extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1883    if (extension_present)
1884    {
1885       /* extended choice */
1886       proto_tree_add_text(ie_tree, tvb, *offset, 0,
1887                           "extension present for IuTransportAssociation, dissection not supported");
1888       return (-1);
1889    }
1890    proceed_nbits(offset, bitoffset, 1);
1891
1892    /* choice */
1893    choice_value = extract_nbits(tvb, *offset, *bitoffset, 1);
1894    proceed_nbits(offset, bitoffset, 1);
1895    allign(offset, bitoffset);
1896    if (choice_value == 0)
1897    {
1898       /*  gTP-TEI */
1899       proto_tree_add_item(ie_tree, hf_ranap_gTP_TEI, tvb, *offset, 4, FALSE);
1900       *offset += 4;
1901    }
1902    else
1903    {
1904       /* bindingID */
1905       proto_tree_add_item(ie_tree, hf_ranap_bindingID, tvb, *offset, 4, FALSE);
1906       *offset += 4;
1907    }
1908
1909    return (0);
1910 }
1911
1912
1913 static int
1914 dissect_transportLayerInformation(tvbuff_t *tvb, proto_tree *ie_tree, gint *offset, gint *bitoffset)
1915 {
1916    proto_item   *optionals_item = NULL;
1917    proto_tree   *optionals_tree = NULL;
1918    int          extension_present;
1919    int          iE_Extensions_present;
1920    int          ret;
1921
1922    /* create subtree for extension/optional/default bitmap */
1923    optionals_item = proto_tree_add_text(ie_tree, tvb, *offset, IE_PROTOCOL_EXTENSION_LENGTH,
1924                                       "TransportLayerInformation Extension/Optional/Default bitmap");
1925    optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
1926
1927
1928    /* protocol extension present ? */
1929    extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1930    proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
1931                             *offset, *bitoffset, 1, 0);
1932    proceed_nbits(offset, bitoffset, 1);
1933
1934    /* iE-Extensions present ? */
1935    iE_Extensions_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1936    proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present,
1937                             tvb, *offset, *bitoffset, 1, 0);
1938    proceed_nbits(offset, bitoffset, 1);
1939
1940
1941    /* transportLayerAddress */
1942    if ((ret=dissect_TransportLayerAddress(tvb, ie_tree, offset, bitoffset)) != 0)
1943        return (ret);
1944
1945    /* iuTransportAssociation */
1946    if ((ret=dissect_iuTransportAssociation(tvb, ie_tree, offset, bitoffset)) != 0)
1947       return (ret);
1948
1949    /* iE-Extensions */
1950    if (iE_Extensions_present)
1951    {
1952      if ((ret=dissect_iE_Extension(tvb, ie_tree, offset, bitoffset, "TransportLayerInformation" )) != 0 )
1953                 return (ret);
1954    }
1955
1956    /* protocol extension */
1957    if (extension_present)
1958    {
1959       /* extended sequence */
1960       proto_tree_add_text(ie_tree, tvb, *offset, 0,
1961                           "extension present for TransportLayerInformation, dissection not supported");
1962       return (-1);
1963    }
1964
1965    return(0);
1966 }
1967
1968
1969 static int
1970 dissect_dataVolumeList (tvbuff_t *tvb, proto_tree *ie_tree, gint *offset, gint *bitoffset, char *parname)
1971 {
1972    proto_item   *optionals_item = NULL;
1973    proto_tree   *optionals_tree = NULL;
1974    gint         extension_present;
1975    gint         dataVolumeReference_present;
1976    gint         iE_Extensions_present;
1977    gint         number_vol;
1978    gint         length;
1979    gint         i;
1980    int          ret;
1981
1982    /* number of volumes */
1983    number_vol = extract_nbits(tvb, *offset, *bitoffset, 1) + 1;
1984    proceed_nbits(offset, bitoffset, 1);
1985
1986    for (i=1; i<=number_vol; i++)
1987    {
1988       /* create subtree for extension/optional/default bitmap */
1989       optionals_item = proto_tree_add_text(ie_tree, tvb, *offset, 1,
1990                                            "%d. %s Extension/Optional/Default bitmap",
1991                                             i, parname);
1992       optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
1993
1994       /* protocol_extension present ? */
1995       extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1996       proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
1997                                *offset, *bitoffset, 1, 0);
1998       proceed_nbits(offset, bitoffset, 1);
1999
2000       /* dataVolumeReference present ? */
2001       dataVolumeReference_present = extract_nbits(tvb, *offset, *bitoffset, 1);
2002       proto_tree_add_uint_bits(optionals_tree, hf_ranap_dataVolumeReference_present, tvb,
2003                                *offset, *bitoffset, 1, 0);
2004       proceed_nbits(offset, bitoffset, 1);
2005
2006       /* iE_Extensions present ? */
2007       iE_Extensions_present = extract_nbits(tvb, *offset, *bitoffset, 1);
2008       proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present, tvb,
2009                                *offset, *bitoffset, 1, 0);
2010       proceed_nbits(offset, bitoffset, 1);
2011
2012
2013       /* UnsuccessfullyTransmittedDataVolume */
2014       proto_tree_add_PERint32(ie_tree, hf_ranap_dl_UnsuccessfullyTransmittedDataVolume,
2015                               tvb, *offset, *bitoffset, &length, 0);
2016       proceed_perint32(offset, bitoffset, length);
2017
2018       /* DataVolumeReference */
2019       if (dataVolumeReference_present)
2020       {
2021          proto_tree_add_uint_bits(ie_tree, hf_ranap_dataVolumeReference, tvb,
2022                                   *offset, *bitoffset, 8, 0);
2023          proceed_nbits(offset, bitoffset, 8);
2024       }
2025
2026      /* iE-Extensions */
2027      if (iE_Extensions_present)
2028      {
2029         if ((ret=dissect_iE_Extension(tvb, ie_tree, offset, bitoffset, "dl-dataVolumes" )) != 0)
2030              return(ret);
2031      }
2032
2033      /* protocol extended */
2034      if (extension_present)
2035      {
2036         /* extended sequence */
2037         /* decoding is not supported */
2038         proto_tree_add_text(ie_tree, tvb, *offset, IE_PROTOCOL_EXTENSION_LENGTH,
2039                           "Protocol extension for dl-dataVolumes present, dissection not supported");
2040         return(-1);
2041      }
2042   }
2043
2044   return (0);
2045
2046 }
2047
2048 static int
2049 dissect_cause(tvbuff_t *tvb, proto_tree *ie_tree, gint *offset, gint *bitoffset)
2050 {
2051    gint         extension_present;
2052    int          cause_choice;
2053
2054   /* protocol extension present ? */
2055   extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
2056   proceed_nbits(offset, bitoffset, 1);
2057   if (extension_present)
2058   {
2059      /* choice extension present */
2060      proto_tree_add_text(ie_tree, tvb, *offset, 0,
2061                           "extension present for cause, dissection not supported");
2062      return (-1);
2063   }
2064   cause_choice = extract_nbits(tvb, *offset, *bitoffset, 3);
2065   proto_tree_add_uint_bits(ie_tree, hf_ranap_cause_choice,
2066                            tvb, *offset, *bitoffset, 3, 0);
2067   proceed_nbits(offset, bitoffset, 3);
2068
2069   switch (cause_choice)
2070   {
2071      case CC_CauseRadioNetwork:
2072         proto_tree_add_uint_bits(ie_tree, hf_ranap_cause_value,
2073                                  tvb, *offset, *bitoffset, 6, 1);
2074         proceed_nbits(offset, bitoffset, 6);
2075         break;
2076      case CC_CauseTransmissionNetwork:
2077         proto_tree_add_uint_bits(ie_tree, hf_ranap_cause_value,
2078                                  tvb, *offset, *bitoffset, 4, 65);
2079         proceed_nbits(offset, bitoffset, 4);
2080         break;
2081      case CC_CauseNAS:
2082         proto_tree_add_uint_bits(ie_tree, hf_ranap_cause_value,
2083                                  tvb, *offset, *bitoffset, 4, 81);
2084         proceed_nbits(offset, bitoffset, 4);
2085         break;
2086      case CC_CauseProtocol:
2087         proto_tree_add_uint_bits(ie_tree, hf_ranap_cause_value,
2088                                  tvb, *offset, *bitoffset, 4, 97);
2089         proceed_nbits(offset, bitoffset, 4);
2090      case CC_CauseMisc:
2091         proto_tree_add_uint_bits(ie_tree, hf_ranap_cause_value,
2092                                  tvb, *offset, *bitoffset, 4, 113);
2093         proceed_nbits(offset, bitoffset, 4);
2094         break;
2095      case CC_CauseNon_Standard:
2096         proto_tree_add_uint_bits(ie_tree, hf_ranap_cause_value,
2097                                  tvb, *offset, *bitoffset, 7, 129);
2098         proceed_nbits(offset, bitoffset, 7);
2099         break;
2100      default:
2101        proto_tree_add_text(ie_tree, tvb, *offset, 0,
2102                             "unexpected cause choice value, dissection not supported");
2103        return(-1);
2104   }
2105   return(0);
2106 }
2107
2108
2109 static int
2110 dissect_iEsCriticalityDiagnostics(tvbuff_t *tvb, proto_tree *ie_tree, gint *offset, gint *bitoffset)
2111 {
2112    proto_item           *diag_item = NULL;
2113    proto_tree           *diag_tree = NULL;
2114    proto_item           *optionals_item = NULL;
2115    proto_tree           *optionals_tree = NULL;
2116    int                  extension_present;
2117    int                  repetitionNumber_present;
2118    int                  iE_Extensions_present;
2119    int                  num_of_errors;
2120    int                  i;
2121
2122    allign(offset, bitoffset);
2123    num_of_errors = extract_nbits(tvb, *offset, *bitoffset, 8) + 1;
2124    proto_tree_add_uint_bits(ie_tree, hf_ranap_num_of_CriticalityDiagnostics_IEs, tvb,
2125                             *offset, *bitoffset, 8, 1);
2126    proceed_nbits(offset, bitoffset, 8);
2127
2128    for ( i= 1; i <= num_of_errors; i++)
2129    {
2130       /* add subtree for CriticalityDiagnostics-IE */
2131       diag_item = proto_tree_add_text(ie_tree, tvb, *offset, 0,
2132                                       "%d. CriticalityDiagnostics-IE", i);
2133       diag_tree = proto_item_add_subtree(diag_item, ett_ranap_CriticalityDiagnostics_IE);
2134
2135       /* create subtree for extension/optional/default bitmap */
2136       optionals_item = proto_tree_add_text(diag_tree, tvb, *offset, 1,
2137                                          "CriticalityDiagnostics-IE Extension/Optional/Default bitmap");
2138       optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
2139
2140       /* protocol_extension present ? */
2141       extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
2142       proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
2143                                *offset, *bitoffset, 1, 0);
2144       proceed_nbits(offset, bitoffset, 1);
2145
2146       /* repetitionNumber present ? */
2147       repetitionNumber_present = extract_nbits(tvb, *offset, *bitoffset, 1);
2148       proto_tree_add_uint_bits(optionals_tree, hf_ranap_repetitionNumber_present, tvb,
2149                                *offset, *bitoffset, 1, 0);
2150       proceed_nbits(offset, bitoffset, 1);
2151
2152       /* iE_Extensions present ? */
2153       iE_Extensions_present = extract_nbits(tvb, *offset, *bitoffset, 1);
2154       proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present,
2155                                tvb, *offset, *bitoffset, 1, 0);
2156       proceed_nbits(offset, bitoffset, 1);
2157
2158       /* iECriticality */
2159       proto_tree_add_uint_bits(diag_tree, hf_ranap_iECriticality,
2160                                tvb, *offset, *bitoffset, 2, 0);
2161       proceed_nbits(offset, bitoffset, 2);
2162
2163       /* iE-ID */
2164       allign(offset, bitoffset);
2165       proto_tree_add_item(diag_tree, hf_ranap_ie_ie_id, tvb,
2166                           *offset, IE_ID_LENGTH, FALSE);
2167       *offset += IE_ID_LENGTH;
2168
2169       /* repetitionNumber */
2170       if (repetitionNumber_present)
2171       {
2172          allign(offset, bitoffset);
2173          proto_tree_add_uint_bits(diag_tree, hf_ranap_repetitionNumber,
2174                                   tvb, *offset, *bitoffset, 8, 1);
2175          proceed_nbits(offset, bitoffset, 8);
2176       }
2177
2178       /* iE-Extensions */
2179       if (iE_Extensions_present)
2180       {
2181         return(dissect_iE_Extension(tvb, diag_tree, offset, bitoffset, "CriticalityDiagnostics-IE"));
2182       }
2183
2184
2185       /* protocol extended */
2186       if (extension_present)
2187       {
2188          /* extended sequence */
2189          /* decoding is not supported */
2190          proto_tree_add_text(diag_tree, tvb, *offset, IE_PROTOCOL_EXTENSION_LENGTH,
2191                           "Protocol extension for CriticalityDiagnostics-IE present, dissection not supported");
2192          return(-1);
2193       }
2194    }
2195
2196    return(0);
2197 }
2198
2199
2200
2201 /*****************************************************************************/
2202 /*                                                                           */
2203 /*  Dissecting Functions for IEs                                             */
2204 /*                                                                           */
2205 /*****************************************************************************/
2206
2207 static int
2208 dissect_IE_RAB_ID(tvbuff_t *tvb, proto_tree *ie_tree)
2209 {
2210   if (ie_tree)
2211   {
2212        proto_tree_add_item(ie_tree, hf_ranap_rab_id, tvb,
2213                            0, RAB_ID_LENGTH, FALSE);
2214   }
2215   return(0);
2216 }
2217
2218
2219 static int
2220 dissect_IE_RAC(tvbuff_t *tvb, proto_tree *ie_tree)
2221 {
2222   if (ie_tree)
2223   {
2224        proto_tree_add_item(ie_tree, hf_ranap_rac, tvb,
2225                            0, RAC_LENGTH, FALSE);
2226   }
2227   return(0);
2228 }
2229
2230
2231 static int
2232 dissect_IE_LAI(tvbuff_t *tvb, proto_tree *ie_tree)
2233 {
2234   proto_item    *optionals_item = NULL;
2235   proto_tree    *optionals_tree = NULL;
2236   int           iE_Extensions_present;
2237   gint          offset = 0;
2238   gint          bitoffset = 0;
2239   int           ret;
2240
2241   if (ie_tree)
2242   {
2243       /* create subtree for extension/optional/default bitmap */
2244      optionals_item = proto_tree_add_text(ie_tree, tvb, offset, 1,
2245                                       "LAI Extension/Optional/Default bitmap");
2246      optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
2247
2248      /* iE_Extensions_present present ? */
2249      iE_Extensions_present = extract_nbits(tvb, offset, bitoffset, 1);
2250      proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present, tvb,
2251                               offset, bitoffset, 1, 0);
2252      proceed_nbits(&offset, &bitoffset, 1);
2253
2254      /* plmn_id */
2255      allign(&offset, &bitoffset);
2256      proto_tree_add_item(ie_tree, hf_ranap_plmn_id, tvb,
2257                          offset, PLMN_ID_LENGTH, FALSE);
2258      offset += PLMN_ID_LENGTH;
2259
2260      /* lac */
2261      proto_tree_add_item(ie_tree, hf_ranap_lac, tvb,
2262                          offset, LAC_LENGTH, FALSE);
2263      offset += LAC_LENGTH;
2264
2265      /* iE_Extensions */
2266      if (iE_Extensions_present)
2267      {
2268         if ((ret=dissect_iE_Extension(tvb, ie_tree, &offset, &bitoffset, "LAI")) != 0)
2269              return (ret);
2270      }
2271   }
2272   return(0);
2273 }
2274
2275
2276 static int
2277 dissect_IE_GlobalRNC_ID(tvbuff_t *tvb, proto_tree *ie_tree)
2278 {
2279   gint          offset = 0;
2280
2281   if (ie_tree)
2282   {
2283      /*  plmn_id */
2284      proto_tree_add_item(ie_tree, hf_ranap_plmn_id, tvb,
2285                            offset, PLMN_ID_LENGTH, FALSE);
2286      offset += PLMN_ID_LENGTH;
2287
2288      /* RNC ID */
2289      proto_tree_add_item(ie_tree, hf_ranap_RNC_ID, tvb, offset, 2, FALSE);
2290      offset += 2;
2291   }
2292
2293   return(0);
2294 }
2295
2296
2297 static int
2298 dissect_IE_SAI(tvbuff_t *tvb, proto_tree *ie_tree)
2299 {
2300   proto_item    *optionals_item = NULL;
2301   proto_tree    *optionals_tree = NULL;
2302   int           iE_Extensions_present;
2303   gint          offset = 0;
2304   gint          bitoffset = 0;
2305   int           ret;
2306
2307   if (ie_tree)
2308   {
2309       /* create subtree for extension/optional/default bitmap */
2310      optionals_item = proto_tree_add_text(ie_tree, tvb, offset, 1,
2311                                       "SAI Extension/Optional/Default bitmap");
2312      optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
2313
2314      /* iE_Extensions_present present ? */
2315      iE_Extensions_present = extract_nbits(tvb, offset, bitoffset, 1);
2316      proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present, tvb,
2317                               offset, bitoffset, 1, 0);
2318      proceed_nbits(&offset, &bitoffset, 1);
2319
2320      /*  plmn_id */
2321      allign(&offset, &bitoffset);
2322      proto_tree_add_item(ie_tree, hf_ranap_plmn_id, tvb,
2323                            offset, PLMN_ID_LENGTH, FALSE);
2324      offset += PLMN_ID_LENGTH;
2325
2326      /* lac */
2327      proto_tree_add_item(ie_tree, hf_ranap_lac, tvb,
2328                            offset, LAC_LENGTH, FALSE);
2329      offset += LAC_LENGTH;
2330
2331      /* sac */
2332      proto_tree_add_item(ie_tree, hf_ranap_sac, tvb,
2333                            offset, SAC_LENGTH, FALSE);
2334      offset += SAC_LENGTH;
2335
2336      /* iE_Extensions */
2337      if (iE_Extensions_present)
2338      {
2339         if ((ret=dissect_iE_Extension(tvb, ie_tree, &offset, &bitoffset, "SAI")) != 0)
2340              return (ret);
2341      }
2342   }
2343   return(0);
2344 }
2345
2346
2347 static int
2348 dissect_IE_NAS_PDU(tvbuff_t *tvb, proto_tree *ie_tree)
2349 {
2350    tvbuff_t             *next_tvb;
2351    gint                 length;
2352    gint                 length_size;
2353
2354    if (extract_length(tvb, 0, &length, &length_size) != 0)
2355    {
2356       if (ie_tree)
2357       {
2358            /* decoding is not supported */
2359            proto_tree_add_text(ie_tree, tvb, 0,
2360                                2, "Number of Octets greater than 0x3FFF, dissection not supported");
2361       }
2362       return(-1);
2363    }
2364
2365    if (ie_tree)
2366    {
2367        /* NAS - PDU length */
2368        proto_tree_add_item(ie_tree, hf_ranap_nas_pdu_length, tvb,
2369                            0, length_size, FALSE);
2370    }
2371
2372    if (ie_tree)
2373    {
2374        /* NAS - PDU */
2375        proto_tree_add_item(ie_tree, hf_ranap_nas_pdu, tvb,
2376                            length_size, length, FALSE);
2377    }
2378
2379    /* call NAS dissector */
2380    next_tvb = tvb_new_subset(tvb, length_size, length, length);
2381
2382    if (dissector_try_port(nas_pdu_dissector_table, 0x1, next_tvb, g_pinfo, g_tree)) return(0);
2383    return(0);
2384 }
2385
2386
2387 static int
2388 dissect_IE_CN_DomainIndicator(tvbuff_t *tvb, proto_tree *ie_tree)
2389 {
2390   gint          offset = 0;
2391   gint          bitoffset = 0;
2392
2393   if (ie_tree)
2394   {
2395      proto_tree_add_uint_bits(ie_tree, hf_ranap_CN_DomainIndicator, tvb,
2396                               offset, bitoffset, 1, 0);
2397   }
2398   return(0);
2399 }
2400
2401
2402 static int
2403 dissect_IE_IuSigConId(tvbuff_t *tvb, proto_tree *ie_tree)
2404 {
2405   guint32       value;
2406
2407   if (ie_tree)
2408   {
2409      value = tvb_get_ntoh24(tvb, 0);
2410      proto_tree_add_uint(ie_tree, hf_ranap_IuSigConId,
2411         tvb, 0, 3, value);
2412
2413   }
2414   return(0);
2415 }
2416
2417
2418 static int
2419 dissect_IE_SAPI(tvbuff_t *tvb, proto_tree *ie_tree)
2420 {
2421   gint          offset = 0;
2422   gint          bitoffset = 0;
2423   int           extension_present;
2424
2425   if (ie_tree)
2426   {
2427      /* protocol_extension present ? */
2428      extension_present = extract_nbits(tvb, offset, bitoffset, 1);
2429      proceed_nbits(&offset, &bitoffset, 1);
2430
2431      if (extension_present)
2432      {
2433         /* extended enum */
2434         /* decoding is not supported */
2435         proto_tree_add_text(ie_tree, tvb, offset, IE_PROTOCOL_EXTENSION_LENGTH,
2436                           "Protocol extension for IE_SAPI present, dissection not supported");
2437         return(-1);
2438      }
2439
2440      /* SAPI */
2441      proto_tree_add_uint_bits(ie_tree, hf_ranap_SAPI, tvb,
2442                               offset, bitoffset, 1, 0);
2443   }
2444   return(0);
2445 }
2446
2447
2448 static int
2449 dissect_IE_TransportLayerAddress(tvbuff_t *tvb, proto_tree *ie_tree)
2450 {
2451   gint          offset = 0;
2452   gint          bitoffset = 0;
2453
2454   if (ie_tree)
2455   {
2456      return(dissect_TransportLayerAddress(tvb, ie_tree, &offset, &bitoffset));
2457   }
2458   return(0);
2459 }
2460
2461
2462 static int
2463 dissect_IE_IuTransportAssociation(tvbuff_t *tvb, proto_tree *ie_tree)
2464 {
2465   gint          offset = 0;
2466   gint          bitoffset = 0;
2467
2468   if (ie_tree)
2469   {
2470      return(dissect_iuTransportAssociation(tvb, ie_tree, &offset, &bitoffset));
2471   }
2472   return(0);
2473 }
2474
2475
2476 static int
2477 dissect_IE_Cause(tvbuff_t *tvb, proto_tree *ie_tree)
2478 {
2479   gint          offset = 0;
2480   gint          bitoffset = 0;
2481
2482   if (ie_tree)
2483   {
2484      return(dissect_cause(tvb, ie_tree, &offset, &bitoffset));
2485   }
2486   return(0);
2487 }
2488
2489
2490 static int
2491 dissect_IE_RAB_ReleasedItem_IuRelComp(tvbuff_t *tvb, proto_tree *ie_tree)
2492 {
2493    proto_item   *optionals_item = NULL;
2494    proto_tree   *optionals_tree = NULL;
2495    int          extension_present;
2496    int          dl_GTP_PDU_SequenceNumber_present;
2497    int          ul_GTP_PDU_SequenceNumber_present;
2498    int          iE_Extensions_present;
2499    gint         offset = 0;
2500    gint         bitoffset = 0;
2501    int          ret;
2502
2503   if (ie_tree)
2504   {
2505      /* create subtree for extension/optional/default bitmap */
2506      optionals_item = proto_tree_add_text(ie_tree, tvb, offset, 1,
2507                                       "RAB_ReleasedItem_IuRelComp Extension/Optional/Default bitmap");
2508      optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
2509
2510      /* protocol_extension present ? */
2511      extension_present = extract_nbits(tvb, offset, bitoffset, 1);
2512      proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
2513                               offset, bitoffset, 1, 0);
2514      proceed_nbits(&offset, &bitoffset, 1);
2515
2516      /* dl_GTP_PDU_SequenceNumber present ? */
2517      dl_GTP_PDU_SequenceNumber_present = extract_nbits(tvb, offset, bitoffset, 1);
2518      proto_tree_add_uint_bits(optionals_tree, hf_ranap_dl_GTP_PDU_SequenceNumber_present, tvb,
2519                               offset, bitoffset, 1, 0);
2520      proceed_nbits(&offset, &bitoffset, 1);
2521
2522      /* ul_GTP_PDU_SequenceNumber present ? */
2523      ul_GTP_PDU_SequenceNumber_present = extract_nbits(tvb, offset, bitoffset, 1);
2524      proto_tree_add_uint_bits(optionals_tree, hf_ranap_ul_GTP_PDU_SequenceNumber_present, tvb,
2525                               offset, bitoffset, 1, 0);
2526      proceed_nbits(&offset, &bitoffset, 1);
2527
2528      /* iE_Extensions_present present ? */
2529      iE_Extensions_present = extract_nbits(tvb, offset, bitoffset, 1);
2530      proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present, tvb,
2531                               offset, bitoffset, 1, 0);
2532      proceed_nbits(&offset, &bitoffset, 1);
2533
2534
2535      /* rAB-ID */
2536      proto_tree_add_uint_bits(ie_tree, hf_ranap_rab_id,
2537                              tvb, offset, bitoffset, 8, 0);
2538      proceed_nbits(&offset, &bitoffset, 8);
2539
2540      /* dl-GTP-PDU-SequenceNumber */
2541      if (dl_GTP_PDU_SequenceNumber_present)
2542      {
2543         allign(&offset, &bitoffset);
2544         proto_tree_add_item(ie_tree, hf_ranap_dl_GTP_PDU_SequenceNumber, tvb, offset, 2, FALSE);
2545         offset += 2;
2546      }
2547
2548      /* ul-GTP-PDU-SequenceNumber */
2549      if (ul_GTP_PDU_SequenceNumber_present)
2550      {
2551         allign(&offset, &bitoffset);
2552         proto_tree_add_item(ie_tree, hf_ranap_ul_GTP_PDU_SequenceNumber, tvb, offset, 2, FALSE);
2553         offset += 2;
2554      }
2555
2556      /* iE-Extensions */
2557      if (iE_Extensions_present)
2558      {
2559         if ((ret=dissect_iE_Extension(tvb, ie_tree, &offset, &bitoffset, "RAB_ReleasedItem_IuRelComp")) != 0)
2560              return (ret);
2561      }
2562
2563      /* protocol extended */
2564      if (extension_present)
2565      {
2566         /* extended sequence */
2567         /* decoding is not supported */
2568         proto_tree_add_text(ie_tree, tvb, offset, IE_PROTOCOL_EXTENSION_LENGTH,
2569                           "Protocol extension for RAB_ReleasedItem_IuRelComp present, dissection not supported");
2570         return(-1);
2571      }
2572   }
2573   return(0);
2574 }
2575
2576
2577 static int
2578 dissect_IE_RAB_DataVolumeReportItem(tvbuff_t *tvb, proto_tree *ie_tree)
2579 {
2580    proto_item   *optionals_item = NULL;
2581    proto_tree   *optionals_tree = NULL;
2582    int          extension_present;
2583    int          dl_UnsuccessfullyTransmittedDataVolume_present;
2584    int          iE_Extensions_present;
2585    gint         offset = 0;
2586    gint         bitoffset = 0;
2587    int          ret;
2588
2589   if (ie_tree)
2590   {
2591      /* create subtree for extension/optional/default bitmap */
2592      optionals_item = proto_tree_add_text(ie_tree, tvb, offset, 1,
2593                                       "RAB_DataVolumeReportItem Extension/Optional/Default bitmap");
2594      optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
2595
2596      /* protocol_extension present ? */
2597      extension_present = extract_nbits(tvb, offset, bitoffset, 1);
2598      proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
2599                               offset, bitoffset, 1, 0);
2600      proceed_nbits(&offset, &bitoffset, 1);
2601
2602      /* dl_UnsuccessfullyTransmittedDataVolume present ? */
2603      dl_UnsuccessfullyTransmittedDataVolume_present = extract_nbits(tvb, offset, bitoffset, 1);
2604      proto_tree_add_uint_bits(optionals_tree, hf_ranap_dl_UnsuccessfullyTransmittedDataVolume_present, tvb,
2605                               offset, bitoffset, 1, 0);
2606      proceed_nbits(&offset, &bitoffset, 1);
2607
2608      /* iE_Extensions_present present ? */
2609      iE_Extensions_present = extract_nbits(tvb, offset, bitoffset, 1);
2610      proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present, tvb,
2611                               offset, bitoffset, 1, 0);
2612      proceed_nbits(&offset, &bitoffset, 1);
2613
2614
2615      /* rAB-ID */
2616      proto_tree_add_uint_bits(ie_tree, hf_ranap_rab_id,
2617                              tvb, offset, bitoffset, 8, 0);
2618      proceed_nbits(&offset, &bitoffset, 8);
2619
2620      /* dl_UnsuccessfullyTransmittedDataVolume */
2621      if (dl_UnsuccessfullyTransmittedDataVolume_present)
2622      {
2623
2624         if ((ret = dissect_dataVolumeList(tvb, ie_tree, &offset, &bitoffset,
2625              "dl_UnsuccessfullyTransmittedDataVolume")) != 0)
2626             return (ret);
2627      }
2628
2629      /* iE-Extensions */
2630      if (iE_Extensions_present)
2631      {
2632         if ((ret=dissect_iE_Extension(tvb, ie_tree, &offset, &bitoffset, "IE_RAB_DataVolumeReportItem")) != 0)
2633              return (ret);
2634      }
2635
2636      /* protocol extended */
2637      if (extension_present)
2638      {
2639         /* extended enum */
2640         /* decoding is not supported */
2641         proto_tree_add_text(ie_tree, tvb, offset, IE_PROTOCOL_EXTENSION_LENGTH,
2642                           "Protocol extension for IE_RAB_DataVolumeReportItem present, dissection not supported");
2643         return(-1);
2644      }
2645   }
2646   return(0);
2647 }
2648
2649
2650 static int
2651 dissect_IE_RAB_SetupOrModifyItemSecond(tvbuff_t *tvb, proto_tree *ie_tree)
2652 {
2653    proto_item   *optionals_item = NULL;
2654    proto_tree   *optionals_tree = NULL;
2655    int          extension_present;
2656    int          tmp_extension;
2657    int          pDP_TypeInformation_present;
2658    int          dataVolumeReportingIndication_present;
2659    int          dl_GTP_PDU_SequenceNumber_present;
2660    int          ul_GTP_PDU_SequenceNumber_present;
2661    int          dl_N_PDU_SequenceNumber_present;
2662    int          ul_N_PDU_SequenceNumber_present;
2663    int          iE_Extensions_present;
2664    gint         offset = 0;
2665    gint         bitoffset = 0;
2666    gint8        tmp_byte;
2667    gint         i;
2668    int          ret;
2669
2670   if (ie_tree)
2671   {
2672      /* create subtree for extension/optional/default bitmap */
2673      optionals_item = proto_tree_add_text(ie_tree, tvb, offset, 1,
2674                                       "SetupOrModifyItemSecond Extension/Optional/Default bitmap");
2675      optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
2676
2677      /* protocol_extension present ? */
2678      extension_present = extract_nbits(tvb, offset, bitoffset, 1);
2679      proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
2680                               offset, bitoffset, 1, 0);
2681      proceed_nbits(&offset, &bitoffset, 1);
2682
2683      /* pDP_TypeInformation present ? */
2684      pDP_TypeInformation_present = extract_nbits(tvb, offset, bitoffset, 1);
2685      proto_tree_add_uint_bits(optionals_tree, hf_ranap_pDP_TypeInformation_present, tvb,
2686                               offset, bitoffset, 1, 0);
2687      proceed_nbits(&offset, &bitoffset, 1);
2688
2689      /* dataVolumeReportingIndication present ? */
2690      dataVolumeReportingIndication_present = extract_nbits(tvb, offset, bitoffset, 1);
2691      proto_tree_add_uint_bits(optionals_tree, hf_ranap_dataVolumeReportingIndication_present, tvb,
2692                               offset, bitoffset, 1, 0);
2693      proceed_nbits(&offset, &bitoffset, 1);
2694
2695      /* dl_GTP_PDU_SequenceNumber present present ? */
2696      dl_GTP_PDU_SequenceNumber_present = extract_nbits(tvb, offset, bitoffset, 1);
2697      proto_tree_add_uint_bits(optionals_tree, hf_ranap_dl_GTP_PDU_SequenceNumber_present, tvb,
2698                               offset, bitoffset, 1, 0);
2699      proceed_nbits(&offset, &bitoffset, 1);
2700
2701
2702      /* ul_GTP_PDU_SequenceNumber present ? */
2703      ul_GTP_PDU_SequenceNumber_present = extract_nbits(tvb, offset, bitoffset, 1);
2704      proto_tree_add_uint_bits(optionals_tree, hf_ranap_ul_GTP_PDU_SequenceNumber_present, tvb,
2705                               offset, bitoffset, 1, 0);
2706      proceed_nbits(&offset, &bitoffset, 1);
2707
2708      /* dl_N_PDU_SequenceNumber present ? */
2709      dl_N_PDU_SequenceNumber_present = extract_nbits(tvb, offset, bitoffset, 1);
2710      proto_tree_add_uint_bits(optionals_tree, hf_ranap_dl_N_PDU_SequenceNumber_present, tvb,
2711                               offset, bitoffset, 1, 0);
2712      proceed_nbits(&offset, &bitoffset, 1);
2713
2714      /* ul_N_PDU_SequenceNumber present ? */
2715      ul_N_PDU_SequenceNumber_present = extract_nbits(tvb, offset, bitoffset, 1);
2716      proto_tree_add_uint_bits(optionals_tree, hf_ranap_ul_N_PDU_SequenceNumber_present, tvb,
2717                               offset, bitoffset, 1, 0);
2718      proceed_nbits(&offset, &bitoffset, 1);
2719
2720      /* iE_Extensions present ? */
2721      iE_Extensions_present = extract_nbits(tvb, offset, bitoffset, 1);
2722      proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present, tvb,
2723                               offset, bitoffset, 1, 0);
2724      proceed_nbits(&offset, &bitoffset, 1);
2725
2726      /* pDP-TypeInformation */
2727      if (pDP_TypeInformation_present)
2728      {
2729         tmp_byte = extract_nbits(tvb, offset, bitoffset, 1) + 1;    /* Sequence 1..2 */
2730         proceed_nbits(&offset, &bitoffset, 1);
2731         for (i=1; i<=tmp_byte; i++)
2732         {
2733            tmp_extension = extract_nbits(tvb, offset, bitoffset, 1);
2734            proceed_nbits(&offset, &bitoffset, 1);
2735            if (tmp_extension != 0)
2736            {
2737               /* extended enum */
2738               /* decoding is not supported */
2739               proto_tree_add_text(ie_tree, tvb, offset, IE_PROTOCOL_EXTENSION_LENGTH,
2740                                   "Protocol extension for PDP-Type present, dissection not supported");
2741               return(-1);
2742            }
2743
2744            proto_tree_add_uint_bits(ie_tree, hf_ranap_PDP_Type, tvb,
2745                                     offset, bitoffset, 3, 0);
2746            proceed_nbits(&offset, &bitoffset, 3);
2747         }
2748      }
2749
2750      /* dataVolumeReportingIndication */
2751      if (dataVolumeReportingIndication_present)
2752      {
2753        proto_tree_add_uint_bits(ie_tree, hf_ranap_dataVolumeReportingIndication, tvb,
2754                                 offset, bitoffset, 1, 0);
2755        proceed_nbits(&offset, &bitoffset, 1);
2756      }
2757
2758      /* dl-GTP-PDU-SequenceNumber */
2759      if (dl_GTP_PDU_SequenceNumber_present)
2760      {
2761         allign(&offset, &bitoffset);
2762         proto_tree_add_item(ie_tree, hf_ranap_dl_GTP_PDU_SequenceNumber, tvb, offset, 2, FALSE);
2763         offset += 2;
2764      }
2765
2766      /* ul-GTP-PDU-SequenceNumber */
2767      if (ul_GTP_PDU_SequenceNumber_present)
2768      {
2769         allign(&offset, &bitoffset);
2770         proto_tree_add_item(ie_tree, hf_ranap_ul_GTP_PDU_SequenceNumber, tvb, offset, 2, FALSE);
2771         offset += 2;
2772      }
2773
2774      /* dl-N-PDU-SequenceNumber */
2775      if (dl_N_PDU_SequenceNumber_present)
2776      {
2777         allign(&offset, &bitoffset);
2778         proto_tree_add_item(ie_tree, hf_ranap_dl_N_PDU_SequenceNumber, tvb, offset, 2, FALSE);
2779         offset += 2;
2780      }
2781
2782      /* ul-N-PDU-SequenceNumber */
2783      if (ul_N_PDU_SequenceNumber_present)
2784      {
2785         allign(&offset, &bitoffset);
2786         proto_tree_add_item(ie_tree, hf_ranap_ul_N_PDU_SequenceNumber, tvb, offset, 2, FALSE);
2787         offset += 2;
2788      }
2789
2790      /* iE-Extensions */
2791      if (iE_Extensions_present)
2792      {
2793         if ((ret=dissect_iE_Extension(tvb, ie_tree, &offset, &bitoffset, "SetupOrModifyItemSecond")) != 0)
2794              return (ret);
2795      }
2796
2797      /* protocol extended */
2798      if (extension_present)
2799      {
2800         /* extended enum */
2801         /* decoding is not supported */
2802         proto_tree_add_text(ie_tree, tvb, offset, IE_PROTOCOL_EXTENSION_LENGTH,
2803                           "Protocol extension for SetupOrModifyItemSecond present, dissection not supported");
2804         return(-1);
2805      }
2806   }
2807   return(0);
2808 }
2809
2810
2811 static int
2812 dissect_IE_RAB_SetupOrModifiedItem (tvbuff_t *tvb, proto_tree *ie_tree)
2813 {
2814    proto_item   *optionals_item = NULL;
2815    proto_tree   *optionals_tree = NULL;
2816    int          ret;
2817    int          extension_present;
2818    int          transportLayerAddress_present;
2819    int          iuTransportAssociation_present;
2820    int          dl_dataVolumes_present;
2821    int          iE_Extensions_present;
2822    gint         offset = 0;
2823    gint         bitoffset = 0;
2824
2825
2826   if (ie_tree)
2827   {
2828      /* create subtree for extension/optional/default bitmap */
2829      optionals_item = proto_tree_add_text(ie_tree, tvb, offset, 1,
2830                                         "RAB-SetupOrModifiedItem Extension/Optional/Default bitmap");
2831      optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
2832
2833      /* protocol_extension present ? */
2834      extension_present = extract_nbits(tvb, offset, bitoffset, 1);
2835      proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
2836                               offset, bitoffset, 1, 0);
2837      proceed_nbits(&offset, &bitoffset, 1);
2838
2839      /* transportLayerAddress present ? */
2840      transportLayerAddress_present = extract_nbits(tvb, offset, bitoffset, 1);
2841      proto_tree_add_uint_bits(optionals_tree, hf_ranap_transportLayerAddress_present, tvb,
2842                               offset, bitoffset, 1, 0);
2843      proceed_nbits(&offset, &bitoffset, 1);
2844
2845      /* iuTransportAssociation present ? */
2846      iuTransportAssociation_present = extract_nbits(tvb, offset, bitoffset, 1);
2847      proto_tree_add_uint_bits(optionals_tree, hf_ranap_iuTransportAssociation_present, tvb,
2848                               offset, bitoffset, 1, 0);
2849      proceed_nbits(&offset, &bitoffset, 1);
2850
2851      /* dl_dataVolumes present ? */
2852      dl_dataVolumes_present = extract_nbits(tvb, offset, bitoffset, 1);
2853      proto_tree_add_uint_bits(optionals_tree, hf_ranap_dl_dataVolumes_present, tvb,
2854                               offset, bitoffset, 1, 0);
2855      proceed_nbits(&offset, &bitoffset, 1);
2856
2857      /* iE_Extensions present ? */
2858      iE_Extensions_present = extract_nbits(tvb, offset, bitoffset, 1);
2859      proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present, tvb,
2860                               offset, bitoffset, 1, 0);
2861      proceed_nbits(&offset, &bitoffset, 1);
2862
2863
2864      /* rAB-ID */
2865      proto_tree_add_uint_bits(ie_tree, hf_ranap_rab_id,
2866                              tvb, offset, bitoffset, 8, 0);
2867      proceed_nbits(&offset, &bitoffset, 8);
2868
2869      /* transportLayerAddress */
2870      if (transportLayerAddress_present)
2871      {
2872         if ((ret=dissect_TransportLayerAddress(tvb, ie_tree, &offset, &bitoffset)) != 0)
2873             return (ret);
2874      }
2875
2876      /* iuTransportAssociation  */
2877      if (iuTransportAssociation_present)
2878      {
2879         if ((ret=dissect_iuTransportAssociation(tvb, ie_tree, &offset, &bitoffset)) != 0)
2880             return (ret);
2881      }
2882
2883      /* dl-dataVolumes  */
2884      if (dl_dataVolumes_present)
2885      {
2886         if ((ret = dissect_dataVolumeList(tvb, ie_tree, &offset, &bitoffset,
2887                                           "dl-dataVolumes")) != 0)
2888             return (ret);
2889      }
2890
2891      /* iE-Extensions   */
2892      if (iE_Extensions_present)
2893      {
2894        if ((ret=dissect_iE_Extension(tvb, ie_tree, &offset, &bitoffset, "RAB_SetupOrModifiedItem")) != 0)
2895            return (ret);
2896      }
2897
2898      /* protocol extended */
2899      if (extension_present)
2900      {
2901         /* extended sequence */
2902         /* decoding is not supported */
2903         proto_tree_add_text(ie_tree, tvb, offset, IE_PROTOCOL_EXTENSION_LENGTH,
2904                           "Protocol extension for RAB_SetupOrModifiedItem present, dissection not supported");
2905         return(-1);
2906      }
2907   }
2908
2909   return (0);
2910 }
2911
2912
2913 static int
2914 dissect_IE_RAB_SetupOrModifyItemFirst (tvbuff_t *tvb, proto_tree *ie_tree)
2915 {
2916   gint          offset;
2917   gint          bitoffset;
2918   proto_item    *optionals_item = NULL;
2919   proto_tree    *optionals_tree = NULL;
2920   int           extension_present;
2921   int           nAS_SynchronisationIndicator_present;
2922   int           rAB_Parameters_present;
2923   int           userPlaneInformation_present;
2924   int           transportLayerInformation_present;
2925   int           service_Handover_present;
2926   int           iE_Extensions_present;
2927   int           tmp_extension_present;
2928   int           ret;
2929
2930   if (ie_tree)
2931   {
2932     offset = 0; bitoffset = 0;
2933
2934     /* create subtree for extension/optional/default bitmap */
2935     optionals_item = proto_tree_add_text(ie_tree, tvb, offset,IE_PROTOCOL_EXTENSION_LENGTH,
2936                                       "RAB_SetupOrModifyItemFirst Extension/Optional/Default bitmap");
2937     optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
2938
2939     /* protocol extension present ? */
2940     extension_present = extract_nbits(tvb, offset, bitoffset, 1);
2941     proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension,
2942                              tvb, offset, bitoffset, 1, 0);
2943     proceed_nbits(&offset, &bitoffset, 1);
2944
2945     /* nAS_SynchronisationIndicator present ? */
2946     nAS_SynchronisationIndicator_present = extract_nbits(tvb, offset, bitoffset, 1);
2947     proto_tree_add_uint_bits(optionals_tree, hf_ranap_nAS_SynchronisationIndicator_present,
2948                              tvb, offset, bitoffset, 1, 0);
2949     proceed_nbits(&offset, &bitoffset, 1);
2950
2951     /* rAB_Parameters present ? */
2952     rAB_Parameters_present = extract_nbits(tvb, offset, bitoffset, 1);
2953     proto_tree_add_uint_bits(optionals_tree, hf_ranap_rAB_Parameters_present,
2954                              tvb, offset, bitoffset, 1, 0);
2955     proceed_nbits(&offset, &bitoffset, 1);
2956
2957     /* userPlaneInformation present ? */
2958     userPlaneInformation_present = extract_nbits(tvb, offset, bitoffset, 1);
2959     proto_tree_add_uint_bits(optionals_tree, hf_ranap_userPlaneInformation_present,
2960                              tvb, offset, bitoffset, 1, 0);
2961     proceed_nbits(&offset, &bitoffset, 1);
2962
2963     /* transportLayerInformation present ? */
2964     transportLayerInformation_present = extract_nbits(tvb, offset, bitoffset, 1);
2965     proto_tree_add_uint_bits(optionals_tree, hf_ranap_transportLayerInformation_present,
2966                              tvb, offset, bitoffset, 1, 0);
2967     proceed_nbits(&offset, &bitoffset, 1);
2968
2969     /* service_Handover present ? */
2970     service_Handover_present = extract_nbits(tvb, offset, bitoffset, 1);
2971     proto_tree_add_uint_bits(optionals_tree, hf_ranap_service_Handover_present,
2972                              tvb, offset, bitoffset, 1, 0);
2973     proceed_nbits(&offset, &bitoffset, 1);
2974
2975     /* iE_Extensions present ? */
2976     iE_Extensions_present = extract_nbits(tvb, offset, bitoffset, 1);
2977     proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present,
2978                              tvb, offset, bitoffset, 1, 0);
2979     proceed_nbits(&offset, &bitoffset, 1);
2980
2981
2982     /* add RAB-ID */
2983     proto_tree_add_uint_bits(ie_tree, hf_ranap_rab_id,
2984                              tvb, offset, bitoffset, 8, 0);
2985     proceed_nbits(&offset, &bitoffset, 8);
2986
2987     /* nAS-SynchronisationIndicator */
2988     if (nAS_SynchronisationIndicator_present)
2989     {
2990        proto_tree_add_uint_bits(ie_tree, hf_ranap_nAS_SynchronisationIndicator,
2991                              tvb, offset, bitoffset, 4, 0);
2992        proceed_nbits(&offset, &bitoffset, 4);
2993     }
2994
2995     /* rAB-Parameters */
2996     if (rAB_Parameters_present)
2997     {
2998        if ((ret=dissect_rAB_Parameters(tvb, ie_tree, &offset, &bitoffset)) != 0)
2999            return(ret);
3000     }
3001
3002     /* userPlaneInformation */
3003     if (userPlaneInformation_present)
3004     {
3005        if ((ret=dissect_userPlaneInformation(tvb, ie_tree, &offset, &bitoffset)) != 0)
3006            return(ret);
3007     }
3008
3009    /* transportLayerInformation */
3010     if (transportLayerInformation_present)
3011     {
3012        if ((ret=dissect_transportLayerInformation(tvb, ie_tree, &offset, &bitoffset)) != 0)
3013            return(ret);
3014     }
3015
3016     /* service_Handover */
3017     if (service_Handover_present)
3018     {
3019        tmp_extension_present = extract_nbits(tvb, offset, bitoffset, 1);
3020        proceed_nbits(&offset, &bitoffset, 1);
3021
3022        if (tmp_extension_present)
3023        {
3024           /* extended enum */
3025           /* decoding is not supported */
3026           proto_tree_add_text(ie_tree, tvb, offset, IE_PROTOCOL_EXTENSION_LENGTH,
3027                                   "Protocol extension for service_Handover present, dissection not supported");
3028           return(-1);
3029        }
3030
3031        proto_tree_add_uint_bits(ie_tree, hf_ranap_service_Handover,
3032                             tvb, offset, bitoffset, 2, 0);
3033        proceed_nbits(&offset, &bitoffset, 2);
3034     }
3035
3036    /* iE-Extensions */
3037    if (iE_Extensions_present)
3038    {
3039      if ((ret=dissect_iE_Extension(tvb, ie_tree, &offset, &bitoffset, "SetupOrModifyItemFirst" )) != 0)
3040                 return(ret);
3041    }
3042
3043   }
3044   return(0);
3045 }
3046
3047
3048 static int
3049 dissect_IE_RAB_ReleaseItem(tvbuff_t *tvb, proto_tree *ie_tree)
3050 {
3051   proto_item    *optionals_item = NULL;
3052   proto_tree    *optionals_tree = NULL;
3053   gint          offset = 0;
3054   gint          bitoffset = 0;
3055   int           extension_present;
3056   int           iE_Extensions_present;
3057   int           ret;
3058
3059
3060   /* create subtree for extension/optional/default bitmap */
3061   optionals_item = proto_tree_add_text(ie_tree, tvb, offset,IE_PROTOCOL_EXTENSION_LENGTH,
3062                                     "RAB_ReleaseItem Extension/Optional/Default bitmap");
3063   optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
3064
3065   /* protocol extension present ? */
3066   extension_present = extract_nbits(tvb, offset, bitoffset, 1);
3067   proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension,
3068                            tvb, offset, bitoffset, 1, 0);
3069   proceed_nbits(&offset, &bitoffset, 1);
3070
3071
3072   /* iE_Extensions present ? */
3073   iE_Extensions_present = extract_nbits(tvb, offset, bitoffset, 1);
3074   proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present,
3075                            tvb, offset, bitoffset, 1, 0);
3076   proceed_nbits(&offset, &bitoffset, 1);
3077
3078
3079   /* add RAB-ID */
3080   proto_tree_add_uint_bits(ie_tree, hf_ranap_rab_id,
3081                            tvb, offset, bitoffset, 8, 0);
3082   proceed_nbits(&offset, &bitoffset, 8);
3083
3084
3085   /* add cause */
3086   if ((ret=dissect_cause(tvb, ie_tree, &offset, &bitoffset)) != 0)
3087              return (ret);
3088
3089   /* iE Extensions */
3090   if (iE_Extensions_present)
3091   {
3092         if ((ret=dissect_iE_Extension(tvb, ie_tree, &offset, &bitoffset, "RAB_ReleasedItem")) != 0)
3093              return (ret);
3094   }
3095
3096   /* protocol extended */
3097   if (extension_present)
3098   {
3099      /* extended sequence */
3100      /* decoding is not supported */
3101      proto_tree_add_text(ie_tree, tvb, offset, IE_PROTOCOL_EXTENSION_LENGTH,
3102                           "Protocol extension for RAB_ReleasedItem present, dissection not supported");
3103      return(-1);
3104   }
3105
3106   return(0);
3107 }
3108
3109
3110 static int
3111 dissect_IE_RAB_ReleasedItem (tvbuff_t *tvb, proto_tree *ie_tree)
3112 {
3113    proto_item   *optionals_item = NULL;
3114    proto_tree   *optionals_tree = NULL;
3115    int          ret;
3116    int          extension_present;
3117    int          dl_dataVolumes_present;
3118    int          dl_GTP_PDU_SequenceNumber_present;
3119    int          ul_GTP_PDU_SequenceNumber_present;
3120    int          iE_Extensions_present;
3121    gint         offset = 0;
3122    gint         bitoffset = 0;
3123
3124   if (ie_tree)
3125   {
3126      /* create subtree for extension/optional/default bitmap */
3127      optionals_item = proto_tree_add_text(ie_tree, tvb, offset, 1,
3128                                         "RAB-ReleasedItem Extension/Optional/Default bitmap");
3129      optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
3130
3131      /* protocol_extension present ? */
3132      extension_present = extract_nbits(tvb, offset, bitoffset, 1);
3133      proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
3134                               offset, bitoffset, 1, 0);
3135      proceed_nbits(&offset, &bitoffset, 1);
3136
3137      /* dl_dataVolumes present ? */
3138      dl_dataVolumes_present = extract_nbits(tvb, offset, bitoffset, 1);
3139      proto_tree_add_uint_bits(optionals_tree, hf_ranap_dl_dataVolumes_present, tvb,
3140                               offset, bitoffset, 1, 0);
3141      proceed_nbits(&offset, &bitoffset, 1);
3142
3143      /* dL_GTP_PDU_SequenceNumber present ? */
3144      dl_GTP_PDU_SequenceNumber_present = extract_nbits(tvb, offset, bitoffset, 1);
3145      proto_tree_add_uint_bits(optionals_tree, hf_ranap_dl_GTP_PDU_SequenceNumber_present,
3146                               tvb, offset, bitoffset, 1, 0);
3147      proceed_nbits(&offset, &bitoffset, 1);
3148
3149      /* uL_GTP_PDU_SequenceNumber present ? */
3150      ul_GTP_PDU_SequenceNumber_present = extract_nbits(tvb, offset, bitoffset, 1);
3151      proto_tree_add_uint_bits(optionals_tree, hf_ranap_ul_GTP_PDU_SequenceNumber_present,
3152                               tvb, offset, bitoffset, 1, 0);
3153      proceed_nbits(&offset, &bitoffset, 1);
3154
3155      /* iE_Extensions present ? */
3156      iE_Extensions_present = extract_nbits(tvb, offset, bitoffset, 1);
3157      proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present,
3158                               tvb, offset, bitoffset, 1, 0);
3159      proceed_nbits(&offset, &bitoffset, 1);
3160
3161      /* rAB-ID */
3162      proto_tree_add_uint_bits(ie_tree, hf_ranap_rab_id,
3163                               tvb, offset, bitoffset, 8, 0);
3164      proceed_nbits(&offset, &bitoffset, 8);
3165
3166      /* dl-dataVolumes */
3167      if (dl_dataVolumes_present)
3168      {
3169         if ((ret=dissect_dataVolumeList(tvb, ie_tree, &offset, &bitoffset,
3170                                         "dl-dataVolumes")) != 0)
3171             return (ret);
3172      }
3173
3174      /* dL-GTP-PDU-SequenceNumber */
3175      if (dl_GTP_PDU_SequenceNumber_present)
3176      {
3177         allign(&offset, &bitoffset);
3178         proto_tree_add_item(ie_tree, hf_ranap_dl_GTP_PDU_SequenceNumber, tvb, offset, 2, FALSE);
3179         offset += 2;
3180      }
3181
3182      /* uL-GTP-PDU-SequenceNumber */
3183      if (ul_GTP_PDU_SequenceNumber_present)
3184      {
3185         allign(&offset, &bitoffset);
3186         proto_tree_add_item(ie_tree, hf_ranap_ul_GTP_PDU_SequenceNumber, tvb, offset, 2, FALSE);
3187         offset += 2;
3188      }
3189
3190      /* iE-Extensions */
3191      if (iE_Extensions_present)
3192      {
3193         if ((ret=dissect_iE_Extension(tvb, ie_tree, &offset, &bitoffset, "UserPlaneInformation")) != 0)
3194            return(ret);
3195      }
3196
3197      /* protocol extended */
3198      if (extension_present)
3199      {
3200         /* extended sequence */
3201         /* decoding is not supported */
3202         proto_tree_add_text(ie_tree, tvb, offset, IE_PROTOCOL_EXTENSION_LENGTH,
3203                           "Protocol extension for RAB_ReleasedItem present, dissection not supported");
3204         return(-1);
3205      }
3206   }
3207
3208   return(0);
3209 }
3210
3211
3212 static int
3213 dissect_IE_RAB_QueuedItem (tvbuff_t *tvb, proto_tree *ie_tree)
3214 {
3215    proto_item   *optionals_item = NULL;
3216    proto_tree   *optionals_tree = NULL;
3217    int          ret;
3218    int          extension_present;
3219    int          iE_Extensions_present;
3220    gint         offset = 0;
3221    gint         bitoffset = 0;
3222
3223
3224   if (ie_tree)
3225   {
3226      /* create subtree for extension/optional/default bitmap */
3227      optionals_item = proto_tree_add_text(ie_tree, tvb, offset, 1,
3228                                         "RAB-QueuedItem Extension/Optional/Default bitmap");
3229      optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
3230
3231      /* protocol_extension present ? */
3232      extension_present = extract_nbits(tvb, offset, bitoffset, 1);
3233      proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
3234                               offset, bitoffset, 1, 0);
3235      proceed_nbits(&offset, &bitoffset, 1);
3236
3237      /* iE_Extensions present ? */
3238      iE_Extensions_present = extract_nbits(tvb, offset, bitoffset, 1);
3239      proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present,
3240                               tvb, offset, bitoffset, 1, 0);
3241      proceed_nbits(&offset, &bitoffset, 1);
3242
3243      /* rAB-ID */
3244      proto_tree_add_uint_bits(ie_tree, hf_ranap_rab_id,
3245                              tvb, offset, bitoffset, 8, 0);
3246      proceed_nbits(&offset, &bitoffset, 8);
3247
3248      /* iE-Extensions */
3249      if (iE_Extensions_present)
3250      {
3251        if ((ret=dissect_iE_Extension(tvb, ie_tree, &offset, &bitoffset, "RAB_QueuedItem" )) != 0 )
3252                         return (ret);
3253      }
3254
3255      /* protocol extended */
3256      if (extension_present)
3257      {
3258         /* extended sequence */
3259         /* decoding is not supported */
3260         proto_tree_add_text(ie_tree, tvb, offset, IE_PROTOCOL_EXTENSION_LENGTH,
3261                           "Protocol extension for RAB_QueuedItem present, dissection not supported");
3262         return(-1);
3263      }
3264   }
3265
3266   return(0);
3267 }
3268
3269
3270 static int
3271 dissect_IE_RAB_FailedItem(tvbuff_t *tvb, proto_tree *ie_tree)
3272 {
3273    proto_item   *optionals_item = NULL;
3274    proto_tree   *optionals_tree = NULL;
3275    int          ret;
3276    int          extension_present;
3277    int          iE_Extensions_present;
3278    gint         offset = 0;
3279    gint         bitoffset = 0;
3280
3281   if (ie_tree)
3282   {
3283      /* create subtree for extension/optional/default bitmap */
3284      optionals_item = proto_tree_add_text(ie_tree, tvb, offset, 1,
3285                                         "RAB-FailedItem Extension/Optional/Default bitmap");
3286      optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
3287
3288      /* protocol_extension present ? */
3289      extension_present = extract_nbits(tvb, offset, bitoffset, 1);
3290      proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
3291                               offset, bitoffset, 1, 0);
3292      proceed_nbits(&offset, &bitoffset, 1);
3293
3294      /* iE_Extensions present ? */
3295      iE_Extensions_present = extract_nbits(tvb, offset, bitoffset, 1);
3296      proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present,
3297                               tvb, offset, bitoffset, 1, 0);
3298      proceed_nbits(&offset, &bitoffset, 1);
3299
3300      /* rAB-ID */
3301      proto_tree_add_uint_bits(ie_tree, hf_ranap_rab_id,
3302                              tvb, offset, bitoffset, 8, 0);
3303      proceed_nbits(&offset, &bitoffset, 8);
3304
3305      /* cause */
3306      if ((ret=dissect_cause(tvb, ie_tree, &offset, &bitoffset)) != 0)
3307                 return (ret);
3308
3309      /* iE-Extensions */
3310      if (iE_Extensions_present)
3311      {
3312        if ((ret=dissect_iE_Extension(tvb, ie_tree, &offset, &bitoffset, "RAB-FailedItem")) != 0)
3313              return (ret);
3314      }
3315
3316
3317      /* protocol extended */
3318      if (extension_present)
3319      {
3320         /* extended sequence */
3321         /* decoding is not supported */
3322         proto_tree_add_text(ie_tree, tvb, offset, IE_PROTOCOL_EXTENSION_LENGTH,
3323                           "Protocol extension for RAB-FailedItem present, dissection not supported");
3324         return(-1);
3325      }
3326   }
3327   return(0);
3328 }
3329
3330
3331 static int
3332 dissect_IE_CriticalityDiagnostics(tvbuff_t *tvb, proto_tree *ie_tree)
3333
3334 {
3335    proto_item   *optionals_item = NULL;
3336    proto_tree   *optionals_tree = NULL;
3337    int          ret;
3338    int          extension_present;
3339    int          procedureCode_present;
3340    int          triggeringMessage_present;
3341    int          procedureCriticality_present;
3342    int          iEsCriticalityDiagnostics_present;
3343    int          iE_Extensions_present;
3344    gint         offset = 0;
3345    gint         bitoffset = 0;
3346
3347
3348   if (ie_tree)
3349   {
3350      /* create subtree for extension/optional/default bitmap */
3351      optionals_item = proto_tree_add_text(ie_tree, tvb, offset, 1,
3352                                         "IE-CriticalityDiagnostics Extension/Optional/Default bitmap");
3353      optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
3354
3355      /* protocol_extension present ? */
3356      extension_present = extract_nbits(tvb, offset, bitoffset, 1);
3357      proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
3358                               offset, bitoffset, 1, 0);
3359      proceed_nbits(&offset, &bitoffset, 1);
3360
3361      /* procedureCode present ? */
3362      procedureCode_present = extract_nbits(tvb, offset, bitoffset, 1);
3363      proto_tree_add_uint_bits(optionals_tree, hf_ranap_procedureCode_present,
3364                               tvb, offset, bitoffset, 1, 0);
3365      proceed_nbits(&offset, &bitoffset, 1);
3366
3367      /* triggeringMessage present ? */
3368      triggeringMessage_present = extract_nbits(tvb, offset, bitoffset, 1);
3369      proto_tree_add_uint_bits(optionals_tree, hf_ranap_triggeringMessage_present,
3370                               tvb, offset, bitoffset, 1, 0);
3371      proceed_nbits(&offset, &bitoffset, 1);
3372
3373      /* procedureCriticality present ? */
3374      procedureCriticality_present = extract_nbits(tvb, offset, bitoffset, 1);
3375      proto_tree_add_uint_bits(optionals_tree, hf_ranap_procedureCriticality_present,
3376                               tvb, offset, bitoffset, 1, 0);
3377      proceed_nbits(&offset, &bitoffset, 1);
3378
3379      /* iEsCriticalityDiagnostics present ? */
3380      iEsCriticalityDiagnostics_present = extract_nbits(tvb, offset, bitoffset, 1);
3381      proto_tree_add_uint_bits(optionals_tree, hf_ranap_iEsCriticalityDiagnostics_present,
3382                               tvb, offset, bitoffset, 1, 0);
3383      proceed_nbits(&offset, &bitoffset, 1);
3384
3385      /* iE_Extensions present ? */
3386      iE_Extensions_present = extract_nbits(tvb, offset, bitoffset, 1);
3387      proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present,
3388                               tvb, offset, bitoffset, 1, 0);
3389      proceed_nbits(&offset, &bitoffset, 1);
3390
3391
3392      /* procedureCode */
3393      if (procedureCode_present)
3394      {
3395         allign (&offset, &bitoffset);
3396         proto_tree_add_item(ie_tree, hf_ranap_procedure_code, tvb, offset, 1, FALSE);
3397         offset += 1;
3398      }
3399
3400      /* triggeringMessage */
3401      if (triggeringMessage_present)
3402      {
3403         proto_tree_add_uint_bits(ie_tree, hf_ranap_triggeringMessage,
3404                                  tvb, offset, bitoffset, 2, 0);
3405         proceed_nbits(&offset, &bitoffset, 2);
3406      }
3407
3408      /* procedureCriticality */
3409      if (procedureCriticality_present)
3410      {
3411         proto_tree_add_uint_bits(ie_tree, hf_ranap_procedureCriticality,
3412                                  tvb, offset, bitoffset, 2, 0);
3413         proceed_nbits(&offset, &bitoffset, 2);
3414      }
3415
3416      /* iEsCriticalityDiagnostics */
3417      if (iEsCriticalityDiagnostics_present)
3418      {
3419         if ((ret=dissect_iEsCriticalityDiagnostics(tvb, ie_tree, &offset, &bitoffset)) != 0)
3420            return(ret);
3421      }
3422
3423      /* iE-Extensions */
3424      if (iE_Extensions_present)
3425      {
3426         if ((ret=dissect_iE_Extension(tvb, ie_tree, &offset, &bitoffset, "IE_CriticalityDiagnostics")) != 0)
3427            return(ret);
3428      }
3429
3430
3431      /* protocol extended */
3432      if (extension_present)
3433      {
3434         /* extended sequence */
3435         /* decoding is not supported */
3436         proto_tree_add_text(ie_tree, tvb, offset, IE_PROTOCOL_EXTENSION_LENGTH,
3437                           "Protocol extension for IE CriticalityDiagnostics present, dissection not supported");
3438         return(-1);
3439      }
3440   }
3441   return(0);
3442 }
3443
3444
3445 static int
3446 dissect_unknown_IE(tvbuff_t *tvb, proto_tree *ie_tree)
3447 {
3448   if (ie_tree)
3449   {
3450      proto_tree_add_text(ie_tree, tvb, 0, -1,
3451                            "IE Contents (dissection not implemented)");
3452   }
3453   return(0);
3454 }
3455
3456
3457
3458 /*****************************************************************************/
3459 /*                                                                           */
3460 /*  Dissecting Functions for IE Lists / Containers                           */
3461 /*                                                                           */
3462 /*****************************************************************************/
3463
3464 static int
3465 dissect_RAB_IE_ContainerPairList(tvbuff_t *tvb, proto_tree *ie_tree)
3466 {
3467   proto_item    *rab_item = NULL;
3468   proto_tree    *rab_tree = NULL;
3469   proto_item    *ie_pair_item = NULL;
3470   proto_tree    *ie_pair_tree = NULL;
3471   proto_item    *first_value_item = NULL;
3472   proto_tree    *first_value_tree = NULL;
3473   proto_item    *second_value_item = NULL;
3474   proto_tree    *second_value_tree = NULL;
3475   guint         number_of_RABs, currentRAB;
3476   guint         number_of_IEs, currentIE;
3477   gint          number_of_octets_first, number_of_octets_second;
3478   gint          number_of_octets_first_size, number_of_octets_second_size ;
3479   gint          offset = 0;
3480   gint          bitoffset = 0;
3481   gint          tmp_offset;
3482   guint16       ie_id;
3483   tvbuff_t      *first_value_tvb;
3484   tvbuff_t      *second_value_tvb;
3485
3486   if (ie_tree)
3487   {
3488      /* number of RABs in the list */
3489      number_of_RABs = 1 + tvb_get_guint8(tvb, offset);
3490      proto_tree_add_uint(ie_tree, hf_ranap_num_rabs,
3491                          tvb, offset,
3492                          NUM_RABS_LENGTH, number_of_RABs);
3493
3494      offset += NUM_RABS_LENGTH;
3495
3496      /* do for each RAB */
3497      for (currentRAB=1; currentRAB<=number_of_RABs; currentRAB++)
3498      {
3499         /* create subtree for RAB */
3500         rab_item = proto_tree_add_text(ie_tree, tvb, offset, 0, "%d. RAB", currentRAB);
3501         rab_tree = proto_item_add_subtree(rab_item, ett_ranap_rab);
3502
3503         /* number of IE pairs for this RAB */
3504         number_of_IEs = tvb_get_ntohs(tvb, offset);
3505         proto_tree_add_uint(rab_tree, hf_ranap_number_of_ies_in_list,
3506                             tvb, offset, 2, number_of_IEs);
3507
3508         offset += 2; /*points now to beginning of first IE pair */
3509
3510         /* do for each IE pair */
3511         for (currentIE=1; currentIE<=number_of_IEs; currentIE++)
3512         {
3513            /*  use tmp_offset to point to current field */
3514            tmp_offset = offset;
3515            /* IE pair ID */
3516            ie_id = tvb_get_ntohs(tvb, tmp_offset);
3517            tmp_offset += IE_ID_LENGTH;
3518
3519            tmp_offset += 1; /* skip first criticality byte */
3520            /* number of octets in first value */
3521            extract_length(tvb, tmp_offset, &number_of_octets_first, &number_of_octets_first_size);
3522            tmp_offset += number_of_octets_first_size + number_of_octets_first;
3523
3524            tmp_offset += 1; /* skip second criticality byte */
3525            /* number of octets in second value */
3526            extract_length(tvb, tmp_offset, &number_of_octets_second, &number_of_octets_second_size);
3527            tmp_offset += number_of_octets_second_size + number_of_octets_second;
3528
3529            /* create subtree for ie_pair */
3530            ie_pair_item = proto_tree_add_text(rab_tree, tvb, offset,
3531                                      tmp_offset - offset,
3532                                      "%s IE Pair (%u)",
3533                                      val_to_str(ie_id, ranap_ie_id_values, "Unknown"),
3534                                      ie_id);
3535            ie_pair_tree = proto_item_add_subtree(ie_pair_item, ett_ranap_ie_pair);
3536
3537            /* add fields to ie pair subtee */
3538            /* use offset to point to current field */
3539             /* IE ID */
3540            proto_tree_add_item(ie_pair_tree, hf_ranap_ie_ie_id, tvb, offset, IE_ID_LENGTH, FALSE);
3541            offset += IE_ID_LENGTH;
3542
3543            /* first criticality */
3544            proto_tree_add_uint_bits(ie_pair_tree, hf_ranap_ie_pair_first_criticality, tvb,
3545                                     offset, bitoffset, 2, 0);
3546            proceed_nbits(&offset, &bitoffset, 2);
3547
3548            /* number of octets in first value */
3549            allign(&offset, &bitoffset);
3550            if (number_of_octets_first != 0)
3551            {
3552               proto_tree_add_uint(ie_pair_tree, hf_ranap_first_value_number_of_octets,
3553                                   tvb, offset,
3554                                   number_of_octets_first_size,
3555                                   number_of_octets_first);
3556            }
3557            else
3558            {
3559               /* decoding is not supported */
3560               proto_tree_add_text(ie_pair_tree, tvb, offset,
3561                             2, "Number of Octets greater than 0x3FFF, dissection not supported");
3562               return(-1);
3563            }
3564            offset += number_of_octets_first_size;
3565
3566            /* add subtree for first value */
3567            first_value_item = proto_tree_add_text(ie_pair_tree, tvb, offset,
3568                                      number_of_octets_first,
3569                                      "%sFirst",
3570                                      val_to_str(ie_id, ranap_ie_id_values, "Unknown"));
3571            first_value_tree = proto_item_add_subtree(first_value_item, ett_ranap_ie_pair_first_value);
3572
3573            /* create tvb containing first value */
3574            first_value_tvb = tvb_new_subset(tvb, offset, number_of_octets_first, number_of_octets_first);
3575
3576            /* add fields of first value */
3577            switch (ie_id)
3578            {
3579               case  IE_RAB_SetupOrModifyItem:
3580                  dissect_IE_RAB_SetupOrModifyItemFirst (first_value_tvb, first_value_tree);
3581                  break;
3582
3583               default:
3584                  dissect_unknown_IE(first_value_tvb, first_value_tree);
3585                  break;
3586            }
3587
3588            offset += number_of_octets_first;
3589
3590
3591            /* second criticality */
3592            proto_tree_add_uint_bits(ie_pair_tree, hf_ranap_ie_pair_second_criticality, tvb,
3593                                     offset, bitoffset, 2, 0);
3594            proceed_nbits(&offset, &bitoffset, 2);
3595
3596            /* number of octets of second value */
3597            allign(&offset, &bitoffset);
3598            if (number_of_octets_second != 0)
3599            {
3600               proto_tree_add_uint(ie_pair_tree, hf_ranap_second_value_number_of_octets,
3601                                   tvb, offset,
3602                                   number_of_octets_second_size,
3603                                   number_of_octets_second);
3604            }
3605            else
3606            {
3607               /* decoding is not supported */
3608               proto_tree_add_text(ie_pair_tree, tvb, offset,
3609                             2, "Number of Octets greater than 0x3FFF, dissection not supported");
3610               return(-1);
3611            }
3612            offset += number_of_octets_second_size;
3613
3614            /* add subtree for second value */
3615            second_value_item = proto_tree_add_text(ie_pair_tree, tvb, offset,
3616                                      number_of_octets_second,
3617                                      "%sSecond",
3618                                      val_to_str(ie_id, ranap_ie_id_values, "Unknown"));
3619            second_value_tree = proto_item_add_subtree(second_value_item, ett_ranap_ie_pair_second_value);
3620
3621            /* create tvb containing first value */
3622            second_value_tvb = tvb_new_subset(tvb, offset, number_of_octets_second, number_of_octets_second);
3623
3624            /* add fields of second value */
3625            switch (ie_id)
3626            {
3627               case  IE_RAB_SetupOrModifyItem:
3628                  dissect_IE_RAB_SetupOrModifyItemSecond (second_value_tvb, second_value_tree);
3629                  break;
3630
3631               default:
3632                  dissect_unknown_IE(second_value_tvb, second_value_tree);
3633                  break;
3634            }
3635
3636            offset += number_of_octets_second;
3637
3638         }/* for each IE ... */
3639      }/* for each RAB ... */
3640    }
3641    return(0);
3642 }
3643
3644
3645 static int
3646 dissect_RAB_IE_ContainerList(tvbuff_t *tvb, proto_tree *list_tree)
3647 {
3648   proto_item    *rab_item = NULL;
3649   proto_tree    *rab_tree = NULL;
3650   proto_item    *ie_item = NULL;
3651   proto_tree    *ie_tree = NULL;
3652
3653   guint         number_of_RABs, currentRAB;
3654   guint         number_of_IEs, currentIE;
3655   gint          ie_number_of_octets = 0;
3656   gint          ie_number_of_octets_size = 0;
3657   gint          offset = 0;
3658   gint          bitoffset = 0;
3659   gint          ie_offset = 0;
3660   gint          ie_header_length;
3661   guint16       ie_id;
3662   tvbuff_t      *ie_tvb;
3663
3664
3665   if (list_tree)
3666   {
3667      /* number of RABs in the list */
3668      number_of_RABs = 1 + tvb_get_guint8(tvb, offset);
3669      proto_tree_add_uint(list_tree, hf_ranap_num_rabs,
3670                          tvb, offset,
3671                          NUM_RABS_LENGTH, number_of_RABs);
3672
3673      offset +=  NUM_RABS_LENGTH;
3674
3675      /* do for each RAB */
3676      for (currentRAB=1; currentRAB<=number_of_RABs; currentRAB++)
3677      {
3678         /* create subtree for RAB */
3679         rab_item = proto_tree_add_text(list_tree, tvb, offset, 0, "%d. RAB", currentRAB);
3680         rab_tree = proto_item_add_subtree(rab_item, ett_ranap_rab);
3681
3682         /* number of IEs for this RAB */
3683         number_of_IEs = tvb_get_ntohs(tvb, offset);
3684         proto_tree_add_uint(rab_tree, hf_ranap_number_of_ies_in_list,
3685                             tvb, offset, 2, number_of_IEs);
3686
3687         offset += 2; /*points now to beginning of first IE in list */
3688         ie_offset = offset;
3689
3690         /* do for each IE */
3691         for (currentIE=1; currentIE<=number_of_IEs; currentIE++)
3692         {
3693            /* extract IE ID */
3694            ie_id = tvb_get_ntohs(tvb, offset);
3695            offset += IE_ID_LENGTH;
3696
3697            offset += IE_CRITICALITY_LENGTH; /* skip criticality byte */
3698
3699            /* number of octets */
3700            extract_length(tvb, offset, &ie_number_of_octets, &ie_number_of_octets_size);
3701            ie_header_length = IE_ID_LENGTH + IE_CRITICALITY_LENGTH + ie_number_of_octets_size;
3702
3703            /* reset offset to beginning of ie */
3704            offset = ie_offset;
3705
3706            /* create subtree for ie */
3707            ie_item = proto_tree_add_text(rab_tree, tvb, offset,
3708                              ie_header_length + ie_number_of_octets,
3709                              "%s IE (%u)",
3710                              val_to_str(ie_id, ranap_ie_id_values, "Unknown"),
3711                              ie_id);
3712            ie_tree = proto_item_add_subtree(ie_item, ett_ranap_ie);
3713
3714            /* IE ID */
3715            proto_tree_add_item(ie_tree, hf_ranap_ie_ie_id, tvb,
3716                                offset, IE_ID_LENGTH, FALSE);
3717            offset += IE_ID_LENGTH;
3718
3719            /* criticality */
3720            proto_tree_add_uint_bits(ie_tree, hf_ranap_ie_criticality, tvb,
3721                                     offset, bitoffset, 2, 0);
3722            proceed_nbits(&offset, &bitoffset, 2);
3723
3724            allign(&offset, &bitoffset);
3725            if (ie_number_of_octets != 0)
3726            {
3727               proto_tree_add_uint(ie_tree, hf_ranap_ie_number_of_octets, tvb,
3728                                   offset, ie_number_of_octets_size, ie_number_of_octets);
3729            }
3730            else
3731            {
3732                   /* decoding is not supported */
3733                   proto_tree_add_text(ie_tree, tvb, offset,
3734                                     0, "Number of Octets greater than 0x3FFF, dissection not supported");
3735                   return(-1);
3736            }
3737            offset += ie_number_of_octets_size;
3738
3739
3740            /* create tvb containing ie */
3741            ie_tvb = tvb_new_subset(tvb, offset, ie_number_of_octets, ie_number_of_octets);
3742
3743            /* add fields of ie */
3744            switch (ie_id)
3745            {
3746               case  IE_RAB_SetupOrModifiedItem:
3747                  dissect_IE_RAB_SetupOrModifiedItem(ie_tvb, ie_tree);
3748                  break;
3749               case  IE_RAB_ReleaseItem:
3750                  dissect_IE_RAB_ReleaseItem(ie_tvb, ie_tree);
3751                  break;
3752               case  IE_RAB_ReleasedItem:
3753                  dissect_IE_RAB_ReleasedItem(ie_tvb, ie_tree);
3754                  break;
3755               case  IE_RAB_ReleasedItem_IuRelComp:
3756                  dissect_IE_RAB_ReleasedItem_IuRelComp(ie_tvb, ie_tree);
3757                  break;
3758               case  IE_RAB_QueuedItem:
3759                  dissect_IE_RAB_QueuedItem(ie_tvb, ie_tree);
3760                  break;
3761               case  IE_RAB_FailedItem:
3762                  dissect_IE_RAB_FailedItem(ie_tvb, ie_tree);
3763                  break;
3764               case  IE_RAB_DataVolumeReportItem:
3765                  dissect_IE_RAB_DataVolumeReportItem(ie_tvb, ie_tree);
3766                  break;
3767               default:
3768                  dissect_unknown_IE(ie_tvb, ie_tree);
3769                  break;
3770            }
3771
3772            ie_offset += (ie_header_length + ie_number_of_octets);
3773            offset = ie_offset;
3774         } /* for each IE */
3775      } /* for each RAB */
3776    }
3777    return (0);
3778 }
3779
3780
3781 static int
3782 dissect_ranap_ie(guint16 ie_id, tvbuff_t *ie_contents_tvb, proto_tree *ie_tree)
3783 {
3784      /* call specific dissection function for ie contents */
3785      switch(ie_id)
3786      {
3787         case IE_RAB_ID:
3788            return(dissect_IE_RAB_ID(ie_contents_tvb, ie_tree));
3789            break;
3790         case IE_NAS_PDU:
3791            return(dissect_IE_NAS_PDU(ie_contents_tvb, ie_tree));
3792            break;
3793         case IE_LAI:
3794            return(dissect_IE_LAI(ie_contents_tvb, ie_tree));
3795            break;
3796         case IE_RAC:
3797            return(dissect_IE_RAC(ie_contents_tvb, ie_tree));
3798            break;
3799         case IE_SAI:
3800            return(dissect_IE_SAI(ie_contents_tvb, ie_tree));
3801            break;
3802         case IE_GlobalRNC_ID:
3803            return(dissect_IE_GlobalRNC_ID(ie_contents_tvb, ie_tree));
3804            break;
3805         case IE_CN_DomainIndicator:
3806            return(dissect_IE_CN_DomainIndicator(ie_contents_tvb, ie_tree));
3807            break;
3808         case IE_IuSigConId:
3809            return(dissect_IE_IuSigConId(ie_contents_tvb, ie_tree));
3810            break;
3811         case IE_SAPI:
3812            return(dissect_IE_SAPI(ie_contents_tvb, ie_tree));
3813            break;
3814         case IE_TransportLayerAddress:
3815            return(dissect_IE_TransportLayerAddress(ie_contents_tvb, ie_tree));
3816            break;
3817         case IE_IuTransportAssociation:
3818            return(dissect_IE_IuTransportAssociation(ie_contents_tvb, ie_tree));
3819            break;
3820         case IE_RAB_SetupOrModifyList:
3821            return(dissect_RAB_IE_ContainerPairList(ie_contents_tvb, ie_tree));
3822            break;
3823         case IE_RAB_SetupOrModifiedList:
3824         case IE_RAB_ReleaseList:
3825         case IE_RAB_ReleasedList:
3826         case IE_RAB_QueuedList:
3827         case IE_RAB_FailedList:
3828         case IE_RAB_ReleaseFailedList:
3829         case IE_RAB_DataVolumeReportList:
3830         case IE_RAB_ReleasedList_IuRelComp:
3831         case IE_RAB_RelocationReleaseList:
3832         case IE_RAB_DataForwardingList:
3833         case IE_RAB_SetupList_RelocReq:
3834         case IE_RAB_SetupList_RelocReqAck:
3835         case IE_RAB_DataForwardingList_SRNS_CtxReq:
3836         case IE_RAB_ContextList:
3837         case IE_RAB_ContextFailedtoTransferList:
3838         case IE_RAB_DataVolumeReportRequestList:
3839         case IE_RAB_FailedtoReportList:
3840         case IE_RAB_ContextList_RANAP_RelocInf:
3841            return(dissect_RAB_IE_ContainerList(ie_contents_tvb, ie_tree));
3842            break;
3843         case IE_CriticalityDiagnostics:
3844            return(dissect_IE_CriticalityDiagnostics(ie_contents_tvb, ie_tree));
3845            break;
3846         case IE_Cause:
3847            return(dissect_IE_Cause(ie_contents_tvb, ie_tree));
3848            break;
3849         default:
3850            return(dissect_unknown_IE(ie_contents_tvb, ie_tree));
3851            break;
3852      }
3853 }
3854
3855
3856 static int
3857 dissect_ranap_ie_container(tvbuff_t *tvb, proto_tree *ranap_tree)
3858 {
3859   proto_item    *ie_item = NULL;
3860   proto_tree    *ie_tree = NULL;
3861   proto_item    *optionals_item = NULL;
3862   proto_tree    *optionals_tree = NULL;
3863
3864   int           msg_extension_present;
3865   int           ProtocolExtensionContainer_present;
3866
3867   guint16       number_of_ies;
3868   guint16       ie_id;
3869   gint          ie_number_of_octets = 0;
3870   gint          ie_number_of_octets_size = 0;
3871   guint16       ie_header_length;
3872   gint          offset = 0;
3873   gint          bitoffset = 0;
3874   gint          i, ie_offset;
3875   tvbuff_t      *ie_contents_tvb;
3876
3877   if (ranap_tree)
3878   {
3879      /* create subtree for extension/optional bitmap of message */
3880      optionals_item = proto_tree_add_text(ranap_tree, tvb, offset, 1,
3881                                         "Message Extension/Optional/Default bitmap");
3882      optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
3883   }
3884
3885   /* msg_extension present ? */
3886   msg_extension_present = extract_nbits(tvb, offset, bitoffset, 1);
3887
3888   if (ranap_tree)
3889   {
3890      proto_tree_add_uint_bits(optionals_tree, hf_ranap_msg_extension_present, tvb,
3891                               offset, bitoffset, 1, 0);
3892   }
3893   proceed_nbits(&offset, &bitoffset, 1);
3894
3895   /* ProtocolExtensionContainer present ? */
3896   ProtocolExtensionContainer_present = extract_nbits(tvb, offset, bitoffset, 1);
3897   if (ranap_tree)
3898   {
3899       proto_tree_add_uint_bits(optionals_tree, hf_ranap_ProtocolExtensionContainer_present,
3900                               tvb, offset, bitoffset, 1, 0);
3901   }
3902   proceed_nbits(&offset, &bitoffset, 1);
3903
3904
3905   /* extract ie container data */
3906   /* number of ies */
3907   allign(&offset, &bitoffset);
3908   number_of_ies = tvb_get_ntohs(tvb, offset);
3909   if (ranap_tree)
3910   {
3911      proto_tree_add_uint(ranap_tree, hf_ranap_number_of_ies,
3912                          tvb, offset, 2, number_of_ies);
3913   }
3914   offset += 2;
3915
3916   ie_offset = offset; /* ie_offset marks beginning of IE-Header */
3917
3918   /* do the following for each IE in the PDU */
3919   for (i=1; i <= number_of_ies; i++)
3920   {
3921      /* extract IE header fields which are needed even if no ranap tree exists*/
3922      /* IE-ID */
3923      ie_id = tvb_get_ntohs(tvb, offset);
3924      offset += IE_ID_LENGTH;
3925
3926     /* number of octets in the IE */
3927     offset += IE_CRITICALITY_LENGTH; /* skip criticality byte */
3928     ie_number_of_octets = 0;
3929     extract_length(tvb, offset, &ie_number_of_octets, &ie_number_of_octets_size);
3930     ie_header_length = IE_ID_LENGTH + IE_CRITICALITY_LENGTH + ie_number_of_octets_size;
3931
3932     if (ranap_tree)
3933     {
3934        offset = ie_offset; /* start from beginning of IE */
3935        /* create subtree for ie */
3936        ie_item = proto_tree_add_text(ranap_tree, tvb, offset,
3937                                      ie_header_length + ie_number_of_octets,
3938                                      "%s IE (%u)",
3939                                      val_to_str(ie_id, ranap_ie_id_values, "Unknown"),
3940                                      ie_id);
3941        ie_tree = proto_item_add_subtree(ie_item, ett_ranap_ie);
3942
3943        /* add fields to ie subtee */
3944        /* IE ID */
3945        proto_tree_add_item(ie_tree, hf_ranap_ie_ie_id, tvb,
3946                            offset, IE_ID_LENGTH, FALSE);
3947        offset += IE_ID_LENGTH;
3948
3949        /* criticality */
3950        proto_tree_add_uint_bits(ie_tree, hf_ranap_ie_criticality, tvb,
3951                                 offset, bitoffset, 2, 0);
3952        proceed_nbits(&offset, &bitoffset, 2);
3953
3954        /* number of octets */
3955        allign(&offset, &bitoffset);
3956        if (ie_number_of_octets != 0)
3957        {
3958           proto_tree_add_uint(ie_tree, hf_ranap_ie_number_of_octets, tvb,
3959                               offset, ie_number_of_octets_size, ie_number_of_octets);
3960           offset += ie_number_of_octets_size;
3961        }
3962        else
3963        {
3964           /* decoding is not supported */
3965           proto_tree_add_text(ranap_tree, tvb, offset,
3966                               2, "Number of Octets greater than 0x3FFF, dissection not supported");
3967           return(-1);
3968        }
3969      }
3970
3971      /* check if number_of_octets could be decoded */
3972      /* in case we skipped if (ranap_tree) {....} */
3973      if (ie_number_of_octets == 0) return (-1);
3974
3975      /* create tvb containing the ie contents */
3976      ie_contents_tvb = tvb_new_subset(tvb, ie_offset + ie_header_length,
3977                                       ie_number_of_octets, ie_number_of_octets);
3978
3979      /* call specific dissection function for ie contents */
3980      dissect_ranap_ie(ie_id, ie_contents_tvb, ie_tree);
3981
3982      /* set ie_offset to beginning of next ie */
3983      ie_offset += (ie_header_length + ie_number_of_octets);
3984      offset = ie_offset;
3985   }
3986
3987   /* protocol Extensions */
3988   if (ProtocolExtensionContainer_present)
3989   {
3990      return(dissect_iE_Extension(tvb, ranap_tree, &offset, &bitoffset, "PDU"));
3991   }
3992
3993   return(0);
3994
3995 }
3996
3997
3998 static void
3999 dissect_ranap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
4000 {
4001   proto_item    *ranap_item = NULL;
4002   proto_tree    *ranap_tree = NULL;
4003
4004   guint         procedure_code;
4005   guint         pdu_index;
4006   gint          number_of_octets = 0;
4007   gint          number_of_octets_size = 0;
4008   gint          offset = 0;
4009   gint          tmp_offset = 0;
4010   gint          bitoffset = 0;
4011   gint          tmp_bitoffset = 0;
4012   guint         extension_present;
4013
4014   tvbuff_t      *ie_tvb;
4015
4016
4017   g_pinfo = pinfo;
4018
4019   /* make entry in the Protocol column on summary display */
4020   if (check_col(pinfo->cinfo, COL_PROTOCOL))
4021     col_set_str(pinfo->cinfo, COL_PROTOCOL, "RANAP");
4022
4023   /* extract header fields which are needed even if no tree exists */
4024
4025   /* protocol_extension present ? */
4026   extension_present = extract_nbits(tvb, tmp_offset, tmp_bitoffset, 1);
4027   proceed_nbits(&tmp_offset, &tmp_bitoffset, 1);
4028   if (extension_present)
4029   {
4030       /* extended choice */
4031       /* decoding is not supported */
4032       col_append_str(pinfo->cinfo, COL_INFO, "RANAP-PDU Protocol extension present, dissection not supported");
4033       return;
4034   }
4035
4036   /* pdu_index choice 0..3 */
4037   pdu_index = extract_nbits(tvb, tmp_offset, tmp_bitoffset, 2);
4038   proceed_nbits(&tmp_offset, &tmp_bitoffset, 2);
4039
4040   /* procedure code */
4041   allign(&tmp_offset, &tmp_bitoffset);
4042   procedure_code = tvb_get_guint8(tvb, tmp_offset);
4043   tmp_offset += 1;
4044
4045   /* add Procedure Code to Info Column */
4046   if (check_col(pinfo->cinfo, COL_INFO))
4047   {
4048     if (procedure_code <= PC_max)
4049     {
4050        col_add_fstr(pinfo->cinfo, COL_INFO, "%s ",
4051                    val_to_str(pdu_index, ranap_message_names[procedure_code],
4052                               "unknown message"));
4053     }
4054   }
4055
4056   /* extract number of octets */
4057   tmp_offset += 1; /* leave out criticality byte */
4058   extract_length(tvb, tmp_offset, &number_of_octets, &number_of_octets_size);
4059
4060   /* In the interest of speed, if "tree" is NULL, don't do any work not
4061      necessary to generate protocol tree items. */
4062   if (tree)
4063   {
4064     g_tree = tree;
4065
4066     /* create the ranap protocol tree */
4067     ranap_item = proto_tree_add_item(tree, proto_ranap, tvb, 0, -1, FALSE);
4068     ranap_tree = proto_item_add_subtree(ranap_item, ett_ranap);
4069
4070     /* Add fields to ranap protocol tree */
4071     /* PDU Index */
4072     proceed_nbits(&offset, &bitoffset, 1);  /* leave out extension bit, checked above */
4073     proto_tree_add_uint_bits(ranap_tree, hf_ranap_pdu_index, tvb,
4074                              offset, bitoffset, 2, 0);
4075     proceed_nbits(&offset, &bitoffset, 2);
4076
4077
4078     /* Procedure Code */
4079     allign(&offset, &bitoffset);
4080     proto_tree_add_item(ranap_tree, hf_ranap_procedure_code, tvb, offset, 1, FALSE);
4081     offset += 1;
4082
4083     /* PDU Criticality */
4084     proto_tree_add_uint_bits(ranap_tree, hf_ranap_pdu_criticality, tvb,
4085                              offset, bitoffset, 2, 0);
4086     proceed_nbits(&offset, &bitoffset, 2);
4087
4088     /* number of octets */
4089     allign(&offset, &bitoffset);
4090     if (number_of_octets != 0)
4091     {
4092        proto_tree_add_uint(ranap_tree, hf_ranap_pdu_number_of_octets,
4093                            tvb, offset,
4094                            number_of_octets_size, number_of_octets);
4095        offset += number_of_octets_size;
4096     }
4097     else
4098     {
4099         /* decoding is not supported */
4100         proto_tree_add_text(ranap_tree, tvb, offset,
4101                             2, "Number of Octets greater than 0x3FFF, dissection not supported");
4102         return;
4103     }
4104   }
4105
4106   /* set offset to the beginning of ProtocolIE-Container */
4107   /* in case we skipped "if(tree){...}" above */
4108   offset = PDU_NUMBER_OF_OCTETS_OFFSET + number_of_octets_size;
4109
4110   /* create a tvb containing the remainder of the PDU */
4111   ie_tvb = tvb_new_subset(tvb, offset, -1, -1);
4112
4113   /* dissect the ies */
4114   dissect_ranap_ie_container(ie_tvb, ranap_tree);
4115 }
4116
4117
4118
4119 /*****************************************************************************/
4120 /*                                                                           */
4121 /*  Protocol Registration Functions                                          */
4122 /*                                                                           */
4123 /*****************************************************************************/
4124
4125 void
4126 proto_register_ranap(void)
4127 {
4128   /* Setup list of header fields */
4129   static hf_register_info hf[] = {
4130     { &hf_ranap_pdu_index,
4131       { "RANAP-PDU Index",
4132         "ranap.ranap_pdu_index",
4133         FT_UINT8, BASE_HEX, VALS(&ranap_pdu_index_values), 0x0,
4134         "", HFILL }
4135     },
4136     { &hf_ranap_procedure_code,
4137       { "Procedure Code",
4138         "ranap.procedure_code",
4139         FT_UINT8, BASE_DEC, VALS(&ranap_procedure_code_values), 0x0,
4140         "", HFILL }
4141     },
4142     { &hf_ranap_pdu_criticality,
4143       { "Criticality of PDU",
4144         "ranap.pdu.criticality",
4145         FT_UINT8, BASE_HEX, VALS(&ranap_criticality_values), 0x0,
4146         "", HFILL }
4147     },
4148     { &hf_ranap_pdu_number_of_octets,
4149       { "Number of Octets in PDU",
4150         "ranap.pdu.num_of_octets",
4151         FT_UINT16, BASE_DEC, NULL, 0x0,
4152         "", HFILL }
4153     },
4154     { &hf_ranap_ie_protocol_extension,
4155       { "Protocol Extension",
4156         "ranap.ie.protocol_extension_present",
4157         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4158         "", HFILL }
4159     },
4160     { &hf_ranap_number_of_ies,
4161       { "Number of IEs in PDU",
4162         "ranap.pdu.number_of_ies",
4163         FT_UINT16, BASE_DEC, NULL, 0x0,
4164         "", HFILL }
4165     },
4166     { &hf_ranap_number_of_ies_in_list,
4167       { "Number of IEs in list",
4168         "ranap.number_of_ies",
4169         FT_UINT16, BASE_DEC, NULL, 0x0,
4170         "", HFILL }
4171     },
4172     { &hf_ranap_ie_ie_id,
4173       { "IE-ID",
4174         "ranap.ie.ie_id",
4175         FT_UINT16, BASE_DEC, VALS(&ranap_ie_id_values), 0x0,
4176         "", HFILL }
4177     },
4178     { &hf_ranap_ext_field_id,
4179       { "ProtocolExtensionField ID",
4180         "ranap.ie.ProtocolExtensionFields.Id",
4181         FT_UINT16, BASE_DEC, NULL, 0x0,
4182         "", HFILL }
4183     },
4184     { &hf_ranap_ie_criticality,
4185       { "Criticality of IE",
4186         "ranap.ie.criticality",
4187         FT_UINT8, BASE_HEX, VALS(&ranap_criticality_values), 0x0,
4188         "", HFILL }
4189     },
4190     { &hf_ranap_ext_field_criticality,
4191       { "Criticality of ProtocolExtensionField",
4192         "ranap.ie.ProtocolExtensionFields.criticality",
4193         FT_UINT8, BASE_HEX, VALS(&ranap_criticality_values), 0x0,
4194         "", HFILL }
4195     },
4196     { &hf_ranap_ie_pair_first_criticality,
4197       { "First Criticality",
4198         "ranap.ie_pair.first_criticality",
4199         FT_UINT8, BASE_HEX, VALS(&ranap_criticality_values), 0x0,
4200         "", HFILL }
4201     },
4202     { &hf_ranap_ie_pair_second_criticality,
4203       { "Second Criticality",
4204         "ranap.ie_pair.second_criticality",
4205         FT_UINT8, BASE_HEX, VALS(&ranap_criticality_values), 0x0,
4206         "", HFILL }
4207     },
4208     { &hf_ranap_ie_number_of_octets,
4209       { "Number of Octets in IE",
4210         "ranap.ie.number_of_octets",
4211         FT_UINT16, BASE_DEC, NULL, 0x0,
4212         "", HFILL }
4213     },
4214     { &hf_ranap_first_value_number_of_octets,
4215       { "Number of Octets in first value",
4216         "ranap.ie_pair.first_value.number_of_octets",
4217         FT_UINT16, BASE_DEC, NULL, 0x0,
4218         "", HFILL }
4219     },
4220     { &hf_ranap_second_value_number_of_octets,
4221       { "Number of Octets in second value",
4222         "ranap.ie_pair.second_value.number_of_octets",
4223         FT_UINT16, BASE_DEC, NULL, 0x0,
4224         "", HFILL }
4225     },
4226     { &hf_ranap_rab_id,
4227       { "RAB-ID",
4228         "ranap.RAB_ID",
4229         FT_UINT8, BASE_HEX, NULL, 0x0,
4230         "", HFILL }
4231     },
4232     { &hf_ranap_nas_pdu,
4233       { "NAS-PDU",
4234         "ranap.NAS_PDU",
4235         FT_BYTES, BASE_NONE, NULL, 0x0,
4236         "", HFILL }
4237     },
4238     { &hf_ranap_extension_field,
4239       { "Extension Field Value",
4240         "ranap.Extension_Field_Value",
4241         FT_BYTES, BASE_NONE, NULL, 0x0,
4242         "", HFILL }
4243     },
4244     { &hf_ranap_plmn_id,
4245       { "PLMN-ID",
4246         "ranap.PLMN_ID",
4247         FT_BYTES, BASE_NONE, NULL, 0x0,
4248         "", HFILL }
4249     },
4250     { &hf_ranap_lac,
4251       { "LAC",
4252         "ranap.LAC",
4253         FT_BYTES, BASE_NONE, NULL, 0x0,
4254         "", HFILL }
4255     },
4256     { &hf_ranap_sac,
4257       { "SAC",
4258         "ranap.SAC",
4259         FT_BYTES, BASE_NONE, NULL, 0x0,
4260         "", HFILL }
4261     },
4262     { &hf_ranap_rac,
4263       { "RAC",
4264         "ranap.RAC",
4265         FT_BYTES, BASE_NONE, NULL, 0x0,
4266         "", HFILL }
4267     },
4268     { &hf_ranap_num_rabs,
4269       { "Number of RABs",
4270         "ranap.number_of_RABs",
4271         FT_UINT8, BASE_DEC, NULL, 0x0,
4272         "", HFILL }
4273     },
4274     { &hf_ranap_nAS_SynchronisationIndicator_present,
4275       { "nAS-SynchronisationIndicator",
4276         "ranap.nAS-SynchronisationIndicator_present",
4277         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4278         "", HFILL }
4279     },
4280     { &hf_ranap_rAB_Parameters_present,
4281       { "rAB-Parameters",
4282         "ranap.rAB_Parameters_present",
4283         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4284         "", HFILL }
4285     },
4286     { &hf_ranap_userPlaneInformation_present,
4287       { "userPlaneInformation",
4288         "ranap.userPlaneInformation_present",
4289         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4290         "", HFILL }
4291     },
4292     { &hf_ranap_transportLayerInformation_present,
4293       { "transportLayerInformation",
4294         "ranap.transportLayerInformation_present",
4295         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4296         "", HFILL }
4297     },
4298     { &hf_ranap_service_Handover_present,
4299       { "service-Handover",
4300         "ranap.service_Handover_present",
4301         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4302         "", HFILL }
4303     },
4304     { &hf_ranap_iE_Extensions_present,
4305       { "iE-Extensions",
4306         "ranap.ie.iE-Extensions_present",
4307         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4308         "", HFILL }
4309     },
4310     { &hf_ranap_nAS_SynchronisationIndicator,
4311       { "nAS-SynchronisationIndicator",
4312         "ranap.nAS-SynchronisationIndicator",
4313         FT_UINT8, BASE_HEX, NULL, 0x0,
4314         "", HFILL }
4315     },
4316     { &hf_ranap_guaranteedBitRate_present,
4317       { "guaranteedBitRate",
4318         "ranap.guaranteedBitRate_present",
4319         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4320         "", HFILL }
4321     },
4322     { &hf_ranap_transferDelay_present,
4323       { "transferDelay",
4324         "ranap.transferDelay_present",
4325         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4326         "", HFILL }
4327     },
4328     { &hf_ranap_trafficHandlingPriority_present,
4329       { "trafficHandlingPriority",
4330         "ranap.trafficHandlingPriority_present",
4331         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4332         "", HFILL }
4333     },
4334     { &hf_ranap_allocationOrRetentionPriority_present,
4335       { "allocationOrRetentionPriority",
4336         "ranap.allocationOrRetentionPriority_present",
4337         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4338         "", HFILL }
4339     },
4340     { &hf_ranap_sourceStatisticsDescriptor_present,
4341       { "sourceStatisticsDescriptor",
4342         "ranap.sourceStatisticsDescriptor_present",
4343         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4344         "", HFILL }
4345     },
4346     { &hf_ranap_relocationRequirement_present,
4347       { "relocationRequirement",
4348         "ranap.relocationRequirement_present",
4349         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4350         "", HFILL }
4351     },
4352     { &hf_ranap_trafficClass,
4353       { "Traffic Class",
4354         "ranap.rab_Parameters.trafficClass",
4355         FT_UINT8, BASE_DEC, VALS(&ranap_trafficClass_values), 0x0,
4356         "", HFILL }
4357     },
4358     { &hf_ranap_rAB_AsymmetryIndicator,
4359       { "rAB_AsymmetryIndicator",
4360         "ranap.rab_Parameters.rAB_AsymmetryIndicator",
4361         FT_UINT8, BASE_DEC, VALS(&ranap_rAB_AsymmetryIndicator_values), 0x0,
4362         "", HFILL }
4363     },
4364     { &hf_ranap_maxBitrate,
4365       { "maxBitrate",
4366         "ranap.rab_Parameters.maxBitrate",
4367         FT_UINT32, BASE_DEC, NULL, 0x0,
4368         "", HFILL }
4369     },
4370     { &hf_ranap_guaranteedBitrate,
4371       { "guaranteedBitrate",
4372         "ranap.rab_Parameters.guaranteedBitrate",
4373         FT_UINT32, BASE_DEC, NULL, 0x0,
4374         "", HFILL }
4375     },
4376     { &hf_ranap_deliveryOrder,
4377       { "deliveryOrder",
4378         "ranap.rab_Parameters.deliveryOrder",
4379         FT_UINT8, BASE_DEC, VALS(&ranap_DeliveryOrder_values), 0x0,
4380         "", HFILL }
4381     },
4382     { &hf_ranap_maxSDU_Size,
4383       { "maxSDU_Size",
4384         "ranap.rab_Parameters.maxSDU_Size",
4385         FT_UINT16, BASE_DEC, NULL, 0x0,
4386         "", HFILL }
4387     },
4388     { &hf_ranap_sDU_ErrorRatio_mantissa,
4389       { "sDU_ErrorRatio: mantissa",
4390         "ranap.rab_Parameters.sDU_ErrorRatio.mantissa",
4391         FT_UINT8, BASE_DEC, NULL, 0x0,
4392         "", HFILL }
4393     },
4394     { &hf_ranap_sDU_ErrorRatio_exponent,
4395       { "sDU_ErrorRatio: exponent",
4396         "ranap.rab_Parameters.sDU_ErrorRatio.exponent",
4397         FT_UINT8, BASE_DEC, NULL, 0x0,
4398         "", HFILL }
4399     },
4400     { &hf_ranap_residualBitErrorRatio_mantissa,
4401       { "residualBitErrorRatio: mantissa",
4402         "ranap.rab_Parameters.residualBitErrorRatio.mantissa",
4403         FT_UINT8, BASE_DEC, NULL, 0x0,
4404         "", HFILL }
4405     },
4406     { &hf_ranap_residualBitErrorRatio_exponent,
4407       { "residualBitErrorRatio: exponent",
4408         "ranap.rab_Parameters.residualBitErrorRatio.exponent",
4409         FT_UINT8, BASE_DEC, NULL, 0x0,
4410         "", HFILL }
4411     },
4412     { &hf_ranap_deliveryOfErroneousSDU,
4413       { "deliveryOfErroneousSDU",
4414         "ranap.rab_Parameters.ranap_deliveryOfErroneousSDU",
4415         FT_UINT8, BASE_DEC, VALS(&ranap_deliveryOfErroneousSDU_values), 0x0,
4416         "", HFILL }
4417     },
4418     { &hf_ranap_subflowSDU_Size,
4419       { "subflowSDU_Size",
4420         "ranap.rab_Parameters.subflowSDU_Size",
4421         FT_UINT8, BASE_DEC, NULL, 0x0,
4422         "", HFILL }
4423     },
4424     { &hf_ranap_rAB_SubflowCombinationBitRate,
4425       { "rAB_SubflowCombinationBitRate",
4426         "ranap.rab_Parameters.rAB_SubflowCombinationBitRate",
4427         FT_UINT32, BASE_DEC, NULL, 0x0,
4428         "", HFILL }
4429     },
4430     { &hf_ranap_sDU_ErrorRatio_present,
4431       { "sDU_ErrorRatio",
4432         "ranap.sDU_ErrorRatio_present",
4433         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4434         "", HFILL }
4435     },
4436     { &hf_ranap_sDU_FormatInformationParameters_present,
4437       { "sDU_FormatInformationParameters",
4438         "ranap.sDU_FormatInformationParameters_present",
4439         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4440         "", HFILL }
4441     },
4442     { &hf_ranap_subflowSDU_Size_present,
4443       { "subflowSDU_Size",
4444         "ranap.subflowSDU_Size_present",
4445         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4446         "", HFILL }
4447     },
4448     { &hf_ranap_rAB_SubflowCombinationBitRate_present,
4449       { "subflowSDU_Size",
4450         "ranap.rAB_SubflowCombinationBitRate_present",
4451         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4452         "", HFILL }
4453     },
4454     { &hf_ranap_transferDelay,
4455       { "transferDelay",
4456         "ranap.rab_Parameters.transferDelay",
4457         FT_UINT16, BASE_DEC, NULL, 0x0,
4458         "", HFILL }
4459     },
4460     { &hf_ranap_trafficHandlingPriority,
4461       { "trafficHandlingPriority",
4462         "ranap.rab_Parameters.trafficHandlingPriority",
4463         FT_UINT8, BASE_DEC, VALS(&ranap_priority_values), 0x0,
4464         "", HFILL }
4465     },
4466     { &hf_ranap_priorityLevel,
4467       { "priorityLevel",
4468         "ranap.rab_Parameters.allocationOrRetentionPriority.priorityLevel",
4469         FT_UINT8, BASE_DEC, VALS(&ranap_priority_values), 0x0,
4470         "", HFILL }
4471     },
4472     { &hf_ranap_pre_emptionCapability,
4473       { "pre-emptionCapability",
4474         "ranap.rab_Parameters.allocationOrRetentionPriority.pre_emptionCapability",
4475         FT_UINT8, BASE_DEC, VALS(&ranap_pre_emptionCapability_values), 0x0,
4476         "", HFILL }
4477     },
4478     { &hf_ranap_pre_emptionVulnerability,
4479       { "pre-emptionVulnerability",
4480         "ranap.rab_Parameters.allocationOrRetentionPriority.pre_emptionVulnerability",
4481         FT_UINT8, BASE_DEC, VALS(&ranap_pre_emptionVulnerability_values), 0x0,
4482         "", HFILL }
4483     },
4484     { &hf_ranap_queuingAllowed,
4485       { "queuingAllowed",
4486         "ranap.rab_Parameters.allocationOrRetentionPriority.queuingAllowed",
4487         FT_UINT8, BASE_DEC, VALS(&ranap_queuingAllowed_values), 0x0,
4488         "", HFILL }
4489     },
4490     { &hf_ranap_sourceStatisticsDescriptor,
4491       { "sourceStatisticsDescriptor",
4492         "ranap.rab_Parameters.sourceStatisticsDescriptor",
4493         FT_UINT8, BASE_DEC, VALS(&ranap_sourceStatisticsDescriptor_values), 0x0,
4494         "", HFILL }
4495     },
4496     { &hf_ranap_relocationRequirement,
4497       { "relocationRequirement",
4498         "ranap.rab_Parameters.relocationRequirement",
4499         FT_UINT8, BASE_DEC, VALS(&ranap_relocationRequirement_values), 0x0,
4500         "", HFILL }
4501     },
4502     { &hf_ranap_userPlaneMode,
4503       { "userPlaneMode",
4504         "ranap.userPlaneMode",
4505         FT_UINT8, BASE_DEC, VALS(&ranap_userPlaneMode_values), 0x0,
4506         "", HFILL }
4507     },
4508     { &hf_ranap_uP_ModeVersions,
4509       { "uP_ModeVersions",
4510         "ranap.uP_ModeVersions",
4511         FT_BYTES, BASE_NONE, NULL, 0x0,
4512         "", HFILL }
4513     },
4514     { &hf_ranap_number_of_ProtocolExtensionFields,
4515       { "Number of ProtocolExtensionFields",
4516         "ranap.number_of_ProtocolExtensionFields",
4517         FT_UINT16, BASE_DEC, NULL, 0x0,
4518         "", HFILL }
4519     },
4520     { &hf_ranap_ext_field_number_of_octets,
4521       { "Number of octets",
4522         "ranap.ProtocolExtensionFields.octets",
4523         FT_UINT16, BASE_DEC, NULL, 0x0,
4524         "", HFILL }
4525     },
4526     { &hf_ranap_transportLayerAddress_length,
4527       { "bit length of transportLayerAddress",
4528         "ranap.transportLayerAddress_length",
4529         FT_UINT8, BASE_DEC, NULL, 0x0,
4530         "", HFILL }
4531     },
4532     { &hf_ranap_transportLayerAddress,
4533       { "transportLayerAddress",
4534         "ranap.transportLayerAddress",
4535         FT_BYTES, BASE_NONE, NULL, 0x0,
4536         "", HFILL }
4537     },
4538     { &hf_ranap_gTP_TEI,
4539       { "gTP_TEI",
4540         "ranap.gTP_TEI",
4541         FT_BYTES, BASE_NONE, NULL, 0x0,
4542         "", HFILL }
4543     },
4544     { &hf_ranap_bindingID,
4545       { "bindingID",
4546         "ranap.bindingID",
4547         FT_BYTES, BASE_NONE, NULL, 0x0,
4548         "", HFILL }
4549     },
4550     { &hf_ranap_pDP_TypeInformation_present,
4551       { "pDP_TypeInformation",
4552         "ranap.pDP_TypeInformation_present",
4553         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4554         "", HFILL }
4555     },
4556     { &hf_ranap_dataVolumeReportingIndication_present,
4557       { "dataVolumeReportingIndication",
4558         "ranap.dataVolumeReportingIndication_present",
4559         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4560         "", HFILL }
4561     },
4562     { &hf_ranap_dl_GTP_PDU_SequenceNumber_present,
4563       { "dl_GTP_PDU_SequenceNumber",
4564         "ranap.dl_GTP_PDU_SequenceNumber_present",
4565         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4566         "", HFILL }
4567     },
4568     { &hf_ranap_ul_GTP_PDU_SequenceNumber_present,
4569       { "ul_GTP_PDU_SequenceNumber",
4570         "ranap.ul_GTP_PDU_SequenceNumber_present",
4571         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4572         "", HFILL }
4573     },
4574     { &hf_ranap_dl_N_PDU_SequenceNumber_present,
4575       { "dl_N_PDU_SequenceNumber",
4576         "ranap.dl_N_PDU_SequenceNumber_present",
4577         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4578         "", HFILL }
4579     },
4580     { &hf_ranap_ul_N_PDU_SequenceNumber_present,
4581       { "ul_N_PDU_SequenceNumber",
4582         "ranap.ul_N_PDU_SequenceNumber_present",
4583         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4584         "", HFILL }
4585     },
4586     { &hf_ranap_PDP_Type,
4587       { "PDP-Type",
4588         "ranap.RAB_SetupOrModifyItemSecond.PDP_Type",
4589         FT_UINT8, BASE_HEX, VALS(&ranap_PDP_Type_values), 0x0,
4590         "", HFILL }
4591     },
4592     { &hf_ranap_dataVolumeReportingIndication,
4593       { "dataVolumeReportingIndication",
4594         "ranap.RAB_SetupOrModifyItemSecond.dataVolumeReportingIndication",
4595         FT_UINT8, BASE_HEX, VALS(&ranap_dataVolumeReportingIndication_values), 0x0,
4596         "", HFILL }
4597     },
4598     { &hf_ranap_dl_GTP_PDU_SequenceNumber,
4599       { "dl_GTP_PDU_SequenceNumber",
4600         "ranap.RAB_SetupOrModifyItemSecond.dl_GTP_PDU_SequenceNumber",
4601         FT_UINT16, BASE_DEC, NULL, 0x0,
4602         "", HFILL }
4603     },
4604     { &hf_ranap_ul_GTP_PDU_SequenceNumber,
4605       { "ul_GTP_PDU_SequenceNumber",
4606         "ranap.RAB_SetupOrModifyItemSecond.ul_GTP_PDU_SequenceNumber",
4607         FT_UINT16, BASE_DEC, NULL, 0x0,
4608         "", HFILL }
4609     },
4610     { &hf_ranap_dl_N_PDU_SequenceNumber,
4611       { "ul_GTP_PDU_SequenceNumber",
4612         "ranap.RAB_SetupOrModifyItemSecond.ul_GTP_PDU_SequenceNumber",
4613         FT_UINT16, BASE_DEC, NULL, 0x0,
4614         "", HFILL }
4615     },
4616     { &hf_ranap_ul_N_PDU_SequenceNumber,
4617       { "ul_GTP_PDU_SequenceNumber",
4618         "ranap.RAB_SetupOrModifyItemSecond.ul_GTP_PDU_SequenceNumber",
4619         FT_UINT16, BASE_DEC, NULL, 0x0,
4620         "", HFILL }
4621     },
4622     { &hf_ranap_cause_choice,
4623       { "cause choice",
4624         "ranap.cause_choice",
4625         FT_UINT8, BASE_HEX, VALS(&ranap_cause_choice_values), 0x0,
4626         "", HFILL }
4627     },
4628     { &hf_ranap_cause_value,
4629       { "cause value",
4630         "ranap.cause_value",
4631         FT_UINT8, BASE_DEC,VALS(&ranap_cause_value_str), 0x0,
4632         "", HFILL }
4633     },
4634     { &hf_ranap_transportLayerAddress_present,
4635       { "transportLayerAddress",
4636         "ranap.transportLayerAddress_present",
4637         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4638         "", HFILL }
4639     },
4640     { &hf_ranap_iuTransportAssociation_present,
4641       { "iuTransportAssociation",
4642         "ranap.iuTransportAssociation_present",
4643         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4644         "", HFILL }
4645     },
4646     { &hf_ranap_dl_dataVolumes_present,
4647       { "dl_dataVolumes",
4648         "ranap.dl_dataVolumes_present",
4649         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4650         "", HFILL }
4651     },
4652     { &hf_ranap_dataVolumeReference_present,
4653       { "dataVolumeReference",
4654         "ranap.dataVolumeReference_present",
4655         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4656         "", HFILL }
4657     },
4658     { &hf_ranap_dl_UnsuccessfullyTransmittedDataVolume,
4659       { "dl-UnsuccessfullyTransmittedDataVolume",
4660         "ranap.dl-UnsuccessfullyTransmittedDataVolume",
4661         FT_UINT32, BASE_DEC, NULL, 0x0,
4662         "", HFILL }
4663     },
4664     { &hf_ranap_dataVolumeReference,
4665       { "dataVolumeReference",
4666         "ranap.dataVolumeReference",
4667         FT_UINT8, BASE_DEC, NULL, 0x0,
4668         "", HFILL }
4669     },
4670     { &hf_ranap_procedureCode_present,
4671       { "procedureCode",
4672         "ranap.procedureCode_present",
4673         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4674         "", HFILL }
4675     },
4676     { &hf_ranap_triggeringMessage_present,
4677       { "triggeringMessage",
4678         "ranap.triggeringMessage_present",
4679         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4680         "", HFILL }
4681     },
4682     { &hf_ranap_procedureCriticality_present,
4683       { "procedureCriticality",
4684         "ranap.procedureCriticality_present",
4685         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4686         "", HFILL }
4687     },
4688     { &hf_ranap_iEsCriticalityDiagnostics_present,
4689       { "iEsCriticalityDiagnostics",
4690         "ranap.iEsCriticalityDiagnostics_present",
4691         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4692         "", HFILL }
4693     },
4694     { &hf_ranap_triggeringMessage,
4695       { "triggeringMessage",
4696         "ranap.triggeringMessage",
4697         FT_UINT8, BASE_HEX, VALS(&ranap_pdu_index_values), 0x0,
4698         "", HFILL }
4699     },
4700     { &hf_ranap_procedureCriticality,
4701       { "procedureCriticality",
4702         "ranap.procedureCriticality",
4703         FT_UINT8, BASE_HEX, VALS(&ranap_criticality_values), 0x0,
4704         "", HFILL }
4705     },
4706     { &hf_ranap_iECriticality,
4707       { "iECriticality",
4708         "ranap.iECriticality",
4709         FT_UINT8, BASE_HEX, VALS(&ranap_criticality_values), 0x0,
4710         "", HFILL }
4711     },
4712     { &hf_ranap_repetitionNumber,
4713       { "repetitionNumber",
4714         "ranap.repetitionNumber",
4715         FT_UINT16, BASE_DEC, NULL, 0x0,
4716         "", HFILL }
4717     },
4718     { &hf_ranap_num_of_CriticalityDiagnostics_IEs,
4719       { "Number of CriticalityDiagnostics-IEs",
4720         "ranap.num_of_CriticalityDiagnostics_IEs",
4721         FT_UINT16, BASE_DEC, NULL, 0x0,
4722         "", HFILL }
4723     },
4724     { &hf_ranap_repetitionNumber_present,
4725       { "repetitionNumber",
4726         "ranap.repetitionNumber_present",
4727         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4728         "", HFILL }
4729     },
4730     { &hf_ranap_dl_UnsuccessfullyTransmittedDataVolume_present,
4731       { "dl-UnsuccessfullyTransmittedDataVolume",
4732         "ranap.dl_UnsuccessfullyTransmittedDataVolume_present",
4733         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4734         "", HFILL }
4735     },
4736     { &hf_ranap_CN_DomainIndicator,
4737       { "CN-DomainIndicator",
4738         "ranap.CN_DomainIndicator",
4739         FT_UINT8, BASE_HEX, VALS(&ranap_CN_DomainIndicator_values), 0x0,
4740         "", HFILL }
4741     },
4742     { &hf_ranap_service_Handover,
4743       { "service-Handover",
4744         "ranap.service_Handover",
4745         FT_UINT8, BASE_HEX, VALS(&ranap_service_Handover_values), 0x0,
4746         "", HFILL }
4747     },
4748     { &hf_ranap_IuSigConId,
4749       { "IuSigConId",
4750         "ranap.IuSigConId",
4751         FT_UINT24, BASE_DEC, NULL, 0x0,
4752         "", HFILL }
4753     },
4754     { &hf_ranap_SAPI,
4755       { "SAPI",
4756         "ranap.sapi",
4757         FT_UINT8, BASE_HEX, VALS(&ranap_SAPI_values), 0x0,
4758         "", HFILL }
4759     },
4760     { &hf_ranap_msg_extension_present,
4761       { "Message Extension",
4762         "ranap.msg_extension_present",
4763         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4764         "", HFILL }
4765     },
4766     { &hf_ranap_ProtocolExtensionContainer_present,
4767       { "ProtocolExtensionContainer",
4768         "ranap.ProtocolExtensionContainer_present",
4769         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4770         "", HFILL }
4771     },
4772     { &hf_ranap_nas_pdu_length,
4773       { "length of NAS-PDU",
4774         "ranap.nas_pdu_length",
4775         FT_UINT16, BASE_DEC, NULL, 0x0,
4776         "", HFILL }
4777     },
4778     { &hf_ranap_RNC_ID,
4779       { "RNC ID",
4780         "ranap.RNC_ID",
4781         FT_UINT16, BASE_DEC, NULL, 0x0fff,
4782         "", HFILL }
4783     }
4784   };
4785
4786   /* Setup protocol subtree array */
4787   static gint *ett[] = {
4788     &ett_ranap,
4789     &ett_ranap_optionals,
4790     &ett_ranap_iE_Extension,
4791     &ett_ranap_ie,
4792     &ett_ranap_ie_pair,
4793     &ett_ranap_rab,
4794     &ett_ranap_ie_pair_first_value,
4795     &ett_ranap_ie_pair_second_value,
4796     &ett_ranap_sDU,
4797     &ett_ranap_rAB_Parameters,
4798     &ett_ranap_allocationOrRetentionPriority  ,
4799     &ett_ranap_CriticalityDiagnostics_IE
4800   };
4801
4802
4803   /* Register the protocol name and description */
4804   proto_ranap = proto_register_protocol("Radio Access Network Application Part",
4805                                        "RANAP", "ranap");
4806
4807   /* Register the header fields and subtrees */
4808   proto_register_field_array(proto_ranap, hf, array_length(hf));
4809   proto_register_subtree_array(ett, array_length(ett));
4810
4811   nas_pdu_dissector_table = register_dissector_table("ranap.nas_pdu", "RANAP NAS PDU", FT_UINT8, BASE_DEC);
4812 };
4813
4814
4815 void
4816 proto_reg_handoff_ranap(void)
4817 {
4818   dissector_handle_t ranap_handle;
4819
4820   ranap_handle = create_dissector_handle(dissect_ranap, proto_ranap);
4821   /*
4822   dissector_add("sua.ssn",  SCCP_SSN_RANAP, ranap_handle);
4823   */
4824   dissector_add("sccp.ssn", SCCP_SSN_RANAP, ranap_handle);
4825 }