diff options
Diffstat (limited to 'include/osmocom/gsm/gsm_utils.h')
-rw-r--r-- | include/osmocom/gsm/gsm_utils.h | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/include/osmocom/gsm/gsm_utils.h b/include/osmocom/gsm/gsm_utils.h index 0909006e..b250c594 100644 --- a/include/osmocom/gsm/gsm_utils.h +++ b/include/osmocom/gsm/gsm_utils.h @@ -17,10 +17,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * */ #pragma once @@ -37,6 +33,7 @@ } while (0) #define GSM_MAX_FN (26*51*2048) +#define GSM_FN_UNSET 0xFFFFFFFF /* Max length of random identifier which can be requested via osmo_get_rand_id() */ #define OSMO_MAX_RAND_ID_LEN 16 @@ -156,6 +153,13 @@ static inline int rach_max_trans_raw2val(int raw) { const int tbl[4] = { 1, 2, 4, 7 }; return tbl[raw & 3]; } +static inline uint8_t rach_tx_integer_raw2val(uint8_t raw) { + const int tbl[6] = { 14, 16, 20, 25, 32, 50 }; + raw &= 0x0f; + if (raw <= 9) + return raw + 3; + return tbl[raw - 10]; +} #define ARFCN_PCS 0x8000 #define ARFCN_UPLINK 0x4000 @@ -177,13 +181,21 @@ void gsm_fn2gsmtime(struct gsm_time *time, uint32_t fn); char *gsm_fn_as_gsmtime_str(uint32_t fn); /* Convert from GSM time to frame number */ -uint32_t gsm_gsmtime2fn(struct gsm_time *time); +uint32_t gsm_gsmtime2fn(const struct gsm_time *time); /* Returns static buffer with string representation of a GSM Time */ char *osmo_dump_gsmtime(const struct gsm_time *tm); char *osmo_dump_gsmtime_buf(char *buf, size_t buf_len, const struct gsm_time *tm); char *osmo_dump_gsmtime_c(const void *ctx, const struct gsm_time *tm); +/* Reduced Frame Number (3GPP TS 44.018 ยง10.5.2.38) */ +#define GSM_RFN_MODULUS 42432 +uint32_t gsm_rfn2fn(uint16_t rfn, uint32_t curr_fn); +static inline uint16_t gsm_fn2rfn(uint32_t fn) +{ + return fn % GSM_RFN_MODULUS; +} + /* GSM TS 03.03 Chapter 2.6 */ enum gprs_tlli_type { TLLI_LOCAL, @@ -213,9 +225,11 @@ enum gsm_phys_chan_config { GSM_PCHAN_UNKNOWN, GSM_PCHAN_CCCH_SDCCH4_CBCH, GSM_PCHAN_SDCCH8_SACCH8C_CBCH, - GSM_PCHAN_TCH_F_TCH_H_PDCH, + GSM_PCHAN_OSMO_DYN, _GSM_PCHAN_MAX }; +/* Backward compatibility with older naming: */ +#define GSM_PCHAN_TCH_F_TCH_H_PDCH GSM_PCHAN_OSMO_DYN /* Osmocom internal, not part of any gsm spec */ enum gsm_chan_t { |