aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-rsl.c
blob: d54f6f0ce0c2bfed35847a6a07d4673834e1ff53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
/* packet-rsl.c
 * Routines for Radio Signalling Link (RSL) dissection.
 *
 * Copyright 2007, Anders Broman <anders.broman@ericsson.com>
 *
 * $Id$
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * Copied from packet-cops.c
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * REF: 3GPP TS 48.058 version 6.1.0 Release 6
 * http://www.3gpp.org/ftp/Specs/html-info/48058.htm
 *
 */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#include <epan/packet.h>
#include <epan/proto.h>
#include <epan/lapd_sapi.h>

#include "packet-gsm_a.h"

/* Initialize the protocol and registered fields */
static int proto_rsl		= -1;

static int hf_rsl_msg_type			= -1;
static int hf_rsl_T_bit				= -1;
static int hf_rsl_msg_dsc			= -1;
static int hf_rsl_ie_id				= -1;
static int hf_rsl_ie_length			= -1;
static int hf_rsl_ch_no_Cbits		= -1;
static int hf_rsl_ch_no_TN			= -1;

static int hf_rsl_acc_delay			= -1;
static int hf_rsl_req_ref_ra		= -1;
static int hf_rsl_req_ref_T1prim	= -1;
static int hf_rsl_req_ref_T3		= -1;
static int hf_rsl_req_ref_T2		= -1;
static int hf_rsl_phy_ctx			= -1;
static int hf_rsl_na				= -1;
static int hf_rsl_ch_type			= -1;
static int hf_rsl_prio				= -1;
static int hf_rsl_sapi				= -1;
static int hf_rsl_cause				= -1;
static int hf_rsl_rel_mode			= -1;
static int hf_rsl_meas_res_no		= -1;
static int hf_rsl_extension_bit		= -1;
static int hf_rsl_class				= -1;
static int hf_rsl_paging_grp		= -1;
static int hf_rsl_ch_needed			= -1;
static int hf_rsl_emlpp_prio		= -1;

/* Initialize the subtree pointers */
static int ett_rsl = -1;
static int ett_ie_link_id;
static int ett_ie_ch_no = -1;
static int ett_ie_frame_no = -1;
static int ett_ie_L3_inf = -1;
static int ett_ie_ms_id = -1;
static int ett_ie_phy_ctx = -1;
static int ett_ie_paging_grp = -1;
static int ett_ie_access_delay = -1;
static int ett_ie_req_ref = -1;
static int ett_ie_rel_mode = -1;
static int ett_ie_rlm_cause	=-1;
static int ett_ie_full_imm_ass_inf = -1;
static int ett_ie_ch_needed = -1;
static int ett_ie_emlpp_prio = -1;
static int ett_ie_cause = -1;
static int ett_ie_meas_res_no = -1;

proto_tree *top_tree;
dissector_handle_t gsm_a_ccch_handle = NULL;
dissector_handle_t gsm_a_dtap_handle = NULL;

static const true_false_string rsl_t_bit_vals = {
  "Considered transparent by BTS",
  "Not considered transparent by BTS"
};

static const true_false_string rsl_na_vals = {
  "Applicable",
  "Not Applicable"
};

static const true_false_string rsl_extension_bit_value = {
  "Extension",
  "No Extension"
};

/*
 * 9.1 Message discriminator
 */
static const value_string rsl_msg_disc_vals[] = {
	{  0x00,		"Reserved" },
	{  0x01,		"Radio Link Layer Management messages" },
	{  0x04,		"Dedicated Channel Management messages" },
	{  0x06,		"Common Channel Management messages" },
	{  0x08,		"TRX Management messages" },
	{  0x16,		"Location Services messages" },
	{ 0,			NULL }
};
/*
 * 9.2 MESSAGE TYPE
 */
#define RSL_MSG_TYPE_DATA_REQ		1
#define RSL_MSG_TYPE_DATA_IND		2
#define RSL_MSG_TYPE_ERROR_IND		3
#define RSL_MSG_TYPE_EST_REQ		4
#define RSL_MSG_TYPE_EST_CONF		5
#define RSL_MSG_EST_IND				6
#define RSL_MSG_REL_REQ				7
#define RSL_MSG_REL_CONF			8
#define RSL_MSG_REL_IND				9
#define RSL_MSG_UNIT_DATA_REQ		10
/* Common Channel Management/TRX Management messages */
#define RSL_MSG_BCCH_INFO			17
#define RSL_MSG_CCCH_LOAD_IND		18
#define RSL_MSG_CHANRQD				19
#define RSL_MSG_DELETE_IND			20
#define RSL_MSG_PAGING_CMD			21
#define RSL_MSG_IMM_ASS_CMD			22

#define RSL_MSG_CHAN_ACTIV			33
#define RSL_MSG_CHAN_ACTIV_ACK		34
#define RSL_MSG_CHAN_ACTIV_N_ACK	35
#define RSL_MSG_CONN_FAIL			36
#define RSL_MSG_DEACTIVATE_SACCH	37
 
