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