summaryrefslogtreecommitdiffstats
path: root/library/GSM_Types.ttcn
blob: 811623ad5fb7b3ea6e930a8a6264e5999e906511 (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
/* Encoding/Decoding routines for GSM System Information messages
 * according to 3GPP TS 44.018 Version 12.3.0 Release 12 */

/* (C) 2017 by Harald Welte <laforge@gnumonks.org> */

module GSM_Types {

	import from General_Types all;
	import from Osmocom_Types all;

	type integer GsmArfcn (0..1023);
	type integer UmtsArfcn (0..16383);
	type integer UmtsScramblingCode (0..511);
	const integer GsmMaxFrameNumber := 26*51*2048;
	type integer GsmFrameNumber (0..GsmMaxFrameNumber);
	type integer GsmRxLev (0..63);
	type integer GsmTsc (0..7) with { variant "FIELDLENGTH(8)" };
	type uint32_t GsmTmsi;
	type uint32_t GprsTlli;

	/* 10.5.2.8 */
	type enumerated ChannelNeeded {
		CHAN_NEED_ANY	(0),
		CHAN_NEED_SDCCH	(1),
		CHAN_NEED_TCH_F	(2),
		CHAN_NEED_TCH_H	(3)
	} with { variant "FIELDLENGTH(2)" };
	type record ChannelNeeded12 {
		ChannelNeeded	second,
		ChannelNeeded	first
	} with { variant "" };


	/* TS 48.058 9.3.1 Channel Number IE */
	type enumerated RslChanNr0 {
		RSL_CHAN_NR_INVALID	('00'H),
		RSL_CHAN_NR_Bm_ACCH	('01'H),
		RSL_CHAN_NR_BCCH	('10'H),
		RSL_CHAN_NR_RACH	('11'H),
		RSL_CHAN_NR_PCH_AGCH	('12'H)
	} with { variant "FIELDLENGTH(5)" variant "FIELDORDER(msb)" };

	type record RslChanNr2 {
		BIT4		tag ('0001'B),
		uint1_t		sub_chan
	} with { variant "FIELDLENGTH(5)" variant "FIELDORDER(msb)" };

	type record RslChanNr4 {
		BIT3		tag ('001'B),
		uint2_t		sub_chan
	} with { variant "FIELDLENGTH(5)" variant "FIELDORDER(msb)" };

	type record RslChanNr8 {
		BIT2		tag ('01'B),
		uint3_t		sub_chan
	} with { variant "FIELDLENGTH(5)" variant "FIELDORDER(msb)" };

	type union RslChanNrU {
		RslChanNr0	ch0,
		RslChanNr2	lm,
		RslChanNr4	sdcch4,
		RslChanNr8	sdcch8
	} with {
		variant "TAG(lm, tag = '0001'B;
			     sdcch4, tag = '001'B;
			     sdcch8, tag = '01'B;
			     ch0, OTHERWISE)"
		variant "FIELDLENGTH(5)"
		variant "FIELDORDER(msb)"
	};

	type record RslChannelNr {
		RslChanNrU	u,
		uint3_t		tn
	} with { variant "FIELDLENGTH(8)" variant "FIELDORDER(msb)" };

	template RslChannelNr t_RslChanNr0(template uint3_t tn, template RslChanNr0 cht) := {
		u := { ch0 := cht },
		tn := tn
	}

	template RslChannelNr t_RslChanNr_RACH(template uint3_t tn) := t_RslChanNr0(tn, RSL_CHAN_NR_RACH);
	template RslChannelNr t_RslChanNr_BCCH(template uint3_t tn) := t_RslChanNr0(tn, RSL_CHAN_NR_BCCH);
	template RslChannelNr t_RslChanNr_PCH_AGCH(template uint3_t tn) := t_RslChanNr0(tn, RSL_CHAN_NR_PCH_AGCH);
	template RslChannelNr t_RslChanNr_Bm(template uint3_t tn) := t_RslChanNr0(tn, RSL_CHAN_NR_Bm_ACCH);
	template RslChannelNr t_RslChanNr_Lm(template uint3_t tn, uint1_t sub_slot) := {
		u := { lm := { tag := '0001'B, sub_chan := sub_slot } },
		tn := tn
	}
	template RslChannelNr t_RslChanNr_SDCCH4(template uint3_t tn, template uint2_t sub_slot) := {
		u := { sdcch4 := { tag := '001'B, sub_chan := sub_slot } },
		tn := tn
	}
	template RslChannelNr t_RslChanNr_SDCCH8(template uint3_t tn, template uint3_t sub_slot) := {
		u := { sdcch8 := { tag := '01'B, sub_chan := sub_slot } },
		tn := tn
	}

	/* TS 48.058 9.3.2 Link ID */
	type enumerated RslLinkIdC {
		FACCH_SDCCH	(0),
		SACCH		(1)
	} with { variant "FIELDLENGTH(2)" };

	type enumerated RslSapi0Prio {
		SAPI0_PRIO_NORMAL	(0),
		SAPI0_PRIO_HIGH		(1),
		SAPI0_PRIO_LOW		(2)
	} with { variant "FIELDLENGTH(2)" };

	type uint3_t GsmSapi;

	type record RslLinkId {
		RslLinkIdC	c,
		boolean		na,
		RslSapi0Prio	prio,
		GsmSapi		sapi
	} with { variant "" };

	template RslLinkId tr_RslLinkId := {
		c := ?,
		na := ?,
		prio := ?,
		sapi := ?
	};

	template RslLinkId tr_RslLinkID_DCCH(template GsmSapi sapi) modifies tr_RslLinkId := {
		c := FACCH_SDCCH,
		na := false,
		sapi := sapi
	};

	template RslLinkId tr_RslLinkID_SACCH(template GsmSapi sapi) modifies tr_RslLinkId := {
		c := SACCH,
		na := false,
		sapi := sapi
	};

	template RslLinkId ts_RslLinkID_DCCH(GsmSapi sapi) := {
		c := FACCH_SDCCH,
		na := false,
		prio := SAPI0_PRIO_NORMAL,
		sapi := sapi
	};

	template RslLinkId ts_RslLinkID_SACCH(GsmSapi sapi) := {
		c := SACCH,
		na := false,
		prio := SAPI0_PRIO_NORMAL,
		sapi := sapi
	};

} with { encode "RAW"; variant "FIELDORDER(msb)" }