blob: 086207cbea3866cd781703f83d791b8b2f173b21 [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}
13
14template (value) Control_field_UI ts_LLC_CtrlUI(uint9_t n_u, boolean encrypted := false,
15 boolean protected := false) := {
16 format := '110'B,
17 spare := '00'B,
18 nU := n_u,
19 e := bool2bit(encrypted),
20 pM := bool2bit(protected)
21}
22
Harald Welte37692d82018-02-18 15:21:34 +010023template (value) Control_field_U ts_LLC_CtrlU(BIT4 m_bits, BIT1 p_f) := {
24 mBits := m_bits,
25 pF := p_f,
26 format := '111'B
27}
28
Harald Welte5ac31492018-02-15 20:39:13 +010029template Control_field_UI tr_LLC_CtrlUI(template uint9_t n_u,
30 template boolean encrypted := ?,
31 template boolean protected := ?) := {
32 format := '110'B,
33 spare := '00'B,
34 nU := n_u,
35 e := bool2bit_tmpl(encrypted),
36 pM := bool2bit_tmpl(protected)
37}
38
Harald Welte37692d82018-02-18 15:21:34 +010039template Control_field_U tr_LLC_CtrlU(template BIT4 m_bits := ?,
40 template BIT1 p_f := ?) := {
41 mBits := m_bits,
42 pF := p_f,
43 format := '111'B
44}
45
46
Harald Welte5ac31492018-02-15 20:39:13 +010047template PDU_LLC ts_LLC_UI(octetstring payload, BIT4 sapi, BIT1 cr, uint9_t n_u,
48 boolean encrypted := false, boolean protected := false) := {
49 pDU_LLC_UI := {
50 address_field := t_LLC_Addr(sapi, cr),
51 control_field := ts_LLC_CtrlUI(n_u, encrypted, protected),
52 information_field_UI := payload,
53 fCS := omit /* causes encoder to generate FCS */
54 }
55}
56
57template PDU_LLC tr_LLC_UI(template octetstring payload := ?, template BIT4 sapi := ?,
58 template BIT1 cr := ?, template uint9_t n_u := ?,
59 template boolean encrypted := ?, template boolean protected := ?) := {
60 pDU_LLC_UI := {
61 address_field := t_LLC_Addr(sapi, cr),
62 control_field := tr_LLC_CtrlUI(n_u, encrypted, protected),
63 information_field_UI := payload,
64 fCS := '000000'O /* provided by decoder if FCS OK */
65 }
66}
67
Harald Welte37692d82018-02-18 15:21:34 +010068template PDU_LLC tr_LLC_XID(template XID_Information xid, template BIT4 sapi := ?,
69 template BIT1 cr := ?, template BIT1 p_f := ?) := {
70 pDU_LLC_U := {
71 address_field := t_LLC_Addr(sapi, cr),
72 control_field := tr_LLC_CtrlU('1011'B, p_f),
73 information_field_U := {
74 xID := xid
75 },
76 fCS := '000000'O /* provided by decoder if FCS OK */
77 }
78}
79
80
Harald Welte5ac31492018-02-15 20:39:13 +010081const BIT4 c_LLC_SAPI_LLGMM := '0001'B;
82const BIT4 c_LLC_SAPI_TOM2 := '0010'B;
83const BIT4 c_LLC_SAPI_LL3 := '0011'B;
84const BIT4 c_LLC_SAPI_LL5 := '0101'B;
85const BIT4 c_LLC_SAPI_LLSMS := '0111'B;
86const BIT4 c_LLC_SAPI_TOM8 := '1000'B;
87const BIT4 c_LLC_SAPI_LL9 := '1001'B;
Harald Welte5ac31492018-02-15 20:39:13 +010088const BIT4 c_LLC_SAPI_LL11 := '1011'B;
89
90const BIT1 LLC_CR_DL_CMD := '1'B;
91const BIT1 LLC_CR_DL_RSP := '0'B;
92const BIT1 LLC_CR_UL_CMD := '0'B;
93const BIT1 LLC_CR_UL_RSP := '1'B;
94
95/* LLC UI frame with SAPI for L3 payload */
Harald Welted4719012018-02-17 16:45:06 +010096template PDU_LLC tr_LLC_UI_L3 := ( tr_LLC_UI(?, c_LLC_SAPI_LLGMM) );
Harald Welte5ac31492018-02-15 20:39:13 +010097
Harald Weltea2526a82018-02-18 19:03:36 +010098/* LLC UI frame with SAPI for User payload */
99template PDU_LLC tr_LLC_UI_USER := tr_LLC_UI(?, (c_LLC_SAPI_LL3,
100 c_LLC_SAPI_LL5,
101 c_LLC_SAPI_LL9,
102 c_LLC_SAPI_LL11)
103 );
104
Harald Welte5ac31492018-02-15 20:39:13 +0100105
106}