pcu_sock: use struct to transfer IMMEDIATE ASSIGNMENT for PCH

When the IMMEDIATE ASSIGNMENT is sent from the PCU to the BSC using the
"direct TLLI" method, the TLLI (and the last three digits of the IMSI)
is prepended to the MAC block. Currently we are taking the fields apart
manually using offsets. The code for this is difficult to read and the
method is error prone. Let's define a struct that we can just overlay
to access the fields directly. Let's also transfer the full IMSI.

Change-Id: Id6acbd243adf26169e5e8319dd66bb68dd6a3c22
Related: OS#5198
This commit is contained in:
Philipp Maier 2023-02-27 20:14:08 +01:00 committed by laforge
parent ecf825dc08
commit 6902fccb1b
2 changed files with 21 additions and 10 deletions

View File

@ -3,6 +3,8 @@
#include <osmocom/gsm/l1sap.h>
#include <arpa/inet.h>
#include <osmocom/gsm/protocol/gsm_04_08.h>
#include <osmocom/gsm/protocol/gsm_23_003.h>
#define PCU_SOCK_DEFAULT "/tmp/pcu_bts"
@ -270,6 +272,17 @@ struct gsm_pcu_if_neigh_addr_cnf {
} cgi_ps;
} __attribute__ ((packed));
/* Struct to send a (confirmed) IMMEDIATE ASSIGNMENT message via PCH. The struct is sent as a data request
* (data_req) under SAPI PCU_IF_SAPI_PCH_DT. */
struct gsm_pcu_if_pch_dt {
/* TLLI as reference for confirmation */
uint32_t tlli;
/* IMSI (to derive paging group) */
char imsi[OSMO_IMSI_BUF_SIZE];
/* GSM mac-block (with immediate assignment message) */
uint8_t data[GSM_MACBLOCK_LEN];
} __attribute__((packed));
struct gsm_pcu_if {
/* context based information */
uint8_t msg_type; /* message type */

View File

@ -535,9 +535,9 @@ static uint8_t extract_paging_group(struct gsm_bts *bts, uint8_t *data)
static int pcu_rx_data_req(struct gsm_bts *bts, uint8_t msg_type,
struct gsm_pcu_if_data *data_req)
{
uint32_t tlli = -1;
uint8_t pag_grp;
int rc = 0;
struct gsm_pcu_if_pch_dt *pch_dt;
LOGP(DPCU, LOGL_DEBUG, "Data request received: sapi=%s arfcn=%d "
"block=%d data=%s\n", sapi_string[data_req->sapi],
@ -558,27 +558,25 @@ static int pcu_rx_data_req(struct gsm_bts *bts, uint8_t msg_type,
/* DT = direct TLLI. A tlli is prefixed so that the BSC/BTS can confirm the sending of the downlink
* IMMEDIATE ASSIGNMENT towards the PCU using this TLLI as a reference. */
if (data_req->len < 8) {
if (data_req->len < sizeof(struct gsm_pcu_if_pch_dt)) {
LOGP(DPCU, LOGL_ERROR, "Received PCU data request with invalid/small length %d\n",
data_req->len);
break;
}
/* Extract 4 byte TLLI */
memcpy(&tlli, data_req->data, 4);
pch_dt = (struct gsm_pcu_if_pch_dt *)data_req->data;
pag_grp = gsm0502_calc_paging_group(&bts->si_common.chan_desc, str_to_imsi(pch_dt->imsi));
/* Extract 3 byte paging group */
pag_grp = extract_paging_group(bts, data_req->data + 4);
LOGP(DPCU, LOGL_DEBUG, "PCU Sends immediate assignment via PCH (tlli=0x%08x, pag_grp=0x%02x)\n",
tlli, pag_grp);
LOGP(DPCU, LOGL_DEBUG, "PCU Sends immediate assignment via PCH (TLLI=0x%08x, IMSI=%s, Paging group=0x%02x)\n",
pch_dt->tlli, pch_dt->imsi, pag_grp);
/* NOTE: Sending an IMMEDIATE ASSIGNMENT via PCH became necessary with GPRS in order to be able to
* assign downlink TBFs directly through the paging channel. However, this method never became part
* of the RSL specs. This means that each BTS vendor has to come up with a proprietary method. At
* the moment we only support Ericsson RBS here. */
if (bts->type == GSM_BTS_TYPE_RBS2000) {
rc = rsl_ericsson_imm_assign_cmd(bts, tlli, data_req->len - 7, data_req->data + 7, pag_grp);
rc = rsl_ericsson_imm_assign_cmd(bts, pch_dt->tlli, sizeof(pch_dt->data),
pch_dt->data, pag_grp);
} else {
LOGP(DPCU, LOGL_ERROR, "BTS model does not support sending immediate assignment via PCH!\n");
rc = -ENOTSUP;