This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
pespin gerrit-no-reply at lists.osmocom.orgpespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/15336 Change subject: Move llc->MM/SM Gb specific glue code to its own file ...................................................................... Move llc->MM/SM Gb specific glue code to its own file Now that we have RANAP/Iu handling specificities in its own file, let's have also Gb specific glue code for messages coming from llc up to MM/SM layer in its own file. This way same entry points in gprs_gmm.c are used by Gb and Iu: gsm0408_rcv_gmm() (for MM) and gsm0408_rcv_gsm() (for SM). Change-Id: Iaf57922a0970c1d03f6f1d6337d27ae3d4aaf32c --- M include/osmocom/sgsn/Makefile.am A include/osmocom/sgsn/gprs_gb.h M include/osmocom/sgsn/gprs_gmm.h M src/gprs/Makefile.am A src/gprs/gprs_gb.c M src/gprs/gprs_gmm.c M tests/sgsn/Makefile.am 7 files changed, 110 insertions(+), 62 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/36/15336/1 diff --git a/include/osmocom/sgsn/Makefile.am b/include/osmocom/sgsn/Makefile.am index b4cd5db..b91c9f1 100644 --- a/include/osmocom/sgsn/Makefile.am +++ b/include/osmocom/sgsn/Makefile.am @@ -3,6 +3,7 @@ crc24.h \ debug.h \ gb_proxy.h \ + gprs_gb.h \ gprs_gb_parse.h \ gprs_gmm.h \ gprs_gmm_attach.h \ diff --git a/include/osmocom/sgsn/gprs_gb.h b/include/osmocom/sgsn/gprs_gb.h new file mode 100644 index 0000000..3bc3676 --- /dev/null +++ b/include/osmocom/sgsn/gprs_gb.h @@ -0,0 +1,9 @@ +#pragma once + +#include <stdbool.h> + +#include <osmocom/core/msgb.h> +#include <osmocom/sgsn/gprs_rllc.h> + +int gsm0408_gprs_rcvmsg_gb(struct msgb *msg, struct gprs_llc_llme *llme, + bool drop_cipherable); diff --git a/include/osmocom/sgsn/gprs_gmm.h b/include/osmocom/sgsn/gprs_gmm.h index 047bd77..9316351 100644 --- a/include/osmocom/sgsn/gprs_gmm.h +++ b/include/osmocom/sgsn/gprs_gmm.h @@ -50,4 +50,8 @@ void pdp_ctx_detach_mm_ctx(struct sgsn_pdp_ctx *pdp); void mmctx_set_pmm_state(struct sgsn_mm_ctx *ctx, enum gprs_pmm_state state); +void mmctx_state_timer_start(struct sgsn_mm_ctx *mm, unsigned int T); +void mmctx_set_mm_state(struct sgsn_mm_ctx *ctx, enum gprs_pmm_state state); + +void msgid2mmctx(struct sgsn_mm_ctx *mm, const struct msgb *msg); #endif /* _GPRS_GMM_H */ diff --git a/src/gprs/Makefile.am b/src/gprs/Makefile.am index 384b893..85ba906 100644 --- a/src/gprs/Makefile.am +++ b/src/gprs/Makefile.am @@ -60,6 +60,7 @@ $(NULL) osmo_sgsn_SOURCES = \ + gprs_gb.c \ gprs_gmm_attach.c \ gprs_gmm.c \ gprs_ranap.c \ diff --git a/src/gprs/gprs_gb.c b/src/gprs/gprs_gb.c new file mode 100644 index 0000000..29bfc53 --- /dev/null +++ b/src/gprs/gprs_gb.c @@ -0,0 +1,91 @@ +/* Messages on the Gb interface (A/Gb mode) */ + +/* (C) 2009-2015 by Harald Welte <laforge at gnumonks.org> + * (C) 2010 by On-Waves + * (C) 2019 by sysmocom s.f.m.c. GmbH <info at 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/rate_ctr.h> + +#include <osmocom/gprs/gprs_msgb.h> +#include <osmocom/gprs/gprs_bssgp.h> + +#include "bscconfig.h" + +#include <osmocom/sgsn/gprs_sgsn.h> +#include <osmocom/sgsn/gprs_gmm.h> +#include <osmocom/sgsn/debug.h> + +/* Update the MM context state */ +static void gsm0408_gprs_notify_pdu_gb(struct sgsn_mm_ctx *mmctx) +{ + switch (mmctx->pmm_state) { + case MM_STANDBY: + mmctx_set_mm_state(mmctx, MM_READY); + break; + case MM_READY: /* RE-arm the timer upon receival of Gb PDUs */ + mmctx_state_timer_start(mmctx, 3314); + break; + default: + break; + } +} + +/* Main entry point for incoming 04.08 GPRS messages from Gb */ +int gsm0408_gprs_rcvmsg_gb(struct msgb *msg, struct gprs_llc_llme *llme, + bool drop_cipherable) +{ + struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_gmmh(msg); + uint8_t pdisc = gsm48_hdr_pdisc(gh); + struct sgsn_mm_ctx *mmctx; + struct gprs_ra_id ra_id; + int rc = -EINVAL; + + bssgp_parse_cell_id(&ra_id, msgb_bcid(msg)); + mmctx = sgsn_mm_ctx_by_tlli(msgb_tlli(msg), &ra_id); + if (mmctx) { + msgid2mmctx(mmctx, msg); + rate_ctr_inc(&mmctx->ctrg->ctr[GMM_CTR_PKTS_SIG_IN]); + mmctx->gb.llme = llme; + } + + /* MMCTX can be NULL */ + + if (mmctx) + gsm0408_gprs_notify_pdu_gb(mmctx); + + switch (pdisc) { + case GSM48_PDISC_MM_GPRS: + rc = gsm0408_rcv_gmm(mmctx, msg, llme, drop_cipherable); + break; + case GSM48_PDISC_SM_GPRS: + rc = gsm0408_rcv_gsm(mmctx, msg, llme); + break; + default: + LOGMMCTXP(LOGL_NOTICE, mmctx, + "Unknown GSM 04.08 discriminator 0x%02x: %s\n", + pdisc, osmo_hexdump((uint8_t *)gh, msgb_l3len(msg))); + /* FIXME: return status message */ + break; + } + + /* MMCTX can be invalid */ + + return rc; +} diff --git a/src/gprs/gprs_gmm.c b/src/gprs/gprs_gmm.c index 96753d3..e5fa047 100644 --- a/src/gprs/gprs_gmm.c +++ b/src/gprs/gprs_gmm.c @@ -124,7 +124,6 @@ } } -static void mmctx_set_mm_state(struct sgsn_mm_ctx *ctx, enum gprs_pmm_state state); static void mmctx_state_timer_cb(void *_mm) { struct sgsn_mm_ctx *mm = _mm; @@ -149,7 +148,7 @@ } } -static void mmctx_state_timer_start(struct sgsn_mm_ctx *mm, unsigned int T) +void mmctx_state_timer_start(struct sgsn_mm_ctx *mm, unsigned int T) { unsigned long seconds; @@ -200,7 +199,7 @@ ctx->pmm_state = state; } -static void mmctx_set_mm_state(struct sgsn_mm_ctx *ctx, enum gprs_pmm_state state) +void mmctx_set_mm_state(struct sgsn_mm_ctx *ctx, enum gprs_pmm_state state) { OSMO_ASSERT(ctx->ran_type == MM_CTX_T_GERAN_Gb); @@ -304,7 +303,7 @@ } /* Store BVCI/NSEI in MM context */ -static void msgid2mmctx(struct sgsn_mm_ctx *mm, const struct msgb *msg) +void msgid2mmctx(struct sgsn_mm_ctx *mm, const struct msgb *msg) { mm->gb.bvci = msgb_bvci(msg); mm->gb.nsei = msgb_nsei(msg); @@ -2916,64 +2915,6 @@ return rc; } -/* Update the MM context state */ -static void gsm0408_gprs_notify_pdu_gb(struct sgsn_mm_ctx *mmctx) -{ - switch (mmctx->pmm_state) { - case MM_STANDBY: - mmctx_set_mm_state(mmctx, MM_READY); - break; - case MM_READY: /* RE-arm the timer upon receival of Gb PDUs */ - mmctx_state_timer_start(mmctx, 3314); - break; - default: - break; - } -} - -/* Main entry point for incoming 04.08 GPRS messages from Gb */ -int gsm0408_gprs_rcvmsg_gb(struct msgb *msg, struct gprs_llc_llme *llme, - bool drop_cipherable) -{ - struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_gmmh(msg); - uint8_t pdisc = gsm48_hdr_pdisc(gh); - struct sgsn_mm_ctx *mmctx; - struct gprs_ra_id ra_id; - int rc = -EINVAL; - - bssgp_parse_cell_id(&ra_id, msgb_bcid(msg)); - mmctx = sgsn_mm_ctx_by_tlli(msgb_tlli(msg), &ra_id); - if (mmctx) { - msgid2mmctx(mmctx, msg); - rate_ctr_inc(&mmctx->ctrg->ctr[GMM_CTR_PKTS_SIG_IN]); - mmctx->gb.llme = llme; - } - - /* MMCTX can be NULL */ - - if (mmctx) - gsm0408_gprs_notify_pdu_gb(mmctx); - - switch (pdisc) { - case GSM48_PDISC_MM_GPRS: - rc = gsm0408_rcv_gmm(mmctx, msg, llme, drop_cipherable); - break; - case GSM48_PDISC_SM_GPRS: - rc = gsm0408_rcv_gsm(mmctx, msg, llme); - break; - default: - LOGMMCTXP(LOGL_NOTICE, mmctx, - "Unknown GSM 04.08 discriminator 0x%02x: %s\n", - pdisc, osmo_hexdump((uint8_t *)gh, msgb_l3len(msg))); - /* FIXME: return status message */ - break; - } - - /* MMCTX can be invalid */ - - return rc; -} - int gprs_gmm_rx_suspend(struct gprs_ra_id *raid, uint32_t tlli) { struct sgsn_mm_ctx *mmctx; diff --git a/tests/sgsn/Makefile.am b/tests/sgsn/Makefile.am index ae397b3..b035468 100644 --- a/tests/sgsn/Makefile.am +++ b/tests/sgsn/Makefile.am @@ -45,6 +45,7 @@ $(top_builddir)/src/gprs/gprs_llc_parse.o \ $(top_builddir)/src/gprs/gprs_llc.o \ $(top_builddir)/src/gprs/crc24.o \ + $(top_builddir)/src/gprs/gprs_gb.o \ $(top_builddir)/src/gprs/gprs_ranap.o \ $(top_builddir)/src/gprs/gprs_sndcp.o \ $(top_builddir)/src/gprs/gprs_gmm_attach.o \ -- To view, visit https://gerrit.osmocom.org/c/osmo-sgsn/+/15336 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-sgsn Gerrit-Branch: master Gerrit-Change-Id: Iaf57922a0970c1d03f6f1d6337d27ae3d4aaf32c Gerrit-Change-Number: 15336 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin at sysmocom.de> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190829/e8fdf30f/attachment.htm>