blob: fe5cf7e17e7106af05c770e9afe5a078df166dd8 [file] [log] [blame]
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02001/*! \file gsm0502.h */
2
Sylvain Munaut12ba7782014-06-16 10:13:40 +02003#pragma once
Harald Welte94df39e2011-06-26 14:33:57 +02004
5#include <stdint.h>
6
7#include <osmocom/gsm/protocol/gsm_04_08.h>
8#include <osmocom/gsm/protocol/gsm_08_58.h>
9
10/* Table 5 Clause 7 TS 05.02 */
11static inline unsigned int
12gsm0502_get_n_pag_blocks(struct gsm48_control_channel_descr *chan_desc)
13{
14 if (chan_desc->ccch_conf == RSL_BCCH_CCCH_CONF_1_C)
15 return 3 - chan_desc->bs_ag_blks_res;
16 else
17 return 9 - chan_desc->bs_ag_blks_res;
18}
19
20/* Chapter 6.5.2 of TS 05.02 */
21static inline unsigned int
22gsm0502_get_ccch_group(uint64_t imsi, unsigned int bs_cc_chans,
23 unsigned int n_pag_blocks)
24{
25 return (imsi % 1000) % (bs_cc_chans * n_pag_blocks) / n_pag_blocks;
26}
27
28/* Chapter 6.5.2 of TS 05.02 */
29static inline unsigned int
30gsm0502_get_paging_group(uint64_t imsi, unsigned int bs_cc_chans,
31 int n_pag_blocks)
32{
33 return (imsi % 1000) % (bs_cc_chans * n_pag_blocks) % n_pag_blocks;
34}
35
Harald Welteea19c972011-06-26 14:47:16 +020036unsigned int
37gsm0502_calc_paging_group(struct gsm48_control_channel_descr *chan_desc, uint64_t imsi);