Harald Welte | a082a69 | 2017-07-15 15:58:13 +0200 | [diff] [blame] | 1 | /* Encoding/Decoding routines for GSM System Information messages |
| 2 | * according to 3GPP TS 44.018 Version 12.3.0 Release 12 */ |
| 3 | |
| 4 | /* (C) 2017 by Harald Welte <laforge@gnumonks.org> */ |
| 5 | |
| 6 | module GSM_Types { |
| 7 | |
| 8 | import from General_Types all; |
| 9 | import from Osmocom_Types all; |
| 10 | |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 11 | type integer GsmArfcn (0..1023); |
| 12 | type integer UmtsArfcn (0..16383); |
| 13 | type integer UmtsScramblingCode (0..511); |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 14 | const integer GsmMaxFrameNumber := 26*51*2048; |
| 15 | type integer GsmFrameNumber (0..GsmMaxFrameNumber); |
| 16 | type integer GsmRxLev (0..63); |
| 17 | type integer GsmTsc (0..7) with { variant "FIELDLENGTH(8)" }; |
| 18 | type uint32_t GsmTmsi; |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 19 | type uint32_t GprsTlli; |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 20 | |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 21 | /* 10.5.2.8 */ |
| 22 | type enumerated ChannelNeeded { |
| 23 | CHAN_NEED_ANY (0), |
| 24 | CHAN_NEED_SDCCH (1), |
| 25 | CHAN_NEED_TCH_F (2), |
| 26 | CHAN_NEED_TCH_H (3) |
| 27 | } with { variant "FIELDLENGTH(2)" }; |
| 28 | type record ChannelNeeded12 { |
| 29 | ChannelNeeded second, |
| 30 | ChannelNeeded first |
| 31 | } with { variant "" }; |
| 32 | |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 33 | |
Harald Welte | 0c8d5c0 | 2017-07-16 18:53:58 +0200 | [diff] [blame] | 34 | /* TS 48.058 9.3.1 Channel Number IE */ |
| 35 | type enumerated RslChanNr0 { |
Harald Welte | 6f3c223 | 2017-07-30 17:17:12 +0200 | [diff] [blame] | 36 | RSL_CHAN_NR_INVALID ('00000'B), |
| 37 | RSL_CHAN_NR_Bm_ACCH ('00001'B), |
| 38 | RSL_CHAN_NR_BCCH ('10000'B), |
| 39 | RSL_CHAN_NR_RACH ('10001'B), |
| 40 | RSL_CHAN_NR_PCH_AGCH ('10010'B), |
| 41 | RSL_CHAN_NR_OSMO_PDCH ('11000'B) |
Harald Welte | c84d847 | 2017-07-30 00:49:56 +0200 | [diff] [blame] | 42 | } with { variant "FIELDLENGTH(5)" variant "FIELDORDER(msb)" }; |
Harald Welte | 0c8d5c0 | 2017-07-16 18:53:58 +0200 | [diff] [blame] | 43 | |
| 44 | type record RslChanNr2 { |
| 45 | BIT4 tag ('0001'B), |
| 46 | uint1_t sub_chan |
Harald Welte | c84d847 | 2017-07-30 00:49:56 +0200 | [diff] [blame] | 47 | } with { variant "FIELDLENGTH(5)" variant "FIELDORDER(msb)" }; |
Harald Welte | 0c8d5c0 | 2017-07-16 18:53:58 +0200 | [diff] [blame] | 48 | |
| 49 | type record RslChanNr4 { |
| 50 | BIT3 tag ('001'B), |
| 51 | uint2_t sub_chan |
Harald Welte | c84d847 | 2017-07-30 00:49:56 +0200 | [diff] [blame] | 52 | } with { variant "FIELDLENGTH(5)" variant "FIELDORDER(msb)" }; |
Harald Welte | 0c8d5c0 | 2017-07-16 18:53:58 +0200 | [diff] [blame] | 53 | |
| 54 | type record RslChanNr8 { |
| 55 | BIT2 tag ('01'B), |
| 56 | uint3_t sub_chan |
Harald Welte | c84d847 | 2017-07-30 00:49:56 +0200 | [diff] [blame] | 57 | } with { variant "FIELDLENGTH(5)" variant "FIELDORDER(msb)" }; |
Harald Welte | 0c8d5c0 | 2017-07-16 18:53:58 +0200 | [diff] [blame] | 58 | |
| 59 | type union RslChanNrU { |
| 60 | RslChanNr0 ch0, |
| 61 | RslChanNr2 lm, |
| 62 | RslChanNr4 sdcch4, |
| 63 | RslChanNr8 sdcch8 |
| 64 | } with { |
| 65 | variant "TAG(lm, tag = '0001'B; |
| 66 | sdcch4, tag = '001'B; |
| 67 | sdcch8, tag = '01'B; |
| 68 | ch0, OTHERWISE)" |
| 69 | variant "FIELDLENGTH(5)" |
Harald Welte | c84d847 | 2017-07-30 00:49:56 +0200 | [diff] [blame] | 70 | variant "FIELDORDER(msb)" |
Harald Welte | 0c8d5c0 | 2017-07-16 18:53:58 +0200 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | type record RslChannelNr { |
| 74 | RslChanNrU u, |
| 75 | uint3_t tn |
Harald Welte | c84d847 | 2017-07-30 00:49:56 +0200 | [diff] [blame] | 76 | } with { variant "FIELDLENGTH(8)" variant "FIELDORDER(msb)" }; |
Harald Welte | 0c8d5c0 | 2017-07-16 18:53:58 +0200 | [diff] [blame] | 77 | |
| 78 | template RslChannelNr t_RslChanNr0(template uint3_t tn, template RslChanNr0 cht) := { |
| 79 | u := { ch0 := cht }, |
| 80 | tn := tn |
| 81 | } |
| 82 | |
| 83 | template RslChannelNr t_RslChanNr_RACH(template uint3_t tn) := t_RslChanNr0(tn, RSL_CHAN_NR_RACH); |
| 84 | template RslChannelNr t_RslChanNr_BCCH(template uint3_t tn) := t_RslChanNr0(tn, RSL_CHAN_NR_BCCH); |
| 85 | template RslChannelNr t_RslChanNr_PCH_AGCH(template uint3_t tn) := t_RslChanNr0(tn, RSL_CHAN_NR_PCH_AGCH); |
| 86 | template RslChannelNr t_RslChanNr_Bm(template uint3_t tn) := t_RslChanNr0(tn, RSL_CHAN_NR_Bm_ACCH); |
| 87 | template RslChannelNr t_RslChanNr_Lm(template uint3_t tn, uint1_t sub_slot) := { |
| 88 | u := { lm := { tag := '0001'B, sub_chan := sub_slot } }, |
| 89 | tn := tn |
| 90 | } |
| 91 | template RslChannelNr t_RslChanNr_SDCCH4(template uint3_t tn, template uint2_t sub_slot) := { |
| 92 | u := { sdcch4 := { tag := '001'B, sub_chan := sub_slot } }, |
| 93 | tn := tn |
| 94 | } |
| 95 | template RslChannelNr t_RslChanNr_SDCCH8(template uint3_t tn, template uint3_t sub_slot) := { |
| 96 | u := { sdcch8 := { tag := '01'B, sub_chan := sub_slot } }, |
| 97 | tn := tn |
| 98 | } |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 99 | |
Harald Welte | b33e727 | 2017-07-16 21:04:12 +0200 | [diff] [blame] | 100 | /* TS 48.058 9.3.2 Link ID */ |
| 101 | type enumerated RslLinkIdC { |
| 102 | FACCH_SDCCH (0), |
| 103 | SACCH (1) |
| 104 | } with { variant "FIELDLENGTH(2)" }; |
| 105 | |
| 106 | type enumerated RslSapi0Prio { |
| 107 | SAPI0_PRIO_NORMAL (0), |
| 108 | SAPI0_PRIO_HIGH (1), |
| 109 | SAPI0_PRIO_LOW (2) |
| 110 | } with { variant "FIELDLENGTH(2)" }; |
| 111 | |
| 112 | type uint3_t GsmSapi; |
| 113 | |
| 114 | type record RslLinkId { |
| 115 | RslLinkIdC c, |
| 116 | boolean na, |
| 117 | RslSapi0Prio prio, |
| 118 | GsmSapi sapi |
| 119 | } with { variant "" }; |
| 120 | |
| 121 | template RslLinkId tr_RslLinkId := { |
| 122 | c := ?, |
| 123 | na := ?, |
| 124 | prio := ?, |
| 125 | sapi := ? |
| 126 | }; |
| 127 | |
| 128 | template RslLinkId tr_RslLinkID_DCCH(template GsmSapi sapi) modifies tr_RslLinkId := { |
| 129 | c := FACCH_SDCCH, |
| 130 | na := false, |
| 131 | sapi := sapi |
| 132 | }; |
| 133 | |
| 134 | template RslLinkId tr_RslLinkID_SACCH(template GsmSapi sapi) modifies tr_RslLinkId := { |
| 135 | c := SACCH, |
| 136 | na := false, |
| 137 | sapi := sapi |
| 138 | }; |
| 139 | |
| 140 | template RslLinkId ts_RslLinkID_DCCH(GsmSapi sapi) := { |
| 141 | c := FACCH_SDCCH, |
| 142 | na := false, |
| 143 | prio := SAPI0_PRIO_NORMAL, |
| 144 | sapi := sapi |
| 145 | }; |
| 146 | |
Harald Welte | cb5d1fb | 2017-07-17 21:00:15 +0200 | [diff] [blame] | 147 | template RslLinkId ts_RslLinkID_SACCH(GsmSapi sapi) := { |
| 148 | c := SACCH, |
| 149 | na := false, |
| 150 | prio := SAPI0_PRIO_NORMAL, |
| 151 | sapi := sapi |
Harald Welte | b33e727 | 2017-07-16 21:04:12 +0200 | [diff] [blame] | 152 | }; |
| 153 | |
Harald Welte | a082a69 | 2017-07-15 15:58:13 +0200 | [diff] [blame] | 154 | } with { encode "RAW"; variant "FIELDORDER(msb)" } |