#define RSL_MSG_MEAS_RES			40
static const value_string rsl_msg_type_vals[] = {
	  /* 	0 0 0 0 - - - - Radio Link Layer Management messages: */
	{  0x01,	"DATA REQuest" },								/* 8.3.1 */
	{  0x02,	"DATA INDication" },							/* 8.3.2 */
	{  0x03,	"ERROR INDication" },							/* 8.3.3 */
	{  0x04,	"ESTablish REQuest" },							/* 8.3.4 */
	{  0x05,	"ESTablish CONFirm" },							/* 8.3.5 */
	{  0x06,	"ESTablish INDication" },						/* 8.3.6 */
	{  0x07,	"RELease REQuest" },							/* 8.3.7 */
	{  0x08,	"RELease CONFirm" },							/* 8.3.8 */
	{  0x09,	"RELease INDication" },							/* 8.3.9 */
	{  0x0a,	"UNIT DATA REQuest" },							/* 8.3.10 */
	/* 0 0 0 1 - - - - Common Channel Management/TRX Management messages: */
	{  0x11,	"BCCH INFOrmation" },							/* 8.5.1 */
	{  0x12,	"CCCH LOAD INDication" },						/* 8.5.2 */
	{  0x13,	"CHANnel ReQuireD" },							/* 8.5.3 */
	{  0x14,	"DELETE INDication" },							/* 8.5.4 */
	{  0x15,	"PAGING CoMmanD" },								/* 8.5.5 */
	{  0x16,	"IMMEDIATE ASSIGN COMMAND" },					/* 8.5.6 */
	{  0x17,	"SMS BroadCast REQuest" },						/* 8.5.7 */
	{  0x18,	"RF RESource INDication" },						/* 8.6.1 */
	{  0x19,	"SACCH FILLing" },								/* 8.6.2 */
	{  0x1b,	"OVERLOAD" },									/* 8.6.3 */
	{  0x1c,	"ERROR REPORT" },								/* 8.6.4 */
	{  0x1d,	"SMS BroadCast CoMmanD" },						/* 8.5.8 */
	{  0x1e,	"CBCH LOAD INDication" },						/* 8.5.9 */
	{  0x1f,	"NOTification CoMmanD" },						/* 8.5.10 */
	/* 0 0 1 - - - - - Dedicated Channel Management messages: */
	{  0x21,	"CHANnel ACTIVation" },							/* 8.4.1 */
	{  0x22,	"CHANnel ACTIVation ACKnowledge" },				/* 8.4.2 */
	{  0x23,	"CHANnel ACTIVation Negative ACK" },			/* 8.4.3 */
	{  0x24,	"CONNection FAILure" },							/* 8.4.4 */
	{  0x25,	"DEACTIVATE SACCH" },							/* 8.4.5 */
	{  0x26,	"ENCRyption CoMmanD" },							/* 8.4.6 */
	{  0x27,	"HANDOver DETection" },							/* 8.4.7 */
	{  0x28,	"MEASurement RESult" },							/* 8.4.8 */
	{  0x29,	"MODE MODIFY REQuest" },						/* 8.4.9 */
	{  0x2a,	"MODE MODIFY ACKnowledge" },					/* 8.4.10 */
	{  0x2b,	"MODE MODIFY Negative ACKnowledge" },			/* 8.4.11 */
	{  0x2c,	"PHYsical CONTEXT REQuest" },					/* 8.4.12 */
	{  0x2d,	"PHYsical CONTEXT CONFirm" },					/* 8.4.13 */
	{  0x2e,	"RF CHANnel RELease" },							/* 8.4.14 */
	{  0x2f,	"MS POWER CONTROL" },							/* 8.4.15 */
	{  0x30,	"BS POWER CONTROL" },							/* 8.4.16 */
	{  0x31,	"PREPROCess CONFIGure" },						/* 8.4.17 */
	{  0x32,	"PREPROCessed MEASurement RESult" },			/* 8.4.18 */
	{  0x33,	"RF CHANnel RELease ACKnowledge" },				/* 8.4.19 */
	{  0x34,	"SACCH INFO MODIFY" },							/* 8.4.20 */
	{  0x35,	"TALKER DETection" },							/* 8.4.21 */
	{  0x36,	"LISTENER DETection" },							/* 8.4.22 */
	{  0x37,	"REMOTE CODEC CONFiguration REPort" },			/* 8.4.23 */
	{  0x38,	"Round Trip Delay REPort" },					/* 8.4.24 */
	{  0x39,	"PRE-HANDOver NOTIFication" },					/* 8.4.25 */
	{  0x3a,	"MultiRate CODEC MODification REQest" },		/* 8.4.26 */
	{  0x3b,	"MultiRate CODEC MOD ACKnowledge" },			/* 8.4.27 */
	{  0x3c,	"MultiRate CODEC MOD Negative ACKnowledge" },	/* 8.4.28 */
	{  0x3d,	"MultiRate CODEC MOD PERformed" },				/* 8.4.29 */
	{  0x3e,	"TFO REPort" },									/* 8.4.30 */
	{  0x3f,	"TFO MODification REQuest" },					/* 8.4.31 */
	/* 	0 1 - - - - - - Location Services messages: */
	{  0x41,	"Location Information" },						/* 8.7.1 */
	{ 0,		NULL }
};


static const value_string rsl_ie_type_vals[] = {
	{  0x01,	"Channel Number" },				/*  9.3.1 */
	{  0x02,	"Link Identifier" },			/*  9.3.2 */
	{  0x03,	"Activation Type" },			/*  9.3.3 */
	{  0x04,	"BS Power" },					/*  9.3.4 */
	{  0x05,	"Channel Identification" },		/*  9.3.5 */
	{  0x06,	"Channel Mode" },				/*  9.3.6 */
	{  0x07,	"Encryption Information" },		/*  9.3.7 */
	{  0x08,	"Frame Number" },				/*  9.3.8 */
	{  0x09,	"Handover Reference" },			/*  9.3.9 */
	{  0x0a,	"L1 Information" },				/*  9.3.10 */
	{  0x0b,	"L3 Information" },				/*  9.3.11 */
	{  0x0c,	"MS Identity" },				/*  9.3.12 */
	{  0x0d,	"MS Power" },					/*  9.3.13 */
	{  0x0e,	"Paging Group" },				/*  9.3.14 */
	{  0x0f,	"Paging Load" },				/*  9.3.15 */
	{  0x10,	"Physical Context" },			/*  9.3.16 */
	{  0x11,	"Access Delay" },				/*  9.3.17 */
	{  0x12,	"RACH Load" },					/*  9.3.18 */
	{  0x13,	"Request Reference" },			/*  9.3.19 */
	{  0x14,	"Release Mode" },				/*  9.3.20 */
	{  0x15,	"Resource Information" },		/*  9.3.21 */
	{  0x16,	"RLM Cause" },					/*  9.3.22 */
	{  0x17,	"Starting Time" },				/*  9.3.23 */
	{  0x18,	"Timing Advance" },				/*  9.3.24 */
	{  0x19,	"Uplink Measurements" },		/*  9.3.25 */
	{  0x1a,	"Cause" },						/*  9.3.26 */
	{  0x1b,	"Measurement result number" },	/*  9.3.27 */
	{  0x1c,	"Message Identifier" },			/*  9.3.28 */
	{  0x1d,	"reserved" },					/*  */
	{  0x1e,	"System Info Type" },			/*  9.3.30 */
	{  0x1f,	"MS Power Parameters" },		/*  9.3.31 */
	{  0x20,	"BS Power Parameters" },		/*  9.3.32 */
	{  0x21,	"Pre-processing Parameters" },	/*  9.3.33 */
	{  0x22,	"Pre-processed Measurements" },	/*  9.3.34 */
	{  0x23,	"reserved" },					/*  */
	{  0x24,	"SMSCB Information" },			/*  9.3.36 */
	{  0x25,	"MS Timing Offset" },			/*  9.3.37 */
	{  0x26,	"Erroneous Message" },			/*  9.3.38 */
	{  0x27,	"Full BCCH Information" },		/*  9.3.39 */
	{  0x28,	"Channel Needed" },				/*  9.3.40 */
	{  0x29,	"CB Command type" },			/*  9.3.41 */
	{  0x2a,	"SMSCB message" },				/*  9.3.42 */
	{  0x2b,	"Full Immediate Assign Info" },	/*  9.3.35 */
	{  0x2c,	"SACCH Information" },			/*  9.3.29 */
	{  0x2d,	"CBCH Load Information" },		/*  9.3.43 */
	{  0x2e,	"SMSCB Channel Indicator" },	/*  9.3.44 */
	{  0x2f,	"Group call reference" },		/*  9.3.45 */
	{  0x30,	"Channel description" },		/*  9.3.46 */
	{  0x31,	"NCH DRX information" },		/*  9.3.47 */
	{  0x32,	"Command indicator" },			/*  9.3.48 */
	{  0x33,	"eMLPP Priority" },				/*  9.3.49 */
	{  0x34,	"UIC" },						/*  9.3.50 */
	{  0x35,	"Main channel reference" },		/*  9.3.51 */
	{  0x36,	"MultiRate configuration" },	/*  9.3.52 */
	{  0x37,	"MultiRate Control" },			/*  9.3.53 */
	{  0x38,	"Supported Codec Types" },		/*  9.3.54 */
	{  0x39,	"Codec Configuration" },		/*  9.3.55 */
	{  0x3a,	"Round Trip Delay" },			/*  9.3.56 */
	{  0x3b,	"TFO Status" },					/*  9.3.57 */
	{  0x3c,	"LLP APDU" },					/*  9.3.58 */
	{  0x3d,	"TFO transparent container" },	/*  9.3.59 */
	/*
			0 0 1 1 1 1 1 0
			to
			1 1 1 0 1 1 1 1
			Reserved for future use

			1 1 1 1 0 0 0 0
			to
			1 1 1 1 1 1 1 1
			Not used

	*/
	{ 0,			NULL }
};


