aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2022-12-23 16:33:17 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2022-12-28 23:11:49 +0100
commit7a74ae492e878c1511c3e35f46e7706d69ca0ddf (patch)
tree6be4fb6d7f728d99d8f05f904780026eb0f88cc0 /src
parent749ca7c850adcb4ae8cc2dfbac8d95e12773769d (diff)
Create new specific file for BSSGP code
Right now there's no much code there since the related code is totally entangled with the LLC one. This will eventually change in the future when we switch to use libosmo-gprs. Hence, this commit is a preparation to have already some place to put new BSSGP specific code in the future. Change-Id: I816396ab5ccb86032bbc21b41a959934a7768780
Diffstat (limited to 'src')
-rw-r--r--src/sgsn/Makefile.am1
-rw-r--r--src/sgsn/gprs_bssgp.c94
-rw-r--r--src/sgsn/gprs_gb.c34
-rw-r--r--src/sgsn/sgsn_libgtp.c3
-rw-r--r--src/sgsn/sgsn_main.c32
-rw-r--r--src/sgsn/sgsn_vty.c3
6 files changed, 104 insertions, 63 deletions
diff --git a/src/sgsn/Makefile.am b/src/sgsn/Makefile.am
index 9e4a34264..8bc5ccb61 100644
--- a/src/sgsn/Makefile.am
+++ b/src/sgsn/Makefile.am
@@ -40,6 +40,7 @@ bin_PROGRAMS = \
$(NULL)
osmo_sgsn_SOURCES = \
+ gprs_bssgp.c \
gprs_gb.c \
gprs_gmm_attach.c \
gprs_gmm.c \
diff --git a/src/sgsn/gprs_bssgp.c b/src/sgsn/gprs_bssgp.c
new file mode 100644
index 000000000..d6bd25f9d
--- /dev/null
+++ b/src/sgsn/gprs_bssgp.c
@@ -0,0 +1,94 @@
+/* GPRS BSSGP protocol implementation as per 3GPP TS 08.18 */
+
+/* (C) 2010 by Harald Welte <laforge@gnumonks.org>
+ * (C) 2010 by On-Waves
+ * (C) 2022 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+#include <osmocom/core/prim.h>
+#include <osmocom/core/rate_ctr.h>
+
+#include <osmocom/gprs/gprs_bssgp.h>
+#include <osmocom/gprs/gprs_ns2.h>
+
+#include <osmocom/sgsn/gprs_llc.h>
+#include <osmocom/sgsn/gprs_gmm.h>
+#include <osmocom/sgsn/sgsn_rim.h>
+
+/* call-back function for the BSSGP protocol */
+int sgsn_bssgp_rx_prim(struct osmo_prim_hdr *oph)
+{
+ struct osmo_bssgp_prim *bp;
+ bp = container_of(oph, struct osmo_bssgp_prim, oph);
+
+ switch (oph->sap) {
+ case SAP_BSSGP_LL:
+ switch (oph->primitive) {
+ case PRIM_BSSGP_UL_UD:
+ return gprs_llc_rcvmsg(oph->msg, bp->tp);
+ }
+ break;
+ case SAP_BSSGP_GMM:
+ switch (oph->primitive) {
+ case PRIM_BSSGP_GMM_SUSPEND:
+ return gprs_gmm_rx_suspend(bp->ra_id, bp->tlli);
+ case PRIM_BSSGP_GMM_RESUME:
+ return gprs_gmm_rx_resume(bp->ra_id, bp->tlli,
+ bp->u.resume.suspend_ref);
+ }
+ break;
+ case SAP_BSSGP_NM:
+ break;
+ case SAP_BSSGP_RIM:
+ return sgsn_rim_rx_from_gb(bp, oph->msg);
+ }
+ return 0;
+}
+
+int sgsn_bssgp_page_ps_ra(struct sgsn_mm_ctx *mmctx)
+{
+ struct bssgp_paging_info pinfo;
+ int rc;
+
+ /* FIXME: page whole routing area, not only the last known cell */
+
+ /* initiate PS PAGING procedure */
+ memset(&pinfo, 0, sizeof(pinfo));
+ pinfo.mode = BSSGP_PAGING_PS;
+ pinfo.scope = BSSGP_PAGING_BVCI;
+ pinfo.bvci = mmctx->gb.bvci;
+ pinfo.imsi = mmctx->imsi;
+ pinfo.ptmsi = &mmctx->p_tmsi;
+ pinfo.drx_params = mmctx->drx_parms;
+ pinfo.qos[0] = 0; // FIXME
+ rc = bssgp_tx_paging(mmctx->gb.nsei, 0, &pinfo);
+ rate_ctr_inc(rate_ctr_group_get_ctr(mmctx->ctrg, GMM_CTR_PAGING_PS));
+
+ return rc;
+}
+
+/* called by the bssgp layer to send NS PDUs */
+int sgsn_bssgp_dispatch_ns_unitdata_req_cb(void *ctx, struct msgb *msg)
+{
+ struct gprs_ns2_inst *nsi = (struct gprs_ns2_inst *) ctx;
+ struct osmo_gprs_ns2_prim nsp = {};
+ nsp.nsei = msgb_nsei(msg);
+ nsp.bvci = msgb_bvci(msg);
+ osmo_prim_init(&nsp.oph, SAP_NS, GPRS_NS2_PRIM_UNIT_DATA, PRIM_OP_REQUEST, msg);
+ return gprs_ns2_recv_prim(nsi, &nsp.oph);
+}
diff --git a/src/sgsn/gprs_gb.c b/src/sgsn/gprs_gb.c
index 96157a01e..703223f91 100644
--- a/src/sgsn/gprs_gb.c
+++ b/src/sgsn/gprs_gb.c
@@ -84,40 +84,6 @@ int gsm0408_gprs_rcvmsg_gb(struct msgb *msg, struct gprs_llc_llme *llme,
return rc;
}
-
-int gprs_gb_page_ps_ra(struct sgsn_mm_ctx *mmctx)
-{
- struct bssgp_paging_info pinfo;
- int rc;
-
- /* FIXME: page whole routing area, not only the last known cell */
-
- /* initiate PS PAGING procedure */
- memset(&pinfo, 0, sizeof(pinfo));
- pinfo.mode = BSSGP_PAGING_PS;
- pinfo.scope = BSSGP_PAGING_BVCI;
- pinfo.bvci = mmctx->gb.bvci;
- pinfo.imsi = mmctx->imsi;
- pinfo.ptmsi = &mmctx->p_tmsi;
- pinfo.drx_params = mmctx->drx_parms;
- pinfo.qos[0] = 0; // FIXME
- rc = bssgp_tx_paging(mmctx->gb.nsei, 0, &pinfo);
- rate_ctr_inc(rate_ctr_group_get_ctr(mmctx->ctrg, GMM_CTR_PAGING_PS));
-
- return rc;
-}
-
-/* called by the bssgp layer to send NS PDUs */
-int gprs_gb_send_cb(void *ctx, struct msgb *msg)
-{
- struct gprs_ns2_inst *nsi = (struct gprs_ns2_inst *) ctx;
- struct osmo_gprs_ns2_prim nsp = {};
- nsp.nsei = msgb_nsei(msg);
- nsp.bvci = msgb_bvci(msg);
- osmo_prim_init(&nsp.oph, SAP_NS, GPRS_NS2_PRIM_UNIT_DATA, PRIM_OP_REQUEST, msg);
- return gprs_ns2_recv_prim(nsi, &nsp.oph);
-}
-
void gprs_ns_prim_status_cb(struct osmo_gprs_ns2_prim *nsp)
{
switch (nsp->u.status.cause) {
diff --git a/src/sgsn/sgsn_libgtp.c b/src/sgsn/sgsn_libgtp.c
index 033637d9f..caab953bd 100644
--- a/src/sgsn/sgsn_libgtp.c
+++ b/src/sgsn/sgsn_libgtp.c
@@ -57,6 +57,7 @@
#include <osmocom/sgsn/gprs_mm_state_gb_fsm.h>
#include <osmocom/sgsn/gtp_mme.h>
#include <osmocom/sgsn/sgsn_rim.h>
+#include <osmocom/sgsn/gprs_bssgp.h>
#include <gtp.h>
#include <pdp.h>
@@ -781,7 +782,7 @@ static int cb_data_ind(struct pdp_t *lib, void *packet, unsigned int len)
LOGMMCTXP(LOGL_INFO, mm, "Paging MS in GMM state %s, MM state %s\n",
osmo_fsm_inst_state_name(mm->gmm_fsm),
osmo_fsm_inst_state_name(mm->gb.mm_state_fsm));
- gprs_gb_page_ps_ra(mm);
+ sgsn_bssgp_page_ps_ra(mm);
/* FIXME: queue the packet we received from GTP */
break;
diff --git a/src/sgsn/sgsn_main.c b/src/sgsn/sgsn_main.c
index c775922dc..77797b9b1 100644
--- a/src/sgsn/sgsn_main.c
+++ b/src/sgsn/sgsn_main.c
@@ -62,6 +62,7 @@
#include <osmocom/sgsn/gprs_gmm.h>
#include <osmocom/sgsn/gprs_ranap.h>
#include <osmocom/sgsn/gprs_gb.h>
+#include <osmocom/sgsn/gprs_bssgp.h>
#include <osmocom/ctrl/control_if.h>
#include <osmocom/ctrl/ports.h>
@@ -97,34 +98,11 @@ const char *openbsc_copyright =
struct sgsn_instance *sgsn;
-/* call-back function for the BSSGP protocol */
+/* call-back function for the BSSGP protocol.
+ * Must be left here so that we can add a new one in tests/sgsn_test */
int bssgp_prim_cb(struct osmo_prim_hdr *oph, void *ctx)
{
- struct osmo_bssgp_prim *bp;
- bp = container_of(oph, struct osmo_bssgp_prim, oph);
-
- switch (oph->sap) {
- case SAP_BSSGP_LL:
- switch (oph->primitive) {
- case PRIM_BSSGP_UL_UD:
- return gprs_llc_rcvmsg(oph->msg, bp->tp);
- }
- break;
- case SAP_BSSGP_GMM:
- switch (oph->primitive) {
- case PRIM_BSSGP_GMM_SUSPEND:
- return gprs_gmm_rx_suspend(bp->ra_id, bp->tlli);
- case PRIM_BSSGP_GMM_RESUME:
- return gprs_gmm_rx_resume(bp->ra_id, bp->tlli,
- bp->u.resume.suspend_ref);
- }
- break;
- case SAP_BSSGP_NM:
- break;
- case SAP_BSSGP_RIM:
- return sgsn_rim_rx_from_gb(bp, oph->msg);
- }
- return 0;
+ return sgsn_bssgp_rx_prim(oph);
}
static void signal_handler(int signum)
@@ -434,7 +412,7 @@ int main(int argc, char **argv)
exit(1);
}
sgsn->cfg.nsi = sgsn_nsi;
- bssgp_set_bssgp_callback(gprs_gb_send_cb, sgsn_nsi);
+ bssgp_set_bssgp_callback(sgsn_bssgp_dispatch_ns_unitdata_req_cb, sgsn_nsi);
gprs_llc_init("/usr/local/lib/osmocom/crypt/");
sgsn_rate_ctr_init();
diff --git a/src/sgsn/sgsn_vty.c b/src/sgsn/sgsn_vty.c
index 0929f1fa4..db76c357a 100644
--- a/src/sgsn/sgsn_vty.c
+++ b/src/sgsn/sgsn_vty.c
@@ -37,6 +37,7 @@
#include <osmocom/gprs/gprs_ns2.h>
#include <osmocom/sgsn/gprs_gb.h>
#include <osmocom/sgsn/gprs_gmm.h>
+#include <osmocom/sgsn/gprs_bssgp.h>
#include <osmocom/sgsn/gprs_sgsn.h>
#include <osmocom/sgsn/gtp_mme.h>
#include <osmocom/sgsn/vty.h>
@@ -1284,7 +1285,7 @@ DEFUN(page_subscr, page_subscr_info_cmd,
return CMD_WARNING;
}
- gprs_gb_page_ps_ra(mm);
+ sgsn_bssgp_page_ps_ra(mm);
return CMD_SUCCESS;
}