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 | } |
Harald Welte | d21f6a2 | 2019-05-02 09:50:34 +0200 | [diff] [blame] | 87 | template 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); |
| 89 | template 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); |
| 91 | template 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); |
| 93 | template 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); |
| 95 | template (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 | |
| 109 | template (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); |
| 111 | template (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); |
| 113 | template (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); |
| 115 | template (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 Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 118 | |
Harald Welte | f7a5c3c | 2019-04-23 22:00:00 +0200 | [diff] [blame] | 119 | template 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 | } |
| 128 | template (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 | |
| 139 | template 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); |
| 142 | template (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 | |
| 147 | template 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); |
| 150 | template (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 | |
| 155 | template 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); |
| 158 | template (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 | |
| 163 | template 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); |
| 165 | template (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 Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 168 | |
Harald Welte | ceaff26 | 2019-04-23 22:18:05 +0200 | [diff] [blame] | 169 | template 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); |
| 171 | template (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 | |
| 175 | template 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); |
| 177 | template (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 Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 182 | const BIT4 c_LLC_SAPI_LLGMM := '0001'B; |
| 183 | const BIT4 c_LLC_SAPI_TOM2 := '0010'B; |
| 184 | const BIT4 c_LLC_SAPI_LL3 := '0011'B; |
| 185 | const BIT4 c_LLC_SAPI_LL5 := '0101'B; |
| 186 | const BIT4 c_LLC_SAPI_LLSMS := '0111'B; |
| 187 | const BIT4 c_LLC_SAPI_TOM8 := '1000'B; |
| 188 | const BIT4 c_LLC_SAPI_LL9 := '1001'B; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 189 | const BIT4 c_LLC_SAPI_LL11 := '1011'B; |
| 190 | |
| 191 | const BIT1 LLC_CR_DL_CMD := '1'B; |
| 192 | const BIT1 LLC_CR_DL_RSP := '0'B; |
| 193 | const BIT1 LLC_CR_UL_CMD := '0'B; |
| 194 | const BIT1 LLC_CR_UL_RSP := '1'B; |
| 195 | |
| 196 | /* LLC UI frame with SAPI for L3 payload */ |
Harald Welte | d471901 | 2018-02-17 16:45:06 +0100 | [diff] [blame] | 197 | 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] | 198 | |
Harald Welte | a2526a8 | 2018-02-18 19:03:36 +0100 | [diff] [blame] | 199 | /* LLC UI frame with SAPI for User payload */ |
| 200 | template 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 Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 206 | |
Harald Welte | d21f6a2 | 2019-05-02 09:50:34 +0200 | [diff] [blame] | 207 | template XID tr_XID(template XID_Data xd := ?) := { |
| 208 | xl := ?, |
| 209 | typefield := ?, |
| 210 | xID_length := ?, |
| 211 | xID_Data := xd |
| 212 | }; |
| 213 | template (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 | |
| 222 | template XID tr_XID_kU(template uint8_t ku) := tr_XID({kU := ku}); |
| 223 | template (value) XID ts_XID_kU(template (value) uint8_t ku) := ts_XID('01010'B, {kU := ku}); |
| 224 | |
| 225 | template XID tr_XID_kD(template uint8_t kd) := tr_XID({kD := kd}); |
| 226 | template (value) XID ts_XID_kD(template (value) uint8_t kd) := ts_XID('01001'B, {kD := kd}); |
| 227 | |
| 228 | template XID tr_XID_mD(template uint15_t md) := tr_XID({mD := {spare := '0'B, mDValue := md}}); |
| 229 | template (value) XID ts_XID_mD(template (value) uint15_t md) := ts_XID('00111'B, {mD := { spare := '0'B, mDValue := md}}); |
| 230 | |
| 231 | template XID tr_XID_mU(template uint15_t mu) := tr_XID({mU := {spare := '0'B, mUValue := mu}}); |
| 232 | template (value) XID ts_XID_mU(template (value) uint15_t mu) := ts_XID('01000'B, {mU := { spare := '0'B, mUValue := mu}}); |
| 233 | |
| 234 | template XID tr_XID_N201I(template uint11_t n201i) := |
| 235 | tr_XID({n201_I := {spare := '00000'B, n201IValue := n201i}}); |
| 236 | template (value) XID ts_XID_N201I(template (value) uint11_t n201i) := |
| 237 | ts_XID('00110'B, {n201_I := { spare := '00000'B, n201IValue := n201i}}); |
| 238 | |
| 239 | template XID tr_XID_N201U(template uint11_t n201u) := |
| 240 | tr_XID({n201_U := {spare := '00000'B, n201UValue := n201u}}); |
| 241 | template (value) XID ts_XID_N201U(template (value) uint11_t n201u) := |
| 242 | ts_XID('00101'B, {n201_U := { spare := '00000'B, n201UValue := n201u}}); |
| 243 | |
| 244 | template XID tr_XID_N200(template uint4_t n200) := |
| 245 | tr_XID({n200 := { retransmissions := n200, spare := '0000'B}}); |
| 246 | template (value) XID ts_XID_N200(template (value) uint4_t n200) := |
| 247 | ts_XID('00100'B, {n200 := { retransmissions := n200, spare := '0000'B}}); |
| 248 | |
| 249 | template XID tr_XID_T200(template uint12_t t200) := |
| 250 | tr_XID({t200 := { spare := '0000'B, t200Value := t200}}); |
| 251 | template (value) XID ts_XID_T200(template (value) uint12_t t200) := |
| 252 | ts_XID('00011'B, {t200 := { spare := '0000'B, t200Value := t200}}); |
| 253 | |
| 254 | template XID tr_XID_version(template uint4_t v) := |
| 255 | tr_XID({version := {version_value := v, spare := '0000'B}}); |
| 256 | template (value) XID ts_XID_version(template (value) uint4_t v) := |
| 257 | ts_XID('00000'B, {version := {version_value := v, spare := '0000'B}}); |
| 258 | |
| 259 | template XID tr_XID_IOV_UI(template OCT4 iov) := tr_XID({iOV_UI := iov}); |
| 260 | template (value) XID ts_XID_IOV_UI(template (value) OCT4 iov) := ts_XID('00001'B, {iOV_UI := iov}); |
| 261 | |
| 262 | template XID tr_XID_IOV_I(template OCT4 iov) := tr_XID({iOV_I := iov}); |
| 263 | template (value) XID ts_XID_IOV_I(template (value) OCT4 iov) := ts_XID('00010'B, {iOV_I := iov}); |
| 264 | |
| 265 | template XID tr_XID_L3(template octetstring l3) := tr_XID({l3param := l3}); |
| 266 | template (value) XID ts_XID_L3(template (value) octetstring l3) := ts_XID('01011'B, {l3param := l3}); |
| 267 | |
| 268 | template XID tr_XID_RESET := tr_XID({reset := ''O}); |
| 269 | template (value) XID ts_XID_RESET := ts_XID('01100'B, {reset := ''O}); |
| 270 | |
| 271 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 272 | } |