/*
C5	C4	C3	C2	C1
0	0	0	0	1	Bm + ACCH's
0	0	0	1	T	Lm + ACCH's
0	0	1	T	T	SDCCH/4 + ACCH
0	1	T	T	T	SDCCH/8 + ACCH
1	0	0	0	0	BCCH
1	0	0	0	1	Uplink CCCH (RACH)
1	0	0	1	0	Downlink CCCH (PCH + AGCH)
*/
static const value_string rsl_ch_no_Cbits_vals[] = {
	{  0x01,	"Bm + ACCH's" },
	{  0x03,	"Lm + ACCH's" },
	{  0x03,	"Lm + ACCH's" },
	{  0x04,	"SDCCH/4 + ACCH" },
	{  0x05,	"SDCCH/4 + ACCH" },
	{  0x06,	"SDCCH/4 + ACCH" },
	{  0x07,	"SDCCH/4 + ACCH" },
	{  0x08,	"SDCCH/8 + ACCH" },
	{  0x09,	"SDCCH/8 + ACCH" },
	{  0x0a,	"SDCCH/8 + ACCH" },
	{  0x0b,	"SDCCH/8 + ACCH" },
	{  0x0c,	"SDCCH/8 + ACCH" },
	{  0x0d,	"SDCCH/8 + ACCH" },
	{  0x0e,	"SDCCH/8 + ACCH" },
	{  0x0f,	"SDCCH/8 + ACCH" },
	{  0x10,	"BCCH" },
	{  0x11,	"Uplink CCCH (RACH)" },
	{  0x12,	"Downlink CCCH (PCH + AGCH)" },
	{ 0,			NULL }
};
/* 9.3.1 Channel number			9.3.1	M TV 2 */
static int
dissect_rsl_ie_ch_no(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
{
	proto_item *ti;
	proto_tree *ie_tree;

	ti = proto_tree_add_text(tree, tvb,offset,2,"Channel number IE ");
	ie_tree = proto_item_add_subtree(ti, ett_ie_ch_no);


	/* Element identifier */
	proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
	offset++;
	/* C-bits */
	proto_tree_add_item(ie_tree, hf_rsl_ch_no_Cbits, tvb, offset, 1, FALSE);
	/* TN is time slot number, binary represented as in 3GPP TS 45.002.
	 * 3 Bits
	 */
	proto_tree_add_item(ie_tree, hf_rsl_ch_no_TN, tvb, offset, 1, FALSE);
	offset++;
	return offset;
}

static const value_string rsl_ch_type_vals[] = {
	{  0x00,	"Main signalling channel (FACCH or SDCCH)" },
	{  0x01,	"SACCH" },
	{ 0,			NULL }
};

static const value_string rsl_prio_vals[] = {
	{  0x00,	"Normal Priority" },
	{  0x01,	"High Priority" },
	{  0x02,	"Low Priority" },
	{ 0,			NULL }
};

/*
 * 9.3.2 Link Identifier M TV 2
 */
static int
dissect_rsl_ie_link_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
{
	proto_item *ti;
	proto_tree *ie_tree;
	guint8 octet;

	ti = proto_tree_add_text(tree, tvb,offset,2,"Link Identifier IE ");
	ie_tree = proto_item_add_subtree(ti, ett_ie_link_id);

	/* Element identifier */
	proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
	offset++;

	octet = tvb_get_guint8(tvb,offset);

	if((octet&0x20) == 0x20){
		/* Not applicable */
		proto_tree_add_item(ie_tree, hf_rsl_na, tvb, offset, 1, FALSE);
		return offset++;
	}
	/* channel type */
	proto_tree_add_item(ie_tree, hf_rsl_ch_type, tvb, offset, 1, FALSE);
	/* NA - Not applicable */
	proto_tree_add_item(ie_tree, hf_rsl_na, tvb, offset, 1, FALSE);
	/* Priority */
	proto_tree_add_item(ie_tree, hf_rsl_prio, tvb, offset, 1, FALSE);
	/* SAPI
	 * The SAPI field contains the SAPI value as defined in 3GPP TS 44.005.
	 */
	proto_tree_add_item(ie_tree, hf_rsl_sapi, tvb, offset, 1, FALSE);
	offset++;

	return offset;
}

 /*
 * 9.3.8 Frame Number
 */
static int
dissect_rsl_ie_frame_no(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
{
	proto_item *ti;
	proto_tree *ie_tree;

	ti = proto_tree_add_text(tree, tvb,offset,0,"Frame Number");
	ie_tree = proto_item_add_subtree(ti, ett_ie_frame_no);

	/* Element identifier */
	proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
	offset++;

	proto_tree_add_item(ie_tree, hf_rsl_req_ref_T1prim, tvb, offset, 1, FALSE);
	proto_tree_add_item(ie_tree, hf_rsl_req_ref_T3, tvb, offset, 2, FALSE);
	offset++;
	proto_tree_add_item(ie_tree, hf_rsl_req_ref_T2, tvb, offset, 1, FALSE);
	offset++;

	return offset;
}


/*
 * 9.3.11 L3 Information			9.3.11	M TLV >=3
 *
 * This element contains a link layer service data unit (L3 message).
 * It is used to forward a complete L3 message as specified in
 * 3GPP TS 24.008 or 3GPP TS 44.018 between BTS and BSC.
 */
static int
dissect_rsl_ie_L3_inf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
{
	proto_item *ti;
	proto_tree *ie_tree;
	tvbuff_t	*next_tvb;
	guint16 length;

	ti = proto_tree_add_text(tree, tvb,offset,0,"L3 Information ");
	ie_tree = proto_item_add_subtree(ti, ett_ie_L3_inf);

	/* Element identifier */
	proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
	offset++;
	/* Length */
	length = tvb_get_ntohs(tvb, offset);
	proto_item_set_len(ti, length+2);
	proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 2, FALSE);
 	offset= offset +2;

	/* Link Layer Service Data Unit (i.e. a layer 3 message
	 * as defined in 3GPP TS 24.008 or 3GPP TS 44.018)
	 */

	proto_tree_add_text(ie_tree, tvb,offset,length,"Link Layer Service Data Unit ( L3 Message)");
	next_tvb = tvb_new_subset(tvb, offset, length, length);
	call_dissector(gsm_a_dtap_handle, next_tvb, pinfo, top_tree);

	offset = offset + length;

	return offset;
 }

/*
 * 9.3.12 MS Identity
 */
static int
dissect_rsl_ie_ms_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
{
	proto_item *ti;
	proto_tree *ie_tree;
	guint length;

	ti = proto_tree_add_text(tree, tvb,offset,0,"MS Identity");
	ie_tree = proto_item_add_subtree(ti, ett_ie_ms_id);

	/* Element identifier */
	proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
	offset++;
	/* Length */
	length = tvb_get_guint8(tvb,offset);
	proto_item_set_len(ti, length+2);
	proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
	offset++;

	de_mid(tvb, ie_tree, offset, length, NULL, 0);

	offset = offset + length;

	return offset;


}
/*
 * 9.3.14 Paging Group M TV 2 2
 */
static int
dissect_rsl_ie_paging_grp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
{
	proto_item *ti;
	proto_tree *ie_tree;

	ti = proto_tree_add_text(tree, tvb,offset,0,"Paging Group");
	ie_tree = proto_item_add_subtree(ti, ett_ie_paging_grp);

	/* Element identifier */
	proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
	offset++;

	/* The Paging Group field (octet 2) contains the binary representation of the paging 
	 * group as defined in 3GPP TS 45.002.
	 */
	proto_tree_add_item(ie_tree, hf_rsl_paging_grp, tvb, offset, 1, FALSE);

	return offset;

}
/*
 * 9.3.16 Physical Context TLV
 */
static int
dissect_rsl_ie_phy_ctx(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
{
	proto_item *ti;
	proto_tree *ie_tree;
	guint length;

	ti = proto_tree_add_text(tree, tvb,offset,0,"Physical Context IE ");
	ie_tree = proto_item_add_subtree(ti, ett_ie_phy_ctx);

	/* Element identifier */
	proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
	offset++;
	/* Length */
	length = tvb_get_guint8(tvb,offset);
	proto_item_set_len(ti, length+2);
	proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
	offset++;

	/*
	 * Physical Context Information:
	 *	The Physical Context Information field is not specified.
	 *	This information should not be analysed by BSC, but merely
	 *	forwarded from one TRX/channel to another.
	 */
	proto_tree_add_item(ie_tree, hf_rsl_phy_ctx, tvb, offset, length, FALSE);
	offset = offset + length;

	return offset;
}
/*
 * 9.3.17 Access Delay M TV 2
 */
static int
dissect_rsl_ie_access_delay(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
{
	proto_item *ti;
	proto_tree *ie_tree;

	ti = proto_tree_add_text(tree, tvb,offset,2,"Access Delay IE ");
	ie_tree = proto_item_add_subtree(ti, ett_ie_access_delay);

	/* Element identifier */
	proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
	offset++;
	proto_tree_add_item(ie_tree, hf_rsl_acc_delay, tvb, offset, 1, FALSE);
	offset++;
	return offset;
}
/*
 * 9.3.19 Request Reference M TV 4
 */
static int
dissect_rsl_ie_req_ref(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
{
	proto_item *ti;
	proto_tree *ie_tree;

	ti = proto_tree_add_text(tree, tvb,offset,4,"Request Reference IE ");
	ie_tree = proto_item_add_subtree(ti, ett_ie_req_ref);

	/* Element identifier */
	proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
	offset++;
	proto_tree_add_item(ie_tree, hf_rsl_req_ref_ra, tvb, offset, 1, FALSE);
	offset++;
	proto_tree_add_item(ie_tree, hf_rsl_req_ref_T1prim, tvb, offset, 1, FALSE);
	proto_tree_add_item(ie_tree, hf_rsl_req_ref_T3, tvb, offset, 2, FALSE);
	offset++;
	proto_tree_add_item(ie_tree, hf_rsl_req_ref_T2, tvb, offset, 1, FALSE);
	offset++;
	return offset;
}

static const value_string rel_mode_vals[] = {
	{  0x00,	"Normal Release" },
	{  0x01,	"Local End Release" },
	{ 0,			NULL }
};

/*
 * 9.3.20 Release Mode				9.3.20	M TV 2
 */
static int
dissect_rsl_ie_rel_mode(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
{
	proto_item *ti;
	proto_tree *ie_tree;

	ti = proto_tree_add_text(tree, tvb,offset,4,"Release Mode IE ");
	ie_tree = proto_item_add_subtree(ti, ett_ie_rel_mode);

	/* Element identifier */
	proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
	offset++;

	/* 	The M bit is coded as follows:
	 * 0 normal release
	 * 1 local end release
	 */
	proto_tree_add_item(ie_tree, hf_rsl_rel_mode, tvb, offset, 1, FALSE);

	offset++;
	return offset;
}

static const value_string rsl_rlm_cause_vals[] = {
	{  0x00,	"reserved" },
	{  0x01,	"timer T200 expired (N200+1) times" },
	{  0x02,	"re-establishment request" },
	{  0x03,	"unsolicited UA response" },
	{  0x04,	"unsolicited DM response" },
	{  0x05,	"unsolicated DM response, multiple frame established state" },
	{  0x06,	"unsolicited supervisory response" },
	{  0x07,	"sequence error" },
	{  0x08,	"U-frame with incorrect parameters" },
	{  0x09,	"S-frame with incorrect parameters" },
	{  0x0a,	"I-frame with incorrect use of M bit" },
	{  0x0b,	"I-frame with incorrect length" },
	{  0x0c,	"frame not implemented" },
	{  0x0d,	"SABM command, multiple frame established state" },
	{  0x0e,	"SABM frame with information not allowed in this state" },
	{ 0,			NULL }
};


/*
 * 9.3.22 RLM Cause				9.3.22	M TLV 2-4
 */
static int
dissect_rsl_ie_rlm_cause(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
{
	proto_item *ti;
	proto_tree *ie_tree;

	guint		length;

	ti = proto_tree_add_text(tree, tvb,offset,0,"RLM Cause IE ");
	ie_tree = proto_item_add_subtree(ti, ett_ie_rlm_cause);

	/* Element identifier */
	proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
	offset++;
	/* Length */
	length = tvb_get_guint8(tvb,offset);
	proto_item_set_len(ti, length+2);

	proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);

	/* The Cause Value is a one octet field if the extension bit is set to 0.
	 * If the extension bit is set to 1, the Cause Value is a two octet field.
	 */
	proto_tree_add_item(ie_tree, hf_rsl_cause, tvb, offset, 1, FALSE);
	offset++;
	offset = offset + length;

	return offset;
}

static const value_string rsl_class_vals[] = {
	{  0x00,	"Normal event" },
	{  0x01,	"Normal event" },
	{  0x02,	"Resource unavailable" },
	{  0x03,	"Service or option not available" },
	{  0x04,	"Service or option not implemented" },
	{  0x05,	"Invalid message (e.g. parameter out of range)" },
	{  0x06,	"Protocol error" },
	{  0x07,	"Interworking" },
	{ 0,			NULL }
};
	
 /*
  * 9.3.26 Cause
  */
static int
dissect_rsl_ie_cause(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
{
	proto_item *ti;
	proto_tree *ie_tree;
	guint		length;
	guint8		octet;
	int			ie_offset;

	ti = proto_tree_add_text(tree, tvb,offset,0,"Cause IE ");
	ie_tree = proto_item_add_subtree(ti, ett_ie_cause);

	/* Element identifier */
	proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
	offset++;
	/* Length */
	length = tvb_get_guint8(tvb,offset);
	proto_item_set_len(ti, length+2);
	proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
	offset++;
	ie_offset = offset;
	
	/* Cause Value */
	octet = tvb_get_guint8(tvb,offset);
	proto_tree_add_item(tree, hf_rsl_extension_bit, tvb, offset, 1, FALSE);
	proto_tree_add_item(tree, hf_rsl_class, tvb, offset, 1, FALSE);
	if ((octet & 0x80) == 80)
		offset++;
	
	/* Cause Extension*/
	/* Diagnostic(s) if any */
	return ie_offset+length;
}
/*
 * 9.3.27 Measurement result number
 */
static int
dissect_rsl_ie_meas_res_no(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
{
	proto_item *ti;
	proto_tree *ie_tree;
	ti = proto_tree_add_text(tree, tvb,offset,0,"Measurement result number IE ");
	ie_tree = proto_item_add_subtree(ti, ett_ie_meas_res_no);

	/* Element identifier */
	proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
	offset++;

	/* Measurement result number */
	proto_tree_add_item(ie_tree, hf_rsl_meas_res_no, tvb, offset, 1, FALSE);
	offset++;

	return offset;
}
/*
 * 9.3.28 Message Identifier
 */
static int
dissect_rsl_ie_message_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
{
	proto_item *ti;
	proto_tree *ie_tree;
	ti = proto_tree_add_text(tree, tvb,offset,0,"Measurement result number IE ");
	ie_tree = proto_item_add_subtree(ti, ett_ie_meas_res_no);

	/* Element identifier */
	proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
	offset++;
	/* Message Type */
	proto_tree_add_item(tree, hf_rsl_msg_type, tvb, offset, 1, FALSE);
	offset++;
	return offset;
}

/*
 * 9.3.35 Full Immediate Assign Info TLV 25
 */
static int
dissect_rsl_ie_full_imm_ass_inf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
{
	proto_item *ti;
	proto_tree *ie_tree;

	guint		length;
	tvbuff_t	*next_tvb;

	ti = proto_tree_add_text(tree, tvb,offset,0,"Full Immediate Assign Info IE ");
	ie_tree = proto_item_add_subtree(ti, ett_ie_full_imm_ass_inf);

	/* Element identifier */
	proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
	offset++;
	/* Length */
	length = tvb_get_guint8(tvb,offset);
	proto_item_set_len(ti, length+2);

	proto_tree_add_item(ie_tree, hf_rsl_ie_length, tvb, offset, 1, FALSE);
	offset++;
	/*	The Full Immediate Assign Info field (octets 3-25)
	 * contains a complete immediate assign message (IMMEDIATE ASSIGNMENT or
	 * IMMEDIATE ASSIGNMENT EXTENDED or IMMEDIATE ASSIGNMENT REJECT)
	 * as defined in 3GPP TS 44.018.
	 */
	proto_tree_add_text(ie_tree, tvb,offset,length,"Full Immediate Assign Info field");
	next_tvb = tvb_new_subset(tvb, offset, length, length);
	call_dissector(gsm_a_ccch_handle, next_tvb, pinfo, top_tree);

	offset = offset + length;

	return offset;
}

/*
 * 9.3.40 Channel Needed
 */
static const value_string rsl_ch_needed_vals[] = {
	{  0x00,	"Any Channel" },
	{  0x01,	"SDCCH" },
	{  0x02,	"TCH/F (Full rate)" },
	{  0x03,	"TCH/F or TCH/H (Dual rate)" },
	{ 0,		NULL }
};

static int
dissect_rsl_ie_ch_needed(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
{
	proto_item *ti;
	proto_tree *ie_tree;


	ti = proto_tree_add_text(tree, tvb,offset,0,"Channel Needed");
	ie_tree = proto_item_add_subtree(ti, ett_ie_ch_needed);

	/* Element identifier */
	proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
	offset++;

	/* Channel */
	proto_tree_add_item(ie_tree, hf_rsl_ch_needed, tvb, offset, 1, FALSE);
	offset++;
	
	return offset;
}

/*
 * 9.3.49 eMLPP Priority
 */
static const value_string rsl_emlpp_prio_vals[] = {
	{  0x00,	"no priority applied" },
	{  0x01,	"call priority level 4" },
	{  0x02,	"call priority level 3" },
	{  0x03,	"call priority level 2" },
	{  0x04,	"call priority level 1" },
	{  0x05,	"call priority level 0" },
	{  0x06,	"call priority level B" },
	{  0x07,	"call priority level A" },
	{ 0,			NULL }
};

static int
dissect_rsl_ie_emlpp_prio(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
{
	proto_item *ti;
	proto_tree *ie_tree;

	ti = proto_tree_add_text(tree, tvb,offset,0,"eMLPP Priority");
	ie_tree = proto_item_add_subtree(ti, ett_ie_emlpp_prio);

	/* Element identifier */
	proto_tree_add_item(ie_tree, hf_rsl_ie_id, tvb, offset, 1, FALSE);
	offset++;

	/* The call priority field (bit 3 to 1 of octet 2) is coded in the same way
	 * as the call priority field (bit 3 to 1 of octet 5) in the 
	 * Descriptive group or broadcast call reference information element
	 * as defined in 3GPP TS 24.008. 
	 */
	proto_tree_add_item(ie_tree, hf_rsl_emlpp_prio, tvb, offset, 1, FALSE);
	offset++;

	return offset;
}

static int
dissct_rsl_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
{
	guint8	msg_type;

	msg_type = tvb_get_guint8(tvb,offset)&0x7f;
	proto_tree_add_item(tree, hf_rsl_msg_type, tvb, offset, 1, FALSE);
	offset++;

	if (check_col(pinfo->cinfo, COL_INFO)){
		col_append_fstr(pinfo->cinfo, COL_INFO, "%s ",val_to_str(msg_type, rsl_msg_type_vals,"unknown %u"));
	}


	switch (msg_type){
/* Radio Link Layer Management messages */
	/* 8.3.1 DATA REQUEST */
	case RSL_MSG_TYPE_DATA_REQ:
		/* Channel number			9.3.1	M TV 2		*/
		offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset);
		/* Link Identifier			9.3.2	M TV 2		*/
		offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset);
		/* L3 Information			9.3.11	M TLV >=3	*/
		offset = dissect_rsl_ie_L3_inf(tvb, pinfo, tree, offset);
		break;
	/* 8.3.2 DATA INDICATION */
	case RSL_MSG_TYPE_DATA_IND:
		/* Channel number			9.3.1	M TV 2		*/
		offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset);
		/* Link Identifier			9.3.2	M TV 2		*/
		offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset);
		/* L3 Information			9.3.11	M TLV >=3	*/
		offset = dissect_rsl_ie_L3_inf(tvb, pinfo, tree, offset);
		break;
	/* 8.3.3 ERROR INDICATION */
	case RSL_MSG_TYPE_ERROR_IND:
		/* Channel number			9.3.1	M TV 2		*/
		offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset);
		/* Link Identifier			9.3.2	M TV 2		*/
		offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset);
		/* RLM Cause				9.3.22	M TLV 2-4	*/
		offset = dissect_rsl_ie_rlm_cause(tvb, pinfo, tree, offset);
		break;
	/* 8.3.4 ESTABLISH REQUEST */
	case RSL_MSG_TYPE_EST_REQ:
		/* Channel number			9.3.1	M TV 2		*/
		offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset);
		/* Link Identifier			9.3.2	M TV 2		*/
		offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset);
		break;
	/* 8.3.5 ESTABLISH CONFIRM */
	case RSL_MSG_TYPE_EST_CONF:
		/* Channel number			9.3.1	M TV 2		*/
		offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset);
		/* Link Identifier			9.3.2	M TV 2		*/
		offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset);
		break;
	/* 8.3.6 */
	case RSL_MSG_EST_IND:
		/* 	Channel number			9.3.1	M TV 2				 */
		offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset);
		/* 	Link Identifier			9.3.2	M TV 2				 */
		offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset);
		/* 	L3 Information			9.3.11	O (note 1) TLV 3-23	 */
		if(tvb_length_remaining(tvb,offset) >1)
			offset = dissect_rsl_ie_L3_inf(tvb, pinfo, tree, offset);
		break;
	/* 8.3.7 RELEASE REQUEST */
	case RSL_MSG_REL_REQ:
		/* 	Channel number			9.3.1	M TV 2				 */
		offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset);
		/* 	Link Identifier			9.3.2	M TV 2				 */
		offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset);
		/* Release Mode				9.3.20	M TV 2				*/
		offset = dissect_rsl_ie_rel_mode(tvb, pinfo, tree, offset);
		break;
	/* 8.3.8 RELEASE CONFIRM */
	case RSL_MSG_REL_CONF:
		/* 	Channel number			9.3.1	M TV 2				 */
		offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset);
		/* 	Link Identifier			9.3.2	M TV 2				 */
		offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset);
		break;
	/* 8.3.9 RELEASE INDICATION */
	case RSL_MSG_REL_IND:
		/* 	Channel number			9.3.1	M TV 2				 */
		offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset);
		/* 	Link Identifier			9.3.2	M TV 2				 */
		offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset);
		break;
	/* 8.3.10 UNIT DATA REQUEST */
	case RSL_MSG_UNIT_DATA_REQ:
		/* 	Channel number			9.3.1	M TV 2				 */
		offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset);
		/* 	Link Identifier			9.3.2	M TV 2				 */
		offset = dissect_rsl_ie_link_id(tvb, pinfo, tree, offset);
		/* 	L3 Information			9.3.11	O (note 1) TLV 3-23	 */
		offset = dissect_rsl_ie_L3_inf(tvb, pinfo, tree, offset);
		break;

