libosmogsm  0.9.3
Osmocom GSM library
include/osmocom/gsm/gsm0502.h
00001 #pragma once
00002 
00003 #include <stdint.h>
00004 
00005 #include <osmocom/gsm/protocol/gsm_04_08.h>
00006 #include <osmocom/gsm/protocol/gsm_08_58.h>
00007 
00008 /* Table 5 Clause 7 TS 05.02 */
00009 static inline unsigned int
00010 gsm0502_get_n_pag_blocks(struct gsm48_control_channel_descr *chan_desc)
00011 {
00012         if (chan_desc->ccch_conf == RSL_BCCH_CCCH_CONF_1_C)
00013                 return 3 - chan_desc->bs_ag_blks_res;
00014         else
00015                 return 9 - chan_desc->bs_ag_blks_res;
00016 }
00017 
00018 /* Chapter 6.5.2 of TS 05.02 */
00019 static inline unsigned int
00020 gsm0502_get_ccch_group(uint64_t imsi, unsigned int bs_cc_chans,
00021                         unsigned int n_pag_blocks)
00022 {
00023         return (imsi % 1000) % (bs_cc_chans * n_pag_blocks) / n_pag_blocks;
00024 }
00025 
00026 /* Chapter 6.5.2 of TS 05.02 */
00027 static inline unsigned int
00028 gsm0502_get_paging_group(uint64_t imsi, unsigned int bs_cc_chans,
00029                          int n_pag_blocks)
00030 {
00031         return (imsi % 1000) % (bs_cc_chans * n_pag_blocks) % n_pag_blocks;
00032 }
00033 
00034 unsigned int
00035 gsm0502_calc_paging_group(struct gsm48_control_channel_descr *chan_desc, uint64_t imsi);