summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-07-29 10:09:12 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-07-31 14:57:21 +0200
commit7e0fec17ceeccfe2bfb74c13d19eb44558ddb535 (patch)
treee04b5aa48fd1bd1ce96d7c2160f8e54e05709b12
parent964a9b3e20b67bebf8d1878ee5c651c10fdd2a94 (diff)
gprs_llc: Assert that we send frames with either tlli or old_tlli
In case we have access to the context verify that the selected msgb_tlli is either the old_tlli or the tlli in either local or foreign format. It is wrong to use any other TLLI.
-rw-r--r--openbsc/src/gprs/gprs_llc.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/openbsc/src/gprs/gprs_llc.c b/openbsc/src/gprs/gprs_llc.c
index 5a74a63..c4be086 100644
--- a/openbsc/src/gprs/gprs_llc.c
+++ b/openbsc/src/gprs/gprs_llc.c
@@ -84,6 +84,21 @@ struct gprs_llc_hdr_parsed {
static struct gprs_llc_llme *llme_alloc(uint32_t tlli);
+/* If the TLLI is foreign, return its local version */
+static inline uint32_t tlli_foreign2local(uint32_t tlli)
+{
+ uint32_t new_tlli;
+
+ if (gprs_tlli_type(tlli) == TLLI_FOREIGN) {
+ new_tlli = tlli | 0x40000000;
+ DEBUGP(DLLC, "TLLI 0x%08x is foreign, converting to "
+ "local TLLI 0x%08x\n", tlli, new_tlli);
+ } else
+ new_tlli = tlli;
+
+ return new_tlli;
+}
+
/* Entry function from upper level (LLC), asking us to transmit a BSSGP PDU
* to a remote MS (identified by TLLI) at a BTS identified by its BVCI and NSEI */
static int _bssgp_tx_dl_ud(struct msgb *msg, struct sgsn_mm_ctx *mmctx)
@@ -100,6 +115,12 @@ static int _bssgp_tx_dl_ud(struct msgb *msg, struct sgsn_mm_ctx *mmctx)
dup.drx_parms = mmctx->drx_parms;
dup.ms_ra_cap.len = mmctx->ms_radio_access_capa.len;
dup.ms_ra_cap.v = mmctx->ms_radio_access_capa.buf;
+
+ /* make sure we only send it to the right llme */
+ OSMO_ASSERT(msgb_tlli(msg) == mmctx->llme->tlli
+ || msgb_tlli(msg) == mmctx->llme->old_tlli
+ || tlli_foreign2local(msgb_tlli(msg)) == mmctx->llme->tlli
+ || tlli_foreign2local(msgb_tlli(msg)) == mmctx->llme->old_tlli);
}
memcpy(&dup.qos_profile, qos_profile_default,
sizeof(qos_profile_default));
@@ -179,21 +200,6 @@ static const struct gprs_llc_params llc_default_params[] = {
LLIST_HEAD(gprs_llc_llmes);
void *llc_tall_ctx;
-/* If the TLLI is foreign, return its local version */
-static inline uint32_t tlli_foreign2local(uint32_t tlli)
-{
- uint32_t new_tlli;
-
- if (gprs_tlli_type(tlli) == TLLI_FOREIGN) {
- new_tlli = tlli | 0x40000000;
- DEBUGP(DLLC, "TLLI 0x%08x is foreign, converting to "
- "local TLLI 0x%08x\n", tlli, new_tlli);
- } else
- new_tlli = tlli;
-
- return new_tlli;
-}
-
/* lookup LLC Entity based on DLCI (TLLI+SAPI tuple) */
static struct gprs_llc_lle *lle_by_tlli_sapi(const uint32_t tlli, uint8_t sapi)
{