import gsm0502_calc_paging_group() from openbsc
[osmocom-bb.git] / include / osmocom / gsm / gsm0502.h
1 #ifndef OSMOCOM_GSM_0502_H
2 #define OSMOCOM_GSM_0502_H
3
4 #include <stdint.h>
5
6 #include <osmocom/gsm/protocol/gsm_04_08.h>
7 #include <osmocom/gsm/protocol/gsm_08_58.h>
8
9 /* Table 5 Clause 7 TS 05.02 */
10 static inline unsigned int
11 gsm0502_get_n_pag_blocks(struct gsm48_control_channel_descr *chan_desc)
12 {
13         if (chan_desc->ccch_conf == RSL_BCCH_CCCH_CONF_1_C)
14                 return 3 - chan_desc->bs_ag_blks_res;
15         else
16                 return 9 - chan_desc->bs_ag_blks_res;
17 }
18
19 /* Chapter 6.5.2 of TS 05.02 */
20 static inline unsigned int
21 gsm0502_get_ccch_group(uint64_t imsi, unsigned int bs_cc_chans,
22                         unsigned int n_pag_blocks)
23 {
24         return (imsi % 1000) % (bs_cc_chans * n_pag_blocks) / n_pag_blocks;
25 }
26
27 /* Chapter 6.5.2 of TS 05.02 */
28 static inline unsigned int
29 gsm0502_get_paging_group(uint64_t imsi, unsigned int bs_cc_chans,
30                          int n_pag_blocks)
31 {
32         return (imsi % 1000) % (bs_cc_chans * n_pag_blocks) % n_pag_blocks;
33 }
34
35 unsigned int
36 gsm0502_calc_paging_group(struct gsm48_control_channel_descr *chan_desc, uint64_t imsi);
37
38 #endif