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