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 | |
| 23 | template Control_field_UI tr_LLC_CtrlUI(template uint9_t n_u, |
| 24 | template boolean encrypted := ?, |
| 25 | template boolean protected := ?) := { |
| 26 | format := '110'B, |
| 27 | spare := '00'B, |
| 28 | nU := n_u, |
| 29 | e := bool2bit_tmpl(encrypted), |
| 30 | pM := bool2bit_tmpl(protected) |
| 31 | } |
| 32 | |
| 33 | template PDU_LLC ts_LLC_UI(octetstring payload, BIT4 sapi, BIT1 cr, uint9_t n_u, |
| 34 | boolean encrypted := false, boolean protected := false) := { |
| 35 | pDU_LLC_UI := { |
| 36 | address_field := t_LLC_Addr(sapi, cr), |
| 37 | control_field := ts_LLC_CtrlUI(n_u, encrypted, protected), |
| 38 | information_field_UI := payload, |
| 39 | fCS := omit /* causes encoder to generate FCS */ |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | template PDU_LLC tr_LLC_UI(template octetstring payload := ?, template BIT4 sapi := ?, |
| 44 | template BIT1 cr := ?, template uint9_t n_u := ?, |
| 45 | template boolean encrypted := ?, template boolean protected := ?) := { |
| 46 | pDU_LLC_UI := { |
| 47 | address_field := t_LLC_Addr(sapi, cr), |
| 48 | control_field := tr_LLC_CtrlUI(n_u, encrypted, protected), |
| 49 | information_field_UI := payload, |
| 50 | fCS := '000000'O /* provided by decoder if FCS OK */ |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | const BIT4 c_LLC_SAPI_LLGMM := '0001'B; |
| 55 | const BIT4 c_LLC_SAPI_TOM2 := '0010'B; |
| 56 | const BIT4 c_LLC_SAPI_LL3 := '0011'B; |
| 57 | const BIT4 c_LLC_SAPI_LL5 := '0101'B; |
| 58 | const BIT4 c_LLC_SAPI_LLSMS := '0111'B; |
| 59 | const BIT4 c_LLC_SAPI_TOM8 := '1000'B; |
| 60 | const BIT4 c_LLC_SAPI_LL9 := '1001'B; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 61 | const BIT4 c_LLC_SAPI_LL11 := '1011'B; |
| 62 | |
| 63 | const BIT1 LLC_CR_DL_CMD := '1'B; |
| 64 | const BIT1 LLC_CR_DL_RSP := '0'B; |
| 65 | const BIT1 LLC_CR_UL_CMD := '0'B; |
| 66 | const BIT1 LLC_CR_UL_RSP := '1'B; |
| 67 | |
| 68 | /* LLC UI frame with SAPI for L3 payload */ |
Harald Welte | d471901 | 2018-02-17 16:45:06 +0100 | [diff] [blame] | 69 | 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] | 70 | |
Harald Welte | a2526a8 | 2018-02-18 19:03:36 +0100 | [diff] [blame^] | 71 | /* LLC UI frame with SAPI for User payload */ |
| 72 | template PDU_LLC tr_LLC_UI_USER := tr_LLC_UI(?, (c_LLC_SAPI_LL3, |
| 73 | c_LLC_SAPI_LL5, |
| 74 | c_LLC_SAPI_LL9, |
| 75 | c_LLC_SAPI_LL11) |
| 76 | ); |
| 77 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 78 | |
| 79 | } |