aboutsummaryrefslogtreecommitdiffstats
path: root/src/pcu_l1_if.cpp
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2023-03-03 16:04:26 +0100
committerPhilipp Maier <pmaier@sysmocom.de>2023-03-20 10:54:28 +0100
commit41e38475edfae844726ca9c9cc754eefb0a03276 (patch)
tree676c66df0e6863ea273a1bc1109b3fd81719d0b3 /src/pcu_l1_if.cpp
parent4bac39892399e2056fc03981140d654eb65b6e54 (diff)
pcu_l1_if: get rid of strange paging group calculation
The PCU uses a 16 bit integer value as paging group which does in fact not really resamble the paging group. Instead it encodes the last three digits of the IMSI from which the paging group can be calculated. The value is then eventually converted back to Ascii-digits and then sent over the PCU-IF interface. Lets get rid of this weird conversion and use the IMSI directly. Change-Id: I40d7fc14c9591b3de091e425faaf325421c70a0e
Diffstat (limited to 'src/pcu_l1_if.cpp')
-rw-r--r--src/pcu_l1_if.cpp44
1 files changed, 10 insertions, 34 deletions
diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index 6ec806be..84d39cb7 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -59,8 +59,6 @@ extern "C" {
extern void *tall_pcu_ctx;
-#define PAGING_GROUP_LEN 3
-
struct e1_ccu_conn_pars {
struct llist_head entry;
@@ -78,27 +76,6 @@ struct e1_ccu_conn_pars {
* when it is needed. */
static LLIST_HEAD(e1_ccu_table);
-/* returns [0,999] on success, > 999 on error */
-uint16_t imsi2paging_group(const char* imsi)
-{
- uint16_t pgroup = 0;
- size_t len;
-
- len = (imsi != NULL) ? strlen(imsi) : 0;
- if (len < PAGING_GROUP_LEN)
- return 0xFFFF;
- imsi += len - PAGING_GROUP_LEN;
-
- while (*imsi != '\0') {
- if (!isdigit(*imsi))
- return 0xFFFF;
- pgroup *= 10;
- pgroup += *imsi - '0';
- imsi++;
- }
- return pgroup;
-}
-
/*
* PCU messages
*/
@@ -286,24 +263,23 @@ void pcu_l1if_tx_agch(struct gprs_rlcmac_bts *bts, bitvec *block, int plen)
pcu_tx_data_req(bts, 0, 0, PCU_IF_SAPI_AGCH, 0, 0, 0, data, sizeof(data));
}
-void pcu_l1if_tx_pch(struct gprs_rlcmac_bts *bts, bitvec *block, int plen, uint16_t pgroup)
+#define IMSI_DIGITS_FOR_PAGING 3
+void pcu_l1if_tx_pch(struct gprs_rlcmac_bts *bts, bitvec *block, int plen, const char *imsi)
{
- uint8_t data[PAGING_GROUP_LEN + GSM_MACBLOCK_LEN];
- int i;
+ uint8_t data[IMSI_DIGITS_FOR_PAGING + GSM_MACBLOCK_LEN];
- /* prepend paging group */
- for (i = 0; i < PAGING_GROUP_LEN; i++) {
- data[PAGING_GROUP_LEN - 1 - i] = '0' + (char)(pgroup % 10);
- pgroup = pgroup / 10;
- }
- OSMO_ASSERT(pgroup == 0);
+ /* prepend last three IMSI digits (if present) from which BTS/BSC will calculate the paging group */
+ if (imsi && strlen(imsi) >= IMSI_DIGITS_FOR_PAGING)
+ memcpy(data, imsi + strlen(imsi) - IMSI_DIGITS_FOR_PAGING, IMSI_DIGITS_FOR_PAGING);
+ else
+ memset(data, '0', IMSI_DIGITS_FOR_PAGING);
/* block provided by upper layer comes without first byte (plen),
* prepend it manually:
*/
- OSMO_ASSERT(sizeof(data) >= PAGING_GROUP_LEN + 1 + block->data_len);
+ OSMO_ASSERT(sizeof(data) >= IMSI_DIGITS_FOR_PAGING + 1 + block->data_len);
data[3] = (plen << 2) | 0x01;
- bitvec_pack(block, data + PAGING_GROUP_LEN + 1);
+ bitvec_pack(block, data + IMSI_DIGITS_FOR_PAGING + 1);
if (the_pcu->gsmtap_categ_mask & (1 << PCU_GSMTAP_C_DL_PCH))
gsmtap_send(the_pcu->gsmtap, 0, 0, GSMTAP_CHANNEL_PCH, 0, 0, 0, 0, data + 3, GSM_MACBLOCK_LEN);