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 | } |
| 13 | |
| 14 | template (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 Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 23 | template (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 Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 29 | template 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 Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 39 | template 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 Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 47 | template 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 | |
| 57 | template 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 Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 68 | template 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 Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 81 | const BIT4 c_LLC_SAPI_LLGMM := '0001'B; |
| 82 | const BIT4 c_LLC_SAPI_TOM2 := '0010'B; |
| 83 | const BIT4 c_LLC_SAPI_LL3 := '0011'B; |
| 84 | const BIT4 c_LLC_SAPI_LL5 := '0101'B; |
| 85 | const BIT4 c_LLC_SAPI_LLSMS := '0111'B; |
| 86 | const BIT4 c_LLC_SAPI_TOM8 := '1000'B; |
| 87 | const BIT4 c_LLC_SAPI_LL9 := '1001'B; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 88 | const BIT4 c_LLC_SAPI_LL11 := '1011'B; |
| 89 | |
| 90 | const BIT1 LLC_CR_DL_CMD := '1'B; |
| 91 | const BIT1 LLC_CR_DL_RSP := '0'B; |
| 92 | const BIT1 LLC_CR_UL_CMD := '0'B; |
| 93 | const BIT1 LLC_CR_UL_RSP := '1'B; |
| 94 | |
| 95 | /* LLC UI frame with SAPI for L3 payload */ |
Harald Welte | d471901 | 2018-02-17 16:45:06 +0100 | [diff] [blame] | 96 | 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] | 97 | |
Harald Welte | a2526a8 | 2018-02-18 19:03:36 +0100 | [diff] [blame] | 98 | /* LLC UI frame with SAPI for User payload */ |
| 99 | template 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 Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 105 | |
| 106 | } |