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