Harald Welte | e38fd7b | 2017-07-23 21:03:02 +0200 | [diff] [blame^] | 1 | module LLC_Types { |
| 2 | import from General_Types all; |
| 3 | import from Osmocom_Types all; |
| 4 | |
| 5 | /* TS 44.064 Chapter 6.2 */ |
| 6 | type record LlcAddressField { |
| 7 | boolean pd, |
| 8 | boolean c_r, |
| 9 | BIT2 reserved, |
| 10 | LlcSapi sapi |
| 11 | } with { |
| 12 | variant (pd) "FIELDLENGTH(1)" |
| 13 | variant (c_r) "FIELDLENGTH(1)" |
| 14 | }; |
| 15 | |
| 16 | type enumerated LlcSapi { |
| 17 | LLC_SAPI_RESERVED_0 ('0000'B), |
| 18 | LLC_SAPI_GMM ('0001'B), |
| 19 | LLC_SAPI_TOM2 ('0010'B), |
| 20 | LLC_SAPI_LL3 ('0011'B), |
| 21 | LLC_SAPI_RESERVED_4 ('0100'B), |
| 22 | LLC_SAPI_LL5 ('0101'B), |
| 23 | LLC_SAPI_RESERVED_6 ('0110'B), |
| 24 | LLC_SAPI_SMS ('0111'B), |
| 25 | LLC_SAPI_TOM8 ('1000'B), |
| 26 | LLC_SAPI_LL9 ('1001'B), |
| 27 | LLC_SAPI_RESERVED_10 ('1010'B), |
| 28 | LLC_SAPI_LL11 ('1011'B), |
| 29 | LLC_SAPI_RESERVED_12 ('1100'B), |
| 30 | LLC_SAPI_RESERVED_13 ('1101'B), |
| 31 | LLC_SAPI_RESERVED_14 ('1110'B), |
| 32 | LLC_SAPI_RESERVED_15 ('1111'B) |
| 33 | } with { variant "FIELDLENGTH(4)" }; |
| 34 | |
| 35 | /* TS 44.064 Chapter 6.3 */ |
| 36 | type record LlcCtrlFieldI { |
| 37 | BIT1 presence ('0'B), |
| 38 | boolean a, |
| 39 | BIT1 spare, |
| 40 | uint9_t n_s, |
| 41 | BIT1 spare2, |
| 42 | uint9_t n_r, |
| 43 | LlcCtrlS s |
| 44 | } with { variant |
| 45 | (a) "FIELDLENGTH(1)" |
| 46 | }; |
| 47 | |
| 48 | /* TS 44.064 Chapter 6.3 */ |
| 49 | type record LlcCtrlFieldS { |
| 50 | BIT2 presence ('10'B), |
| 51 | boolean a, |
| 52 | BIT2 spare, |
| 53 | uint9_t n_r, |
| 54 | LlcCtrlS s |
| 55 | } with { |
| 56 | variant (a) "FIELDLENGTH(1)" |
| 57 | }; |
| 58 | |
| 59 | /* TS 44.064 Chapter 6.3 */ |
| 60 | type record LlcCtrlFieldUI { |
| 61 | BIT3 presence ('110'B), |
| 62 | BIT2 spare, |
| 63 | uint9_t n_u, |
| 64 | boolean e, |
| 65 | boolean pm |
| 66 | } with { |
| 67 | variant (e) "FIELDLENGTH(1)" |
| 68 | variant (pm) "FIELDLENGTH(1)" |
| 69 | }; |
| 70 | |
| 71 | /* TS 44.064 Chapter 6.3 */ |
| 72 | type record LlcCtrlFieldU { |
| 73 | BIT3 presence ('111'B), |
| 74 | boolean p_f, |
| 75 | LlcCtrlM m |
| 76 | } with { |
| 77 | variant (p_f) "FIELDLENGTH(1)" |
| 78 | }; |
| 79 | |
| 80 | |
| 81 | /* TS 44.064 Chapter 6.4 */ |
| 82 | type enumerated LlcCtrlS { |
| 83 | LLC_S_RR ('00'B), |
| 84 | LLC_S_ACK ('01'B), |
| 85 | LLC_S_RNR ('10'B), |
| 86 | LLC_S_SACK ('11'B) |
| 87 | } with { variant "FIELDLENGTH(2)" }; |
| 88 | |
| 89 | /* TS 44.064 Chapter 6.4 */ |
| 90 | type enumerated LlcCtrlM { |
| 91 | LLC_M_DM ('0001'B), |
| 92 | LLC_M_DISC ('0100'B), |
| 93 | LLC_M_UA ('0110'B), |
| 94 | LLC_M_SABM ('0111'B), |
| 95 | LLC_M_FRMR ('1000'B), |
| 96 | LLC_M_XID ('1011'B), |
| 97 | LLC_M_NULL ('0000'B) |
| 98 | } with { variant "FIELDLENGTH(4)" }; |
| 99 | |
| 100 | type union LlcCtrlUnion { |
| 101 | LlcCtrlFieldI i, |
| 102 | LlcCtrlFieldS s, |
| 103 | LlcCtrlFieldUI ui, |
| 104 | LlcCtrlFieldU u |
| 105 | } with { variant "TAG(i, presence = '0'B; |
| 106 | s, presence = '10'B; |
| 107 | ui, presence = '110'B; |
| 108 | u, presence = '111'B)" |
| 109 | variant "FIELDORDER(msb)" |
| 110 | }; |
| 111 | |
| 112 | external function enc_LlcCtrlUnion(in LlcCtrlUnion pdu) return octetstring |
| 113 | with { extension "prototype(convert) encode(RAW)" }; |
| 114 | external function dec_LlcCtrlUnion(in octetstring stream) return LlcCtrlUnion |
| 115 | with { extension "prototype(convert) decode(RAW)" }; |
| 116 | |
| 117 | |
| 118 | type uint24_t LlcFcs; |
| 119 | |
| 120 | type record LlcPdu { |
| 121 | LlcAddressField addr, |
| 122 | LlcCtrlUnion ctrl, |
| 123 | octetstring payload, |
| 124 | LlcFcs fcs |
| 125 | } with { variant "" }; |
| 126 | |
| 127 | external function enc_LlcPdu(in LlcPdu pdu) return octetstring |
| 128 | with { extension "prototype(convert) encode(RAW)" }; |
| 129 | external function dec_LlcPdu(in octetstring stream) return LlcPdu |
| 130 | with { extension "prototype(convert) decode(RAW)" }; |
| 131 | |
| 132 | } with { encode "RAW"; variant "FIELDORDER(msb)" } |