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