dexter submitted this change.
pcu_sock: use PCUIF version 11 (direct TLLI)
OsmoBTS still uses the deprecated version 10 of the PCUIF protocol.
OsmoPCU is still compatible to version 10, but to maintain a clean
interface it is planned to drop the support for version 10 in the near
future.
Moving to PCUIF v.11 essentially means using the "Direct TLLI" method to
convey IMMEDIATE ASSIGNMENT and also PAGING COMMAND messages through the
PCU socket. This means in particular that we use a TLLI as an identifier
to confirm IMMEDIATE ASSIGNMENT messages towards the PCU (PAGING COMMAND
is not confirmed at all). Also we now use struct gsm_pcu_if_pch_dt to
parse the incoming PCU_IF_SAPI_PCH_DT, which is much cleaner than using
offsets in a buffer.
Change-Id: I25816ac12e63cc6b641eb414e6bc7eaa9c85fc25
Depends: osmo-ttcn3-hacks.git I08de02e951e10bc8b4381cc2ad32e63f2747e3c4
Depends: docker-playground.git Ia28bc0d6d3cbfe63be19443db86631fb67bb80fb
Related: OS#5927
---
M include/osmo-bts/paging.h
M include/osmo-bts/pcu_if.h
M include/osmo-bts/pcuif_proto.h
M src/common/paging.c
M src/common/pcu_sock.c
5 files changed, 67 insertions(+), 28 deletions(-)
diff --git a/include/osmo-bts/paging.h b/include/osmo-bts/paging.h
index 9a30abb..d604536 100644
--- a/include/osmo-bts/paging.h
+++ b/include/osmo-bts/paging.h
@@ -37,7 +37,7 @@
/* Add a ready formatted MAC block message to the paging queue, this can be an IMMEDIATE ASSIGNMENT, or a
* PAGING COMMAND (from the PCU) */
-int paging_add_macblock(struct paging_state *ps, const char *imsi, bool confirm, const uint8_t *macblock);
+int paging_add_macblock(struct paging_state *ps, uint32_t tlli, const char *imsi, bool confirm, const uint8_t *macblock);
/* generate paging message for given gsm time */
int paging_gen_msg(struct paging_state *ps, uint8_t *out_buf, struct gsm_time *gt,
diff --git a/include/osmo-bts/pcu_if.h b/include/osmo-bts/pcu_if.h
index 8e3b3ba..b8ce9c4 100644
--- a/include/osmo-bts/pcu_if.h
+++ b/include/osmo-bts/pcu_if.h
@@ -23,7 +23,7 @@
int pcu_tx_time_ind(uint32_t fn);
int pcu_tx_interf_ind(const struct gsm_bts_trx *trx, uint32_t fn);
int pcu_tx_pag_req(const uint8_t *identity_lv, uint8_t chan_needed);
-int pcu_tx_pch_data_cnf(uint32_t fn, uint8_t *data, uint8_t len);
+int pcu_tx_pch_data_cnf(uint32_t fn, uint32_t tlli);
int pcu_tx_susp_req(struct gsm_lchan *lchan, uint32_t tlli, const uint8_t *ra_id, uint8_t cause);
int pcu_sock_send(struct msgb *msg);
diff --git a/include/osmo-bts/pcuif_proto.h b/include/osmo-bts/pcuif_proto.h
index 0fece48..bae6cda 100644
--- a/include/osmo-bts/pcuif_proto.h
+++ b/include/osmo-bts/pcuif_proto.h
@@ -3,10 +3,11 @@
#include <osmocom/gsm/l1sap.h>
#include <arpa/inet.h>
+#include <osmocom/gsm/protocol/gsm_23_003.h>
#define PCU_SOCK_DEFAULT "/tmp/pcu_bts"
-#define PCU_IF_VERSION 0x0a
+#define PCU_IF_VERSION 0x0b
#define TXT_MAX_LEN 128
/* msg_type */
@@ -34,7 +35,7 @@
#define PCU_IF_SAPI_PDTCH 0x05 /* packet data/control/ccch block */
#define PCU_IF_SAPI_PRACH 0x06 /* packet random access channel */
#define PCU_IF_SAPI_PTCCH 0x07 /* packet TA control channel */
-#define PCU_IF_SAPI_AGCH_DT 0x08 /* assignment on AGCH but with additional TLLI */
+#define PCU_IF_SAPI_PCH_DT 0x08 /* assignment on PCH (confirmed using TLLI) */
/* flags */
#define PCU_IF_FLAG_ACTIVE (1 << 0)/* BTS is active */
@@ -229,6 +230,17 @@
uint8_t data[0];
} __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 */
diff --git a/src/common/paging.c b/src/common/paging.c
index 55f85f6..0ea7de7 100644
--- a/src/common/paging.c
+++ b/src/common/paging.c
@@ -64,6 +64,7 @@
struct {
uint8_t msg[GSM_MACBLOCK_LEN];
bool confirm;
+ uint32_t tlli; /* used as identifier for confirmation */
} macblock;
} u;
};
@@ -270,7 +271,7 @@
/* Add a ready formatted MAC block message to the paging queue, this can be an IMMEDIATE ASSIGNMENT, or a
* PAGING COMMAND (from the PCU) */
-int paging_add_macblock(struct paging_state *ps, const char *imsi, bool confirm, const uint8_t *macblock)
+int paging_add_macblock(struct paging_state *ps, uint32_t tlli, const char *imsi, bool confirm, const uint8_t *macblock)
{
struct llist_head *group_q;
struct paging_record *pr;
@@ -308,6 +309,7 @@
paging_group);
memcpy(pr->u.macblock.msg, macblock, GSM_MACBLOCK_LEN);
pr->u.macblock.confirm = confirm;
+ pr->u.macblock.tlli = tlli;
/* enqueue the new message to the HEAD of the queue */
llist_add(&pr->list, group_q);
@@ -627,7 +629,7 @@
num_imsi++;
}
- /* if we have a MAC block (from the PCU), we send a conformation back */
+ /* Handle MAC block (from the PCU) */
if (macblock) {
/* re-add normal paging records */
for (i = 0; i < num_pr; i++)
@@ -636,10 +638,9 @@
/* get MAC block message and free record */
memcpy(out_buf, pr[num_pr]->u.macblock.msg,
GSM_MACBLOCK_LEN);
- if (pr[num_pr]->u.macblock.confirm) {
- pcu_tx_pch_data_cnf(gt->fn, pr[num_pr]->u.macblock.msg,
- GSM_MACBLOCK_LEN);
- }
+ /* send a confirmation back (if required) */
+ if (pr[num_pr]->u.macblock.confirm)
+ pcu_tx_pch_data_cnf(gt->fn, pr[num_pr]->u.macblock.tlli);
talloc_free(pr[num_pr]);
return GSM_MACBLOCK_LEN;
}
diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c
index 33b6740..8f34c33 100644
--- a/src/common/pcu_sock.c
+++ b/src/common/pcu_sock.c
@@ -59,6 +59,7 @@
[PCU_IF_SAPI_PDTCH] = "PDTCH",
[PCU_IF_SAPI_PRACH] = "PRACH",
[PCU_IF_SAPI_PTCCH] = "PTCCH",
+ [PCU_IF_SAPI_PCH_DT] = "PCH_DT",
};
/*
@@ -617,28 +618,26 @@
return pcu_sock_send(msg);
}
-int pcu_tx_pch_data_cnf(uint32_t fn, uint8_t *data, uint8_t len)
+int pcu_tx_pch_data_cnf(uint32_t fn, uint32_t tlli)
{
struct gsm_bts *bts;
struct msgb *msg;
struct gsm_pcu_if *pcu_prim;
- struct gsm_pcu_if_data *data_cnf;
/* FIXME: allow multiple BTS */
bts = llist_entry(g_bts_sm->bts_list.next, struct gsm_bts, list);
LOGP(DPCU, LOGL_DEBUG, "Sending PCH confirm\n");
- msg = pcu_msgb_alloc(PCU_IF_MSG_DATA_CNF, bts->nr);
+ msg = pcu_msgb_alloc(PCU_IF_MSG_DATA_CNF_DT, bts->nr);
if (!msg)
return -ENOMEM;
pcu_prim = (struct gsm_pcu_if *) msg->data;
- data_cnf = &pcu_prim->u.data_cnf;
-
- data_cnf->sapi = PCU_IF_SAPI_PCH;
- data_cnf->fn = fn;
- memcpy(data_cnf->data, data, len);
- data_cnf->len = len;
+ pcu_prim->u.data_cnf_dt = (struct gsm_pcu_if_data_cnf_dt) {
+ .sapi = PCU_IF_SAPI_PCH_DT,
+ .tlli = tlli,
+ .fn = fn,
+ };
return pcu_sock_send(msg);
}
@@ -675,21 +674,23 @@
osmo_hexdump(data_req->data, data_req->len));
switch (data_req->sapi) {
- case PCU_IF_SAPI_PCH:
+ case PCU_IF_SAPI_PCH_DT:
{
+ const struct gsm_pcu_if_pch_dt *gsm_pcu_if_pch_dt;
const struct gsm48_imm_ass *gsm48_imm_ass;
bool confirm;
- char imsi[4];
- OSMO_STRLCPY_ARRAY(imsi, (char *)data_req->data);
- if (data_req->len-3 != GSM_MACBLOCK_LEN) {
- LOGP(DPCU, LOGL_ERROR, "MAC block with invalid length %d (expecting GSM_MACBLOCK_LEN = %d)\n",
- data_req->len-3, GSM_MACBLOCK_LEN);
- rc = -ENOMEM;
+
+ if (OSMO_UNLIKELY(data_req->len != sizeof(*gsm_pcu_if_pch_dt))) {
+ LOGP(DPCU, LOGL_ERROR, "Rx malformed DATA.req for PCH\n");
+ rc = -EINVAL;
break;
}
- gsm48_imm_ass = (struct gsm48_imm_ass *)(data_req->data + 3);
+
+ gsm_pcu_if_pch_dt = (struct gsm_pcu_if_pch_dt *)data_req->data;
+ gsm48_imm_ass = (struct gsm48_imm_ass *)gsm_pcu_if_pch_dt->data;
confirm = (gsm48_imm_ass->msg_type == GSM48_MT_RR_IMM_ASS);
- paging_add_macblock(bts->paging_state, imsi, confirm, data_req->data + 3);
+ rc = paging_add_macblock(bts->paging_state, gsm_pcu_if_pch_dt->tlli,
+ gsm_pcu_if_pch_dt->imsi, confirm, gsm_pcu_if_pch_dt->data);
break;
}
case PCU_IF_SAPI_AGCH:
To view, visit change 33522. To unsubscribe, or for help writing mail filters, visit settings.