diff options
-rw-r--r-- | openbsc/include/openbsc/pcu_if.h | 3 | ||||
-rw-r--r-- | openbsc/src/libbsc/bsc_api.c | 31 | ||||
-rw-r--r-- | openbsc/src/libbsc/pcu_sock.c | 20 |
3 files changed, 50 insertions, 4 deletions
diff --git a/openbsc/include/openbsc/pcu_if.h b/openbsc/include/openbsc/pcu_if.h index 1f398b4aa..2d85a88d7 100644 --- a/openbsc/include/openbsc/pcu_if.h +++ b/openbsc/include/openbsc/pcu_if.h @@ -26,6 +26,9 @@ int pcu_tx_imm_ass_sent(struct gsm_bts *bts, uint32_t tlli); /* Confirm the sending of an immediate assignment to the pcu */ int pcu_tx_imm_ass_sent(struct gsm_bts *bts, uint32_t tlli); +/* forward data from a RR GPRS SUSPEND REQ towards PCU */ +int pcu_tx_susp_req(struct gsm_lchan *lchan, uint32_t tlli, const uint8_t *ra_id, uint8_t cause); + /* Open connection to PCU */ int pcu_sock_init(const char *path, struct gsm_bts *bts); diff --git a/openbsc/src/libbsc/bsc_api.c b/openbsc/src/libbsc/bsc_api.c index 7613cac90..a7675fbab 100644 --- a/openbsc/src/libbsc/bsc_api.c +++ b/openbsc/src/libbsc/bsc_api.c @@ -2,7 +2,7 @@ /* (C) 2010-2011 by Holger Hans Peter Freyther * (C) 2010-2011 by On-Waves - * (C) 2009 by Harald Welte <laforge@gnumonks.org> + * (C) 2009-2017 by Harald Welte <laforge@gnumonks.org> * * All Rights Reserved * @@ -32,11 +32,13 @@ #include <openbsc/debug.h> #include <openbsc/gsm_04_08.h> #include <openbsc/trau_mux.h> +#include <openbsc/pcu_if.h> #include <osmocom/gsm/protocol/gsm_08_08.h> #include <osmocom/gsm/gsm48.h> #include <osmocom/core/talloc.h> +#include <osmocom/core/byteswap.h> #define GSM0808_T10_VALUE 6, 0 @@ -570,6 +572,30 @@ static void handle_rr_ho_fail(struct msgb *msg) /* FIXME: release allocated new channel */ } +/* TS 44.018 9.1.13b GPRS suspension request */ +static int handle_gprs_susp_req(struct msgb *msg) +{ + struct gsm48_hdr *gh = msgb_l3(msg); + struct gsm48_gprs_susp_req *gsr; + uint32_t tlli; + int rc; + + if (!gh || msgb_l3len(msg) < sizeof(*gh)+sizeof(*gsr)) { + LOGP(DRSL, LOGL_NOTICE, "%s Short GPRS SUSPEND REQ received, ignoring\n", gsm_lchan_name(msg->lchan)); + return -EINVAL; + } + + gsr = (struct gsm48_gprs_susp_req *) gh->data; + tlli = osmo_ntohl(gsr->tlli); + + LOGP(DRSL, LOGL_INFO, "%s Fwd GPRS SUSPEND REQ for TLLI=0x%08x to PCU\n", + gsm_lchan_name(msg->lchan), tlli); + rc = pcu_tx_susp_req(msg->lchan, tlli, gsr->ra_id, gsr->cause); + + msgb_free(msg); + + return rc; +} static void dispatch_dtap(struct gsm_subscriber_connection *conn, uint8_t link_id, struct msgb *msg) @@ -599,8 +625,7 @@ static void dispatch_dtap(struct gsm_subscriber_connection *conn, case GSM48_PDISC_RR: switch (msg_type) { case GSM48_MT_RR_GPRS_SUSP_REQ: - DEBUGP(DRR, "%s\n", - gsm48_rr_msg_name(GSM48_MT_RR_GPRS_SUSP_REQ)); + handle_gprs_susp_req(msg); break; case GSM48_MT_RR_STATUS: LOGP(DRR, LOGL_NOTICE, "%s (cause: %s)\n", diff --git a/openbsc/src/libbsc/pcu_sock.c b/openbsc/src/libbsc/pcu_sock.c index 98e12fad4..637e4c6a3 100644 --- a/openbsc/src/libbsc/pcu_sock.c +++ b/openbsc/src/libbsc/pcu_sock.c @@ -1,6 +1,6 @@ /* pcu_sock.c: Connect from PCU via unix domain socket */ -/* (C) 2008-2010 by Harald Welte <laforge@gnumonks.org> +/* (C) 2008-2017 by Harald Welte <laforge@gnumonks.org> * (C) 2009-2012 by Andreas Eversberg <jolly@eversberg.eu> * (C) 2012 by Holger Hans Peter Freyther * All Rights Reserved @@ -307,6 +307,24 @@ int pcu_tx_imm_ass_sent(struct gsm_bts *bts, uint32_t tlli) return pcu_sock_send(bts, msg); } +/* forward data from a RR GPRS SUSPEND REQ towards PCU */ +int pcu_tx_susp_req(struct gsm_lchan *lchan, uint32_t tlli, const uint8_t *ra_id, uint8_t cause) +{ + struct gsm_bts *bts = lchan->ts->trx->bts; + struct msgb *msg; + struct gsm_pcu_if *pcu_prim; + + msg = pcu_msgb_alloc(PCU_IF_MSG_SUSP_REQ, bts->nr); + if (!msg) + return -ENOMEM; + pcu_prim = (struct gsm_pcu_if *) msg->data; + pcu_prim->u.susp_req.tlli = tlli; + memcpy(pcu_prim->u.susp_req.ra_id, ra_id, sizeof(pcu_prim->u.susp_req.ra_id)); + pcu_prim->u.susp_req.cause = cause; + + return pcu_sock_send(bts, msg); +} + /* we need to decode the raw RR paging messsage (see PCU code * Encoding::write_paging_request) and extract the mobile identity * (P-TMSI) from it */ |