/* Common Channel Management/TRX Management messages: */
	/* 8.5.3 */
	case RSL_MSG_CHANRQD: /* 19 */
		/* Channel number			9.3.1	M TV 2 */
		offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset);
		/* Request Reference		9.3.19	M TV 4 */
		offset = dissect_rsl_ie_req_ref(tvb, pinfo, tree, offset);
		/* Access Delay				9.3.17	M TV 2 */
		offset = dissect_rsl_ie_access_delay(tvb, pinfo, tree, offset);
		/* Physical Context			9.3.16	O 1) TLV >=2 */
		if(tvb_length_remaining(tvb,offset) > 0)
			offset = dissect_rsl_ie_phy_ctx(tvb, pinfo, tree, offset);
		break;
	/* 8.5.4 DELETE INDICATION */
	case RSL_MSG_DELETE_IND: /* 20 */
		/* Channel number			9.3.1	M TV 2 */
		offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset);
		/* Full Imm. Assign Info	9.3.35	M TLV 25 */
		offset = dissect_rsl_ie_full_imm_ass_inf(tvb, pinfo, tree, offset);
		break;
	case RSL_MSG_PAGING_CMD: /* 21 */
		/* Channel number			9.3.1	M TV 2 */
		offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset);
		/* Paging Group				9.3.14	M TV 2 2 */
		offset = dissect_rsl_ie_paging_grp(tvb, pinfo, tree, offset);
		/* MS Identity				9.3.12	M TLV 2-10 2 */
		offset = dissect_rsl_ie_ms_id(tvb, pinfo, tree, offset);
		/* Channel Needed			9.3.40	O 1) TV 2 2 */
		if(tvb_length_remaining(tvb,offset) > 0)
			offset = dissect_rsl_ie_ch_needed(tvb, pinfo, tree, offset);
		/* eMLPP Priority			9.3.49	O 2) TV 2 2 */
		if(tvb_length_remaining(tvb,offset) > 0)
			offset = dissect_rsl_ie_emlpp_prio(tvb, pinfo, tree, offset);
		break;
	/* 8.5.6 */
	case RSL_MSG_IMM_ASS_CMD:
		/* Channel number			9.3.1	M TV 2 */
		offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset);
		/* Full Imm. Assign Info	9.3.35	M TLV 25 */
		offset = dissect_rsl_ie_full_imm_ass_inf(tvb, pinfo, tree, offset);
		break;
