Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 1 | module LLC_Templates { |
| 2 | |
| 3 | import from LLC_Types all; |
| 4 | import from Osmocom_Types all; |
| 5 | import from General_Types all; |
| 6 | |
| 7 | template 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 Welte | f7a5c3c | 2019-04-23 22:00:00 +0200 | [diff] [blame^] | 13 | template (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 Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 21 | |
| 22 | template (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 Welte | f7a5c3c | 2019-04-23 22:00:00 +0200 | [diff] [blame^] | 31 | template (value) Control_field_U ts_LLC_CtrlU(template (value) BIT4 m_bits, template (value) BIT1 p_f) := { |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 32 | mBits := m_bits, |
| 33 | pF := p_f, |
| 34 | format := '111'B |
| 35 | } |
| 36 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 37 | template 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 Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 47 | template 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 Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 55 | template 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 Welte | f7a5c3c | 2019-04-23 22:00:00 +0200 | [diff] [blame^] | 58 | address_field := ts_LLC_Addr(sapi, cr), |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 59 | 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 | |
| 65 | template 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 Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 76 | template 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 Welte | f7a5c3c | 2019-04-23 22:00:00 +0200 | [diff] [blame^] | 88 | template 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 | } |
| 97 | template (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 | |
| 108 | template 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); |
| 111 | template (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 | |
| 116 | template 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); |
| 119 | template (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 | |
| 124 | template 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); |
| 127 | template (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 | |
| 132 | template 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); |
| 134 | template (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 Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 137 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 138 | const BIT4 c_LLC_SAPI_LLGMM := '0001'B; |
| 139 | const BIT4 c_LLC_SAPI_TOM2 := '0010'B; |
| 140 | const BIT4 c_LLC_SAPI_LL3 := '0011'B; |
| 141 | const BIT4 c_LLC_SAPI_LL5 := '0101'B; |
| 142 | const BIT4 c_LLC_SAPI_LLSMS := '0111'B; |
| 143 | const BIT4 c_LLC_SAPI_TOM8 := '1000'B; |
| 144 | const BIT4 c_LLC_SAPI_LL9 := '1001'B; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 145 | const BIT4 c_LLC_SAPI_LL11 := '1011'B; |
| 146 | |
| 147 | const BIT1 LLC_CR_DL_CMD := '1'B; |
| 148 | const BIT1 LLC_CR_DL_RSP := '0'B; |
| 149 | const BIT1 LLC_CR_UL_CMD := '0'B; |
| 150 | const BIT1 LLC_CR_UL_RSP := '1'B; |
| 151 | |
| 152 | /* LLC UI frame with SAPI for L3 payload */ |
Harald Welte | d471901 | 2018-02-17 16:45:06 +0100 | [diff] [blame] | 153 | template PDU_LLC tr_LLC_UI_L3 := ( tr_LLC_UI(?, c_LLC_SAPI_LLGMM) ); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 154 | |
Harald Welte | a2526a8 | 2018-02-18 19:03:36 +0100 | [diff] [blame] | 155 | /* LLC UI frame with SAPI for User payload */ |
| 156 | template 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 Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 162 | |
| 163 | } |