From Todd Sabin: allocate the buffer for the decrypted payload, rather
[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.16 2002/12/10 21:41:23 tuexen 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 /* pdu header fields */
777 static int hf_ranap_pdu_number_of_octets = -1;
778 static int hf_ranap_pdu_index = -1;
779 static int hf_ranap_procedure_code = -1;
780 static int hf_ranap_pdu_criticality = -1;
781 static int hf_ranap_number_of_ies = -1;
782
783 /* ie header fields */
784 static int hf_ranap_ie_ie_id = -1;
785 static int hf_ranap_ie_criticality = -1;
786 static int hf_ranap_ie_number_of_octets = -1;
787 static int hf_ranap_ie_protocol_extension = -1;
788
789 /*ie contents fields */
790 static int hf_ranap_number_of_ies_in_list = -1;
791 static int hf_ranap_ie_pair_first_criticality = -1;
792 static int hf_ranap_ie_pair_second_criticality = -1;
793 static int hf_ranap_first_value_number_of_octets = -1;
794 static int hf_ranap_second_value_number_of_octets = -1;
795 static int hf_ranap_rab_id = -1;
796 static int hf_ranap_nas_pdu = -1;
797 static int hf_ranap_plmn_id = -1;
798 static int hf_ranap_lac = -1;
799 static int hf_ranap_sac = -1;
800 static int hf_ranap_rac = -1;
801 static int hf_ranap_nAS_SynchronisationIndicator = -1;
802 static int hf_ranap_trafficClass = -1;
803 static int hf_ranap_deliveryOrder = -1;
804 static int hf_ranap_iE_Extensions_present = -1;
805 static int hf_ranap_num_rabs = -1;
806 static int hf_ranap_nAS_SynchronisationIndicator_present = -1;
807 static int hf_ranap_rAB_Parameters_present = -1;
808 static int hf_ranap_userPlaneInformation_present = -1;
809 static int hf_ranap_transportLayerInformation_present = -1;
810 static int hf_ranap_service_Handover_present = -1;
811 static int hf_ranap_guaranteedBitRate_present = -1;
812 static int hf_ranap_transferDelay_present = -1;
813 static int hf_ranap_trafficHandlingPriority_present = -1;
814 static int hf_ranap_allocationOrRetentionPriority_present = -1;
815 static int hf_ranap_sourceStatisticsDescriptor_present = -1;
816 static int hf_ranap_relocationRequirement_present = -1;
817 static int hf_ranap_rAB_AsymmetryIndicator = -1;
818 static int hf_ranap_maxBitrate = -1;
819 static int hf_ranap_guaranteedBitrate = -1;
820 static int hf_ranap_maxSDU_Size = -1;
821 static int hf_ranap_sDU_ErrorRatio_mantissa = -1;
822 static int hf_ranap_sDU_ErrorRatio_exponent = -1;
823 static int hf_ranap_residualBitErrorRatio_mantissa = -1;
824 static int hf_ranap_residualBitErrorRatio_exponent = -1;
825 static int hf_ranap_deliveryOfErroneousSDU = -1;
826 static int hf_ranap_subflowSDU_Size = -1;
827 static int hf_ranap_rAB_SubflowCombinationBitRate = -1;
828 static int hf_ranap_sDU_ErrorRatio_present = -1;
829 static int hf_ranap_sDU_FormatInformationParameters_present = -1;
830 static int hf_ranap_subflowSDU_Size_present = -1;
831 static int hf_ranap_rAB_SubflowCombinationBitRate_present = -1;
832 static int hf_ranap_transferDelay = -1;
833 static int hf_ranap_trafficHandlingPriority = -1;
834 static int hf_ranap_priorityLevel = -1;
835 static int hf_ranap_pre_emptionCapability = -1;
836 static int hf_ranap_pre_emptionVulnerability = -1;
837 static int hf_ranap_queuingAllowed = -1;
838 static int hf_ranap_sourceStatisticsDescriptor = -1;
839 static int hf_ranap_userPlaneMode = -1;
840 static int hf_ranap_uP_ModeVersions = -1;
841 static int hf_ranap_number_of_ProtocolExtensionFields = -1;
842 static int hf_ranap_ext_field_id = -1;
843 static int hf_ranap_ext_field_criticality = -1;
844 static int hf_ranap_ext_field_number_of_octets = -1;
845 static int hf_ranap_transportLayerAddress = -1;
846 static int hf_ranap_transportLayerAddress_length = -1;
847 static int hf_ranap_gTP_TEI = -1;
848 static int hf_ranap_bindingID = -1;
849 static int hf_ranap_pDP_TypeInformation_present = -1;
850 static int hf_ranap_dataVolumeReportingIndication_present = -1;
851 static int hf_ranap_dl_GTP_PDU_SequenceNumber_present = -1;
852 static int hf_ranap_ul_GTP_PDU_SequenceNumber_present = -1;
853 static int hf_ranap_dl_N_PDU_SequenceNumber_present = -1;
854 static int hf_ranap_ul_N_PDU_SequenceNumber_present = -1;
855 static int hf_ranap_PDP_Type = -1;
856 static int hf_ranap_dataVolumeReportingIndication = -1;
857 static int hf_ranap_dl_GTP_PDU_SequenceNumber = -1;
858 static int hf_ranap_ul_GTP_PDU_SequenceNumber = -1;
859 static int hf_ranap_dl_N_PDU_SequenceNumber = -1;
860 static int hf_ranap_ul_N_PDU_SequenceNumber = -1;
861 static int hf_ranap_cause_choice = -1;
862 static int hf_ranap_cause_value = -1;
863 static int hf_ranap_transportLayerAddress_present = -1;
864 static int hf_ranap_iuTransportAssociation_present = -1;
865 static int hf_ranap_dl_dataVolumes_present = -1;
866 static int hf_ranap_dataVolumeReference_present = -1;
867 static int hf_ranap_dl_UnsuccessfullyTransmittedDataVolume = -1;
868 static int hf_ranap_dataVolumeReference = -1;
869 static int hf_ranap_procedureCode_present = -1;
870 static int hf_ranap_triggeringMessage_present = -1;
871 static int hf_ranap_procedureCriticality_present = -1;
872 static int hf_ranap_iEsCriticalityDiagnostics_present = -1;
873 static int hf_ranap_triggeringMessage = -1;
874 static int hf_ranap_iECriticality = -1;
875 static int hf_ranap_procedureCriticality = -1;
876 static int hf_ranap_repetitionNumber = -1;
877 static int hf_ranap_num_of_CriticalityDiagnostics_IEs = -1;
878 static int hf_ranap_repetitionNumber_present = -1;
879 static int hf_ranap_dl_UnsuccessfullyTransmittedDataVolume_present = -1;
880 static int hf_ranap_CN_DomainIndicator = -1;
881 static int hf_ranap_IuSigConId = -1;
882 static int hf_ranap_SAPI = -1;
883 static int hf_ranap_msg_extension_present = -1;
884 static int hf_ranap_ProtocolExtensionContainer_present = -1;
885 static int hf_ranap_nas_pdu_length = -1;
886 static int hf_ranap_relocationRequirement = -1;
887 static int hf_ranap_service_Handover = -1;
888 static int hf_ranap_extension_field = -1;
889
890
891 /* subtrees */
892 static gint ett_ranap = -1;
893 static gint ett_ranap_optionals = -1;
894 static gint ett_ranap_iE_Extension = -1;
895 static gint ett_ranap_ie = -1;
896 static gint ett_ranap_ie_pair = -1;
897 static gint ett_ranap_rab = -1;
898 static gint ett_ranap_ie_pair_first_value = -1;
899 static gint ett_ranap_ie_pair_second_value = -1;
900 static gint ett_ranap_rAB_Parameters = -1;
901 static gint ett_ranap_sDU = -1;
902 static gint ett_ranap_allocationOrRetentionPriority = -1;
903 static gint ett_ranap_CriticalityDiagnostics_IE = -1;
904
905
906
907 /*****************************************************************************/
908 /*                                                                           */
909 /*  Utility Functions                                                        */
910 /*                                                                           */
911 /*****************************************************************************/
912
913 /* sets *offset and *bitoffset n bits further */
914 static void
915 proceed_nbits(gint *offset, gint *bitoffset, gint n)
916 {
917    *bitoffset += n;
918    *offset += *bitoffset / 8;
919    *bitoffset %= 8;
920 }
921
922 /* sets *offset and *bitoffset to the next byte boundary */
923 static void allign(gint *offset, gint *bitoffset)
924 {
925   if ( *bitoffset != 0 )
926   {
927      (*offset)++;
928      *bitoffset=0;
929   }
930 }
931
932 /* sets *offset and *bitoffset behind the following integer */
933 static void
934 proceed_perint32(gint *offset, gint *bitoffset, gint length)
935 {
936    proceed_nbits(offset, bitoffset, 2);
937    allign(offset, bitoffset);
938    *offset += length;
939 }
940
941
942 /* extract length field found at offset */
943 /* if length field spans more than two bytes -1 is returned and the field is not decoded */
944 static guint8
945 extract_length(tvbuff_t *tvb, gint offset, gint *length, gint *length_size)
946 {
947    guint8       tmp_length8;
948    guint16      tmp_length16;
949
950    tmp_length8 = tvb_get_guint8(tvb, offset);
951    if ((tmp_length8 & 0x80) == 0)
952    {
953         /* length coded in one byte */
954         *length = tmp_length8;
955         *length_size = 1;
956     }
957     else
958     {
959         tmp_length16 = tvb_get_ntohs(tvb, offset);
960         if ( ((tmp_length16 & 0x8000) == 0x8000) &&  ((tmp_length16 & 0x4000) == 0) )
961         {
962             /* length coded in two bytes */
963             *length = tmp_length16 & 0x3FFF;
964             *length_size = 2;
965         }
966         else
967         {   /* length is coded in more than 2 bytes */
968            return (-1);
969         }
970     }
971     return(0);
972 }
973
974 /* extract the next n bits and return them alligned to the LSB */
975 static guint8
976 extract_nbits(tvbuff_t *tvb, gint offset, gint bitoffset, gint n)
977 {
978    guint8       uint_bits;
979    guint16      tmp_2bytes;
980
981    /* extract value */
982    if (bitoffset + n <= 8)
983    {
984       /* all bits contained in one byte */
985       uint_bits = tvb_get_guint8(tvb, offset);
986       uint_bits <<= bitoffset;                          /* remove bitoffset */
987       uint_bits >>= 8-n;                                /* allign to LSB */
988    }
989    else
990    {
991       /* bits contained within 2 bytes */
992       tmp_2bytes = tvb_get_ntohs(tvb, offset);
993       tmp_2bytes <<=  bitoffset;                        /* remove bitoffset */
994       uint_bits = tmp_2bytes >> ( 8 + (8-n));           /* allign to LSB */
995    }
996
997    return(uint_bits);
998 }
999
1000
1001 /* extract an integer with 2bit length field and return the int value*/
1002 static guint32
1003 extract_int32(tvbuff_t *tvb, gint offset, gint bitoffset, gint *length)
1004 {
1005    guint16      tmp_2byte;
1006    guint32      result = 0;
1007
1008    tmp_2byte = tvb_get_ntohs(tvb, offset);
1009
1010    tmp_2byte <<= bitoffset;             /* remove bitoffset */
1011    *length = tmp_2byte >> (6 + 8);      /* allign 2bit length field to LSB */
1012    (*length)++;                         /* now we have the length of the int value */
1013
1014    proceed_nbits(&offset, &bitoffset, 2);
1015    allign(&offset, &bitoffset);
1016
1017    switch (*length)
1018    {
1019       case 1:
1020          result = tvb_get_guint8(tvb, offset);
1021          break;
1022       case 2:
1023          result = tvb_get_ntohs(tvb, offset);
1024          break;
1025       case 3:
1026          result = tvb_get_ntoh24(tvb, offset);
1027          break;
1028       case 4:
1029          result = tvb_get_ntohl(tvb, offset);
1030          break;
1031     }
1032
1033     return(result);
1034 }
1035
1036
1037 /* return bitmask string looking like "..01 0..."  */
1038 static char *
1039 bitmaskstr(guint bitoffset, guint bitlength, guint16 value, guint *length)
1040 {
1041    static char          maskstr[20];
1042    guint                i;
1043
1044
1045    strcpy(maskstr, "                   ");
1046
1047    for (i=0; i<16; i++)
1048    {
1049       if ( i < bitoffset  ||  i > bitoffset+bitlength-1 )
1050       {
1051          /* i is outside extracted bitfield */
1052          maskstr[i + i/4] = '.';
1053       }
1054       else
1055       {  /* i is inside extracted bitfield */
1056          if ( ((0x8000 >> i) & value) != 0x0000 )
1057          {
1058             /* bit is set */
1059             maskstr[i + i/4] = '1';
1060          }
1061          else
1062          {
1063             /* bit is not set */
1064             maskstr[i + i/4] = '0';
1065          }
1066       }
1067    }
1068    if (bitoffset + bitlength <= 8)
1069    {
1070       /* bitfield is located within first byte only */
1071       maskstr[9] = '\0';
1072       *length = 1;
1073    }
1074    else
1075    {
1076       /* bitfield is located within first & second byte */
1077       maskstr[19] = '\0';
1078       *length = 2;
1079    }
1080
1081    return(maskstr);
1082 }
1083
1084 /* add bitstring */
1085 static proto_item *
1086 proto_tree_add_bitstring(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint offset,
1087                          gint bitoffset, gint bitlength)
1088 {
1089    guint16              read_2bytes;
1090    guint16              alligned_2bytes;
1091    guint8               one_byte;
1092    char                 *maskstr;
1093    char                 maskstr_buf[56] = "\0";
1094    guint                length;
1095    int                  i;
1096    guint8               bitstr[128];
1097    char                 buf[256] = "\0";
1098    header_field_info    *hf_info_p;
1099    gint                 byte_span;
1100    gint                 initial_offset = offset;
1101
1102    memset(bitstr, 0, 128);
1103
1104    /* create bitmask string for first byte */
1105    read_2bytes = tvb_get_ntohs(tvb, offset);
1106    maskstr = bitmaskstr(bitoffset, (bitoffset+bitlength >8) ? 8-bitoffset : bitlength, read_2bytes, &length);
1107    if (bitoffset+bitlength > 8)
1108    {
1109       sprintf(maskstr_buf, "%s + %d Bits = ", maskstr, bitlength - (8-bitoffset));
1110    }
1111    else
1112    {
1113       sprintf(maskstr_buf, "%s = ", maskstr);
1114    }
1115
1116
1117    /* print all but the last byte to buf */
1118    byte_span = (bitoffset + bitlength + 7) / 8;
1119    for (i=0; i < byte_span - 1; i++, offset++)
1120    {
1121       read_2bytes = tvb_get_ntohs(tvb, offset);
1122       alligned_2bytes = read_2bytes << bitoffset;       /* remove bitoffset */
1123       one_byte = alligned_2bytes >> 8;                  /* move to low byte */
1124
1125       bitstr[i]=one_byte;
1126       sprintf(&(buf[2*i]), "%02X", one_byte);
1127    }
1128
1129    /* add last byte if it contains bits which have not yet been shifted in */
1130    if ( ((bitlength + 7) / 8 ) == byte_span )
1131    {
1132       read_2bytes = tvb_get_ntohs(tvb, offset);
1133       alligned_2bytes = read_2bytes << bitoffset;       /* remove bitoffset */
1134       one_byte = alligned_2bytes >> 8;                  /* move to low byte */
1135       one_byte >>= (8 - (bitlength%8));                 /*cut off surplus bits */
1136       one_byte <<= (8 - (bitlength%8));                 /* allign to MSB in low byte*/
1137
1138       bitstr[i]=one_byte;
1139       sprintf(&(buf[2*i]), "%02X", one_byte);
1140    }
1141
1142    /* get header field info */
1143    hf_info_p = proto_registrar_get_nth(hfindex);
1144
1145
1146   return ( proto_tree_add_bytes_format(tree, hfindex, tvb, initial_offset,
1147            byte_span , bitstr, "%s %s: %s", maskstr_buf, hf_info_p->name, buf) );
1148
1149 }
1150
1151
1152 /* add unsigned int, 1-8 bits long */
1153 static proto_item *
1154 proto_tree_add_uint_bits(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint offset,
1155                          gint bitoffset, gint bitlength, gint min)
1156 {
1157    guint8               uint_bits;
1158    guint16              read_2bytes, alligned_2bytes;
1159    char                 *maskstr;
1160    guint                length;
1161    header_field_info    *hf_info_p;
1162
1163
1164    /* extract value */
1165    if (bitoffset + bitlength <= 8)
1166    {
1167       /* all bits contained in one byte */
1168       uint_bits = tvb_get_guint8(tvb, offset);
1169       read_2bytes = uint_bits;
1170       read_2bytes <<= 8;
1171    }
1172    else
1173    {
1174       /* bits contained within 2 bytes */
1175       read_2bytes = tvb_get_ntohs(tvb, offset);
1176    }
1177    alligned_2bytes = read_2bytes << bitoffset;                  /* remove bitoffset */
1178    uint_bits = alligned_2bytes >> ( 8 + (8-bitlength));         /* allign to LSB */
1179
1180    uint_bits += min;
1181
1182    /* create bitmask string */
1183    maskstr = bitmaskstr(bitoffset, bitlength, read_2bytes, &length);
1184
1185    /* get header field info */
1186    hf_info_p = proto_registrar_get_nth(hfindex);
1187
1188    if (hf_info_p->strings != NULL)
1189    {
1190       /* string representation for decoded header field present */
1191       return ( proto_tree_add_uint_format(tree, hfindex, tvb, offset,
1192               length, uint_bits, "%s = %s: %s (%d)", maskstr, hf_info_p->name,
1193               val_to_str(uint_bits, hf_info_p->strings, "%d"), uint_bits) );
1194    }
1195    else
1196    {
1197       /* no string representation */
1198       return ( proto_tree_add_uint_format(tree, hfindex, tvb, offset,
1199               length, uint_bits, "%s = %s: %d", maskstr, hf_info_p->name, uint_bits) );
1200    }
1201 }
1202
1203 /* add PER encoded integer (maximum length of value: 4 bytes) */
1204 static proto_item *
1205 proto_tree_add_PERint32(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint offset,
1206                          gint bitoffset, gint *length, gint min)
1207 {
1208     guint32             value;
1209     guint16             tmp_2bytes;
1210     char                *maskstr;
1211     guint               length_size;
1212     header_field_info   *hf_info_p;
1213
1214     /* get value */
1215     value = extract_int32(tvb, offset, bitoffset, length);
1216     value += min;
1217
1218     /* create bitmask string for 2 bit length field */
1219     tmp_2bytes = tvb_get_ntohs(tvb, offset);
1220     maskstr = bitmaskstr(bitoffset, 2, tmp_2bytes, &length_size);
1221
1222     /* get header field info */
1223     hf_info_p = proto_registrar_get_nth(hfindex);
1224
1225     return ( proto_tree_add_uint_format(tree, hfindex, tvb, offset,
1226              (*length) + length_size, value,
1227              "%s + %d Bytes = %s: %d", maskstr, *length, hf_info_p->name, value) );
1228 }
1229
1230
1231
1232 /*****************************************************************************/
1233 /*                                                                           */
1234 /*  Dissecting Functions for single parameters                               */
1235 /*                                                                           */
1236 /*****************************************************************************/
1237 static int
1238 dissect_iE_Extension(tvbuff_t *tvb, proto_tree *tree, gint *offset, gint *bitoffset, char *description)
1239 {
1240   proto_item    *ext_item = NULL;
1241   proto_tree    *ext_tree = NULL;
1242   guint16       number_of_extFields;
1243   gint          number_of_octets = 0;
1244   gint          number_of_octets_size = 0;
1245   int           i;
1246
1247   allign(offset, bitoffset);
1248
1249   /* create subtree for iE_Extension */
1250   if (tree)
1251   {
1252      ext_item = proto_tree_add_text(tree, tvb, *offset, 0, "%s iE-Extensions", description);
1253      ext_tree = proto_item_add_subtree(ext_item, ett_ranap_iE_Extension);
1254   }
1255
1256   /* number of extension fields */
1257   number_of_extFields = tvb_get_ntohs(tvb, *offset) + 1;
1258   if (ext_tree)
1259   {
1260      proto_tree_add_uint(ext_tree, hf_ranap_number_of_ProtocolExtensionFields,
1261                                  tvb, *offset, 2, number_of_extFields);
1262   }
1263
1264   *offset += 2;
1265
1266   /*  for each extension field */
1267   for (i=1; i <= number_of_extFields; i++)
1268   {
1269      /* add fields to ie subtee */
1270      /* Extension Field ID */
1271      if (ext_tree)
1272      {
1273         proto_tree_add_item(ext_tree, hf_ranap_ext_field_id, tvb,
1274                             *offset, IE_ID_LENGTH, FALSE);
1275      }
1276      *offset += IE_ID_LENGTH;
1277
1278      /* criticality */
1279      if (ext_tree)
1280      {
1281         proto_tree_add_uint_bits(ext_tree, hf_ranap_ext_field_criticality, tvb,
1282                                  *offset, *bitoffset, 2, 0);
1283      }
1284      proceed_nbits(offset, bitoffset, 2);
1285
1286      /* number of octets in the IE */
1287      allign(offset, bitoffset);
1288      if (0 == extract_length(tvb, *offset, &number_of_octets, &number_of_octets_size))
1289      {
1290        if (ext_tree)
1291        {
1292           proto_tree_add_uint(ext_tree, hf_ranap_ext_field_number_of_octets, tvb,
1293                               *offset, number_of_octets_size, number_of_octets);
1294        }
1295      }
1296      else
1297      {
1298        /* decoding is not supported */
1299        if (ext_tree)
1300        {
1301           proto_tree_add_text(ext_tree, tvb, *offset, 0,
1302                               "Number of Octets greater than 0x3FFF, dissection not supported");
1303        }
1304        return(-1);
1305      }
1306
1307      *offset += number_of_octets_size;
1308      if (ext_tree)
1309      {
1310         proto_tree_add_item(ext_tree, hf_ranap_extension_field, tvb,
1311                             *offset, number_of_octets, FALSE);
1312
1313      }
1314
1315      *offset +=  number_of_octets;
1316   }
1317
1318   return(0);
1319 }
1320
1321
1322 static int
1323 dissect_userPlaneInformation(tvbuff_t *tvb, proto_tree *tree, gint *offset, gint *bitoffset)
1324 {
1325    int          extension_present;
1326    int          iE_Extensions_present;
1327    int          tmp_extension_present;
1328
1329    /* protocol_extension present ? */
1330    extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1331    proceed_nbits(offset, bitoffset, 1);
1332
1333    /* iE_Extensions present ? */
1334    iE_Extensions_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1335    proceed_nbits(offset, bitoffset, 1);
1336
1337    /* userPlaneMode */
1338    tmp_extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1339    proceed_nbits(offset, bitoffset, 1);
1340
1341    proto_tree_add_uint_bits(tree, hf_ranap_userPlaneMode, tvb, *offset,
1342                             *bitoffset, 1, 0);
1343    proceed_nbits(offset, bitoffset, 1);
1344
1345    /* uP-ModeVersions */
1346    proto_tree_add_bitstring(tree, hf_ranap_uP_ModeVersions, tvb, *offset,
1347                             *bitoffset, 16);
1348    proceed_nbits(offset, bitoffset, 16);
1349
1350    /* iE-Extensions */
1351    if (iE_Extensions_present)
1352    {
1353       return(dissect_iE_Extension(tvb, tree, offset, bitoffset, "UserPlaneInformation"));
1354    }
1355    return(0);
1356 }
1357
1358
1359
1360 static int
1361 dissect_sDU_Parameters(tvbuff_t *tvb, proto_tree *ie_tree, gint *offset, gint *bitoffset)
1362 {
1363    proto_item   *sDU_item = NULL;
1364    proto_tree   *sDU_tree = NULL;
1365    proto_item   *optionals_item = NULL;
1366    proto_tree   *optionals_tree = NULL;
1367    int          ret;
1368    int          extension_present;
1369    int          sDU_ErrorRatio_present;
1370    int          sDU_FormatInformationParameters_present;
1371    int          iE_Extensions_present;
1372    int          sDU_ErrorRatio_iE_Extensions_present;
1373    int          residualBitErrorRatio_iE_Extensions_present;
1374    gint         length;
1375    gint         number_of_sDU_FormatInformationParameters;
1376    int          sDU_FormatInformationParameters_extension_present;
1377    int          subflowSDU_Size_present;
1378    int          rAB_SubflowCombinationBitRate_present;
1379    int          sDU_FormatInformationParameters_iE_Extensions_present;
1380    gint         i;
1381
1382    /* create subtree for sDU_Parameters */
1383    sDU_item = proto_tree_add_text(ie_tree, tvb, *offset, 0,
1384                                       "sDU Parameters");
1385    sDU_tree = proto_item_add_subtree(sDU_item, ett_ranap_sDU);
1386
1387    /* create subtree for extension/optional/default bitmap */
1388    optionals_item = proto_tree_add_text(sDU_tree, tvb, *offset, 1,
1389                                       "sDU_Parameters Extension/Optional/Default bitmap");
1390    optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
1391
1392    /* protocol_extension present ? */
1393    extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1394    proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
1395                             *offset, *bitoffset, 1, 0);
1396    proceed_nbits(offset, bitoffset, 1);
1397
1398    /*  sDU_ErrorRatio present ? */
1399    sDU_ErrorRatio_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1400    proto_tree_add_uint_bits(optionals_tree, hf_ranap_sDU_ErrorRatio_present, tvb,
1401                             *offset, *bitoffset, 1, 0);
1402    proceed_nbits(offset, bitoffset, 1);
1403
1404    /*  sDU_FormatInformationParameters present ? */
1405    sDU_FormatInformationParameters_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1406    proto_tree_add_uint_bits(optionals_tree, hf_ranap_sDU_FormatInformationParameters_present, tvb,
1407                             *offset, *bitoffset, 1, 0);
1408    proceed_nbits(offset, bitoffset, 1);
1409
1410    /* iE_Extensions present ? */
1411    iE_Extensions_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1412    proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present, tvb,
1413                             *offset, *bitoffset, 1, 0);
1414    proceed_nbits(offset, bitoffset, 1);
1415
1416
1417    /* sDU_ErrorRatio */
1418    if (sDU_ErrorRatio_present)
1419    {
1420       sDU_ErrorRatio_iE_Extensions_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1421       proceed_nbits(offset, bitoffset, 1);
1422
1423       proto_tree_add_uint_bits(sDU_tree, hf_ranap_sDU_ErrorRatio_mantissa, tvb, *offset,
1424                                *bitoffset, 4, 1);
1425       proceed_nbits(offset, bitoffset, 4);
1426
1427       proto_tree_add_uint_bits(sDU_tree, hf_ranap_sDU_ErrorRatio_exponent, tvb, *offset,
1428                                *bitoffset, 3, 1);
1429       proceed_nbits(offset, bitoffset, 3);
1430
1431       if (sDU_ErrorRatio_iE_Extensions_present)
1432       {
1433          if ((ret=dissect_iE_Extension(tvb, sDU_tree, offset, bitoffset, "sDU_ErrorRatio")) != 0)
1434              return (ret);
1435       }
1436    }
1437
1438    /* residualBitErrorRatio */
1439    residualBitErrorRatio_iE_Extensions_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1440    proceed_nbits(offset, bitoffset, 1);
1441
1442    proto_tree_add_uint_bits(sDU_tree, hf_ranap_residualBitErrorRatio_mantissa, tvb, *offset,
1443                             *bitoffset, 4, 1);
1444    proceed_nbits(offset, bitoffset, 4);
1445
1446    proto_tree_add_uint_bits(sDU_tree, hf_ranap_sDU_ErrorRatio_exponent, tvb, *offset,
1447                             *bitoffset, 3, 1);
1448    proceed_nbits(offset, bitoffset, 3);
1449
1450
1451    if (residualBitErrorRatio_iE_Extensions_present)
1452    {
1453       if ((ret=dissect_iE_Extension(tvb, sDU_tree, offset, bitoffset, "residualBitErrorRatio")) != 0)
1454            return(ret);
1455    }
1456
1457
1458    /* deliveryOfErroneousSDU */
1459    proto_tree_add_uint_bits(sDU_tree, hf_ranap_deliveryOfErroneousSDU, tvb, *offset,
1460                             *bitoffset, 2, 0);
1461    proceed_nbits(offset, bitoffset, 2);
1462
1463
1464    /* sDU_FormatInformationParameters */
1465    if (sDU_FormatInformationParameters_present)
1466    {
1467       number_of_sDU_FormatInformationParameters = extract_nbits(tvb, *offset, *bitoffset, 6) + 1;
1468       proceed_nbits(offset, bitoffset, 6);
1469
1470       for (i=1; i<= number_of_sDU_FormatInformationParameters; i++)
1471       {
1472           /* create subtree for extension/optional/default bitmap */
1473          optionals_item = proto_tree_add_text(sDU_tree, tvb, *offset, 1,
1474                                       "sDU_FormatInformationParameters Extension/Optional/Default bitmap");
1475          optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
1476
1477          /* protocol extension present ? */
1478          sDU_FormatInformationParameters_extension_present =
1479              extract_nbits(tvb, *offset, *bitoffset, 1);
1480          proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
1481                             *offset, *bitoffset, 1, 0);
1482          proceed_nbits(offset, bitoffset, 1);
1483
1484          /* subflowSDU_Size present ? */
1485          subflowSDU_Size_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1486          proto_tree_add_uint_bits(optionals_tree, hf_ranap_subflowSDU_Size_present, tvb,
1487                             *offset, *bitoffset, 1, 0);
1488          proceed_nbits(offset, bitoffset, 1);
1489
1490          /* rAB_SubflowCombinationBitRate present ? */
1491          rAB_SubflowCombinationBitRate_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1492          proto_tree_add_uint_bits(optionals_tree, hf_ranap_rAB_SubflowCombinationBitRate_present, tvb,
1493                             *offset, *bitoffset, 1, 0);
1494          proceed_nbits(offset, bitoffset, 1);
1495
1496          /* ie_Extension present ? */
1497          sDU_FormatInformationParameters_iE_Extensions_present =
1498              extract_nbits(tvb, *offset, *bitoffset, 1);
1499          proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present, tvb,
1500                             *offset, *bitoffset, 1, 0);
1501          proceed_nbits(offset, bitoffset, 1);
1502
1503          if (subflowSDU_Size_present)
1504          {
1505             allign(offset, bitoffset);
1506             proto_tree_add_item(sDU_tree, hf_ranap_subflowSDU_Size,
1507                         tvb, *offset, subflowSDU_Size_LENGTH, FALSE);
1508             offset += subflowSDU_Size_LENGTH;
1509          }
1510
1511          if (rAB_SubflowCombinationBitRate_present)
1512          {
1513              proto_tree_add_PERint32(sDU_tree, hf_ranap_rAB_SubflowCombinationBitRate,
1514                                      tvb, *offset, *bitoffset, &length, 0);
1515              proceed_perint32(offset, bitoffset, length);
1516          }
1517
1518          if (sDU_FormatInformationParameters_iE_Extensions_present)
1519          {
1520             if ((ret=dissect_iE_Extension(tvb, sDU_tree, offset, bitoffset,
1521                                            "sDU_FormatInformationParameters" )) != 0)
1522                 return (ret);
1523          }
1524       }
1525     }
1526
1527     if (extension_present)
1528     {
1529         /* extended sequence */
1530         /* decoding is not supported */
1531         proto_tree_add_text(ie_tree, tvb, *offset, IE_PROTOCOL_EXTENSION_LENGTH,
1532                           "Protocol extension for sDU_FormatInformationParameters present, dissection not supported");
1533         return(-1);
1534     }
1535
1536   return (0);
1537
1538 }
1539
1540
1541 static int
1542 dissect_rAB_Parameters(tvbuff_t *tvb, proto_tree *ie_tree, gint *offset, gint *bitoffset)
1543 {
1544    guint8       tmp_byte;
1545    proto_item   *rab_item = NULL;
1546    proto_tree   *rab_tree = NULL;
1547    proto_item   *optionals_item = NULL;
1548    proto_tree   *optionals_tree = NULL;
1549    proto_item   *prio_item = NULL;
1550    proto_tree   *prio_tree = NULL;
1551    int          ret;
1552    int          extension_present;
1553    int          tmp_extension_present;
1554    int          guaranteedBitRate_present;
1555    int          transferDelay_present;
1556    int          trafficHandlingPriority_present;
1557    int          allocationOrRetentionPriority_present;
1558    int          sourceStatisticsDescriptor_present;
1559    int          relocationRequirement_present;
1560    int          iE_Extensions_present;
1561    int          tmp_iE_Extensions_present;
1562    int          i;
1563    gint         length;
1564
1565    /* create subtree for rAB_Parameters */
1566    rab_item = proto_tree_add_text(ie_tree, tvb, *offset, 0,
1567                                       "rAB_Parameters");
1568    rab_tree = proto_item_add_subtree(rab_item, ett_ranap_rAB_Parameters);
1569
1570    /* create subtree for extension/optional/default bitmap */
1571    optionals_item = proto_tree_add_text(rab_tree, tvb, *offset, IE_PROTOCOL_EXTENSION_LENGTH,
1572                                       "rAB_Parameters Extension/Optional/Default bitmap");
1573    optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
1574
1575    /* protocol extension present ? */
1576    extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1577    proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
1578                             *offset, *bitoffset, 1, 0);
1579    proceed_nbits(offset, bitoffset, 1);
1580
1581    /* guaranteedBitRate present ? */
1582    guaranteedBitRate_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1583    proto_tree_add_uint_bits(optionals_tree, hf_ranap_guaranteedBitRate_present,
1584                             tvb, *offset, *bitoffset, 1, 0);
1585    proceed_nbits(offset, bitoffset, 1);
1586
1587    /* transferDelay present ? */
1588    transferDelay_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1589    proto_tree_add_uint_bits(optionals_tree, hf_ranap_transferDelay_present,
1590                             tvb, *offset, *bitoffset, 1, 0);
1591    proceed_nbits(offset, bitoffset, 1);
1592
1593    /* trafficHandlingPriority present ? */
1594    trafficHandlingPriority_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1595    proto_tree_add_uint_bits(optionals_tree, hf_ranap_trafficHandlingPriority_present,
1596                             tvb, *offset, *bitoffset, 1, 0);
1597    proceed_nbits(offset, bitoffset, 1);
1598
1599    /* allocationOrRetentionPriority present ? */
1600    allocationOrRetentionPriority_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1601    proto_tree_add_uint_bits(optionals_tree, hf_ranap_allocationOrRetentionPriority_present,
1602                             tvb, *offset, *bitoffset, 1, 0);
1603    proceed_nbits(offset, bitoffset, 1);
1604
1605    /* sourceStatisticsDescriptor present ? */
1606    sourceStatisticsDescriptor_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1607    proto_tree_add_uint_bits(optionals_tree, hf_ranap_sourceStatisticsDescriptor_present,
1608                             tvb, *offset, *bitoffset, 1, 0);
1609    proceed_nbits(offset, bitoffset, 1);
1610
1611    /* relocationRequirement present ? */
1612    relocationRequirement_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1613    proto_tree_add_uint_bits(optionals_tree, hf_ranap_relocationRequirement_present,
1614                             tvb, *offset, *bitoffset, 1, 0);
1615    proceed_nbits(offset, bitoffset, 1);
1616
1617    /* iE-Extensions present ? */
1618    iE_Extensions_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1619    proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present,
1620                             tvb, *offset, *bitoffset, 1, 0);
1621    proceed_nbits(offset, bitoffset, 1);
1622
1623
1624    /* trafficClass */
1625    tmp_extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1626    proceed_nbits(offset, bitoffset, 1);
1627
1628    proto_tree_add_uint_bits(rab_tree, hf_ranap_trafficClass,
1629                             tvb, *offset, *bitoffset, 2, 0);
1630    proceed_nbits(offset, bitoffset, 2);
1631
1632    if (tmp_extension_present)
1633    {
1634       /* decoding is not supported */
1635       proto_tree_add_text(rab_tree, tvb, *offset, IE_PROTOCOL_EXTENSION_LENGTH,
1636                           "Protocol extension for trafficClass present, dissection not supported");
1637       return(-1);
1638    }
1639
1640
1641    /* rAB-AsymmetryIndicator */
1642    tmp_extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1643    proceed_nbits(offset, bitoffset, 1);
1644
1645    proto_tree_add_uint_bits(rab_tree, hf_ranap_rAB_AsymmetryIndicator,
1646                             tvb, *offset, *bitoffset, 2, 0);
1647    proceed_nbits(offset, bitoffset, 2);
1648
1649    if (tmp_extension_present)
1650    {
1651       /* decoding is not supported */
1652       proto_tree_add_text(rab_tree, tvb, *offset, IE_PROTOCOL_EXTENSION_LENGTH,
1653                           "Protocol extension for rAB-AsymmetryIndicator present, dissection not supported");
1654       return(-1);
1655    }
1656
1657
1658    /* maxBitrate */
1659    tmp_byte = extract_nbits(tvb, *offset, *bitoffset, 1) +1 ;  /*sequence 1..2 */
1660    proceed_nbits(offset, bitoffset, 1);
1661
1662    for (i=1; i<= tmp_byte; i++)
1663    {
1664       proto_tree_add_PERint32(rab_tree, hf_ranap_maxBitrate,
1665                               tvb, *offset, *bitoffset, &length, 1);
1666       proceed_perint32(offset, bitoffset, length);
1667    }
1668
1669
1670    /* guaranteedBitRate */
1671    if (guaranteedBitRate_present)
1672    {
1673       tmp_byte = extract_nbits(tvb, *offset, *bitoffset, 1) +1 ;  /*sequence 1..2 */
1674       proceed_nbits(offset, bitoffset, 1);
1675
1676       for (i=1; i<= tmp_byte; i++)
1677       {
1678         proto_tree_add_PERint32(rab_tree, hf_ranap_guaranteedBitrate,
1679                                 tvb, *offset, *bitoffset, &length, 0);
1680         proceed_perint32(offset, bitoffset, length);
1681       }
1682    }
1683
1684    /* deliveryOrder */
1685    proto_tree_add_uint_bits(rab_tree, hf_ranap_deliveryOrder, tvb, *offset,
1686                             *bitoffset, 1, 0);
1687    proceed_nbits(offset, bitoffset, 1);
1688
1689
1690    /* maxSDU-Size */
1691    allign(offset, bitoffset);
1692    proto_tree_add_item(rab_tree, hf_ranap_maxSDU_Size,
1693                         tvb, *offset, maxSDU_Size_LENGTH, FALSE);
1694    *offset += maxSDU_Size_LENGTH;
1695
1696    /* sDU-Parameters */
1697    tmp_byte = extract_nbits(tvb, *offset, *bitoffset, 3) + 1; /*sequence 1..7 */
1698    proceed_nbits(offset, bitoffset, 3);
1699    for (i=1; i<= tmp_byte; i++)
1700    {
1701       if ((ret=dissect_sDU_Parameters(tvb, rab_tree, offset, bitoffset))!=0) return(ret);
1702    }
1703
1704    /* transferDelay  */
1705    if (transferDelay_present)
1706    {
1707       allign(offset, bitoffset);
1708       proto_tree_add_item(rab_tree, hf_ranap_transferDelay,
1709                           tvb, *offset, transferDelay_LENGTH, FALSE);
1710       *offset += transferDelay_LENGTH;
1711    }
1712
1713
1714    /* trafficHandlingPriority */
1715    if (trafficHandlingPriority_present)
1716    {
1717       proto_tree_add_uint_bits(rab_tree, hf_ranap_trafficHandlingPriority, tvb, *offset,
1718                                *bitoffset, 4, 0);
1719       proceed_nbits(offset, bitoffset, 4);
1720    }
1721
1722    /* allocationOrRetentionPriority */
1723    if (allocationOrRetentionPriority_present)
1724    {
1725       /* create subtree for */
1726       prio_item = proto_tree_add_text(rab_tree, tvb, *offset, 0,
1727                                       "allocationOrRetentionPriority");
1728       prio_tree = proto_item_add_subtree(prio_item, ett_ranap_allocationOrRetentionPriority);
1729
1730       /* protocol extension  present ? */
1731       tmp_extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1732       proceed_nbits(offset, bitoffset, 1);
1733
1734       /* iE Extension present ? */
1735       tmp_iE_Extensions_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1736       proceed_nbits(offset, bitoffset, 1);
1737
1738       /* allocationOrRetentionPriority */
1739       proto_tree_add_uint_bits(prio_tree, hf_ranap_priorityLevel, tvb, *offset,
1740                                *bitoffset, 4, 0);
1741       proceed_nbits(offset, bitoffset, 4);
1742
1743       /* pre-emptionCapability */
1744       proto_tree_add_uint_bits(prio_tree, hf_ranap_pre_emptionCapability, tvb, *offset,
1745                                *bitoffset, 1, 0);
1746       proceed_nbits(offset, bitoffset, 1);
1747
1748       /* pre-emptionVulnerability */
1749       proto_tree_add_uint_bits(prio_tree, hf_ranap_pre_emptionVulnerability, tvb, *offset,
1750                                *bitoffset, 1, 0);
1751       proceed_nbits(offset, bitoffset, 1);
1752
1753       /* queuingAllowed */
1754       proto_tree_add_uint_bits(prio_tree, hf_ranap_queuingAllowed, tvb, *offset,
1755                                *bitoffset, 1, 0);
1756       proceed_nbits(offset, bitoffset, 1);
1757
1758       if (tmp_iE_Extensions_present)
1759       {
1760          if ((ret=dissect_iE_Extension(tvb, prio_tree, offset, bitoffset,
1761                                            "AllocationOrRetentionPriority")) != 0)
1762                 return (ret);
1763       }
1764
1765       if (tmp_extension_present)
1766       {
1767          /* decoding is not supported */
1768          proto_tree_add_text(prio_tree, tvb, *offset, IE_PROTOCOL_EXTENSION_LENGTH,
1769                           "Protocol extension for rAB-allocationOrRetentionPriority present, dissection not supported");
1770          return(-1);
1771       }
1772    }
1773
1774    /* sourceStatisticsDescriptor */
1775    if (sourceStatisticsDescriptor_present)
1776    {
1777       /* protocol extension */
1778       tmp_extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1779       proceed_nbits(offset, bitoffset, 1);
1780
1781       if (tmp_extension_present)
1782       {
1783          /* decoding is not supported */
1784          proto_tree_add_text(prio_tree, tvb, *offset, IE_PROTOCOL_EXTENSION_LENGTH,
1785                           "Protocol extension for sourceStatisticsDescriptor present, dissection not supported");
1786          return(-1);
1787       }
1788
1789       proto_tree_add_uint_bits(rab_tree, hf_ranap_sourceStatisticsDescriptor, tvb, *offset,
1790                                *bitoffset, 1, 0);
1791       proceed_nbits(offset, bitoffset, 1);
1792     }
1793
1794     /* relocationRequirement */
1795     if (relocationRequirement_present)
1796     {
1797       /* protocol extension */
1798       tmp_extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1799       proceed_nbits(offset, bitoffset, 1);
1800
1801       if (tmp_extension_present)
1802       {
1803          /* decoding is not supported */
1804          proto_tree_add_text(prio_tree, tvb, *offset, IE_PROTOCOL_EXTENSION_LENGTH,
1805                           "Protocol extension for relocationRequirement present, dissection not supported");
1806          return(-1);
1807       }
1808
1809       proto_tree_add_uint_bits(rab_tree, hf_ranap_relocationRequirement, tvb, *offset,
1810                                *bitoffset, 1, 0);
1811       proceed_nbits(offset, bitoffset, 1);
1812     }
1813
1814
1815    /* iE-Extensions */
1816    if (iE_Extensions_present)
1817    {
1818      if ((ret=dissect_iE_Extension(tvb, rab_tree, offset, bitoffset, "rAB_Parameters" )) != 0 )
1819                 return (ret);
1820    }
1821
1822    /* extended */
1823    if (extension_present)
1824    {
1825       /* decoding is not supported */
1826       proto_tree_add_text(rab_tree, tvb, *offset, IE_PROTOCOL_EXTENSION_LENGTH,
1827                           "Protocol extension for rAB_Parameters present, dissection not supported");
1828       return(-1);
1829    }
1830
1831    return(0);
1832 }
1833
1834
1835
1836 static int
1837 dissect_TransportLayerAddress(tvbuff_t *tvb, proto_tree *ie_tree, gint *offset, gint *bitoffset)
1838 {
1839    gint         extension_present;
1840    gint         str_length;
1841
1842    extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1843    proceed_nbits(offset, bitoffset, 1);
1844    if (extension_present)
1845    {
1846       /* extended integer */
1847       proto_tree_add_text(ie_tree, tvb, *offset, 0,
1848                           "extension present for TransportLayerAddress, dissection not supported");
1849       return (-1);
1850    }
1851
1852    /* extract and add length of transportLayerAddress bitstring */
1853    str_length = extract_nbits(tvb, *offset, *bitoffset, 8) + 1;
1854    proto_tree_add_uint_bits(ie_tree, hf_ranap_transportLayerAddress_length,
1855                              tvb, *offset, *bitoffset, 8, 1);
1856    proceed_nbits(offset, bitoffset, 8);
1857    allign(offset, bitoffset);
1858
1859    /* add transportLayerAddress */
1860    proto_tree_add_bitstring(ie_tree, hf_ranap_transportLayerAddress, tvb, *offset,
1861                             *bitoffset, str_length);
1862    proceed_nbits(offset, bitoffset, str_length);
1863
1864    return (0);
1865 }
1866
1867
1868
1869 static int
1870 dissect_iuTransportAssociation(tvbuff_t *tvb, proto_tree *ie_tree, gint *offset, gint *bitoffset)
1871 {
1872    guint        extension_present;
1873    guint        choice_value;
1874
1875    /* extension present ? */
1876    extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1877    if (extension_present)
1878    {
1879       /* extended choice */
1880       proto_tree_add_text(ie_tree, tvb, *offset, 0,
1881                           "extension present for IuTransportAssociation, dissection not supported");
1882       return (-1);
1883    }
1884    proceed_nbits(offset, bitoffset, 1);
1885
1886    /* choice */
1887    choice_value = extract_nbits(tvb, *offset, *bitoffset, 1);
1888    proceed_nbits(offset, bitoffset, 1);
1889    allign(offset, bitoffset);
1890    if (choice_value == 0)
1891    {
1892       /*  gTP-TEI */
1893       proto_tree_add_item(ie_tree, hf_ranap_gTP_TEI, tvb, *offset, 4, FALSE);
1894       *offset += 4;
1895    }
1896    else
1897    {
1898       /* bindingID */
1899       proto_tree_add_item(ie_tree, hf_ranap_bindingID, tvb, *offset, 4, FALSE);
1900       *offset += 4;
1901    }
1902
1903    return (0);
1904 }
1905
1906
1907 static int
1908 dissect_transportLayerInformation(tvbuff_t *tvb, proto_tree *ie_tree, gint *offset, gint *bitoffset)
1909 {
1910    proto_item   *optionals_item = NULL;
1911    proto_tree   *optionals_tree = NULL;
1912    int          extension_present;
1913    int          iE_Extensions_present;
1914    int          ret;
1915
1916    /* create subtree for extension/optional/default bitmap */
1917    optionals_item = proto_tree_add_text(ie_tree, tvb, *offset, IE_PROTOCOL_EXTENSION_LENGTH,
1918                                       "TransportLayerInformation Extension/Optional/Default bitmap");
1919    optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
1920
1921
1922    /* protocol extension present ? */
1923    extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1924    proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
1925                             *offset, *bitoffset, 1, 0);
1926    proceed_nbits(offset, bitoffset, 1);
1927
1928    /* iE-Extensions present ? */
1929    iE_Extensions_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1930    proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present,
1931                             tvb, *offset, *bitoffset, 1, 0);
1932    proceed_nbits(offset, bitoffset, 1);
1933
1934
1935    /* transportLayerAddress */
1936    if ((ret=dissect_TransportLayerAddress(tvb, ie_tree, offset, bitoffset)) != 0)
1937        return (ret);
1938
1939    /* iuTransportAssociation */
1940    if ((ret=dissect_iuTransportAssociation(tvb, ie_tree, offset, bitoffset)) != 0)
1941       return (ret);
1942
1943    /* iE-Extensions */
1944    if (iE_Extensions_present)
1945    {
1946      if ((ret=dissect_iE_Extension(tvb, ie_tree, offset, bitoffset, "TransportLayerInformation" )) != 0 )
1947                 return (ret);
1948    }
1949
1950    /* protocol extension */
1951    if (extension_present)
1952    {
1953       /* extended sequence */
1954       proto_tree_add_text(ie_tree, tvb, *offset, 0,
1955                           "extension present for TransportLayerInformation, dissection not supported");
1956       return (-1);
1957    }
1958
1959    return(0);
1960 }
1961
1962
1963 static int
1964 dissect_dataVolumeList (tvbuff_t *tvb, proto_tree *ie_tree, gint *offset, gint *bitoffset, char *parname)
1965 {
1966    proto_item   *optionals_item = NULL;
1967    proto_tree   *optionals_tree = NULL;
1968    gint         extension_present;
1969    gint         dataVolumeReference_present;
1970    gint         iE_Extensions_present;
1971    gint         number_vol;
1972    gint         length;
1973    gint         i;
1974    int          ret;
1975
1976    /* number of volumes */
1977    number_vol = extract_nbits(tvb, *offset, *bitoffset, 1) + 1;
1978    proceed_nbits(offset, bitoffset, 1);
1979
1980    for (i=1; i<=number_vol; i++)
1981    {
1982       /* create subtree for extension/optional/default bitmap */
1983       optionals_item = proto_tree_add_text(ie_tree, tvb, *offset, 1,
1984                                            "%d. %s Extension/Optional/Default bitmap",
1985                                             i, parname);
1986       optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
1987
1988       /* protocol_extension present ? */
1989       extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1990       proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
1991                                *offset, *bitoffset, 1, 0);
1992       proceed_nbits(offset, bitoffset, 1);
1993
1994       /* dataVolumeReference present ? */
1995       dataVolumeReference_present = extract_nbits(tvb, *offset, *bitoffset, 1);
1996       proto_tree_add_uint_bits(optionals_tree, hf_ranap_dataVolumeReference_present, tvb,
1997                                *offset, *bitoffset, 1, 0);
1998       proceed_nbits(offset, bitoffset, 1);
1999
2000       /* iE_Extensions present ? */
2001       iE_Extensions_present = extract_nbits(tvb, *offset, *bitoffset, 1);
2002       proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present, tvb,
2003                                *offset, *bitoffset, 1, 0);
2004       proceed_nbits(offset, bitoffset, 1);
2005
2006
2007       /* UnsuccessfullyTransmittedDataVolume */
2008       proto_tree_add_PERint32(ie_tree, hf_ranap_dl_UnsuccessfullyTransmittedDataVolume,
2009                               tvb, *offset, *bitoffset, &length, 0);
2010       proceed_perint32(offset, bitoffset, length);
2011
2012       /* DataVolumeReference */
2013       if (dataVolumeReference_present)
2014       {
2015          proto_tree_add_uint_bits(ie_tree, hf_ranap_dataVolumeReference, tvb,
2016                                   *offset, *bitoffset, 8, 0);
2017          proceed_nbits(offset, bitoffset, 8);
2018       }
2019
2020      /* iE-Extensions */
2021      if (iE_Extensions_present)
2022      {
2023         if ((ret=dissect_iE_Extension(tvb, ie_tree, offset, bitoffset, "dl-dataVolumes" )) != 0)
2024              return(ret);
2025      }
2026
2027      /* protocol extended */
2028      if (extension_present)
2029      {
2030         /* extended sequence */
2031         /* decoding is not supported */
2032         proto_tree_add_text(ie_tree, tvb, *offset, IE_PROTOCOL_EXTENSION_LENGTH,
2033                           "Protocol extension for dl-dataVolumes present, dissection not supported");
2034         return(-1);
2035      }
2036   }
2037
2038   return (0);
2039
2040 }
2041
2042 static int
2043 dissect_cause(tvbuff_t *tvb, proto_tree *ie_tree, gint *offset, gint *bitoffset)
2044 {
2045    gint         extension_present;
2046    int          cause_choice;
2047
2048   /* protocol extension present ? */
2049   extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
2050   proceed_nbits(offset, bitoffset, 1);
2051   if (extension_present)
2052   {
2053      /* choice extension present */
2054      proto_tree_add_text(ie_tree, tvb, *offset, 0,
2055                           "extension present for cause, dissection not supported");
2056      return (-1);
2057   }
2058   cause_choice = extract_nbits(tvb, *offset, *bitoffset, 3);
2059   proto_tree_add_uint_bits(ie_tree, hf_ranap_cause_choice,
2060                            tvb, *offset, *bitoffset, 3, 0);
2061   proceed_nbits(offset, bitoffset, 3);
2062
2063   switch (cause_choice)
2064   {
2065      case CC_CauseRadioNetwork:
2066         proto_tree_add_uint_bits(ie_tree, hf_ranap_cause_value,
2067                                  tvb, *offset, *bitoffset, 6, 1);
2068         proceed_nbits(offset, bitoffset, 6);
2069         break;
2070      case CC_CauseTransmissionNetwork:
2071         proto_tree_add_uint_bits(ie_tree, hf_ranap_cause_value,
2072                                  tvb, *offset, *bitoffset, 4, 65);
2073         proceed_nbits(offset, bitoffset, 4);
2074         break;
2075      case CC_CauseNAS:
2076         proto_tree_add_uint_bits(ie_tree, hf_ranap_cause_value,
2077                                  tvb, *offset, *bitoffset, 4, 81);
2078         proceed_nbits(offset, bitoffset, 4);
2079         break;
2080      case CC_CauseProtocol:
2081         proto_tree_add_uint_bits(ie_tree, hf_ranap_cause_value,
2082                                  tvb, *offset, *bitoffset, 4, 97);
2083         proceed_nbits(offset, bitoffset, 4);
2084      case CC_CauseMisc:
2085         proto_tree_add_uint_bits(ie_tree, hf_ranap_cause_value,
2086                                  tvb, *offset, *bitoffset, 4, 113);
2087         proceed_nbits(offset, bitoffset, 4);
2088         break;
2089      case CC_CauseNon_Standard:
2090         proto_tree_add_uint_bits(ie_tree, hf_ranap_cause_value,
2091                                  tvb, *offset, *bitoffset, 7, 129);
2092         proceed_nbits(offset, bitoffset, 7);
2093         break;
2094      default:
2095        proto_tree_add_text(ie_tree, tvb, *offset, 0,
2096                             "unexpected cause choice value, dissection not supported");
2097        return(-1);
2098   }
2099   return(0);
2100 }
2101
2102
2103 static int
2104 dissect_iEsCriticalityDiagnostics(tvbuff_t *tvb, proto_tree *ie_tree, gint *offset, gint *bitoffset)
2105 {
2106    proto_item           *diag_item = NULL;
2107    proto_tree           *diag_tree = NULL;
2108    proto_item           *optionals_item = NULL;
2109    proto_tree           *optionals_tree = NULL;
2110    int                  extension_present;
2111    int                  repetitionNumber_present;
2112    int                  iE_Extensions_present;
2113    int                  num_of_errors;
2114    int                  i;
2115
2116    allign(offset, bitoffset);
2117    num_of_errors = extract_nbits(tvb, *offset, *bitoffset, 8) + 1;
2118    proto_tree_add_uint_bits(ie_tree, hf_ranap_num_of_CriticalityDiagnostics_IEs, tvb,
2119                             *offset, *bitoffset, 8, 1);
2120    proceed_nbits(offset, bitoffset, 8);
2121
2122    for ( i= 1; i <= num_of_errors; i++)
2123    {
2124       /* add subtree for CriticalityDiagnostics-IE */
2125       diag_item = proto_tree_add_text(ie_tree, tvb, *offset, 0,
2126                                       "%d. CriticalityDiagnostics-IE", i);
2127       diag_tree = proto_item_add_subtree(diag_item, ett_ranap_CriticalityDiagnostics_IE);
2128
2129       /* create subtree for extension/optional/default bitmap */
2130       optionals_item = proto_tree_add_text(diag_tree, tvb, *offset, 1,
2131                                          "CriticalityDiagnostics-IE Extension/Optional/Default bitmap");
2132       optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
2133
2134       /* protocol_extension present ? */
2135       extension_present = extract_nbits(tvb, *offset, *bitoffset, 1);
2136       proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
2137                                *offset, *bitoffset, 1, 0);
2138       proceed_nbits(offset, bitoffset, 1);
2139
2140       /* repetitionNumber present ? */
2141       repetitionNumber_present = extract_nbits(tvb, *offset, *bitoffset, 1);
2142       proto_tree_add_uint_bits(optionals_tree, hf_ranap_repetitionNumber_present, tvb,
2143                                *offset, *bitoffset, 1, 0);
2144       proceed_nbits(offset, bitoffset, 1);
2145
2146       /* iE_Extensions present ? */
2147       iE_Extensions_present = extract_nbits(tvb, *offset, *bitoffset, 1);
2148       proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present,
2149                                tvb, *offset, *bitoffset, 1, 0);
2150       proceed_nbits(offset, bitoffset, 1);
2151
2152       /* iECriticality */
2153       proto_tree_add_uint_bits(diag_tree, hf_ranap_iECriticality,
2154                                tvb, *offset, *bitoffset, 2, 0);
2155       proceed_nbits(offset, bitoffset, 2);
2156
2157       /* iE-ID */
2158       allign(offset, bitoffset);
2159       proto_tree_add_item(diag_tree, hf_ranap_ie_ie_id, tvb,
2160                           *offset, IE_ID_LENGTH, FALSE);
2161       *offset += IE_ID_LENGTH;
2162
2163       /* repetitionNumber */
2164       if (repetitionNumber_present)
2165       {
2166          allign(offset, bitoffset);
2167          proto_tree_add_uint_bits(diag_tree, hf_ranap_repetitionNumber,
2168                                   tvb, *offset, *bitoffset, 8, 1);
2169          proceed_nbits(offset, bitoffset, 8);
2170       }
2171
2172       /* iE-Extensions */
2173       if (iE_Extensions_present)
2174       {
2175         return(dissect_iE_Extension(tvb, diag_tree, offset, bitoffset, "CriticalityDiagnostics-IE"));
2176       }
2177
2178
2179       /* protocol extended */
2180       if (extension_present)
2181       {
2182          /* extended sequence */
2183          /* decoding is not supported */
2184          proto_tree_add_text(diag_tree, tvb, *offset, IE_PROTOCOL_EXTENSION_LENGTH,
2185                           "Protocol extension for CriticalityDiagnostics-IE present, dissection not supported");
2186          return(-1);
2187       }
2188    }
2189
2190    return(0);
2191 }
2192
2193
2194
2195 /*****************************************************************************/
2196 /*                                                                           */
2197 /*  Dissecting Functions for IEs                                             */
2198 /*                                                                           */
2199 /*****************************************************************************/
2200
2201 static int
2202 dissect_IE_RAB_ID(tvbuff_t *tvb, proto_tree *ie_tree)
2203 {
2204   if (ie_tree)
2205   {
2206        proto_tree_add_item(ie_tree, hf_ranap_rab_id, tvb,
2207                            0, RAB_ID_LENGTH, FALSE);
2208   }
2209   return(0);
2210 }
2211
2212
2213 static int
2214 dissect_IE_RAC(tvbuff_t *tvb, proto_tree *ie_tree)
2215 {
2216   if (ie_tree)
2217   {
2218        proto_tree_add_item(ie_tree, hf_ranap_rac, tvb,
2219                            0, RAC_LENGTH, FALSE);
2220   }
2221   return(0);
2222 }
2223
2224
2225 static int
2226 dissect_IE_LAI(tvbuff_t *tvb, proto_tree *ie_tree)
2227 {
2228   proto_item    *optionals_item = NULL;
2229   proto_tree    *optionals_tree = NULL;
2230   int           iE_Extensions_present;
2231   gint          offset = 0;
2232   gint          bitoffset = 0;
2233   int           ret;
2234
2235   if (ie_tree)
2236   {
2237       /* create subtree for extension/optional/default bitmap */
2238      optionals_item = proto_tree_add_text(ie_tree, tvb, offset, 1,
2239                                       "LAI Extension/Optional/Default bitmap");
2240      optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
2241
2242      /* iE_Extensions_present present ? */
2243      iE_Extensions_present = extract_nbits(tvb, offset, bitoffset, 1);
2244      proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present, tvb,
2245                               offset, bitoffset, 1, 0);
2246      proceed_nbits(&offset, &bitoffset, 1);
2247
2248      /* plmn_id */
2249      allign(&offset, &bitoffset);
2250      proto_tree_add_item(ie_tree, hf_ranap_plmn_id, tvb,
2251                          offset, PLMN_ID_LENGTH, FALSE);
2252      offset += PLMN_ID_LENGTH;
2253
2254      /* lac */
2255      proto_tree_add_item(ie_tree, hf_ranap_lac, tvb,
2256                          offset, LAC_LENGTH, FALSE);
2257      offset += LAC_LENGTH;
2258
2259      /* iE_Extensions */
2260      if (iE_Extensions_present)
2261      {
2262         if ((ret=dissect_iE_Extension(tvb, ie_tree, &offset, &bitoffset, "LAI")) != 0)
2263              return (ret);
2264      }
2265   }
2266   return(0);
2267 }
2268
2269
2270 static int
2271 dissect_IE_SAI(tvbuff_t *tvb, proto_tree *ie_tree)
2272 {
2273   proto_item    *optionals_item = NULL;
2274   proto_tree    *optionals_tree = NULL;
2275   int           iE_Extensions_present;
2276   gint          offset = 0;
2277   gint          bitoffset = 0;
2278   int           ret;
2279
2280   if (ie_tree)
2281   {
2282       /* create subtree for extension/optional/default bitmap */
2283      optionals_item = proto_tree_add_text(ie_tree, tvb, offset, 1,
2284                                       "SAI Extension/Optional/Default bitmap");
2285      optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
2286
2287      /* iE_Extensions_present present ? */
2288      iE_Extensions_present = extract_nbits(tvb, offset, bitoffset, 1);
2289      proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present, tvb,
2290                               offset, bitoffset, 1, 0);
2291      proceed_nbits(&offset, &bitoffset, 1);
2292
2293      /*  plmn_id */
2294      proto_tree_add_item(ie_tree, hf_ranap_plmn_id, tvb,
2295                            offset, PLMN_ID_LENGTH, FALSE);
2296      offset += PLMN_ID_LENGTH;
2297
2298      /* lac */
2299      proto_tree_add_item(ie_tree, hf_ranap_lac, tvb,
2300                            offset, LAC_LENGTH, FALSE);
2301      offset += LAC_LENGTH;
2302
2303      /* sac */
2304      proto_tree_add_item(ie_tree, hf_ranap_sac, tvb,
2305                            offset, SAC_LENGTH, FALSE);
2306      offset += SAC_LENGTH;
2307
2308      /* iE_Extensions */
2309      if (iE_Extensions_present)
2310      {
2311         if ((ret=dissect_iE_Extension(tvb, ie_tree, &offset, &bitoffset, "LAI")) != 0)
2312              return (ret);
2313      }
2314   }
2315   return(0);
2316 }
2317
2318
2319 static int
2320 dissect_IE_NAS_PDU(tvbuff_t *tvb, proto_tree *ie_tree)
2321 {
2322    gint                 length;
2323    gint                 length_size;
2324
2325    if (extract_length(tvb, 0, &length, &length_size) != 0)
2326    {
2327       if (ie_tree)
2328       {
2329            /* decoding is not supported */
2330            proto_tree_add_text(ie_tree, tvb, 0,
2331                                2, "Number of Octets greater than 0x3FFF, dissection not supported");
2332       }
2333       return(-1);
2334    }
2335
2336    if (ie_tree)
2337    {
2338        /* NAS - PDU length */
2339        proto_tree_add_item(ie_tree, hf_ranap_nas_pdu_length, tvb,
2340                            0, length_size, FALSE);
2341    }
2342
2343    /* call NAS dissector (not implemented yet) */
2344    /* ............. */
2345
2346    /* meanwhile display in hex */
2347    if (ie_tree)
2348    {
2349        /* NAS - PDU */
2350        proto_tree_add_item(ie_tree, hf_ranap_nas_pdu, tvb,
2351                            length_size, length, FALSE);
2352    }
2353    return(0);
2354 }
2355
2356
2357 static int
2358 dissect_IE_CN_DomainIndicator(tvbuff_t *tvb, proto_tree *ie_tree)
2359 {
2360   gint          offset = 0;
2361   gint          bitoffset = 0;
2362
2363   if (ie_tree)
2364   {
2365      proto_tree_add_uint_bits(ie_tree, hf_ranap_CN_DomainIndicator, tvb,
2366                               offset, bitoffset, 1, 0);
2367   }
2368   return(0);
2369 }
2370
2371
2372 static int
2373 dissect_IE_IuSigConId(tvbuff_t *tvb, proto_tree *ie_tree)
2374 {
2375   if (ie_tree)
2376   {
2377      proto_tree_add_bitstring(ie_tree, hf_ranap_IuSigConId, tvb, 0, 0, 24);
2378   }
2379   return(0);
2380 }
2381
2382
2383 static int
2384 dissect_IE_SAPI(tvbuff_t *tvb, proto_tree *ie_tree)
2385 {
2386   gint          offset = 0;
2387   gint          bitoffset = 0;
2388   int           extension_present;
2389
2390   if (ie_tree)
2391   {
2392      /* protocol_extension present ? */
2393      extension_present = extract_nbits(tvb, offset, bitoffset, 1);
2394      proceed_nbits(&offset, &bitoffset, 1);
2395
2396      if (extension_present)
2397      {
2398         /* extended enum */
2399         /* decoding is not supported */
2400         proto_tree_add_text(ie_tree, tvb, offset, IE_PROTOCOL_EXTENSION_LENGTH,
2401                           "Protocol extension for IE_SAPI present, dissection not supported");
2402         return(-1);
2403      }
2404
2405      /* SAPI */
2406      proto_tree_add_uint_bits(ie_tree, hf_ranap_SAPI, tvb,
2407                               offset, bitoffset, 1, 0);
2408   }
2409   return(0);
2410 }
2411
2412
2413 static int
2414 dissect_IE_TransportLayerAddress(tvbuff_t *tvb, proto_tree *ie_tree)
2415 {
2416   gint          offset = 0;
2417   gint          bitoffset = 0;
2418
2419   if (ie_tree)
2420   {
2421      return(dissect_TransportLayerAddress(tvb, ie_tree, &offset, &bitoffset));
2422   }
2423   return(0);
2424 }
2425
2426
2427 static int
2428 dissect_IE_IuTransportAssociation(tvbuff_t *tvb, proto_tree *ie_tree)
2429 {
2430   gint          offset = 0;
2431   gint          bitoffset = 0;
2432
2433   if (ie_tree)
2434   {
2435      return(dissect_iuTransportAssociation(tvb, ie_tree, &offset, &bitoffset));
2436   }
2437   return(0);
2438 }
2439
2440
2441 static int
2442 dissect_IE_Cause(tvbuff_t *tvb, proto_tree *ie_tree)
2443 {
2444   gint          offset = 0;
2445   gint          bitoffset = 0;
2446
2447   if (ie_tree)
2448   {
2449      return(dissect_cause(tvb, ie_tree, &offset, &bitoffset));
2450   }
2451   return(0);
2452 }
2453
2454
2455 static int
2456 dissect_IE_RAB_ReleasedItem_IuRelComp(tvbuff_t *tvb, proto_tree *ie_tree)
2457 {
2458    proto_item   *optionals_item = NULL;
2459    proto_tree   *optionals_tree = NULL;
2460    int          extension_present;
2461    int          dl_GTP_PDU_SequenceNumber_present;
2462    int          ul_GTP_PDU_SequenceNumber_present;
2463    int          iE_Extensions_present;
2464    gint         offset = 0;
2465    gint         bitoffset = 0;
2466    int          ret;
2467
2468   if (ie_tree)
2469   {
2470      /* create subtree for extension/optional/default bitmap */
2471      optionals_item = proto_tree_add_text(ie_tree, tvb, offset, 1,
2472                                       "RAB_ReleasedItem_IuRelComp Extension/Optional/Default bitmap");
2473      optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
2474
2475      /* protocol_extension present ? */
2476      extension_present = extract_nbits(tvb, offset, bitoffset, 1);
2477      proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
2478                               offset, bitoffset, 1, 0);
2479      proceed_nbits(&offset, &bitoffset, 1);
2480
2481      /* dl_GTP_PDU_SequenceNumber present ? */
2482      dl_GTP_PDU_SequenceNumber_present = extract_nbits(tvb, offset, bitoffset, 1);
2483      proto_tree_add_uint_bits(optionals_tree, hf_ranap_dl_GTP_PDU_SequenceNumber_present, tvb,
2484                               offset, bitoffset, 1, 0);
2485      proceed_nbits(&offset, &bitoffset, 1);
2486
2487      /* ul_GTP_PDU_SequenceNumber present ? */
2488      ul_GTP_PDU_SequenceNumber_present = extract_nbits(tvb, offset, bitoffset, 1);
2489      proto_tree_add_uint_bits(optionals_tree, hf_ranap_ul_GTP_PDU_SequenceNumber_present, tvb,
2490                               offset, bitoffset, 1, 0);
2491      proceed_nbits(&offset, &bitoffset, 1);
2492
2493      /* iE_Extensions_present present ? */
2494      iE_Extensions_present = extract_nbits(tvb, offset, bitoffset, 1);
2495      proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present, tvb,
2496                               offset, bitoffset, 1, 0);
2497      proceed_nbits(&offset, &bitoffset, 1);
2498
2499
2500      /* rAB-ID */
2501      proto_tree_add_uint_bits(ie_tree, hf_ranap_rab_id,
2502                              tvb, offset, bitoffset, 8, 0);
2503      proceed_nbits(&offset, &bitoffset, 8);
2504
2505      /* dl-GTP-PDU-SequenceNumber */
2506      if (dl_GTP_PDU_SequenceNumber_present)
2507      {
2508         allign(&offset, &bitoffset);
2509         proto_tree_add_item(ie_tree, hf_ranap_dl_GTP_PDU_SequenceNumber, tvb, offset, 2, FALSE);
2510         offset += 2;
2511      }
2512
2513      /* ul-GTP-PDU-SequenceNumber */
2514      if (ul_GTP_PDU_SequenceNumber_present)
2515      {
2516         allign(&offset, &bitoffset);
2517         proto_tree_add_item(ie_tree, hf_ranap_ul_GTP_PDU_SequenceNumber, tvb, offset, 2, FALSE);
2518         offset += 2;
2519      }
2520
2521      /* iE-Extensions */
2522      if (iE_Extensions_present)
2523      {
2524         if ((ret=dissect_iE_Extension(tvb, ie_tree, &offset, &bitoffset, "RAB_ReleasedItem_IuRelComp")) != 0)
2525              return (ret);
2526      }
2527
2528      /* protocol extended */
2529      if (extension_present)
2530      {
2531         /* extended sequence */
2532         /* decoding is not supported */
2533         proto_tree_add_text(ie_tree, tvb, offset, IE_PROTOCOL_EXTENSION_LENGTH,
2534                           "Protocol extension for RAB_ReleasedItem_IuRelComp present, dissection not supported");
2535         return(-1);
2536      }
2537   }
2538   return(0);
2539 }
2540
2541
2542 static int
2543 dissect_IE_RAB_DataVolumeReportItem(tvbuff_t *tvb, proto_tree *ie_tree)
2544 {
2545    proto_item   *optionals_item = NULL;
2546    proto_tree   *optionals_tree = NULL;
2547    int          extension_present;
2548    int          dl_UnsuccessfullyTransmittedDataVolume_present;
2549    int          iE_Extensions_present;
2550    gint         offset = 0;
2551    gint         bitoffset = 0;
2552    int          ret;
2553
2554   if (ie_tree)
2555   {
2556      /* create subtree for extension/optional/default bitmap */
2557      optionals_item = proto_tree_add_text(ie_tree, tvb, offset, 1,
2558                                       "RAB_DataVolumeReportItem Extension/Optional/Default bitmap");
2559      optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
2560
2561      /* protocol_extension present ? */
2562      extension_present = extract_nbits(tvb, offset, bitoffset, 1);
2563      proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
2564                               offset, bitoffset, 1, 0);
2565      proceed_nbits(&offset, &bitoffset, 1);
2566
2567      /* dl_UnsuccessfullyTransmittedDataVolume present ? */
2568      dl_UnsuccessfullyTransmittedDataVolume_present = extract_nbits(tvb, offset, bitoffset, 1);
2569      proto_tree_add_uint_bits(optionals_tree, hf_ranap_dl_UnsuccessfullyTransmittedDataVolume_present, tvb,
2570                               offset, bitoffset, 1, 0);
2571      proceed_nbits(&offset, &bitoffset, 1);
2572
2573      /* iE_Extensions_present present ? */
2574      iE_Extensions_present = extract_nbits(tvb, offset, bitoffset, 1);
2575      proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present, tvb,
2576                               offset, bitoffset, 1, 0);
2577      proceed_nbits(&offset, &bitoffset, 1);
2578
2579
2580      /* rAB-ID */
2581      proto_tree_add_uint_bits(ie_tree, hf_ranap_rab_id,
2582                              tvb, offset, bitoffset, 8, 0);
2583      proceed_nbits(&offset, &bitoffset, 8);
2584
2585      /* dl_UnsuccessfullyTransmittedDataVolume */
2586      if (dl_UnsuccessfullyTransmittedDataVolume_present)
2587      {
2588
2589         if ((ret = dissect_dataVolumeList(tvb, ie_tree, &offset, &bitoffset,
2590              "dl_UnsuccessfullyTransmittedDataVolume")) != 0)
2591             return (ret);
2592      }
2593
2594      /* iE-Extensions */
2595      if (iE_Extensions_present)
2596      {
2597         if ((ret=dissect_iE_Extension(tvb, ie_tree, &offset, &bitoffset, "IE_RAB_DataVolumeReportItem")) != 0)
2598              return (ret);
2599      }
2600
2601      /* protocol extended */
2602      if (extension_present)
2603      {
2604         /* extended enum */
2605         /* decoding is not supported */
2606         proto_tree_add_text(ie_tree, tvb, offset, IE_PROTOCOL_EXTENSION_LENGTH,
2607                           "Protocol extension for IE_RAB_DataVolumeReportItem present, dissection not supported");
2608         return(-1);
2609      }
2610   }
2611   return(0);
2612 }
2613
2614
2615 static int
2616 dissect_IE_RAB_SetupOrModifyItemSecond(tvbuff_t *tvb, proto_tree *ie_tree)
2617 {
2618    proto_item   *optionals_item = NULL;
2619    proto_tree   *optionals_tree = NULL;
2620    int          extension_present;
2621    int          tmp_extension;
2622    int          pDP_TypeInformation_present;
2623    int          dataVolumeReportingIndication_present;
2624    int          dl_GTP_PDU_SequenceNumber_present;
2625    int          ul_GTP_PDU_SequenceNumber_present;
2626    int          dl_N_PDU_SequenceNumber_present;
2627    int          ul_N_PDU_SequenceNumber_present;
2628    int          iE_Extensions_present;
2629    gint         offset = 0;
2630    gint         bitoffset = 0;
2631    gint8        tmp_byte;
2632    gint         i;
2633    int          ret;
2634
2635   if (ie_tree)
2636   {
2637      /* create subtree for extension/optional/default bitmap */
2638      optionals_item = proto_tree_add_text(ie_tree, tvb, offset, 1,
2639                                       "SetupOrModifyItemSecond Extension/Optional/Default bitmap");
2640      optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
2641
2642      /* protocol_extension present ? */
2643      extension_present = extract_nbits(tvb, offset, bitoffset, 1);
2644      proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
2645                               offset, bitoffset, 1, 0);
2646      proceed_nbits(&offset, &bitoffset, 1);
2647
2648      /* pDP_TypeInformation present ? */
2649      pDP_TypeInformation_present = extract_nbits(tvb, offset, bitoffset, 1);
2650      proto_tree_add_uint_bits(optionals_tree, hf_ranap_pDP_TypeInformation_present, tvb,
2651                               offset, bitoffset, 1, 0);
2652      proceed_nbits(&offset, &bitoffset, 1);
2653
2654      /* dataVolumeReportingIndication present ? */
2655      dataVolumeReportingIndication_present = extract_nbits(tvb, offset, bitoffset, 1);
2656      proto_tree_add_uint_bits(optionals_tree, hf_ranap_dataVolumeReportingIndication_present, tvb,
2657                               offset, bitoffset, 1, 0);
2658      proceed_nbits(&offset, &bitoffset, 1);
2659
2660      /* dl_GTP_PDU_SequenceNumber present present ? */
2661      dl_GTP_PDU_SequenceNumber_present = extract_nbits(tvb, offset, bitoffset, 1);
2662      proto_tree_add_uint_bits(optionals_tree, hf_ranap_dl_GTP_PDU_SequenceNumber_present, tvb,
2663                               offset, bitoffset, 1, 0);
2664      proceed_nbits(&offset, &bitoffset, 1);
2665
2666
2667      /* ul_GTP_PDU_SequenceNumber present ? */
2668      ul_GTP_PDU_SequenceNumber_present = extract_nbits(tvb, offset, bitoffset, 1);
2669      proto_tree_add_uint_bits(optionals_tree, hf_ranap_ul_GTP_PDU_SequenceNumber_present, tvb,
2670                               offset, bitoffset, 1, 0);
2671      proceed_nbits(&offset, &bitoffset, 1);
2672
2673      /* dl_N_PDU_SequenceNumber present ? */
2674      dl_N_PDU_SequenceNumber_present = extract_nbits(tvb, offset, bitoffset, 1);
2675      proto_tree_add_uint_bits(optionals_tree, hf_ranap_dl_N_PDU_SequenceNumber_present, tvb,
2676                               offset, bitoffset, 1, 0);
2677      proceed_nbits(&offset, &bitoffset, 1);
2678
2679      /* ul_N_PDU_SequenceNumber present ? */
2680      ul_N_PDU_SequenceNumber_present = extract_nbits(tvb, offset, bitoffset, 1);
2681      proto_tree_add_uint_bits(optionals_tree, hf_ranap_ul_N_PDU_SequenceNumber_present, tvb,
2682                               offset, bitoffset, 1, 0);
2683      proceed_nbits(&offset, &bitoffset, 1);
2684
2685      /* iE_Extensions present ? */
2686      iE_Extensions_present = extract_nbits(tvb, offset, bitoffset, 1);
2687      proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present, tvb,
2688                               offset, bitoffset, 1, 0);
2689      proceed_nbits(&offset, &bitoffset, 1);
2690
2691      /* pDP-TypeInformation */
2692      if (pDP_TypeInformation_present)
2693      {
2694         tmp_byte = extract_nbits(tvb, offset, bitoffset, 1) + 1;    /* Sequence 1..2 */
2695         proceed_nbits(&offset, &bitoffset, 1);
2696         for (i=1; i<=tmp_byte; i++)
2697         {
2698            tmp_extension = extract_nbits(tvb, offset, bitoffset, 1);
2699            proceed_nbits(&offset, &bitoffset, 1);
2700            if (tmp_extension != 0)
2701            {
2702               /* extended enum */
2703               /* decoding is not supported */
2704               proto_tree_add_text(ie_tree, tvb, offset, IE_PROTOCOL_EXTENSION_LENGTH,
2705                                   "Protocol extension for PDP-Type present, dissection not supported");
2706               return(-1);
2707            }
2708
2709            proto_tree_add_uint_bits(ie_tree, hf_ranap_PDP_Type, tvb,
2710                                     offset, bitoffset, 3, 0);
2711            proceed_nbits(&offset, &bitoffset, 3);
2712         }
2713      }
2714
2715      /* dataVolumeReportingIndication */
2716      if (dataVolumeReportingIndication_present)
2717      {
2718        proto_tree_add_uint_bits(ie_tree, hf_ranap_dataVolumeReportingIndication, tvb,
2719                                 offset, bitoffset, 1, 0);
2720        proceed_nbits(&offset, &bitoffset, 1);
2721      }
2722
2723      /* dl-GTP-PDU-SequenceNumber */
2724      if (dl_GTP_PDU_SequenceNumber_present)
2725      {
2726         allign(&offset, &bitoffset);
2727         proto_tree_add_item(ie_tree, hf_ranap_dl_GTP_PDU_SequenceNumber, tvb, offset, 2, FALSE);
2728         offset += 2;
2729      }
2730
2731      /* ul-GTP-PDU-SequenceNumber */
2732      if (ul_GTP_PDU_SequenceNumber_present)
2733      {
2734         allign(&offset, &bitoffset);
2735         proto_tree_add_item(ie_tree, hf_ranap_ul_GTP_PDU_SequenceNumber, tvb, offset, 2, FALSE);
2736         offset += 2;
2737      }
2738
2739      /* dl-N-PDU-SequenceNumber */
2740      if (dl_N_PDU_SequenceNumber_present)
2741      {
2742         allign(&offset, &bitoffset);
2743         proto_tree_add_item(ie_tree, hf_ranap_dl_N_PDU_SequenceNumber, tvb, offset, 2, FALSE);
2744         offset += 2;
2745      }
2746
2747      /* ul-N-PDU-SequenceNumber */
2748      if (ul_N_PDU_SequenceNumber_present)
2749      {
2750         allign(&offset, &bitoffset);
2751         proto_tree_add_item(ie_tree, hf_ranap_ul_N_PDU_SequenceNumber, tvb, offset, 2, FALSE);
2752         offset += 2;
2753      }
2754
2755      /* iE-Extensions */
2756      if (iE_Extensions_present)
2757      {
2758         if ((ret=dissect_iE_Extension(tvb, ie_tree, &offset, &bitoffset, "SetupOrModifyItemSecond")) != 0)
2759              return (ret);
2760      }
2761
2762      /* protocol extended */
2763      if (extension_present)
2764      {
2765         /* extended enum */
2766         /* decoding is not supported */
2767         proto_tree_add_text(ie_tree, tvb, offset, IE_PROTOCOL_EXTENSION_LENGTH,
2768                           "Protocol extension for SetupOrModifyItemSecond present, dissection not supported");
2769         return(-1);
2770      }
2771   }
2772   return(0);
2773 }
2774
2775
2776 static int
2777 dissect_IE_RAB_SetupOrModifiedItem (tvbuff_t *tvb, proto_tree *ie_tree)
2778 {
2779    proto_item   *optionals_item = NULL;
2780    proto_tree   *optionals_tree = NULL;
2781    int          ret;
2782    int          extension_present;
2783    int          transportLayerAddress_present;
2784    int          iuTransportAssociation_present;
2785    int          dl_dataVolumes_present;
2786    int          iE_Extensions_present;
2787    gint         offset = 0;
2788    gint         bitoffset = 0;
2789
2790
2791   if (ie_tree)
2792   {
2793      /* create subtree for extension/optional/default bitmap */
2794      optionals_item = proto_tree_add_text(ie_tree, tvb, offset, 1,
2795                                         "RAB-SetupOrModifiedItem Extension/Optional/Default bitmap");
2796      optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
2797
2798      /* protocol_extension present ? */
2799      extension_present = extract_nbits(tvb, offset, bitoffset, 1);
2800      proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
2801                               offset, bitoffset, 1, 0);
2802      proceed_nbits(&offset, &bitoffset, 1);
2803
2804      /* transportLayerAddress present ? */
2805      transportLayerAddress_present = extract_nbits(tvb, offset, bitoffset, 1);
2806      proto_tree_add_uint_bits(optionals_tree, hf_ranap_transportLayerAddress_present, tvb,
2807                               offset, bitoffset, 1, 0);
2808      proceed_nbits(&offset, &bitoffset, 1);
2809
2810      /* iuTransportAssociation present ? */
2811      iuTransportAssociation_present = extract_nbits(tvb, offset, bitoffset, 1);
2812      proto_tree_add_uint_bits(optionals_tree, hf_ranap_iuTransportAssociation_present, tvb,
2813                               offset, bitoffset, 1, 0);
2814      proceed_nbits(&offset, &bitoffset, 1);
2815
2816      /* dl_dataVolumes present ? */
2817      dl_dataVolumes_present = extract_nbits(tvb, offset, bitoffset, 1);
2818      proto_tree_add_uint_bits(optionals_tree, hf_ranap_dl_dataVolumes_present, tvb,
2819                               offset, bitoffset, 1, 0);
2820      proceed_nbits(&offset, &bitoffset, 1);
2821
2822      /* iE_Extensions present ? */
2823      iE_Extensions_present = extract_nbits(tvb, offset, bitoffset, 1);
2824      proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present, tvb,
2825                               offset, bitoffset, 1, 0);
2826      proceed_nbits(&offset, &bitoffset, 1);
2827
2828
2829      /* rAB-ID */
2830      proto_tree_add_uint_bits(ie_tree, hf_ranap_rab_id,
2831                              tvb, offset, bitoffset, 8, 0);
2832      proceed_nbits(&offset, &bitoffset, 8);
2833
2834      /* transportLayerAddress */
2835      if (transportLayerAddress_present)
2836      {
2837         if ((ret=dissect_TransportLayerAddress(tvb, ie_tree, &offset, &bitoffset)) != 0)
2838             return (ret);
2839      }
2840
2841      /* iuTransportAssociation  */
2842      if (iuTransportAssociation_present)
2843      {
2844         if ((ret=dissect_iuTransportAssociation(tvb, ie_tree, &offset, &bitoffset)) != 0)
2845             return (ret);
2846      }
2847
2848      /* dl-dataVolumes  */
2849      if (dl_dataVolumes_present)
2850      {
2851         if ((ret = dissect_dataVolumeList(tvb, ie_tree, &offset, &bitoffset,
2852                                           "dl-dataVolumes")) != 0)
2853             return (ret);
2854      }
2855
2856      /* iE-Extensions   */
2857      if (iE_Extensions_present)
2858      {
2859        if ((ret=dissect_iE_Extension(tvb, ie_tree, &offset, &bitoffset, "RAB_SetupOrModifiedItem")) != 0)
2860            return (ret);
2861      }
2862
2863      /* protocol extended */
2864      if (extension_present)
2865      {
2866         /* extended sequence */
2867         /* decoding is not supported */
2868         proto_tree_add_text(ie_tree, tvb, offset, IE_PROTOCOL_EXTENSION_LENGTH,
2869                           "Protocol extension for RAB_SetupOrModifiedItem present, dissection not supported");
2870         return(-1);
2871      }
2872   }
2873
2874   return (0);
2875 }
2876
2877
2878 static int
2879 dissect_IE_RAB_SetupOrModifyItemFirst (tvbuff_t *tvb, proto_tree *ie_tree)
2880 {
2881   gint          offset;
2882   gint          bitoffset;
2883   proto_item    *optionals_item = NULL;
2884   proto_tree    *optionals_tree = NULL;
2885   int           extension_present;
2886   int           nAS_SynchronisationIndicator_present;
2887   int           rAB_Parameters_present;
2888   int           userPlaneInformation_present;
2889   int           transportLayerInformation_present;
2890   int           service_Handover_present;
2891   int           iE_Extensions_present;
2892   int           tmp_extension_present;
2893   int           ret;
2894
2895   if (ie_tree)
2896   {
2897     offset = 0; bitoffset = 0;
2898
2899     /* create subtree for extension/optional/default bitmap */
2900     optionals_item = proto_tree_add_text(ie_tree, tvb, offset,IE_PROTOCOL_EXTENSION_LENGTH,
2901                                       "RAB_SetupOrModifyItemFirst Extension/Optional/Default bitmap");
2902     optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
2903
2904     /* protocol extension present ? */
2905     extension_present = extract_nbits(tvb, offset, bitoffset, 1);
2906     proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension,
2907                              tvb, offset, bitoffset, 1, 0);
2908     proceed_nbits(&offset, &bitoffset, 1);
2909
2910     /* nAS_SynchronisationIndicator present ? */
2911     nAS_SynchronisationIndicator_present = extract_nbits(tvb, offset, bitoffset, 1);
2912     proto_tree_add_uint_bits(optionals_tree, hf_ranap_nAS_SynchronisationIndicator_present,
2913                              tvb, offset, bitoffset, 1, 0);
2914     proceed_nbits(&offset, &bitoffset, 1);
2915
2916     /* rAB_Parameters present ? */
2917     rAB_Parameters_present = extract_nbits(tvb, offset, bitoffset, 1);
2918     proto_tree_add_uint_bits(optionals_tree, hf_ranap_rAB_Parameters_present,
2919                              tvb, offset, bitoffset, 1, 0);
2920     proceed_nbits(&offset, &bitoffset, 1);
2921
2922     /* userPlaneInformation present ? */
2923     userPlaneInformation_present = extract_nbits(tvb, offset, bitoffset, 1);
2924     proto_tree_add_uint_bits(optionals_tree, hf_ranap_userPlaneInformation_present,
2925                              tvb, offset, bitoffset, 1, 0);
2926     proceed_nbits(&offset, &bitoffset, 1);
2927
2928     /* transportLayerInformation present ? */
2929     transportLayerInformation_present = extract_nbits(tvb, offset, bitoffset, 1);
2930     proto_tree_add_uint_bits(optionals_tree, hf_ranap_transportLayerInformation_present,
2931                              tvb, offset, bitoffset, 1, 0);
2932     proceed_nbits(&offset, &bitoffset, 1);
2933
2934     /* service_Handover present ? */
2935     service_Handover_present = extract_nbits(tvb, offset, bitoffset, 1);
2936     proto_tree_add_uint_bits(optionals_tree, hf_ranap_service_Handover_present,
2937                              tvb, offset, bitoffset, 1, 0);
2938     proceed_nbits(&offset, &bitoffset, 1);
2939
2940     /* iE_Extensions present ? */
2941     iE_Extensions_present = extract_nbits(tvb, offset, bitoffset, 1);
2942     proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present,
2943                              tvb, offset, bitoffset, 1, 0);
2944     proceed_nbits(&offset, &bitoffset, 1);
2945
2946
2947     /* add RAB-ID */
2948     proto_tree_add_uint_bits(ie_tree, hf_ranap_rab_id,
2949                              tvb, offset, bitoffset, 8, 0);
2950     proceed_nbits(&offset, &bitoffset, 8);
2951
2952     /* nAS-SynchronisationIndicator */
2953     if (nAS_SynchronisationIndicator_present)
2954     {
2955        proto_tree_add_uint_bits(ie_tree, hf_ranap_nAS_SynchronisationIndicator,
2956                              tvb, offset, bitoffset, 4, 0);
2957        proceed_nbits(&offset, &bitoffset, 4);
2958     }
2959
2960     /* rAB-Parameters */
2961     if (rAB_Parameters_present)
2962     {
2963        if ((ret=dissect_rAB_Parameters(tvb, ie_tree, &offset, &bitoffset)) != 0)
2964            return(ret);
2965     }
2966
2967     /* userPlaneInformation */
2968     if (userPlaneInformation_present)
2969     {
2970        if ((ret=dissect_userPlaneInformation(tvb, ie_tree, &offset, &bitoffset)) != 0)
2971            return(ret);
2972     }
2973
2974    /* transportLayerInformation */
2975     if (transportLayerInformation_present)
2976     {
2977        if ((ret=dissect_transportLayerInformation(tvb, ie_tree, &offset, &bitoffset)) != 0)
2978            return(ret);
2979     }
2980
2981     /* service_Handover */
2982     if (service_Handover_present)
2983     {
2984        tmp_extension_present = extract_nbits(tvb, offset, bitoffset, 1);
2985        proceed_nbits(&offset, &bitoffset, 1);
2986
2987        if (tmp_extension_present)
2988        {
2989           /* extended enum */
2990           /* decoding is not supported */
2991           proto_tree_add_text(ie_tree, tvb, offset, IE_PROTOCOL_EXTENSION_LENGTH,
2992                                   "Protocol extension for service_Handover present, dissection not supported");
2993           return(-1);
2994        }
2995
2996        proto_tree_add_uint_bits(ie_tree, hf_ranap_service_Handover,
2997                             tvb, offset, bitoffset, 2, 0);
2998        proceed_nbits(&offset, &bitoffset, 2);
2999     }
3000
3001    /* iE-Extensions */
3002    if (iE_Extensions_present)
3003    {
3004      if ((ret=dissect_iE_Extension(tvb, ie_tree, &offset, &bitoffset, "SetupOrModifyItemFirst" )) != 0)
3005                 return(ret);
3006    }
3007
3008   }
3009   return(0);
3010 }
3011
3012
3013 static int
3014 dissect_IE_RAB_ReleaseItem(tvbuff_t *tvb, proto_tree *ie_tree)
3015 {
3016   proto_item    *optionals_item = NULL;
3017   proto_tree    *optionals_tree = NULL;
3018   gint          offset = 0;
3019   gint          bitoffset = 0;
3020   int           extension_present;
3021   int           iE_Extensions_present;
3022   int           ret;
3023
3024
3025   /* create subtree for extension/optional/default bitmap */
3026   optionals_item = proto_tree_add_text(ie_tree, tvb, offset,IE_PROTOCOL_EXTENSION_LENGTH,
3027                                     "RAB_ReleaseItem Extension/Optional/Default bitmap");
3028   optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
3029
3030   /* protocol extension present ? */
3031   extension_present = extract_nbits(tvb, offset, bitoffset, 1);
3032   proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension,
3033                            tvb, offset, bitoffset, 1, 0);
3034   proceed_nbits(&offset, &bitoffset, 1);
3035
3036
3037   /* iE_Extensions present ? */
3038   iE_Extensions_present = extract_nbits(tvb, offset, bitoffset, 1);
3039   proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present,
3040                            tvb, offset, bitoffset, 1, 0);
3041   proceed_nbits(&offset, &bitoffset, 1);
3042
3043
3044   /* add RAB-ID */
3045   proto_tree_add_uint_bits(ie_tree, hf_ranap_rab_id,
3046                            tvb, offset, bitoffset, 8, 0);
3047   proceed_nbits(&offset, &bitoffset, 8);
3048
3049
3050   /* add cause */
3051   if ((ret=dissect_cause(tvb, ie_tree, &offset, &bitoffset)) != 0)
3052              return (ret);
3053
3054   /* iE Extensions */
3055   if (iE_Extensions_present)
3056   {
3057         if ((ret=dissect_iE_Extension(tvb, ie_tree, &offset, &bitoffset, "RAB_ReleasedItem")) != 0)
3058              return (ret);
3059   }
3060
3061   /* protocol extended */
3062   if (extension_present)
3063   {
3064      /* extended sequence */
3065      /* decoding is not supported */
3066      proto_tree_add_text(ie_tree, tvb, offset, IE_PROTOCOL_EXTENSION_LENGTH,
3067                           "Protocol extension for RAB_ReleasedItem present, dissection not supported");
3068      return(-1);
3069   }
3070
3071   return(0);
3072 }
3073
3074
3075 static int
3076 dissect_IE_RAB_ReleasedItem (tvbuff_t *tvb, proto_tree *ie_tree)
3077 {
3078    proto_item   *optionals_item = NULL;
3079    proto_tree   *optionals_tree = NULL;
3080    int          ret;
3081    int          extension_present;
3082    int          dl_dataVolumes_present;
3083    int          dl_GTP_PDU_SequenceNumber_present;
3084    int          ul_GTP_PDU_SequenceNumber_present;
3085    int          iE_Extensions_present;
3086    gint         offset = 0;
3087    gint         bitoffset = 0;
3088
3089   if (ie_tree)
3090   {
3091      /* create subtree for extension/optional/default bitmap */
3092      optionals_item = proto_tree_add_text(ie_tree, tvb, offset, 1,
3093                                         "RAB-ReleasedItem Extension/Optional/Default bitmap");
3094      optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
3095
3096      /* protocol_extension present ? */
3097      extension_present = extract_nbits(tvb, offset, bitoffset, 1);
3098      proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
3099                               offset, bitoffset, 1, 0);
3100      proceed_nbits(&offset, &bitoffset, 1);
3101
3102      /* dl_dataVolumes present ? */
3103      dl_dataVolumes_present = extract_nbits(tvb, offset, bitoffset, 1);
3104      proto_tree_add_uint_bits(optionals_tree, hf_ranap_dl_dataVolumes_present, tvb,
3105                               offset, bitoffset, 1, 0);
3106      proceed_nbits(&offset, &bitoffset, 1);
3107
3108      /* dL_GTP_PDU_SequenceNumber present ? */
3109      dl_GTP_PDU_SequenceNumber_present = extract_nbits(tvb, offset, bitoffset, 1);
3110      proto_tree_add_uint_bits(optionals_tree, hf_ranap_dl_GTP_PDU_SequenceNumber_present,
3111                               tvb, offset, bitoffset, 1, 0);
3112      proceed_nbits(&offset, &bitoffset, 1);
3113
3114      /* uL_GTP_PDU_SequenceNumber present ? */
3115      ul_GTP_PDU_SequenceNumber_present = extract_nbits(tvb, offset, bitoffset, 1);
3116      proto_tree_add_uint_bits(optionals_tree, hf_ranap_ul_GTP_PDU_SequenceNumber_present,
3117                               tvb, offset, bitoffset, 1, 0);
3118      proceed_nbits(&offset, &bitoffset, 1);
3119
3120      /* iE_Extensions present ? */
3121      iE_Extensions_present = extract_nbits(tvb, offset, bitoffset, 1);
3122      proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present,
3123                               tvb, offset, bitoffset, 1, 0);
3124      proceed_nbits(&offset, &bitoffset, 1);
3125
3126      /* rAB-ID */
3127      proto_tree_add_uint_bits(ie_tree, hf_ranap_rab_id,
3128                               tvb, offset, bitoffset, 8, 0);
3129      proceed_nbits(&offset, &bitoffset, 8);
3130
3131      /* dl-dataVolumes */
3132      if (dl_dataVolumes_present)
3133      {
3134         if ((ret=dissect_dataVolumeList(tvb, ie_tree, &offset, &bitoffset,
3135                                         "dl-dataVolumes")) != 0)
3136             return (ret);
3137      }
3138
3139      /* dL-GTP-PDU-SequenceNumber */
3140      if (dl_GTP_PDU_SequenceNumber_present)
3141      {
3142         allign(&offset, &bitoffset);
3143         proto_tree_add_item(ie_tree, hf_ranap_dl_GTP_PDU_SequenceNumber, tvb, offset, 2, FALSE);
3144         offset += 2;
3145      }
3146
3147      /* uL-GTP-PDU-SequenceNumber */
3148      if (ul_GTP_PDU_SequenceNumber_present)
3149      {
3150         allign(&offset, &bitoffset);
3151         proto_tree_add_item(ie_tree, hf_ranap_ul_GTP_PDU_SequenceNumber, tvb, offset, 2, FALSE);
3152         offset += 2;
3153      }
3154
3155      /* iE-Extensions */
3156      if (iE_Extensions_present)
3157      {
3158         if ((ret=dissect_iE_Extension(tvb, ie_tree, &offset, &bitoffset, "UserPlaneInformation")) != 0)
3159            return(ret);
3160      }
3161
3162      /* protocol extended */
3163      if (extension_present)
3164      {
3165         /* extended sequence */
3166         /* decoding is not supported */
3167         proto_tree_add_text(ie_tree, tvb, offset, IE_PROTOCOL_EXTENSION_LENGTH,
3168                           "Protocol extension for RAB_ReleasedItem present, dissection not supported");
3169         return(-1);
3170      }
3171   }
3172
3173   return(0);
3174 }
3175
3176
3177 static int
3178 dissect_IE_RAB_QueuedItem (tvbuff_t *tvb, proto_tree *ie_tree)
3179 {
3180    proto_item   *optionals_item = NULL;
3181    proto_tree   *optionals_tree = NULL;
3182    int          ret;
3183    int          extension_present;
3184    int          iE_Extensions_present;
3185    gint         offset = 0;
3186    gint         bitoffset = 0;
3187
3188
3189   if (ie_tree)
3190   {
3191      /* create subtree for extension/optional/default bitmap */
3192      optionals_item = proto_tree_add_text(ie_tree, tvb, offset, 1,
3193                                         "RAB-QueuedItem Extension/Optional/Default bitmap");
3194      optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
3195
3196      /* protocol_extension present ? */
3197      extension_present = extract_nbits(tvb, offset, bitoffset, 1);
3198      proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
3199                               offset, bitoffset, 1, 0);
3200      proceed_nbits(&offset, &bitoffset, 1);
3201
3202      /* iE_Extensions present ? */
3203      iE_Extensions_present = extract_nbits(tvb, offset, bitoffset, 1);
3204      proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present,
3205                               tvb, offset, bitoffset, 1, 0);
3206      proceed_nbits(&offset, &bitoffset, 1);
3207
3208      /* rAB-ID */
3209      proto_tree_add_uint_bits(ie_tree, hf_ranap_rab_id,
3210                              tvb, offset, bitoffset, 8, 0);
3211      proceed_nbits(&offset, &bitoffset, 8);
3212
3213      /* iE-Extensions */
3214      if (iE_Extensions_present)
3215      {
3216        if ((ret=dissect_iE_Extension(tvb, ie_tree, &offset, &bitoffset, "RAB_QueuedItem" )) != 0 )
3217                         return (ret);
3218      }
3219
3220      /* protocol extended */
3221      if (extension_present)
3222      {
3223         /* extended sequence */
3224         /* decoding is not supported */
3225         proto_tree_add_text(ie_tree, tvb, offset, IE_PROTOCOL_EXTENSION_LENGTH,
3226                           "Protocol extension for RAB_QueuedItem present, dissection not supported");
3227         return(-1);
3228      }
3229   }
3230
3231   return(0);
3232 }
3233
3234
3235 static int
3236 dissect_IE_RAB_FailedItem(tvbuff_t *tvb, proto_tree *ie_tree)
3237 {
3238    proto_item   *optionals_item = NULL;
3239    proto_tree   *optionals_tree = NULL;
3240    int          ret;
3241    int          extension_present;
3242    int          iE_Extensions_present;
3243    gint         offset = 0;
3244    gint         bitoffset = 0;
3245
3246   if (ie_tree)
3247   {
3248      /* create subtree for extension/optional/default bitmap */
3249      optionals_item = proto_tree_add_text(ie_tree, tvb, offset, 1,
3250                                         "RAB-FailedItem Extension/Optional/Default bitmap");
3251      optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
3252
3253      /* protocol_extension present ? */
3254      extension_present = extract_nbits(tvb, offset, bitoffset, 1);
3255      proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
3256                               offset, bitoffset, 1, 0);
3257      proceed_nbits(&offset, &bitoffset, 1);
3258
3259      /* iE_Extensions present ? */
3260      iE_Extensions_present = extract_nbits(tvb, offset, bitoffset, 1);
3261      proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present,
3262                               tvb, offset, bitoffset, 1, 0);
3263      proceed_nbits(&offset, &bitoffset, 1);
3264
3265      /* rAB-ID */
3266      proto_tree_add_uint_bits(ie_tree, hf_ranap_rab_id,
3267                              tvb, offset, bitoffset, 8, 0);
3268      proceed_nbits(&offset, &bitoffset, 8);
3269
3270      /* cause */
3271      if ((ret=dissect_cause(tvb, ie_tree, &offset, &bitoffset)) != 0)
3272                 return (ret);
3273
3274      /* iE-Extensions */
3275      if (iE_Extensions_present)
3276      {
3277        if ((ret=dissect_iE_Extension(tvb, ie_tree, &offset, &bitoffset, "RAB-FailedItem")) != 0)
3278              return (ret);
3279      }
3280
3281
3282      /* protocol extended */
3283      if (extension_present)
3284      {
3285         /* extended sequence */
3286         /* decoding is not supported */
3287         proto_tree_add_text(ie_tree, tvb, offset, IE_PROTOCOL_EXTENSION_LENGTH,
3288                           "Protocol extension for RAB-FailedItem present, dissection not supported");
3289         return(-1);
3290      }
3291   }
3292   return(0);
3293 }
3294
3295
3296 static int
3297 dissect_IE_CriticalityDiagnostics(tvbuff_t *tvb, proto_tree *ie_tree)
3298
3299 {
3300    proto_item   *optionals_item = NULL;
3301    proto_tree   *optionals_tree = NULL;
3302    int          ret;
3303    int          extension_present;
3304    int          procedureCode_present;
3305    int          triggeringMessage_present;
3306    int          procedureCriticality_present;
3307    int          iEsCriticalityDiagnostics_present;
3308    int          iE_Extensions_present;
3309    gint         offset = 0;
3310    gint         bitoffset = 0;
3311
3312
3313   if (ie_tree)
3314   {
3315      /* create subtree for extension/optional/default bitmap */
3316      optionals_item = proto_tree_add_text(ie_tree, tvb, offset, 1,
3317                                         "IE-CriticalityDiagnostics Extension/Optional/Default bitmap");
3318      optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
3319
3320      /* protocol_extension present ? */
3321      extension_present = extract_nbits(tvb, offset, bitoffset, 1);
3322      proto_tree_add_uint_bits(optionals_tree, hf_ranap_ie_protocol_extension, tvb,
3323                               offset, bitoffset, 1, 0);
3324      proceed_nbits(&offset, &bitoffset, 1);
3325
3326      /* procedureCode present ? */
3327      procedureCode_present = extract_nbits(tvb, offset, bitoffset, 1);
3328      proto_tree_add_uint_bits(optionals_tree, hf_ranap_procedureCode_present,
3329                               tvb, offset, bitoffset, 1, 0);
3330      proceed_nbits(&offset, &bitoffset, 1);
3331
3332      /* triggeringMessage present ? */
3333      triggeringMessage_present = extract_nbits(tvb, offset, bitoffset, 1);
3334      proto_tree_add_uint_bits(optionals_tree, hf_ranap_triggeringMessage_present,
3335                               tvb, offset, bitoffset, 1, 0);
3336      proceed_nbits(&offset, &bitoffset, 1);
3337
3338      /* procedureCriticality present ? */
3339      procedureCriticality_present = extract_nbits(tvb, offset, bitoffset, 1);
3340      proto_tree_add_uint_bits(optionals_tree, hf_ranap_procedureCriticality_present,
3341                               tvb, offset, bitoffset, 1, 0);
3342      proceed_nbits(&offset, &bitoffset, 1);
3343
3344      /* iEsCriticalityDiagnostics present ? */
3345      iEsCriticalityDiagnostics_present = extract_nbits(tvb, offset, bitoffset, 1);
3346      proto_tree_add_uint_bits(optionals_tree, hf_ranap_iEsCriticalityDiagnostics_present,
3347                               tvb, offset, bitoffset, 1, 0);
3348      proceed_nbits(&offset, &bitoffset, 1);
3349
3350      /* iE_Extensions present ? */
3351      iE_Extensions_present = extract_nbits(tvb, offset, bitoffset, 1);
3352      proto_tree_add_uint_bits(optionals_tree, hf_ranap_iE_Extensions_present,
3353                               tvb, offset, bitoffset, 1, 0);
3354      proceed_nbits(&offset, &bitoffset, 1);
3355
3356
3357      /* procedureCode */
3358      if (procedureCode_present)
3359      {
3360         allign (&offset, &bitoffset);
3361         proto_tree_add_item(ie_tree, hf_ranap_procedure_code, tvb, offset, 1, FALSE);
3362         offset += 1;
3363      }
3364
3365      /* triggeringMessage */
3366      if (triggeringMessage_present)
3367      {
3368         proto_tree_add_uint_bits(ie_tree, hf_ranap_triggeringMessage,
3369                                  tvb, offset, bitoffset, 2, 0);
3370         proceed_nbits(&offset, &bitoffset, 2);
3371      }
3372
3373      /* procedureCriticality */
3374      if (procedureCriticality_present)
3375      {
3376         proto_tree_add_uint_bits(ie_tree, hf_ranap_procedureCriticality,
3377                                  tvb, offset, bitoffset, 2, 0);
3378         proceed_nbits(&offset, &bitoffset, 2);
3379      }
3380
3381      /* iEsCriticalityDiagnostics */
3382      if (iEsCriticalityDiagnostics_present)
3383      {
3384         if ((ret=dissect_iEsCriticalityDiagnostics(tvb, ie_tree, &offset, &bitoffset)) != 0)
3385            return(ret);
3386      }
3387
3388      /* iE-Extensions */
3389      if (iE_Extensions_present)
3390      {
3391         if ((ret=dissect_iE_Extension(tvb, ie_tree, &offset, &bitoffset, "IE_CriticalityDiagnostics")) != 0)
3392            return(ret);
3393      }
3394
3395
3396      /* protocol extended */
3397      if (extension_present)
3398      {
3399         /* extended sequence */
3400         /* decoding is not supported */
3401         proto_tree_add_text(ie_tree, tvb, offset, IE_PROTOCOL_EXTENSION_LENGTH,
3402                           "Protocol extension for IE CriticalityDiagnostics present, dissection not supported");
3403         return(-1);
3404      }
3405   }
3406   return(0);
3407 }
3408
3409
3410 static int
3411 dissect_unknown_IE(tvbuff_t *tvb, proto_tree *ie_tree)
3412 {
3413   if (ie_tree)
3414   {
3415      proto_tree_add_text(ie_tree, tvb, 0, -1,
3416                            "IE Contents (dissection not implemented)");
3417   }
3418   return(0);
3419 }
3420
3421
3422
3423 /*****************************************************************************/
3424 /*                                                                           */
3425 /*  Dissecting Functions for IE Lists / Containers                           */
3426 /*                                                                           */
3427 /*****************************************************************************/
3428
3429 static int
3430 dissect_RAB_IE_ContainerPairList(tvbuff_t *tvb, proto_tree *ie_tree)
3431 {
3432   proto_item    *rab_item = NULL;
3433   proto_tree    *rab_tree = NULL;
3434   proto_item    *ie_pair_item = NULL;
3435   proto_tree    *ie_pair_tree = NULL;
3436   proto_item    *first_value_item = NULL;
3437   proto_tree    *first_value_tree = NULL;
3438   proto_item    *second_value_item = NULL;
3439   proto_tree    *second_value_tree = NULL;
3440   guint         number_of_RABs, currentRAB;
3441   guint         number_of_IEs, currentIE;
3442   gint          number_of_octets_first, number_of_octets_second;
3443   gint          number_of_octets_first_size, number_of_octets_second_size ;
3444   gint          offset = 0;
3445   gint          bitoffset = 0;
3446   gint          tmp_offset;
3447   guint16       ie_id;
3448   tvbuff_t      *first_value_tvb;
3449   tvbuff_t      *second_value_tvb;
3450
3451   if (ie_tree)
3452   {
3453      /* number of RABs in the list */
3454      number_of_RABs = 1 + tvb_get_guint8(tvb, offset);
3455      proto_tree_add_uint(ie_tree, hf_ranap_num_rabs,
3456                          tvb, offset,
3457                          NUM_RABS_LENGTH, number_of_RABs);
3458
3459      offset += NUM_RABS_LENGTH;
3460
3461      /* do for each RAB */
3462      for (currentRAB=1; currentRAB<=number_of_RABs; currentRAB++)
3463      {
3464         /* create subtree for RAB */
3465         rab_item = proto_tree_add_text(ie_tree, tvb, offset, 0, "%d. RAB", currentRAB);
3466         rab_tree = proto_item_add_subtree(rab_item, ett_ranap_rab);
3467
3468         /* number of IE pairs for this RAB */
3469         number_of_IEs = tvb_get_ntohs(tvb, offset);
3470         proto_tree_add_uint(rab_tree, hf_ranap_number_of_ies_in_list,
3471                             tvb, offset, 2, number_of_IEs);
3472
3473         offset += 2; /*points now to beginning of first IE pair */
3474
3475         /* do for each IE pair */
3476         for (currentIE=1; currentIE<=number_of_IEs; currentIE++)
3477         {
3478            /*  use tmp_offset to point to current field */
3479            tmp_offset = offset;
3480            /* IE pair ID */
3481            ie_id = tvb_get_ntohs(tvb, tmp_offset);
3482            tmp_offset += IE_ID_LENGTH;
3483
3484            tmp_offset += 1; /* skip first criticality byte */
3485            /* number of octets in first value */
3486            extract_length(tvb, tmp_offset, &number_of_octets_first, &number_of_octets_first_size);
3487            tmp_offset += number_of_octets_first_size + number_of_octets_first;
3488
3489            tmp_offset += 1; /* skip second criticality byte */
3490            /* number of octets in second value */
3491            extract_length(tvb, tmp_offset, &number_of_octets_second, &number_of_octets_second_size);
3492            tmp_offset += number_of_octets_second_size + number_of_octets_second;
3493
3494            /* create subtree for ie_pair */
3495            ie_pair_item = proto_tree_add_text(rab_tree, tvb, offset,
3496                                      tmp_offset - offset,
3497                                      "%s IE Pair (%u)",
3498                                      val_to_str(ie_id, ranap_ie_id_values, "Unknown"),
3499                                      ie_id);
3500            ie_pair_tree = proto_item_add_subtree(ie_pair_item, ett_ranap_ie_pair);
3501
3502            /* add fields to ie pair subtee */
3503            /* use offset to point to current field */
3504             /* IE ID */
3505            proto_tree_add_item(ie_pair_tree, hf_ranap_ie_ie_id, tvb, offset, IE_ID_LENGTH, FALSE);
3506            offset += IE_ID_LENGTH;
3507
3508            /* first criticality */
3509            proto_tree_add_uint_bits(ie_pair_tree, hf_ranap_ie_pair_first_criticality, tvb,
3510                                     offset, bitoffset, 2, 0);
3511            proceed_nbits(&offset, &bitoffset, 2);
3512
3513            /* number of octets in first value */
3514            allign(&offset, &bitoffset);
3515            if (number_of_octets_first != 0)
3516            {
3517               proto_tree_add_uint(ie_pair_tree, hf_ranap_first_value_number_of_octets,
3518                                   tvb, offset,
3519                                   number_of_octets_first_size,
3520                                   number_of_octets_first);
3521            }
3522            else
3523            {
3524               /* decoding is not supported */
3525               proto_tree_add_text(ie_pair_tree, tvb, offset,
3526                             2, "Number of Octets greater than 0x3FFF, dissection not supported");
3527               return(-1);
3528            }
3529            offset += number_of_octets_first_size;
3530
3531            /* add subtree for first value */
3532            first_value_item = proto_tree_add_text(ie_pair_tree, tvb, offset,
3533                                      number_of_octets_first,
3534                                      "%sFirst",
3535                                      val_to_str(ie_id, ranap_ie_id_values, "Unknown"));
3536            first_value_tree = proto_item_add_subtree(first_value_item, ett_ranap_ie_pair_first_value);
3537
3538            /* create tvb containing first value */
3539            first_value_tvb = tvb_new_subset(tvb, offset, number_of_octets_first, number_of_octets_first);
3540
3541            /* add fields of first value */
3542            switch (ie_id)
3543            {
3544               case  IE_RAB_SetupOrModifyItem:
3545                  dissect_IE_RAB_SetupOrModifyItemFirst (first_value_tvb, first_value_tree);
3546                  break;
3547
3548               default:
3549                  dissect_unknown_IE(first_value_tvb, first_value_tree);
3550                  break;
3551            }
3552
3553            offset += number_of_octets_first;
3554
3555
3556            /* second criticality */
3557            proto_tree_add_uint_bits(ie_pair_tree, hf_ranap_ie_pair_second_criticality, tvb,
3558                                     offset, bitoffset, 2, 0);
3559            proceed_nbits(&offset, &bitoffset, 2);
3560
3561            /* number of octets of second value */
3562            allign(&offset, &bitoffset);
3563            if (number_of_octets_second != 0)
3564            {
3565               proto_tree_add_uint(ie_pair_tree, hf_ranap_second_value_number_of_octets,
3566                                   tvb, offset,
3567                                   number_of_octets_second_size,
3568                                   number_of_octets_second);
3569            }
3570            else
3571            {
3572               /* decoding is not supported */
3573               proto_tree_add_text(ie_pair_tree, tvb, offset,
3574                             2, "Number of Octets greater than 0x3FFF, dissection not supported");
3575               return(-1);
3576            }
3577            offset += number_of_octets_second_size;
3578
3579            /* add subtree for second value */
3580            second_value_item = proto_tree_add_text(ie_pair_tree, tvb, offset,
3581                                      number_of_octets_second,
3582                                      "%sSecond",
3583                                      val_to_str(ie_id, ranap_ie_id_values, "Unknown"));
3584            second_value_tree = proto_item_add_subtree(second_value_item, ett_ranap_ie_pair_second_value);
3585
3586            /* create tvb containing first value */
3587            second_value_tvb = tvb_new_subset(tvb, offset, number_of_octets_second, number_of_octets_second);
3588
3589            /* add fields of second value */
3590            switch (ie_id)
3591            {
3592               case  IE_RAB_SetupOrModifyItem:
3593                  dissect_IE_RAB_SetupOrModifyItemSecond (second_value_tvb, second_value_tree);
3594                  break;
3595
3596               default:
3597                  dissect_unknown_IE(second_value_tvb, second_value_tree);
3598                  break;
3599            }
3600
3601            offset += number_of_octets_second;
3602
3603         }/* for each IE ... */
3604      }/* for each RAB ... */
3605    }
3606    return(0);
3607 }
3608
3609
3610 static int
3611 dissect_RAB_IE_ContainerList(tvbuff_t *tvb, proto_tree *list_tree)
3612 {
3613   proto_item    *rab_item = NULL;
3614   proto_tree    *rab_tree = NULL;
3615   proto_item    *ie_item = NULL;
3616   proto_tree    *ie_tree = NULL;
3617
3618   guint         number_of_RABs, currentRAB;
3619   guint         number_of_IEs, currentIE;
3620   gint          ie_number_of_octets = 0;
3621   gint          ie_number_of_octets_size = 0;
3622   gint          offset = 0;
3623   gint          bitoffset = 0;
3624   gint          ie_offset = 0;
3625   gint          ie_header_length;
3626   guint16       ie_id;
3627   tvbuff_t      *ie_tvb;
3628
3629
3630   if (list_tree)
3631   {
3632      /* number of RABs in the list */
3633      number_of_RABs = 1 + tvb_get_guint8(tvb, offset);
3634      proto_tree_add_uint(list_tree, hf_ranap_num_rabs,
3635                          tvb, offset,
3636                          NUM_RABS_LENGTH, number_of_RABs);
3637
3638      offset +=  NUM_RABS_LENGTH;
3639
3640      /* do for each RAB */
3641      for (currentRAB=1; currentRAB<=number_of_RABs; currentRAB++)
3642      {
3643         /* create subtree for RAB */
3644         rab_item = proto_tree_add_text(list_tree, tvb, offset, 0, "%d. RAB", currentRAB);
3645         rab_tree = proto_item_add_subtree(rab_item, ett_ranap_rab);
3646
3647         /* number of IEs for this RAB */
3648         number_of_IEs = tvb_get_ntohs(tvb, offset);
3649         proto_tree_add_uint(rab_tree, hf_ranap_number_of_ies_in_list,
3650                             tvb, offset, 2, number_of_IEs);
3651
3652         offset += 2; /*points now to beginning of first IE in list */
3653         ie_offset = offset;
3654
3655         /* do for each IE */
3656         for (currentIE=1; currentIE<=number_of_IEs; currentIE++)
3657         {
3658            /* extract IE ID */
3659            ie_id = tvb_get_ntohs(tvb, offset);
3660            offset += IE_ID_LENGTH;
3661
3662            offset += IE_CRITICALITY_LENGTH; /* skip criticality byte */
3663
3664            /* number of octets */
3665            extract_length(tvb, offset, &ie_number_of_octets, &ie_number_of_octets_size);
3666            ie_header_length = IE_ID_LENGTH + IE_CRITICALITY_LENGTH + ie_number_of_octets_size;
3667
3668            /* reset offset to beginning of ie */
3669            offset = ie_offset;
3670
3671            /* create subtree for ie */
3672            ie_item = proto_tree_add_text(rab_tree, tvb, offset,
3673                              ie_header_length + ie_number_of_octets,
3674                              "%s IE (%u)",
3675                              val_to_str(ie_id, ranap_ie_id_values, "Unknown"),
3676                              ie_id);
3677            ie_tree = proto_item_add_subtree(ie_item, ett_ranap_ie);
3678
3679            /* IE ID */
3680            proto_tree_add_item(ie_tree, hf_ranap_ie_ie_id, tvb,
3681                                offset, IE_ID_LENGTH, FALSE);
3682            offset += IE_ID_LENGTH;
3683
3684            /* criticality */
3685            proto_tree_add_uint_bits(ie_tree, hf_ranap_ie_criticality, tvb,
3686                                     offset, bitoffset, 2, 0);
3687            proceed_nbits(&offset, &bitoffset, 2);
3688
3689            allign(&offset, &bitoffset);
3690            if (ie_number_of_octets != 0)
3691            {
3692               proto_tree_add_uint(ie_tree, hf_ranap_ie_number_of_octets, tvb,
3693                                   offset, ie_number_of_octets_size, ie_number_of_octets);
3694            }
3695            else
3696            {
3697                   /* decoding is not supported */
3698                   proto_tree_add_text(ie_tree, tvb, offset,
3699                                     0, "Number of Octets greater than 0x3FFF, dissection not supported");
3700                   return(-1);
3701            }
3702            offset += ie_number_of_octets_size;
3703
3704
3705            /* create tvb containing ie */
3706            ie_tvb = tvb_new_subset(tvb, offset, ie_number_of_octets, ie_number_of_octets);
3707
3708            /* add fields of ie */
3709            switch (ie_id)
3710            {
3711               case  IE_RAB_SetupOrModifiedItem:
3712                  dissect_IE_RAB_SetupOrModifiedItem(ie_tvb, ie_tree);
3713                  break;
3714               case  IE_RAB_ReleaseItem:
3715                  dissect_IE_RAB_ReleaseItem(ie_tvb, ie_tree);
3716                  break;
3717               case  IE_RAB_ReleasedItem:
3718                  dissect_IE_RAB_ReleasedItem(ie_tvb, ie_tree);
3719                  break;
3720               case  IE_RAB_ReleasedItem_IuRelComp:
3721                  dissect_IE_RAB_ReleasedItem_IuRelComp(ie_tvb, ie_tree);
3722                  break;
3723               case  IE_RAB_QueuedItem:
3724                  dissect_IE_RAB_QueuedItem(ie_tvb, ie_tree);
3725                  break;
3726               case  IE_RAB_FailedItem:
3727                  dissect_IE_RAB_FailedItem(ie_tvb, ie_tree);
3728                  break;
3729               case  IE_RAB_DataVolumeReportItem:
3730                  dissect_IE_RAB_DataVolumeReportItem(ie_tvb, ie_tree);
3731                  break;
3732               default:
3733                  dissect_unknown_IE(ie_tvb, ie_tree);
3734                  break;
3735            }
3736
3737            ie_offset += (ie_header_length + ie_number_of_octets);
3738            offset = ie_offset;
3739         } /* for each IE */
3740      } /* for each RAB */
3741    }
3742    return (0);
3743 }
3744
3745
3746 static int
3747 dissect_ranap_ie(guint16 ie_id, tvbuff_t *ie_contents_tvb, proto_tree *ie_tree)
3748 {
3749      /* call specific dissection function for ie contents */
3750      switch(ie_id)
3751      {
3752         case IE_RAB_ID:
3753            return(dissect_IE_RAB_ID(ie_contents_tvb, ie_tree));
3754            break;
3755         case IE_NAS_PDU:
3756            return(dissect_IE_NAS_PDU(ie_contents_tvb, ie_tree));
3757            break;
3758         case IE_LAI:
3759            return(dissect_IE_LAI(ie_contents_tvb, ie_tree));
3760            break;
3761         case IE_RAC:
3762            return(dissect_IE_RAC(ie_contents_tvb, ie_tree));
3763            break;
3764         case IE_SAI:
3765            return(dissect_IE_SAI(ie_contents_tvb, ie_tree));
3766            break;
3767         case IE_CN_DomainIndicator:
3768            return(dissect_IE_CN_DomainIndicator(ie_contents_tvb, ie_tree));
3769            break;
3770         case IE_IuSigConId:
3771            return(dissect_IE_IuSigConId(ie_contents_tvb, ie_tree));
3772            break;
3773         case IE_SAPI:
3774            return(dissect_IE_SAPI(ie_contents_tvb, ie_tree));
3775            break;
3776         case IE_TransportLayerAddress:
3777            return(dissect_IE_TransportLayerAddress(ie_contents_tvb, ie_tree));
3778            break;
3779         case IE_IuTransportAssociation:
3780            return(dissect_IE_IuTransportAssociation(ie_contents_tvb, ie_tree));
3781            break;
3782         case IE_RAB_SetupOrModifyList:
3783            return(dissect_RAB_IE_ContainerPairList(ie_contents_tvb, ie_tree));
3784            break;
3785         case IE_RAB_SetupOrModifiedList:
3786         case IE_RAB_ReleaseList:
3787         case IE_RAB_ReleasedList:
3788         case IE_RAB_QueuedList:
3789         case IE_RAB_FailedList:
3790         case IE_RAB_ReleaseFailedList:
3791         case IE_RAB_DataVolumeReportList:
3792         case IE_RAB_ReleasedList_IuRelComp:
3793         case IE_RAB_RelocationReleaseList:
3794         case IE_RAB_DataForwardingList:
3795         case IE_RAB_SetupList_RelocReq:
3796         case IE_RAB_SetupList_RelocReqAck:
3797         case IE_RAB_DataForwardingList_SRNS_CtxReq:
3798         case IE_RAB_ContextList:
3799         case IE_RAB_ContextFailedtoTransferList:
3800         case IE_RAB_DataVolumeReportRequestList:
3801         case IE_RAB_FailedtoReportList:
3802         case IE_RAB_ContextList_RANAP_RelocInf:
3803            return(dissect_RAB_IE_ContainerList(ie_contents_tvb, ie_tree));
3804            break;
3805         case IE_CriticalityDiagnostics:
3806            return(dissect_IE_CriticalityDiagnostics(ie_contents_tvb, ie_tree));
3807            break;
3808         case IE_Cause:
3809            return(dissect_IE_Cause(ie_contents_tvb, ie_tree));
3810            break;
3811         default:
3812            return(dissect_unknown_IE(ie_contents_tvb, ie_tree));
3813            break;
3814      }
3815 }
3816
3817
3818 static int
3819 dissect_ranap_ie_container(tvbuff_t *tvb, proto_tree *ranap_tree)
3820 {
3821   proto_item    *ie_item = NULL;
3822   proto_tree    *ie_tree = NULL;
3823   proto_item    *optionals_item = NULL;
3824   proto_tree    *optionals_tree = NULL;
3825
3826   int           msg_extension_present;
3827   int           ProtocolExtensionContainer_present;
3828
3829   guint16       number_of_ies;
3830   guint16       ie_id;
3831   gint          ie_number_of_octets = 0;
3832   gint          ie_number_of_octets_size = 0;
3833   guint16       ie_header_length;
3834   gint          offset = 0;
3835   gint          bitoffset = 0;
3836   gint          i, ie_offset;
3837   tvbuff_t      *ie_contents_tvb;
3838
3839   if (ranap_tree)
3840   {
3841      /* create subtree for extension/optional bitmap of message */
3842      optionals_item = proto_tree_add_text(ranap_tree, tvb, offset, 1,
3843                                         "Message Extension/Optional/Default bitmap");
3844      optionals_tree = proto_item_add_subtree(optionals_item, ett_ranap_optionals);
3845   }
3846
3847   /* msg_extension present ? */
3848   msg_extension_present = extract_nbits(tvb, offset, bitoffset, 1);
3849
3850   if (ranap_tree)
3851   {
3852      proto_tree_add_uint_bits(optionals_tree, hf_ranap_msg_extension_present, tvb,
3853                               offset, bitoffset, 1, 0);
3854   }
3855   proceed_nbits(&offset, &bitoffset, 1);
3856
3857   /* ProtocolExtensionContainer present ? */
3858   ProtocolExtensionContainer_present = extract_nbits(tvb, offset, bitoffset, 1);
3859   if (ranap_tree)
3860   {
3861       proto_tree_add_uint_bits(optionals_tree, hf_ranap_ProtocolExtensionContainer_present,
3862                               tvb, offset, bitoffset, 1, 0);
3863   }
3864   proceed_nbits(&offset, &bitoffset, 1);
3865
3866
3867   /* extract ie container data */
3868   /* number of ies */
3869   allign(&offset, &bitoffset);
3870   number_of_ies = tvb_get_ntohs(tvb, offset);
3871   if (ranap_tree)
3872   {
3873      proto_tree_add_uint(ranap_tree, hf_ranap_number_of_ies,
3874                          tvb, offset, 2, number_of_ies);
3875   }
3876   offset += 2;
3877
3878   ie_offset = offset; /* ie_offset marks beginning of IE-Header */
3879
3880   /* do the following for each IE in the PDU */
3881   for (i=1; i <= number_of_ies; i++)
3882   {
3883      /* extract IE header fields which are needed even if no ranap tree exists*/
3884      /* IE-ID */
3885      ie_id = tvb_get_ntohs(tvb, offset);
3886      offset += IE_ID_LENGTH;
3887
3888     /* number of octets in the IE */
3889     offset += IE_CRITICALITY_LENGTH; /* skip criticality byte */
3890     ie_number_of_octets = 0;
3891     extract_length(tvb, offset, &ie_number_of_octets, &ie_number_of_octets_size);
3892     ie_header_length = IE_ID_LENGTH + IE_CRITICALITY_LENGTH + ie_number_of_octets_size;
3893
3894     if (ranap_tree)
3895     {
3896        offset = ie_offset; /* start from beginning of IE */
3897        /* create subtree for ie */
3898        ie_item = proto_tree_add_text(ranap_tree, tvb, offset,
3899                                      ie_header_length + ie_number_of_octets,
3900                                      "%s IE (%u)",
3901                                      val_to_str(ie_id, ranap_ie_id_values, "Unknown"),
3902                                      ie_id);
3903        ie_tree = proto_item_add_subtree(ie_item, ett_ranap_ie);
3904
3905        /* add fields to ie subtee */
3906        /* IE ID */
3907        proto_tree_add_item(ie_tree, hf_ranap_ie_ie_id, tvb,
3908                            offset, IE_ID_LENGTH, FALSE);
3909        offset += IE_ID_LENGTH;
3910
3911        /* criticality */
3912        proto_tree_add_uint_bits(ie_tree, hf_ranap_ie_criticality, tvb,
3913                                 offset, bitoffset, 2, 0);
3914        proceed_nbits(&offset, &bitoffset, 2);
3915
3916        /* number of octets */
3917        allign(&offset, &bitoffset);
3918        if (ie_number_of_octets != 0)
3919        {
3920           proto_tree_add_uint(ie_tree, hf_ranap_ie_number_of_octets, tvb,
3921                               offset, ie_number_of_octets_size, ie_number_of_octets);
3922           offset += ie_number_of_octets_size;
3923        }
3924        else
3925        {
3926           /* decoding is not supported */
3927           proto_tree_add_text(ranap_tree, tvb, offset,
3928                               2, "Number of Octets greater than 0x3FFF, dissection not supported");
3929           return(-1);
3930        }
3931      }
3932
3933      /* check if number_of_octets could be decoded */
3934      /* in case we skipped if (ranap_tree) {....} */
3935      if (ie_number_of_octets == 0) return (-1);
3936
3937      /* create tvb containing the ie contents */
3938      ie_contents_tvb = tvb_new_subset(tvb, ie_offset + ie_header_length,
3939                                       ie_number_of_octets, ie_number_of_octets);
3940
3941      /* call specific dissection function for ie contents */
3942      dissect_ranap_ie(ie_id, ie_contents_tvb, ie_tree);
3943
3944      /* set ie_offset to beginning of next ie */
3945      ie_offset += (ie_header_length + ie_number_of_octets);
3946      offset = ie_offset;
3947   }
3948
3949   /* protocol Extensions */
3950   if (ProtocolExtensionContainer_present)
3951   {
3952      return(dissect_iE_Extension(tvb, ranap_tree, &offset, &bitoffset, "PDU"));
3953   }
3954
3955   return(0);
3956
3957 }
3958
3959
3960 static void
3961 dissect_ranap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3962 {
3963   proto_item    *ranap_item = NULL;
3964   proto_tree    *ranap_tree = NULL;
3965
3966   guint         procedure_code;
3967   guint         pdu_index;
3968   gint          number_of_octets = 0;
3969   gint          number_of_octets_size = 0;
3970   gint          offset = 0;
3971   gint          tmp_offset = 0;
3972   gint          bitoffset = 0;
3973   gint          tmp_bitoffset = 0;
3974   guint         extension_present;
3975
3976   tvbuff_t      *ie_tvb;
3977
3978
3979   /* make entry in the Protocol column on summary display */
3980   if (check_col(pinfo->cinfo, COL_PROTOCOL))
3981     col_set_str(pinfo->cinfo, COL_PROTOCOL, "RANAP");
3982
3983   /* extract header fields which are needed even if no tree exists */
3984
3985   /* protocol_extension present ? */
3986   extension_present = extract_nbits(tvb, tmp_offset, tmp_bitoffset, 1);
3987   proceed_nbits(&tmp_offset, &tmp_bitoffset, 1);
3988   if (extension_present)
3989   {
3990       /* extended choice */
3991       /* decoding is not supported */
3992       col_append_str(pinfo->cinfo, COL_INFO, "RANAP-PDU Protocol extension present, dissection not supported");
3993       return;
3994   }
3995
3996   /* pdu_index choice 0..3 */
3997   pdu_index = extract_nbits(tvb, tmp_offset, tmp_bitoffset, 2);
3998   proceed_nbits(&tmp_offset, &tmp_bitoffset, 2);
3999
4000   /* procedure code */
4001   allign(&tmp_offset, &tmp_bitoffset);
4002   procedure_code = tvb_get_guint8(tvb, tmp_offset);
4003   tmp_offset += 1;
4004
4005   /* add Procedure Code to Info Column */
4006   if (check_col(pinfo->cinfo, COL_INFO))
4007   {
4008     if (procedure_code <= PC_max)
4009     {
4010        col_append_str(pinfo->cinfo, COL_INFO,
4011                    val_to_str(pdu_index, ranap_message_names[procedure_code],
4012                               "unknown message"));
4013        col_append_str(pinfo->cinfo, COL_INFO, " ");
4014     }
4015   }
4016
4017   /* extract number of octets */
4018   tmp_offset += 1; /* leave out criticality byte */
4019   extract_length(tvb, tmp_offset, &number_of_octets, &number_of_octets_size);
4020
4021   /* In the interest of speed, if "tree" is NULL, don't do any work not
4022      necessary to generate protocol tree items. */
4023   if (tree)
4024   {
4025     /* create the ranap protocol tree */
4026     ranap_item = proto_tree_add_item(tree, proto_ranap, tvb, 0, -1, FALSE);
4027     ranap_tree = proto_item_add_subtree(ranap_item, ett_ranap);
4028
4029     /* Add fields to ranap protocol tree */
4030     /* PDU Index */
4031     proceed_nbits(&offset, &bitoffset, 1);  /* leave out extension bit, checked above */
4032     proto_tree_add_uint_bits(ranap_tree, hf_ranap_pdu_index, tvb,
4033                              offset, bitoffset, 2, 0);
4034     proceed_nbits(&offset, &bitoffset, 2);
4035
4036
4037     /* Procedure Code */
4038     allign(&offset, &bitoffset);
4039     proto_tree_add_item(ranap_tree, hf_ranap_procedure_code, tvb, offset, 1, FALSE);
4040     offset += 1;
4041
4042     /* PDU Criticality */
4043     proto_tree_add_uint_bits(ranap_tree, hf_ranap_pdu_criticality, tvb,
4044                              offset, bitoffset, 2, 0);
4045     proceed_nbits(&offset, &bitoffset, 2);
4046
4047     /* number of octets */
4048     allign(&offset, &bitoffset);
4049     if (number_of_octets != 0)
4050     {
4051        proto_tree_add_uint(ranap_tree, hf_ranap_pdu_number_of_octets,
4052                            tvb, offset,
4053                            number_of_octets_size, number_of_octets);
4054        offset += number_of_octets_size;
4055     }
4056     else
4057     {
4058         /* decoding is not supported */
4059         proto_tree_add_text(ranap_tree, tvb, offset,
4060                             2, "Number of Octets greater than 0x3FFF, dissection not supported");
4061         return;
4062     }
4063   }
4064
4065   /* set offset to the beginning of ProtocolIE-Container */
4066   /* in case we skipped "if(tree){...}" above */
4067   offset = PDU_NUMBER_OF_OCTETS_OFFSET + number_of_octets_size;
4068
4069   /* create a tvb containing the remainder of the PDU */
4070   ie_tvb = tvb_new_subset(tvb, offset, -1, -1);
4071
4072   /* dissect the ies */
4073   dissect_ranap_ie_container(ie_tvb, ranap_tree);
4074 }
4075
4076
4077
4078 /*****************************************************************************/
4079 /*                                                                           */
4080 /*  Protocol Registration Functions                                          */
4081 /*                                                                           */
4082 /*****************************************************************************/
4083
4084 void
4085 proto_register_ranap(void)
4086 {
4087   /* Setup list of header fields */
4088   static hf_register_info hf[] = {
4089     { &hf_ranap_pdu_index,
4090       { "RANAP-PDU Index",
4091         "ranap.ranap_pdu_index",
4092         FT_UINT8, BASE_HEX, VALS(&ranap_pdu_index_values), 0x0,
4093         "", HFILL }
4094     },
4095     { &hf_ranap_procedure_code,
4096       { "Procedure Code",
4097         "ranap.procedure_code",
4098         FT_UINT8, BASE_DEC, VALS(&ranap_procedure_code_values), 0x0,
4099         "", HFILL }
4100     },
4101     { &hf_ranap_pdu_criticality,
4102       { "Criticality of PDU",
4103         "ranap.pdu.criticality",
4104         FT_UINT8, BASE_HEX, VALS(&ranap_criticality_values), 0x0,
4105         "", HFILL }
4106     },
4107     { &hf_ranap_pdu_number_of_octets,
4108       { "Number of Octets in PDU",
4109         "ranap.pdu.num_of_octets",
4110         FT_UINT16, BASE_DEC, NULL, 0x0,
4111         "", HFILL }
4112     },
4113     { &hf_ranap_ie_protocol_extension,
4114       { "Protocol Extension",
4115         "ranap.ie.protocol_extension_present",
4116         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4117         "", HFILL }
4118     },
4119     { &hf_ranap_number_of_ies,
4120       { "Number of IEs in PDU",
4121         "ranap.pdu.number_of_ies",
4122         FT_UINT16, BASE_DEC, NULL, 0x0,
4123         "", HFILL }
4124     },
4125     { &hf_ranap_number_of_ProtocolExtensionFields,
4126       { "Number of Protocol Extension Fields",
4127         "ranap.ie.number_of_ProtocolExtensionFields",
4128         FT_UINT16, BASE_DEC, NULL, 0x0,
4129         "", HFILL }
4130     },
4131     { &hf_ranap_number_of_ies_in_list,
4132       { "Number of IEs in list",
4133         "ranap.number_of_ies",
4134         FT_UINT16, BASE_DEC, NULL, 0x0,
4135         "", HFILL }
4136     },
4137     { &hf_ranap_ie_ie_id,
4138       { "IE-ID",
4139         "ranap.ie.ie_id",
4140         FT_UINT16, BASE_DEC, VALS(&ranap_ie_id_values), 0x0,
4141         "", HFILL }
4142     },
4143     { &hf_ranap_ext_field_id,
4144       { "ProtocolExtensionField ID",
4145         "ranap.ie.ProtocolExtensionFields.Id",
4146         FT_UINT16, BASE_DEC, NULL, 0x0,
4147         "", HFILL }
4148     },
4149     { &hf_ranap_ie_criticality,
4150       { "Criticality of IE",
4151         "ranap.ie.criticality",
4152         FT_UINT8, BASE_HEX, VALS(&ranap_criticality_values), 0x0,
4153         "", HFILL }
4154     },
4155     { &hf_ranap_ext_field_criticality,
4156       { "Criticality of ProtocolExtensionField",
4157         "ranap.ie.ProtocolExtensionFields.criticality",
4158         FT_UINT8, BASE_HEX, VALS(&ranap_criticality_values), 0x0,
4159         "", HFILL }
4160     },
4161     { &hf_ranap_ie_pair_first_criticality,
4162       { "First Criticality",
4163         "ranap.ie_pair.first_criticality",
4164         FT_UINT8, BASE_HEX, VALS(&ranap_criticality_values), 0x0,
4165         "", HFILL }
4166     },
4167     { &hf_ranap_ie_pair_second_criticality,
4168       { "Second Criticality",
4169         "ranap.ie_pair.second_criticality",
4170         FT_UINT8, BASE_HEX, VALS(&ranap_criticality_values), 0x0,
4171         "", HFILL }
4172     },
4173     { &hf_ranap_ie_number_of_octets,
4174       { "Number of Octets in IE",
4175         "ranap.ie.number_of_octets",
4176         FT_UINT16, BASE_DEC, NULL, 0x0,
4177         "", HFILL }
4178     },
4179     { &hf_ranap_first_value_number_of_octets,
4180       { "Number of Octets in first value",
4181         "ranap.ie_pair.first_value.number_of_octets",
4182         FT_UINT16, BASE_DEC, NULL, 0x0,
4183         "", HFILL }
4184     },
4185     { &hf_ranap_second_value_number_of_octets,
4186       { "Number of Octets in second value",
4187         "ranap.ie_pair.second_value.number_of_octets",
4188         FT_UINT16, BASE_DEC, NULL, 0x0,
4189         "", HFILL }
4190     },
4191     { &hf_ranap_rab_id,
4192       { "RAB-ID",
4193         "ranap.RAB_ID",
4194         FT_UINT8, BASE_HEX, NULL, 0x0,
4195         "", HFILL }
4196     },
4197     { &hf_ranap_nas_pdu,
4198       { "NAS-PDU",
4199         "ranap.NAS_PDU",
4200         FT_BYTES, BASE_NONE, NULL, 0x0,
4201         "", HFILL }
4202     },
4203     { &hf_ranap_extension_field,
4204       { "Extension Field Value",
4205         "ranap.Extension_Field_Value",
4206         FT_BYTES, BASE_NONE, NULL, 0x0,
4207         "", HFILL }
4208     },
4209     { &hf_ranap_plmn_id,
4210       { "PLMN-ID",
4211         "ranap.PLMN_ID",
4212         FT_BYTES, BASE_NONE, NULL, 0x0,
4213         "", HFILL }
4214     },
4215     { &hf_ranap_lac,
4216       { "LAC",
4217         "ranap.PLMN_ID",
4218         FT_BYTES, BASE_NONE, NULL, 0x0,
4219         "", HFILL }
4220     },
4221     { &hf_ranap_plmn_id,
4222       { "PLMN-ID",
4223         "ranap.PLMN_ID",
4224         FT_BYTES, BASE_NONE, NULL, 0x0,
4225         "", HFILL }
4226     },
4227     { &hf_ranap_lac,
4228       { "LAC",
4229         "ranap.PLMN_ID",
4230         FT_BYTES, BASE_NONE, NULL, 0x0,
4231         "", HFILL }
4232     },
4233     { &hf_ranap_sac,
4234       { "SAC",
4235         "ranap.SAC",
4236         FT_BYTES, BASE_NONE, NULL, 0x0,
4237         "", HFILL }
4238     },
4239     { &hf_ranap_rac,
4240       { "RAC",
4241         "ranap.RAC",
4242         FT_BYTES, BASE_NONE, NULL, 0x0,
4243         "", HFILL }
4244     },
4245     { &hf_ranap_num_rabs,
4246       { "Number of RABs",
4247         "ranap.number_of_RABs",
4248         FT_UINT8, BASE_DEC, NULL, 0x0,
4249         "", HFILL }
4250     },
4251     { &hf_ranap_nAS_SynchronisationIndicator_present,
4252       { "nAS-SynchronisationIndicator",
4253         "ranap.nAS-SynchronisationIndicator_present",
4254         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4255         "", HFILL }
4256     },
4257     { &hf_ranap_rAB_Parameters_present,
4258       { "rAB-Parameters",
4259         "ranap.rAB_Parameters_present",
4260         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4261         "", HFILL }
4262     },
4263     { &hf_ranap_userPlaneInformation_present,
4264       { "userPlaneInformation",
4265         "ranap.userPlaneInformation_present",
4266         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4267         "", HFILL }
4268     },
4269     { &hf_ranap_transportLayerInformation_present,
4270       { "transportLayerInformation",
4271         "ranap.transportLayerInformation_present",
4272         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4273         "", HFILL }
4274     },
4275     { &hf_ranap_service_Handover_present,
4276       { "service-Handover",
4277         "ranap.service_Handover_present",
4278         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4279         "", HFILL }
4280     },
4281     { &hf_ranap_iE_Extensions_present,
4282       { "iE-Extensions",
4283         "ranap.ie.iE-Extensions_present",
4284         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4285         "", HFILL }
4286     },
4287     { &hf_ranap_nAS_SynchronisationIndicator,
4288       { "nAS-SynchronisationIndicator",
4289         "ranap.nAS-SynchronisationIndicator",
4290         FT_UINT8, BASE_HEX, NULL, 0x0,
4291         "", HFILL }
4292     },
4293     { &hf_ranap_guaranteedBitRate_present,
4294       { "guaranteedBitRate",
4295         "ranap.guaranteedBitRate_present",
4296         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4297         "", HFILL }
4298     },
4299     { &hf_ranap_transferDelay_present,
4300       { "transferDelay",
4301         "ranap.transferDelay_present",
4302         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4303         "", HFILL }
4304     },
4305     { &hf_ranap_trafficHandlingPriority_present,
4306       { "trafficHandlingPriority",
4307         "ranap.trafficHandlingPriority_present",
4308         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4309         "", HFILL }
4310     },
4311     { &hf_ranap_allocationOrRetentionPriority_present,
4312       { "allocationOrRetentionPriority",
4313         "ranap.allocationOrRetentionPriority_present",
4314         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4315         "", HFILL }
4316     },
4317     { &hf_ranap_sourceStatisticsDescriptor_present,
4318       { "sourceStatisticsDescriptor",
4319         "ranap.sourceStatisticsDescriptor_present",
4320         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4321         "", HFILL }
4322     },
4323     { &hf_ranap_relocationRequirement_present,
4324       { "relocationRequirement",
4325         "ranap.relocationRequirement_present",
4326         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4327         "", HFILL }
4328     },
4329     { &hf_ranap_trafficClass,
4330       { "Traffic Class",
4331         "ranap.rab_Parameters.trafficClass",
4332         FT_UINT8, BASE_DEC, VALS(&ranap_trafficClass_values), 0x0,
4333         "", HFILL }
4334     },
4335     { &hf_ranap_rAB_AsymmetryIndicator,
4336       { "rAB_AsymmetryIndicator",
4337         "ranap.rab_Parameters.rAB_AsymmetryIndicator",
4338         FT_UINT8, BASE_DEC, VALS(&ranap_rAB_AsymmetryIndicator_values), 0x0,
4339         "", HFILL }
4340     },
4341     { &hf_ranap_maxBitrate,
4342       { "maxBitrate",
4343         "ranap.rab_Parameters.maxBitrate",
4344         FT_UINT32, BASE_DEC, NULL, 0x0,
4345         "", HFILL }
4346     },
4347     { &hf_ranap_guaranteedBitrate,
4348       { "guaranteedBitrate",
4349         "ranap.rab_Parameters.guaranteedBitrate",
4350         FT_UINT32, BASE_DEC, NULL, 0x0,
4351         "", HFILL }
4352     },
4353     { &hf_ranap_deliveryOrder,
4354       { "deliveryOrder",
4355         "ranap.rab_Parameters.deliveryOrder",
4356         FT_UINT8, BASE_DEC, VALS(&ranap_DeliveryOrder_values), 0x0,
4357         "", HFILL }
4358     },
4359     { &hf_ranap_maxSDU_Size,
4360       { "maxSDU_Size",
4361         "ranap.rab_Parameters.maxSDU_Size",
4362         FT_UINT16, BASE_DEC, NULL, 0x0,
4363         "", HFILL }
4364     },
4365     { &hf_ranap_sDU_ErrorRatio_mantissa,
4366       { "sDU_ErrorRatio: mantissa",
4367         "ranap.rab_Parameters.sDU_ErrorRatio.mantissa",
4368         FT_UINT8, BASE_DEC, NULL, 0x0,
4369         "", HFILL }
4370     },
4371     { &hf_ranap_sDU_ErrorRatio_exponent,
4372       { "sDU_ErrorRatio: exponent",
4373         "ranap.rab_Parameters.sDU_ErrorRatio.exponent",
4374         FT_UINT8, BASE_DEC, NULL, 0x0,
4375         "", HFILL }
4376     },
4377     { &hf_ranap_residualBitErrorRatio_mantissa,
4378       { "residualBitErrorRatio: mantissa",
4379         "ranap.rab_Parameters.residualBitErrorRatio.mantissa",
4380         FT_UINT8, BASE_DEC, NULL, 0x0,
4381         "", HFILL }
4382     },
4383     { &hf_ranap_residualBitErrorRatio_exponent,
4384       { "residualBitErrorRatio: exponent",
4385         "ranap.rab_Parameters.residualBitErrorRatio.exponent",
4386         FT_UINT8, BASE_DEC, NULL, 0x0,
4387         "", HFILL }
4388     },
4389     { &hf_ranap_deliveryOfErroneousSDU,
4390       { "deliveryOfErroneousSDU",
4391         "ranap.rab_Parameters.ranap_deliveryOfErroneousSDU",
4392         FT_UINT8, BASE_DEC, VALS(&ranap_deliveryOfErroneousSDU_values), 0x0,
4393         "", HFILL }
4394     },
4395     { &hf_ranap_subflowSDU_Size,
4396       { "subflowSDU_Size",
4397         "ranap.rab_Parameters.subflowSDU_Size",
4398         FT_UINT8, BASE_DEC, NULL, 0x0,
4399         "", HFILL }
4400     },
4401     { &hf_ranap_rAB_SubflowCombinationBitRate,
4402       { "rAB_SubflowCombinationBitRate",
4403         "ranap.rab_Parameters.rAB_SubflowCombinationBitRate",
4404         FT_UINT32, BASE_DEC, NULL, 0x0,
4405         "", HFILL }
4406     },
4407     { &hf_ranap_sDU_ErrorRatio_present,
4408       { "sDU_ErrorRatio",
4409         "ranap.sDU_ErrorRatio_present",
4410         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4411         "", HFILL }
4412     },
4413     { &hf_ranap_sDU_FormatInformationParameters_present,
4414       { "sDU_FormatInformationParameters",
4415         "ranap.sDU_FormatInformationParameters_present",
4416         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4417         "", HFILL }
4418     },
4419     { &hf_ranap_subflowSDU_Size_present,
4420       { "subflowSDU_Size",
4421         "ranap.subflowSDU_Size_present",
4422         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4423         "", HFILL }
4424     },
4425     { &hf_ranap_rAB_SubflowCombinationBitRate_present,
4426       { "subflowSDU_Size",
4427         "ranap.rAB_SubflowCombinationBitRate_present",
4428         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4429         "", HFILL }
4430     },
4431     { &hf_ranap_transferDelay,
4432       { "transferDelay",
4433         "ranap.rab_Parameters.transferDelay",
4434         FT_UINT16, BASE_DEC, NULL, 0x0,
4435         "", HFILL }
4436     },
4437     { &hf_ranap_trafficHandlingPriority,
4438       { "trafficHandlingPriority",
4439         "ranap.rab_Parameters.trafficHandlingPriority",
4440         FT_UINT8, BASE_DEC, VALS(&ranap_priority_values), 0x0,
4441         "", HFILL }
4442     },
4443     { &hf_ranap_priorityLevel,
4444       { "priorityLevel",
4445         "ranap.rab_Parameters.allocationOrRetentionPriority.priorityLevel",
4446         FT_UINT8, BASE_DEC, VALS(&ranap_priority_values), 0x0,
4447         "", HFILL }
4448     },
4449     { &hf_ranap_pre_emptionCapability,
4450       { "pre-emptionCapability",
4451         "ranap.rab_Parameters.allocationOrRetentionPriority.pre_emptionCapability",
4452         FT_UINT8, BASE_DEC, VALS(&ranap_pre_emptionCapability_values), 0x0,
4453         "", HFILL }
4454     },
4455     { &hf_ranap_pre_emptionVulnerability,
4456       { "pre-emptionVulnerability",
4457         "ranap.rab_Parameters.allocationOrRetentionPriority.pre_emptionVulnerability",
4458         FT_UINT8, BASE_DEC, VALS(&ranap_pre_emptionVulnerability_values), 0x0,
4459         "", HFILL }
4460     },
4461     { &hf_ranap_queuingAllowed,
4462       { "queuingAllowed",
4463         "ranap.rab_Parameters.allocationOrRetentionPriority.queuingAllowed",
4464         FT_UINT8, BASE_DEC, VALS(&ranap_queuingAllowed_values), 0x0,
4465         "", HFILL }
4466     },
4467     { &hf_ranap_sourceStatisticsDescriptor,
4468       { "sourceStatisticsDescriptor",
4469         "ranap.rab_Parameters.sourceStatisticsDescriptor",
4470         FT_UINT8, BASE_DEC, VALS(&ranap_sourceStatisticsDescriptor_values), 0x0,
4471         "", HFILL }
4472     },
4473     { &hf_ranap_relocationRequirement,
4474       { "relocationRequirement",
4475         "ranap.rab_Parameters.relocationRequirement",
4476         FT_UINT8, BASE_DEC, VALS(&ranap_relocationRequirement_values), 0x0,
4477         "", HFILL }
4478     },
4479     { &hf_ranap_userPlaneMode,
4480       { "userPlaneMode",
4481         "ranap.userPlaneMode",
4482         FT_UINT8, BASE_DEC, VALS(&ranap_userPlaneMode_values), 0x0,
4483         "", HFILL }
4484     },
4485     { &hf_ranap_uP_ModeVersions,
4486       { "uP_ModeVersions",
4487         "ranap.uP_ModeVersions",
4488         FT_BYTES, BASE_NONE, NULL, 0x0,
4489         "", HFILL }
4490     },
4491     { &hf_ranap_number_of_ProtocolExtensionFields,
4492       { "Number of ProtocolExtensionFields",
4493         "ranap.number_of_ProtocolExtensionFields",
4494         FT_UINT16, BASE_DEC, NULL, 0x0,
4495         "", HFILL }
4496     },
4497     { &hf_ranap_ext_field_number_of_octets,
4498       { "Number of octets",
4499         "ranap.ProtocolExtensionFields.octets",
4500         FT_UINT16, BASE_DEC, NULL, 0x0,
4501         "", HFILL }
4502     },
4503     { &hf_ranap_transportLayerAddress_length,
4504       { "bit length of transportLayerAddress",
4505         "ranap.transportLayerAddress_length",
4506         FT_UINT8, BASE_DEC, NULL, 0x0,
4507         "", HFILL }
4508     },
4509     { &hf_ranap_transportLayerAddress,
4510       { "transportLayerAddress",
4511         "ranap.transportLayerAddress",
4512         FT_BYTES, BASE_NONE, NULL, 0x0,
4513         "", HFILL }
4514     },
4515     { &hf_ranap_gTP_TEI,
4516       { "gTP_TEI",
4517         "ranap.gTP_TEI",
4518         FT_BYTES, BASE_NONE, NULL, 0x0,
4519         "", HFILL }
4520     },
4521     { &hf_ranap_bindingID,
4522       { "bindingID",
4523         "ranap.bindingID",
4524         FT_BYTES, BASE_NONE, NULL, 0x0,
4525         "", HFILL }
4526     },
4527     { &hf_ranap_pDP_TypeInformation_present,
4528       { "pDP_TypeInformation",
4529         "ranap.pDP_TypeInformation_present",
4530         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4531         "", HFILL }
4532     },
4533     { &hf_ranap_dataVolumeReportingIndication_present,
4534       { "dataVolumeReportingIndication",
4535         "ranap.dataVolumeReportingIndication_present",
4536         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4537         "", HFILL }
4538     },
4539     { &hf_ranap_dl_GTP_PDU_SequenceNumber_present,
4540       { "dl_GTP_PDU_SequenceNumber",
4541         "ranap.dl_GTP_PDU_SequenceNumber_present",
4542         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4543         "", HFILL }
4544     },
4545     { &hf_ranap_ul_GTP_PDU_SequenceNumber_present,
4546       { "ul_GTP_PDU_SequenceNumber",
4547         "ranap.ul_GTP_PDU_SequenceNumber_present",
4548         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4549         "", HFILL }
4550     },
4551     { &hf_ranap_dl_N_PDU_SequenceNumber_present,
4552       { "dl_N_PDU_SequenceNumber",
4553         "ranap.dl_N_PDU_SequenceNumber_present",
4554         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4555         "", HFILL }
4556     },
4557     { &hf_ranap_ul_N_PDU_SequenceNumber_present,
4558       { "ul_N_PDU_SequenceNumber",
4559         "ranap.ul_N_PDU_SequenceNumber_present",
4560         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4561         "", HFILL }
4562     },
4563     { &hf_ranap_PDP_Type,
4564       { "PDP-Type",
4565         "ranap.RAB_SetupOrModifyItemSecond.PDP_Type",
4566         FT_UINT8, BASE_HEX, VALS(&ranap_PDP_Type_values), 0x0,
4567         "", HFILL }
4568     },
4569     { &hf_ranap_dataVolumeReportingIndication,
4570       { "dataVolumeReportingIndication",
4571         "ranap.RAB_SetupOrModifyItemSecond.dataVolumeReportingIndication",
4572         FT_UINT8, BASE_HEX, VALS(&ranap_dataVolumeReportingIndication_values), 0x0,
4573         "", HFILL }
4574     },
4575     { &hf_ranap_dl_GTP_PDU_SequenceNumber,
4576       { "dl_GTP_PDU_SequenceNumber",
4577         "ranap.RAB_SetupOrModifyItemSecond.dl_GTP_PDU_SequenceNumber",
4578         FT_UINT16, BASE_DEC, NULL, 0x0,
4579         "", HFILL }
4580     },
4581     { &hf_ranap_ul_GTP_PDU_SequenceNumber,
4582       { "ul_GTP_PDU_SequenceNumber",
4583         "ranap.RAB_SetupOrModifyItemSecond.ul_GTP_PDU_SequenceNumber",
4584         FT_UINT16, BASE_DEC, NULL, 0x0,
4585         "", HFILL }
4586     },
4587     { &hf_ranap_dl_N_PDU_SequenceNumber,
4588       { "ul_GTP_PDU_SequenceNumber",
4589         "ranap.RAB_SetupOrModifyItemSecond.ul_GTP_PDU_SequenceNumber",
4590         FT_UINT16, BASE_DEC, NULL, 0x0,
4591         "", HFILL }
4592     },
4593     { &hf_ranap_ul_N_PDU_SequenceNumber,
4594       { "ul_GTP_PDU_SequenceNumber",
4595         "ranap.RAB_SetupOrModifyItemSecond.ul_GTP_PDU_SequenceNumber",
4596         FT_UINT16, BASE_DEC, NULL, 0x0,
4597         "", HFILL }
4598     },
4599     { &hf_ranap_cause_choice,
4600       { "cause choice",
4601         "ranap.cause_choice",
4602         FT_UINT8, BASE_HEX, VALS(&ranap_cause_choice_values), 0x0,
4603         "", HFILL }
4604     },
4605     { &hf_ranap_cause_value,
4606       { "cause value",
4607         "ranap.cause_value",
4608         FT_UINT8, BASE_DEC,VALS(&ranap_cause_value_str), 0x0,
4609         "", HFILL }
4610     },
4611     { &hf_ranap_transportLayerAddress_present,
4612       { "transportLayerAddress",
4613         "ranap.transportLayerAddress_present",
4614         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4615         "", HFILL }
4616     },
4617     { &hf_ranap_iuTransportAssociation_present,
4618       { "iuTransportAssociation",
4619         "ranap.iuTransportAssociation_present",
4620         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4621         "", HFILL }
4622     },
4623     { &hf_ranap_dl_dataVolumes_present,
4624       { "dl_dataVolumes",
4625         "ranap.dl_dataVolumes_present",
4626         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4627         "", HFILL }
4628     },
4629     { &hf_ranap_dataVolumeReference_present,
4630       { "dataVolumeReference",
4631         "ranap.dataVolumeReference_present",
4632         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4633         "", HFILL }
4634     },
4635     { &hf_ranap_dl_UnsuccessfullyTransmittedDataVolume,
4636       { "dl-UnsuccessfullyTransmittedDataVolume",
4637         "ranap.dl-UnsuccessfullyTransmittedDataVolume",
4638         FT_UINT32, BASE_DEC, NULL, 0x0,
4639         "", HFILL }
4640     },
4641     { &hf_ranap_dataVolumeReference,
4642       { "dataVolumeReference",
4643         "ranap.dataVolumeReference",
4644         FT_UINT8, BASE_DEC, NULL, 0x0,
4645         "", HFILL }
4646     },
4647     { &hf_ranap_procedureCode_present,
4648       { "procedureCode",
4649         "ranap.procedureCode_present",
4650         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4651         "", HFILL }
4652     },
4653     { &hf_ranap_triggeringMessage_present,
4654       { "triggeringMessage",
4655         "ranap.triggeringMessage_present",
4656         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4657         "", HFILL }
4658     },
4659     { &hf_ranap_procedureCriticality_present,
4660       { "procedureCriticality",
4661         "ranap.procedureCriticality_present",
4662         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4663         "", HFILL }
4664     },
4665     { &hf_ranap_iEsCriticalityDiagnostics_present,
4666       { "iEsCriticalityDiagnostics",
4667         "ranap.iEsCriticalityDiagnostics_present",
4668         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4669         "", HFILL }
4670     },
4671     { &hf_ranap_triggeringMessage,
4672       { "triggeringMessage",
4673         "ranap.triggeringMessage",
4674         FT_UINT8, BASE_HEX, VALS(&ranap_pdu_index_values), 0x0,
4675         "", HFILL }
4676     },
4677     { &hf_ranap_procedureCriticality,
4678       { "procedureCriticality",
4679         "ranap.procedureCriticality",
4680         FT_UINT8, BASE_HEX, VALS(&ranap_criticality_values), 0x0,
4681         "", HFILL }
4682     },
4683     { &hf_ranap_iECriticality,
4684       { "iECriticality",
4685         "ranap.iECriticality",
4686         FT_UINT8, BASE_HEX, VALS(&ranap_criticality_values), 0x0,
4687         "", HFILL }
4688     },
4689     { &hf_ranap_repetitionNumber,
4690       { "repetitionNumber",
4691         "ranap.repetitionNumber",
4692         FT_UINT16, BASE_DEC, NULL, 0x0,
4693         "", HFILL }
4694     },
4695     { &hf_ranap_num_of_CriticalityDiagnostics_IEs,
4696       { "Number of CriticalityDiagnostics-IEs",
4697         "ranap.num_of_CriticalityDiagnostics_IEs",
4698         FT_UINT16, BASE_DEC, NULL, 0x0,
4699         "", HFILL }
4700     },
4701     { &hf_ranap_repetitionNumber_present,
4702       { "repetitionNumber",
4703         "ranap.repetitionNumber_present",
4704         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4705         "", HFILL }
4706     },
4707     { &hf_ranap_dl_UnsuccessfullyTransmittedDataVolume_present,
4708       { "dl-UnsuccessfullyTransmittedDataVolume",
4709         "ranap.dl_UnsuccessfullyTransmittedDataVolume_present",
4710         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4711         "", HFILL }
4712     },
4713     { &hf_ranap_CN_DomainIndicator,
4714       { "CN-DomainIndicator",
4715         "ranap.CN_DomainIndicator",
4716         FT_UINT8, BASE_HEX, VALS(&ranap_CN_DomainIndicator_values), 0x0,
4717         "", HFILL }
4718     },
4719     { &hf_ranap_service_Handover,
4720       { "service-Handover",
4721         "ranap.service_Handover",
4722         FT_UINT8, BASE_HEX, VALS(&ranap_service_Handover_values), 0x0,
4723         "", HFILL }
4724     },
4725     { &hf_ranap_IuSigConId,
4726       { "IuSigConId",
4727         "ranap.IuSigConId",
4728         FT_BYTES, BASE_NONE, NULL, 0x0,
4729         "", HFILL }
4730     },
4731     { &hf_ranap_SAPI,
4732       { "SAPI",
4733         "ranap.IuSigConId",
4734         FT_UINT8, BASE_HEX, VALS(&ranap_SAPI_values), 0x0,
4735         "", HFILL }
4736     },
4737     { &hf_ranap_msg_extension_present,
4738       { "Message Extension",
4739         "ranap.msg_extension_present",
4740         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4741         "", HFILL }
4742     },
4743     { &hf_ranap_ProtocolExtensionContainer_present,
4744       { "ProtocolExtensionContainer",
4745         "ranap.ProtocolExtensionContainer_present",
4746         FT_UINT8, BASE_HEX, VALS(&ranap_presence_values), 0x0,
4747         "", HFILL }
4748     },
4749     { &hf_ranap_nas_pdu_length,
4750       { "length of NAS-PDU",
4751         "ranap.nas_pdu_length",
4752         FT_UINT16, BASE_DEC, NULL, 0x0,
4753         "", HFILL }
4754     }
4755   };
4756
4757   /* Setup protocol subtree array */
4758   static gint *ett[] = {
4759     &ett_ranap,
4760     &ett_ranap_optionals,
4761     &ett_ranap_iE_Extension,
4762     &ett_ranap_ie,
4763     &ett_ranap_ie_pair,
4764     &ett_ranap_rab,
4765     &ett_ranap_ie_pair_first_value,
4766     &ett_ranap_ie_pair_second_value,
4767     &ett_ranap_sDU,
4768     &ett_ranap_rAB_Parameters,
4769     &ett_ranap_allocationOrRetentionPriority  ,
4770     &ett_ranap_CriticalityDiagnostics_IE
4771   };
4772
4773
4774   /* Register the protocol name and description */
4775   proto_ranap = proto_register_protocol("Radio Access Network Application Part",
4776                                        "RANAP", "ranap");
4777
4778   /* Register the header fields and subtrees */
4779   proto_register_field_array(proto_ranap, hf, array_length(hf));
4780   proto_register_subtree_array(ett, array_length(ett));
4781
4782 };
4783
4784
4785 void
4786 proto_reg_handoff_ranap(void)
4787 {
4788   dissector_handle_t ranap_handle;
4789
4790   ranap_handle = create_dissector_handle(dissect_ranap, proto_ranap);
4791   /*
4792   dissector_add("sua.ssn",  SCCP_SSN_RANAP, ranap_handle);
4793   */
4794   dissector_add("sccp.ssn", SCCP_SSN_RANAP, ranap_handle);
4795 }