blob: 024ae0b2e9912e1d384290c3e8eeafaf8f98f7ba [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}
87
Harald Weltef7a5c3c2019-04-23 22:00:00 +020088template PDU_LLC tr_LLC_U(template BIT4 m_bits, template BIT1 p_f, template Information_field_U u,
89 template BIT4 sapi, template BIT1 cr) := {
90 pDU_LLC_U := {
91 address_field := t_LLC_Addr(sapi, cr),
92 control_field := tr_LLC_CtrlU(m_bits, p_f),
93 information_field_U := u,
94 fCS := '000000'O /* provided by decoder if FCS OK */
95 }
96}
97template (value) PDU_LLC ts_LLC_U(template (value) BIT4 m_bits, template (value) BIT1 p_f,
98 template (value) Information_field_U u,
99 template (value) BIT4 sapi, template (value) BIT1 cr) := {
100 pDU_LLC_U := {
101 address_field := ts_LLC_Addr(sapi, cr),
102 control_field := ts_LLC_CtrlU(m_bits, p_f),
103 information_field_U := u,
104 fCS := omit /* causes encoder to generate FCS */
105 }
106}
107
108template PDU_LLC tr_LLC_SABM(template SABM_Information sabm_xid, template BIT1 p_f,
109 template BIT4 sapi, template BIT1 cr) :=
110 tr_LLC_U('0111'B, p_f, Information_field_U:{sABM := sabm_xid}, sapi, cr);
111template (value) PDU_LLC ts_LLC_SABM(template (value) SABM_Information sabm_xid,
112 template (value) BIT1 p_f,
113 template (value) BIT4 sapi, template (value) BIT1 cr) :=
114 ts_LLC_U('0111'B, p_f, Information_field_U:{sABM := sabm_xid}, sapi, cr);
115
116template PDU_LLC tr_LLC_UA(template UA_Information ua_xid, template BIT1 p_f,
117 template BIT4 sapi, template BIT1 cr) :=
118 tr_LLC_U('0110'B, p_f, Information_field_U:{uA := ua_xid}, sapi, cr);
119template (value) PDU_LLC ts_LLC_UA(template (value) UA_Information ua_xid,
120 template (value) BIT1 p_f,
121 template (value) BIT4 sapi, template (value) BIT1 cr) :=
122 ts_LLC_U('0110'B, p_f, Information_field_U:{uA := ua_xid}, sapi, cr);
123
124template PDU_LLC tr_LLC_FRMR(template FRMR_Information frmr, template BIT1 p_f,
125 template BIT4 sapi, template BIT1 cr) :=
126 tr_LLC_U('1000'B, p_f, Information_field_U:{fRMR := frmr}, sapi, cr);
127template (value) PDU_LLC ts_LLC_FRMR(template (value) FRMR_Information frmr,
128 template (value) BIT1 p_f,
129 template (value) BIT4 sapi, template (value) BIT1 cr) :=
130 ts_LLC_U('1000'B, p_f, Information_field_U:{fRMR := frmr}, sapi, cr);
131
132template PDU_LLC tr_LLC_DM(template BIT1 p_f, template BIT4 sapi, template BIT1 cr) :=
133 tr_LLC_U('0001'B, p_f, Information_field_U:{dM := ''O}, sapi, cr);
134template (value) PDU_LLC ts_LLC_DM(template (value) BIT1 p_f, template (value) BIT4 sapi,
135 template (value) BIT1 cr) :=
136 ts_LLC_U('0001'B, p_f, Information_field_U:{dM := ''O}, sapi, cr);
Harald Welte37692d82018-02-18 15:21:34 +0100137
Harald Welte5ac31492018-02-15 20:39:13 +0100138const BIT4 c_LLC_SAPI_LLGMM := '0001'B;
139const BIT4 c_LLC_SAPI_TOM2 := '0010'B;
140const BIT4 c_LLC_SAPI_LL3 := '0011'B;
141const BIT4 c_LLC_SAPI_LL5 := '0101'B;
142const BIT4 c_LLC_SAPI_LLSMS := '0111'B;
143const BIT4 c_LLC_SAPI_TOM8 := '1000'B;
144const BIT4 c_LLC_SAPI_LL9 := '1001'B;
Harald Welte5ac31492018-02-15 20:39:13 +0100145const BIT4 c_LLC_SAPI_LL11 := '1011'B;
146
147const BIT1 LLC_CR_DL_CMD := '1'B;
148const BIT1 LLC_CR_DL_RSP := '0'B;
149const BIT1 LLC_CR_UL_CMD := '0'B;
150const BIT1 LLC_CR_UL_RSP := '1'B;
151
152/* LLC UI frame with SAPI for L3 payload */
Harald Welted4719012018-02-17 16:45:06 +0100153template PDU_LLC tr_LLC_UI_L3 := ( tr_LLC_UI(?, c_LLC_SAPI_LLGMM) );
Harald Welte5ac31492018-02-15 20:39:13 +0100154
Harald Weltea2526a82018-02-18 19:03:36 +0100155/* LLC UI frame with SAPI for User payload */
156template PDU_LLC tr_LLC_UI_USER := tr_LLC_UI(?, (c_LLC_SAPI_LL3,
157 c_LLC_SAPI_LL5,
158 c_LLC_SAPI_LL9,
159 c_LLC_SAPI_LL11)
160 );
161
Harald Welte5ac31492018-02-15 20:39:13 +0100162
163}