/* Dedicated Channel Management messages: */
	/* 8.4.1 CHANNEL ACTIVATION 33*/
	case RSL_MSG_CHAN_ACTIV:
		break;
		/* Channel number			9.3.1	M TV 2			*/
		/* Activation Type			9.3.3	M TV 2			*/
		/* Channel Mode				9.3.6	M TLV 8-9		*/
		/* Channel Identification	9.3.5	O 7) TLV 8		*/
		/* Encryption information	9.3.7	O 1) TLV >=3	*/
		/* Handover Reference		9.3.9	C 2) TV 2		*/
		/* BS Power					9.3.4	O 3) TV 2		*/
		/* MS Power					9.3.13	O 3) TV 2		*/
		/* Timing Advance			9.3.24	C 3) 4) TV 2	*/
		/* BS Power Parameters		9.3.32	O 5) TLV >=2	*/
		/* MS Power Parameters		9.3.31	O 5) TLV >=2	*/
		/* Physical Context			9.3.16	O 6) TLV >=2	*/
		/* SACCH Information		9.3.29	O 8) TLV >=3	*/
		/* UIC						9.3.50	O 9) TLV 3		*/
		/* Main channel reference	9.3.51	O 10) TV 2		*/
		/* MultiRate configuration	9.3.52	O 11) TLV >=4	*/
		/* MultiRate Control		9.3.53	O 12) TV 2		*/
		/* Supported Codec Types	9.3.54	O 12) TLV >=5	*/
		/* TFO transparent container 9.3.59 O 12) TLV >=3	*/

	/* 8.4.2 CHANNEL ACTIVATION ACKNOWLEDGE	34*/
	case RSL_MSG_CHAN_ACTIV_ACK:
		/* Channel number			9.3.1	M TV 2			*/
		offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset);
		/* Frame number				9.3.8	M TV 3			*/
		offset = dissect_rsl_ie_frame_no(tvb, pinfo, tree, offset);
		break;
	case RSL_MSG_CHAN_ACTIV_N_ACK:
	/* 8.4.3 CHANNEL ACTIVATION NEGATIVE ACKNOWLEDGE */
		/* Channel number			9.3.1	M TV 2			*/
		offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset);
		/* Cause					9.3.26	M TLV >=3		*/
		offset = dissect_rsl_ie_cause(tvb, pinfo, tree, offset);
		break;
	/* 8.4.4 CONNECTION FAILURE INDICATION */
	case RSL_MSG_CONN_FAIL:
		/* Channel number			9.3.1	M TV 2			*/
		offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset);
		/* Cause					9.3.26	M TLV >=3		*/
		offset = dissect_rsl_ie_cause(tvb, pinfo, tree, offset);
		break;
	/* 8.4.5 DEACTIVATE SACCH */
	case RSL_MSG_DEACTIVATE_SACCH:
		/* Channel number			9.3.1	M TV 2			*/
		offset = dissect_rsl_ie_ch_no(tvb, pinfo, tree, offset);
		break;
	/* 8.4.6 ENCRYPTION COMMAND */
		/* Encryption information	9.3.7	M TLV >=3		*/
		/* Link Identifier			9.3.2	M TV 2			*/
		/* L3 Info (CIPH MOD CMD)	9.3.11	M TLV 6			*/
	/* 8.4.7 HANDOVER DETECTION */
		/* Channel number			9.3.1	M TV 2			*/
		/* Access Delay				9.3.17 O 1) TV 2		*/
	/* 8.4.8 MEASUREMENT RESULT 40 */
	case RSL_MSG_MEAS_RES:
		/* Channel number			9.3.1	M TV 2			*/
		/* Measurement result number 9.3.27 M TV 2			*/
		/* Uplink Measurements		9.3.25	M TLV >=5		*/
		/* BS Power					9.3.4	M TV 2			*/
		/* L1 Information			9.3.10 O 1) TV 3		*/
		/* L3 Info (MEAS REP, EXT MEAS REP or ENH MEAS REP) 9.3.11 O 1) TLV 21*/
		/* MS Timing Offset			9.3.37 O 2) TV 2		*/
		break;
	default:
		break;
	}

	return offset;

}
static void
dissect_rsl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
	proto_item *ti;
	proto_tree *rsl_tree;


	int offset = 0;

	if (check_col(pinfo->cinfo, COL_PROTOCOL))
		col_set_str(pinfo->cinfo, COL_PROTOCOL, "RSL");
	if (check_col(pinfo->cinfo, COL_INFO))
		col_clear(pinfo->cinfo, COL_INFO);

	top_tree = tree;
	/*if (tree) {*/
		ti = proto_tree_add_item(tree, proto_rsl, tvb, 0, -1, FALSE);
		rsl_tree = proto_item_add_subtree(ti, ett_rsl);

		/* 9.1 Message discriminator */
		proto_tree_add_item(rsl_tree, hf_rsl_msg_dsc, tvb, offset, 1, FALSE);
		proto_tree_add_item(rsl_tree, hf_rsl_T_bit, tvb, offset, 1, FALSE);
		offset++;
		offset = dissct_rsl_msg(tvb, pinfo, rsl_tree, offset );

	/*}*/

}

