blob: 46b629e4e8bf47ae78f90be755a0ecda7c9d01ae [file] [log] [blame]
Harald Welte94df39e2011-06-26 14:33:57 +02001#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 */
10static inline unsigned int
11gsm0502_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 */
20static inline unsigned int
21gsm0502_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 */
28static inline unsigned int
29gsm0502_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
Harald Welteea19c972011-06-26 14:47:16 +020035unsigned int
36gsm0502_calc_paging_group(struct gsm48_control_channel_descr *chan_desc, uint64_t imsi);
37
Harald Welte94df39e2011-06-26 14:33:57 +020038#endif