blob: b71bce16c85bbe0b2de1ba27f40036b913f22499 [file] [log] [blame]
Harald Welte5ac31492018-02-15 20:39:13 +01001module LLC_Templates {
2
3import from LLC_Types all;
4import from Osmocom_Types all;
5import from General_Types all;
6
7template Address_field t_LLC_Addr(template BIT4 sapi, template BIT1 cr, template BIT1 pd := '0'B) := {
8 sAPI := sapi,
9 spare := '00'B,
10 cR := cr,
11 pD := '0'B
12}
Harald Weltef7a5c3c2019-04-23 22:00:00 +020013template (value) Address_field ts_LLC_Addr(template (value) BIT4 sapi,
14 template (value) BIT1 cr,
15 template (value) BIT1 pd := '0'B) := {
16 sAPI := sapi,
17 spare := '00'B,
18 cR := cr,
19 pD := '0'B
20}
Harald Welte5ac31492018-02-15 20:39:13 +010021
22template (value) Control_field_UI ts_LLC_CtrlUI(uint9_t n_u, boolean encrypted := false,
23 boolean protected := false) := {
24 format := '110'B,
25 spare := '00'B,
26 nU := n_u,
27 e := bool2bit(encrypted),
28 pM := bool2bit(protected)
29}
30
Harald Weltef7a5c3c2019-04-23 22:00:00 +020031template (value) Control_field_U ts_LLC_CtrlU(template (value) BIT4 m_bits, template (value) BIT1 p_f) := {
Harald Welte37692d82018-02-18 15:21:34 +010032 mBits := m_bits,
33 pF := p_f,
34 format := '111'B
35}
36
Harald Welte5ac31492018-02-15 20:39:13 +010037template Control_field_UI tr_LLC_CtrlUI(template uint9_t n_u,
38 template boolean encrypted := ?,
39 template boolean protected := ?) := {
40 format := '110'B,
41 spare := '00'B,
42 nU := n_u,
43 e := bool2bit_tmpl(encrypted),
44 pM := bool2bit_tmpl(protected)
45}
46
Harald Welte37692d82018-02-18 15:21:34 +010047template Control_field_U tr_LLC_CtrlU(template BIT4 m_bits := ?,
48 template BIT1 p_f := ?) := {
49 mBits := m_bits,
50 pF := p_f,
51 format := '111'B
52}
53
54
Harald Welte5ac31492018-02-15 20:39:13 +010055template PDU_LLC ts_LLC_UI(octetstring payload, BIT4 sapi, BIT1 cr, uint9_t n_u,
56 boolean encrypted := false, boolean protected := false) := {
57 pDU_LLC_UI := {
Harald Weltef7a5c3c2019-04-23 22:00:00 +020058 address_field := ts_LLC_Addr(sapi, cr),
Harald Welte5ac31492018-02-15 20:39:13 +010059 control_field := ts_LLC_CtrlUI(n_u, encrypted, protected),
60 information_field_UI := payload,
61 fCS := omit /* causes encoder to generate FCS */
62 }
63}
64
65template PDU_LLC tr_LLC_UI(template octetstring payload := ?, template BIT4 sapi := ?,
66 template BIT1 cr := ?, template uint9_t n_u := ?,
67 template boolean encrypted := ?, template boolean protected := ?) := {
68 pDU_LLC_UI := {
69 address_field := t_LLC_Addr(sapi, cr),
70 control_field := tr_LLC_CtrlUI(n_u, encrypted, protected),
71 information_field_UI := payload,
72 fCS := '000000'O /* provided by decoder if FCS OK */
73 }
74}
75
Harald Welte37692d82018-02-18 15:21:34 +010076template PDU_LLC tr_LLC_XID(template XID_Information xid, template BIT4 sapi := ?,
77 template BIT1 cr := ?, template BIT1 p_f := ?) := {
78 pDU_LLC_U := {
79 address_field := t_LLC_Addr(sapi, cr),
80 control_field := tr_LLC_CtrlU('1011'B, p_f),
81 information_field_U := {
82 xID := xid
83 },
84 fCS := '000000'O /* provided by decoder if FCS OK */
85 }
86}
Harald Welted21f6a22019-05-02 09:50:34 +020087template PDU_LLC tr_LLC_XID_MO_CMD(template XID_Information xid, template BIT4 sapi) :=
88 tr_LLC_XID(xid, sapi, LLC_CR_UL_CMD, '1'B);
89template PDU_LLC tr_LLC_XID_MO_RSP(template XID_Information xid, template BIT4 sapi) :=
90 tr_LLC_XID(xid, sapi, LLC_CR_UL_RSP, '1'B);
91template PDU_LLC tr_LLC_XID_MT_CMD(template XID_Information xid, template BIT4 sapi) :=
92 tr_LLC_XID(xid, sapi, LLC_CR_DL_CMD, '1'B);
93template PDU_LLC tr_LLC_XID_MT_RSP(template XID_Information xid, template BIT4 sapi) :=
94 tr_LLC_XID(xid, sapi, LLC_CR_DL_RSP, '1'B);
95template (value) PDU_LLC ts_LLC_XID(template (value) XID_Information xid,
96 template (value) BIT4 sapi,
97 template (value) BIT1 cr,
98 template (value) BIT1 p_f) := {
99 pDU_LLC_U := {
100 address_field := ts_LLC_Addr(sapi, cr),
101 control_field := ts_LLC_CtrlU('1011'B, p_f),
102 information_field_U := {
103 xID := xid
104 },
105 fCS := omit /* causes encoder to generate FCS */
106 }
107}
108
109template (value) PDU_LLC ts_LLC_XID_MO_CMD(template (value) XID_Information xid, template (value) BIT4 sapi) :=
110 ts_LLC_XID(xid, sapi, LLC_CR_UL_CMD, '1'B);
111template (value) PDU_LLC ts_LLC_XID_MO_RSP(template (value) XID_Information xid, template (value) BIT4 sapi) :=
112 ts_LLC_XID(xid, sapi, LLC_CR_UL_RSP, '1'B);
113template (value) PDU_LLC ts_LLC_XID_MT_CMD(template (value) XID_Information xid, template (value) BIT4 sapi) :=
114 ts_LLC_XID(xid, sapi, LLC_CR_DL_CMD, '1'B);
115template (value) PDU_LLC ts_LLC_XID_MT_RSP(template (value) XID_Information xid, template (value) BIT4 sapi) :=
116 ts_LLC_XID(xid, sapi, LLC_CR_DL_RSP, '1'B);
117
Harald Welte37692d82018-02-18 15:21:34 +0100118
Harald Weltef7a5c3c2019-04-23 22:00:00 +0200119template PDU_LLC tr_LLC_U(template BIT4 m_bits, template BIT1 p_f, template Information_field_U u,
120 template BIT4 sapi, template BIT1 cr) := {
121 pDU_LLC_U := {
122 address_field := t_LLC_Addr(sapi, cr),
123 control_field := tr_LLC_CtrlU(m_bits, p_f),
124 information_field_U := u,
125 fCS := '000000'O /* provided by decoder if FCS OK */
126 }
127}
128template (value) PDU_LLC ts_LLC_U(template (value) BIT4 m_bits, template (value) BIT1 p_f,
129 template (value) Information_field_U u,
130 template (value) BIT4 sapi, template (value) BIT1 cr) := {
131 pDU_LLC_U := {
132 address_field := ts_LLC_Addr(sapi, cr),
133 control_field := ts_LLC_CtrlU(m_bits, p_f),
134 information_field_U := u,
135 fCS := omit /* causes encoder to generate FCS */
136 }
137}
138
139template PDU_LLC tr_LLC_SABM(template SABM_Information sabm_xid, template BIT1 p_f,
140 template BIT4 sapi, template BIT1 cr) :=
141 tr_LLC_U('0111'B, p_f, Information_field_U:{sABM := sabm_xid}, sapi, cr);
142template (value) PDU_LLC ts_LLC_SABM(template (value) SABM_Information sabm_xid,
143 template (value) BIT1 p_f,
144 template (value) BIT4 sapi, template (value) BIT1 cr) :=
145 ts_LLC_U('0111'B, p_f, Information_field_U:{sABM := sabm_xid}, sapi, cr);
146
147template PDU_LLC tr_LLC_UA(template UA_Information ua_xid, template BIT1 p_f,
148 template BIT4 sapi, template BIT1 cr) :=
149 tr_LLC_U('0110'B, p_f, Information_field_U:{uA := ua_xid}, sapi, cr);
150template (value) PDU_LLC ts_LLC_UA(template (value) UA_Information ua_xid,
151 template (value) BIT1 p_f,
152 template (value) BIT4 sapi, template (value) BIT1 cr) :=
153 ts_LLC_U('0110'B, p_f, Information_field_U:{uA := ua_xid}, sapi, cr);
154
155template PDU_LLC tr_LLC_FRMR(template FRMR_Information frmr, template BIT1 p_f,
156 template BIT4 sapi, template BIT1 cr) :=
157 tr_LLC_U('1000'B, p_f, Information_field_U:{fRMR := frmr}, sapi, cr);
158template (value) PDU_LLC ts_LLC_FRMR(template (value) FRMR_Information frmr,
159 template (value) BIT1 p_f,
160 template (value) BIT4 sapi, template (value) BIT1 cr) :=
161 ts_LLC_U('1000'B, p_f, Information_field_U:{fRMR := frmr}, sapi, cr);
162
163template PDU_LLC tr_LLC_DM(template BIT1 p_f, template BIT4 sapi, template BIT1 cr) :=
164 tr_LLC_U('0001'B, p_f, Information_field_U:{dM := ''O}, sapi, cr);
165template (value) PDU_LLC ts_LLC_DM(template (value) BIT1 p_f, template (value) BIT4 sapi,
166 template (value) BIT1 cr) :=
167 ts_LLC_U('0001'B, p_f, Information_field_U:{dM := ''O}, sapi, cr);
Harald Welte37692d82018-02-18 15:21:34 +0100168
Harald Welteceaff262019-04-23 22:18:05 +0200169template PDU_LLC tr_LLC_NULL(template BIT1 p_f, template BIT4 sapi, template BIT1 cr) :=
170 tr_LLC_U('0000'B, p_f, Information_field_U:{nULL := ''O}, sapi, cr);
171template (value) PDU_LLC ts_LLC_NULL(template (value) BIT1 p_f, template (value) BIT4 sapi,
172 template (value) BIT1 cr) :=
173 ts_LLC_U('0000'B, p_f, Information_field_U:{nULL := ''O}, sapi, cr);
174
175template PDU_LLC tr_LLC_DISC(template BIT1 p_f, template BIT4 sapi, template BIT1 cr) :=
176 tr_LLC_U('0100'B, p_f, Information_field_U:{dISC := ''O}, sapi, cr);
177template (value) PDU_LLC ts_LLC_DISC(template (value) BIT1 p_f, template (value) BIT4 sapi,
178 template (value) BIT1 cr) :=
179 ts_LLC_U('0100'B, p_f, Information_field_U:{dISC := ''O}, sapi, cr);
180
181
Harald Welte5ac31492018-02-15 20:39:13 +0100182const BIT4 c_LLC_SAPI_LLGMM := '0001'B;
183const BIT4 c_LLC_SAPI_TOM2 := '0010'B;
184const BIT4 c_LLC_SAPI_LL3 := '0011'B;
185const BIT4 c_LLC_SAPI_LL5 := '0101'B;
186const BIT4 c_LLC_SAPI_LLSMS := '0111'B;
187const BIT4 c_LLC_SAPI_TOM8 := '1000'B;
188const BIT4 c_LLC_SAPI_LL9 := '1001'B;
Harald Welte5ac31492018-02-15 20:39:13 +0100189const BIT4 c_LLC_SAPI_LL11 := '1011'B;
190
191const BIT1 LLC_CR_DL_CMD := '1'B;
192const BIT1 LLC_CR_DL_RSP := '0'B;
193const BIT1 LLC_CR_UL_CMD := '0'B;
194const BIT1 LLC_CR_UL_RSP := '1'B;
195
196/* LLC UI frame with SAPI for L3 payload */
Harald Welted4719012018-02-17 16:45:06 +0100197template PDU_LLC tr_LLC_UI_L3 := ( tr_LLC_UI(?, c_LLC_SAPI_LLGMM) );
Harald Welte5ac31492018-02-15 20:39:13 +0100198
Harald Weltea2526a82018-02-18 19:03:36 +0100199/* LLC UI frame with SAPI for User payload */
200template PDU_LLC tr_LLC_UI_USER := tr_LLC_UI(?, (c_LLC_SAPI_LL3,
201 c_LLC_SAPI_LL5,
202 c_LLC_SAPI_LL9,
203 c_LLC_SAPI_LL11)
204 );
205
Harald Welte5ac31492018-02-15 20:39:13 +0100206
Harald Welted21f6a22019-05-02 09:50:34 +0200207template XID tr_XID(template XID_Data xd := ?) := {
208 xl := ?,
209 typefield := ?,
210 xID_length := ?,
211 xID_Data := xd
212};
213template (value) XID ts_XID(template (value) BIT5 tf, template (value) XID_Data xd) := {
214 xl := '0'B,
215 typefield := tf,
216 xID_length := {
217 short_len := 0
218 },
219 xID_Data := xd
220};
221
222template XID tr_XID_kU(template uint8_t ku) := tr_XID({kU := ku});
223template (value) XID ts_XID_kU(template (value) uint8_t ku) := ts_XID('01010'B, {kU := ku});
224
225template XID tr_XID_kD(template uint8_t kd) := tr_XID({kD := kd});
226template (value) XID ts_XID_kD(template (value) uint8_t kd) := ts_XID('01001'B, {kD := kd});
227
228template XID tr_XID_mD(template uint15_t md) := tr_XID({mD := {spare := '0'B, mDValue := md}});
229template (value) XID ts_XID_mD(template (value) uint15_t md) := ts_XID('00111'B, {mD := { spare := '0'B, mDValue := md}});
230
231template XID tr_XID_mU(template uint15_t mu) := tr_XID({mU := {spare := '0'B, mUValue := mu}});
232template (value) XID ts_XID_mU(template (value) uint15_t mu) := ts_XID('01000'B, {mU := { spare := '0'B, mUValue := mu}});
233
234template XID tr_XID_N201I(template uint11_t n201i) :=
235 tr_XID({n201_I := {spare := '00000'B, n201IValue := n201i}});
236template (value) XID ts_XID_N201I(template (value) uint11_t n201i) :=
237 ts_XID('00110'B, {n201_I := { spare := '00000'B, n201IValue := n201i}});
238
239template XID tr_XID_N201U(template uint11_t n201u) :=
240 tr_XID({n201_U := {spare := '00000'B, n201UValue := n201u}});
241template (value) XID ts_XID_N201U(template (value) uint11_t n201u) :=
242 ts_XID('00101'B, {n201_U := { spare := '00000'B, n201UValue := n201u}});
243
244template XID tr_XID_N200(template uint4_t n200) :=
245 tr_XID({n200 := { retransmissions := n200, spare := '0000'B}});
246template (value) XID ts_XID_N200(template (value) uint4_t n200) :=
247 ts_XID('00100'B, {n200 := { retransmissions := n200, spare := '0000'B}});
248
249template XID tr_XID_T200(template uint12_t t200) :=
250 tr_XID({t200 := { spare := '0000'B, t200Value := t200}});
251template (value) XID ts_XID_T200(template (value) uint12_t t200) :=
252 ts_XID('00011'B, {t200 := { spare := '0000'B, t200Value := t200}});
253
254template XID tr_XID_version(template uint4_t v) :=
255 tr_XID({version := {version_value := v, spare := '0000'B}});
256template (value) XID ts_XID_version(template (value) uint4_t v) :=
257 ts_XID('00000'B, {version := {version_value := v, spare := '0000'B}});
258
259template XID tr_XID_IOV_UI(template OCT4 iov) := tr_XID({iOV_UI := iov});
260template (value) XID ts_XID_IOV_UI(template (value) OCT4 iov) := ts_XID('00001'B, {iOV_UI := iov});
261
262template XID tr_XID_IOV_I(template OCT4 iov) := tr_XID({iOV_I := iov});
263template (value) XID ts_XID_IOV_I(template (value) OCT4 iov) := ts_XID('00010'B, {iOV_I := iov});
264
265template XID tr_XID_L3(template octetstring l3) := tr_XID({l3param := l3});
266template (value) XID ts_XID_L3(template (value) octetstring l3) := ts_XID('01011'B, {l3param := l3});
267
268template XID tr_XID_RESET := tr_XID({reset := ''O});
269template (value) XID ts_XID_RESET := ts_XID('01100'B, {reset := ''O});
270
271
Harald Welte5ac31492018-02-15 20:39:13 +0100272}