void
proto_reg_handoff_rsl(void)
{
	dissector_handle_t rsl_handle;

	rsl_handle = create_dissector_handle(dissect_rsl, proto_rsl);
	dissector_add("lapd.gsm.sapi", LAPD_GSM_SAPI_RA_SIG_PROC, rsl_handle);

	gsm_a_ccch_handle = find_dissector("gsm_a_ccch");
	gsm_a_dtap_handle = find_dissector("gsm_a_dtap");
}

/* Register the protocol with Wireshark */
void proto_register_rsl(void)
{

	/* Setup list of header fields */
	static hf_register_info hf[] = {
		{ &hf_rsl_msg_dsc,
			{ "Message discriminator",           "rsl.msg_dsc",
			FT_UINT8, BASE_DEC, VALS(rsl_msg_disc_vals), 0xfe,
			"Message discriminator", HFILL }
		},
		{ &hf_rsl_T_bit,
			{ "T bit",           "rsl.T_bit",
			FT_BOOLEAN, 8, TFS(&rsl_t_bit_vals), 0x01,
			"T bit", HFILL }
		},
		{ &hf_rsl_msg_type,
			{ "Message type",           "rsl.msg_type",
			FT_UINT8, BASE_HEX_DEC, VALS(rsl_msg_type_vals), 0x7f,
			"Message type", HFILL }
		},
		{ &hf_rsl_ie_id,
			{ "Element identifier",           "rsl.ie_id",
			FT_UINT8, BASE_HEX_DEC, VALS(rsl_ie_type_vals), 0x0,
			"Element identifier", HFILL }
		},
		{ &hf_rsl_ie_length,
			{ "Length",           "rsl.ie_length",
			FT_UINT16, BASE_DEC, NULL, 0x0,
			"Length", HFILL }
		},
		{ &hf_rsl_ch_no_Cbits,
			{ "C-bits",           "rsl.ch_no_Cbits",
			FT_UINT8, BASE_DEC, VALS(rsl_ch_no_Cbits_vals), 0xf8,
			"C-bits", HFILL }
		},
		{ &hf_rsl_ch_no_TN,
			{ "Time slot number (TN)",  "rsl.ch_no_TN",
			FT_UINT8, BASE_DEC, NULL, 0x03,
			"Time slot number (TN)", HFILL }
		},
		{ &hf_rsl_req_ref_ra,
			{ "Random Access Information (RA)", "rsl.req_ref_ra",
			FT_UINT8, BASE_DEC, NULL, 0x0,
			"Random Access Information (RA)", HFILL }
		},
		{ &hf_rsl_req_ref_T1prim,
			{ "T1'",           "rsl.req_ref_T1prim",
			FT_UINT8, BASE_DEC, NULL, 0xf8,
			"T1'", HFILL }
		},
		{ &hf_rsl_req_ref_T3,
			{ "T3",           "rsl.req_ref_T3",
			FT_UINT16, BASE_DEC, NULL, 0x07e0,
			"T3", HFILL }
		},
		{ &hf_rsl_req_ref_T2,
			{ "T2",           "rsl.req_ref_T2",
			FT_UINT8, BASE_DEC, NULL, 0x1f,
			"T2", HFILL }
		},
		{ &hf_rsl_acc_delay,
			{ "Access Delay",           "rsl.acc_del",
			FT_UINT8, BASE_DEC, NULL, 0x0,
			"Access Delay", HFILL }
		},
		{ &hf_rsl_phy_ctx,
			{ "Physical Context",           "rsl.phy_ctx",
			FT_BYTES, BASE_NONE, NULL, 0x0,
			"Physical Context", HFILL }
		},
		{ &hf_rsl_na,
			{ "Not applicable (NA)",           "rsl.na",
			FT_BOOLEAN, 8, TFS(&rsl_na_vals), 0x20,
			"Not applicable (NA)", HFILL }
		},
		{ &hf_rsl_ch_type,
			{ "channel type",           "rsl.ch_type",
			FT_UINT8, BASE_DEC, VALS(rsl_ch_type_vals), 0xc0,
			"channel type", HFILL }
		},
		{ &hf_rsl_prio,
			{ "Priority",           "rsl.prio",
			FT_UINT8, BASE_DEC, VALS(rsl_prio_vals), 0x18,
			"Priority", HFILL }
		},
		{ &hf_rsl_sapi,
			{ "SAPI",           "rsl.sapi",
			FT_UINT8, BASE_DEC, NULL, 0x07,
			"SAPI", HFILL }
		},
		{ &hf_rsl_cause,
			{ "Cause",           "rsl.cause",
			FT_UINT8, BASE_DEC, VALS(rsl_rlm_cause_vals), 0x7f,
			"Cause", HFILL }
		},
		{ &hf_rsl_rel_mode,
			{ "Release Mode",           "rsl.rel_mode",
			FT_UINT8, BASE_DEC, VALS(rel_mode_vals), 0x01,
			"Relese Mode", HFILL }
		},
		{ &hf_rsl_meas_res_no,
			{ "Measurement result number",           "rsl.meas_res_no",
			FT_UINT8, BASE_DEC, NULL, 0x0,
			"Measurement result number", HFILL }
		},
		{ &hf_rsl_extension_bit,
			{ "Extension", "rsl.extension_bit",
			FT_BOOLEAN, 8, TFS(&rsl_extension_bit_value), 0x80,
			"Extension", HFILL }},
		{ &hf_rsl_class,
			{ "Class",           "rsl.class",
			FT_UINT8, BASE_DEC, VALS(rsl_class_vals), 0x70,
			"Class", HFILL }
		},
		{ &hf_rsl_paging_grp,
			{ "Paging Group",           "rsl.paging_grp",
			FT_UINT8, BASE_DEC, NULL, 0x0,
			"Paging Group", HFILL }
		},
		{ &hf_rsl_ch_needed,
			{ "Channel Needed",           "rsl.class",
			FT_UINT8, BASE_DEC, VALS(rsl_ch_needed_vals), 0x03,
			"Channel Needed", HFILL }
		},
		{ &hf_rsl_emlpp_prio,
			{ "eMLPP Priority",           "rsl.class",
			FT_UINT8, BASE_DEC, VALS(rsl_emlpp_prio_vals), 0x03,
			"eMLPP Priority", HFILL }
		},
	};
	static gint *ett[] = {
		&ett_rsl,
		&ett_ie_link_id,
		&ett_ie_ch_no,
		&ett_ie_frame_no,
		&ett_ie_L3_inf,
		&ett_ie_ms_id,
		&ett_ie_phy_ctx,
		&ett_ie_paging_grp,
		&ett_ie_access_delay,
		&ett_ie_req_ref,
		&ett_ie_rel_mode,
		&ett_ie_rlm_cause,
		&ett_ie_full_imm_ass_inf,
		&ett_ie_ch_needed,
		&ett_ie_emlpp_prio,
		&ett_ie_cause,
		&ett_ie_meas_res_no,
	};

	/* Register the protocol name and description */
	proto_rsl = proto_register_protocol("Radio Signalling Link (RSL)",
	                                    "RSL", "rsl");

	proto_register_field_array(proto_rsl, hf, array_length(hf));
	proto_register_subtree_array(ett, array_length(ett));


}