lynxis lazus submitted this change.
move gsm48_gmm_att_tlvdef into gprs_gmm_util
The gprs_gmm.c is huge. Move message parsing into gprs_gmm_util.c.
Change-Id: I67dcdb986fd01dc093501d324b5c376246a5d30d
---
M include/osmocom/sgsn/Makefile.am
A include/osmocom/sgsn/gprs_gmm_util.h
M src/sgsn/Makefile.am
M src/sgsn/gprs_gmm.c
A src/sgsn/gprs_gmm_util.c
M tests/gprs_routing_area/Makefile.am
M tests/sgsn/Makefile.am
7 files changed, 63 insertions(+), 23 deletions(-)
diff --git a/include/osmocom/sgsn/Makefile.am b/include/osmocom/sgsn/Makefile.am
index 9f87fd8..270ac7d 100644
--- a/include/osmocom/sgsn/Makefile.am
+++ b/include/osmocom/sgsn/Makefile.am
@@ -8,6 +8,7 @@
gprs_gmm.h \
gprs_gmm_fsm.h \
gprs_gmm_attach.h \
+ gprs_gmm_util.h \
gprs_mm_state_gb_fsm.h \
gprs_mm_state_iu_fsm.h \
gprs_ns.h \
diff --git a/include/osmocom/sgsn/gprs_gmm_util.h b/include/osmocom/sgsn/gprs_gmm_util.h
new file mode 100644
index 0000000..be89c35
--- /dev/null
+++ b/include/osmocom/sgsn/gprs_gmm_util.h
@@ -0,0 +1,5 @@
+#pragma once
+
+#include <osmocom/gsm/tlv.h>
+
+extern const struct tlv_definition gsm48_gmm_ie_tlvdef;
diff --git a/src/sgsn/Makefile.am b/src/sgsn/Makefile.am
index c363a48..660e490 100644
--- a/src/sgsn/Makefile.am
+++ b/src/sgsn/Makefile.am
@@ -45,6 +45,7 @@
gprs_gmm_attach.c \
gprs_gmm.c \
gprs_gmm_fsm.c \
+ gprs_gmm_util.c \
gprs_mm_state_gb_fsm.c \
gprs_ns.c \
gprs_routing_area.c \
diff --git a/src/sgsn/gprs_gmm.c b/src/sgsn/gprs_gmm.c
index ea9ffe0..324c6bf 100644
--- a/src/sgsn/gprs_gmm.c
+++ b/src/sgsn/gprs_gmm.c
@@ -63,30 +63,12 @@
#include <osmocom/sgsn/gprs_sm.h>
#include <osmocom/sgsn/gtp.h>
#include <osmocom/sgsn/pdpctx.h>
+#include <osmocom/sgsn/gprs_gmm_util.h>
#include <pdp.h>
#define PTMSI_ALLOC
-static const struct tlv_definition gsm48_gmm_att_tlvdef = {
- .def = {
- [GSM48_IE_GMM_CIPH_CKSN] = { TLV_TYPE_SINGLE_TV, 1 },
- [GSM48_IE_GMM_TIMER_READY] = { TLV_TYPE_TV, 1 },
- [GSM48_IE_GMM_ALLOC_PTMSI] = { TLV_TYPE_TLV, 0 },
- [GSM48_IE_GMM_PTMSI_SIG] = { TLV_TYPE_FIXED, 3 },
- [GSM48_IE_GMM_AUTH_RAND] = { TLV_TYPE_FIXED, 16 },
- [GSM48_IE_GMM_AUTH_SRES] = { TLV_TYPE_FIXED, 4 },
- [GSM48_IE_GMM_AUTH_RES_EXT] = { TLV_TYPE_TLV, 0 },
- [GSM48_IE_GMM_AUTH_FAIL_PAR] = { TLV_TYPE_TLV, 0 },
- [GSM48_IE_GMM_IMEISV] = { TLV_TYPE_TLV, 0 },
- [GSM48_IE_GMM_RX_NPDU_NUM_LIST] = { TLV_TYPE_TLV, 0 },
- [GSM48_IE_GMM_DRX_PARAM] = { TLV_TYPE_FIXED, 2 },
- [GSM48_IE_GMM_MS_NET_CAPA] = { TLV_TYPE_TLV, 0 },
- [GSM48_IE_GMM_PDP_CTX_STATUS] = { TLV_TYPE_TLV, 0 },
- [GSM48_IE_GMM_PS_LCS_CAPA] = { TLV_TYPE_TLV, 0 },
- [GSM48_IE_GMM_GMM_MBMS_CTX_ST] = { TLV_TYPE_TLV, 0 },
- },
-};
/* Our implementation, should be kept in SGSN */
@@ -635,7 +617,7 @@
/* Stop T3360 */
mmctx_timer_stop(ctx, 3360);
- tlv_parse(&tp, &gsm48_gmm_att_tlvdef, acr->data,
+ tlv_parse(&tp, &gsm48_gmm_ie_tlvdef, acr->data,
(msg->data + msg->len) - acr->data, 0, 0);
if (!TLVP_PRESENT(&tp, GSM48_IE_GMM_AUTH_SRES) ||
@@ -694,7 +676,7 @@
LOGMMCTXP(LOGL_INFO, ctx, "-> GMM AUTH AND CIPH FAILURE (cause = %s)\n",
get_value_string(gsm48_gmm_cause_names, gmm_cause));
- tlv_parse(&tp, &gsm48_gmm_att_tlvdef, gh->data+1, msg->len - 1, 0, 0);
+ tlv_parse(&tp, &gsm48_gmm_ie_tlvdef, gh->data+1, msg->len - 1, 0, 0);
/* Only if GMM cause is present and the AUTS is provided, we can
* start re-sync procedure */
@@ -1651,7 +1633,7 @@
/* Optional: Old P-TMSI Signature, Requested READY timer, TMSI Status,
* DRX parameter, MS network capability */
- tlv_parse(&tp, &gsm48_gmm_att_tlvdef, cur,
+ tlv_parse(&tp, &gsm48_gmm_ie_tlvdef, cur,
(msg->data + msg->len) - cur, 0, 0);
switch (upd_type) {
@@ -1937,7 +1919,7 @@
LOGPC(DMM, LOGL_INFO, "\n");
/* Optional: PDP context status, MBMS context status, Uplink data status, Device properties */
- tlv_parse(&tp, &gsm48_gmm_att_tlvdef, cur, (msg->data + msg->len) - cur, 0, 0);
+ tlv_parse(&tp, &gsm48_gmm_ie_tlvdef, cur, (msg->data + msg->len) - cur, 0, 0);
switch (mi.type) {
case GSM_MI_TYPE_IMSI:
diff --git a/src/sgsn/gprs_gmm_util.c b/src/sgsn/gprs_gmm_util.c
new file mode 100644
index 0000000..1248e93
--- /dev/null
+++ b/src/sgsn/gprs_gmm_util.c
@@ -0,0 +1,49 @@
+/*! \file gprs_bssgp_util.c
+ * GPRS GMM protocol implementation as per 3GPP TS 24.008 */
+/*
+ * (C) 2009-2015 by Harald Welte <laforge@gnumonks.org>
+ * (C) 2024 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
+ * All Rights Reserved
+ *
+ * SPDX-License-Identifier: AGPL-3.0+
+ *
+ * Author: Alexander Couzens <lynxis@fe80.eu>
+ *
+ * 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/gsm/gsm48.h>
+#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
+#include <osmocom/gsm/tlv.h>
+
+const struct tlv_definition gsm48_gmm_ie_tlvdef = {
+ .def = {
+ [GSM48_IE_GMM_CIPH_CKSN] = { TLV_TYPE_SINGLE_TV, 1 },
+ [GSM48_IE_GMM_TIMER_READY] = { TLV_TYPE_TV, 1 },
+ [GSM48_IE_GMM_ALLOC_PTMSI] = { TLV_TYPE_TLV, 0 },
+ [GSM48_IE_GMM_PTMSI_SIG] = { TLV_TYPE_FIXED, 3 },
+ [GSM48_IE_GMM_AUTH_RAND] = { TLV_TYPE_FIXED, 16 },
+ [GSM48_IE_GMM_AUTH_SRES] = { TLV_TYPE_FIXED, 4 },
+ [GSM48_IE_GMM_AUTH_RES_EXT] = { TLV_TYPE_TLV, 0 },
+ [GSM48_IE_GMM_AUTH_FAIL_PAR] = { TLV_TYPE_TLV, 0 },
+ [GSM48_IE_GMM_IMEISV] = { TLV_TYPE_TLV, 0 },
+ [GSM48_IE_GMM_RX_NPDU_NUM_LIST] = { TLV_TYPE_TLV, 0 },
+ [GSM48_IE_GMM_DRX_PARAM] = { TLV_TYPE_FIXED, 2 },
+ [GSM48_IE_GMM_MS_NET_CAPA] = { TLV_TYPE_TLV, 0 },
+ [GSM48_IE_GMM_PDP_CTX_STATUS] = { TLV_TYPE_TLV, 0 },
+ [GSM48_IE_GMM_PS_LCS_CAPA] = { TLV_TYPE_TLV, 0 },
+ [GSM48_IE_GMM_GMM_MBMS_CTX_ST] = { TLV_TYPE_TLV, 0 },
+ },
+};
+
diff --git a/tests/gprs_routing_area/Makefile.am b/tests/gprs_routing_area/Makefile.am
index a61f866..f95d3ae 100644
--- a/tests/gprs_routing_area/Makefile.am
+++ b/tests/gprs_routing_area/Makefile.am
@@ -45,6 +45,7 @@
$(top_builddir)/src/sgsn/gprs_gmm_attach.o \
$(top_builddir)/src/sgsn/gprs_gmm.o \
$(top_builddir)/src/sgsn/gprs_gmm_fsm.o \
+ $(top_builddir)/src/sgsn/gprs_gmm_util.o \
$(top_builddir)/src/sgsn/gprs_mm_state_gb_fsm.o \
$(top_builddir)/src/sgsn/gprs_routing_area.o \
$(top_builddir)/src/sgsn/gtp_ggsn.o \
diff --git a/tests/sgsn/Makefile.am b/tests/sgsn/Makefile.am
index db40f99..f698774 100644
--- a/tests/sgsn/Makefile.am
+++ b/tests/sgsn/Makefile.am
@@ -59,6 +59,7 @@
$(top_builddir)/src/sgsn/gprs_gmm_attach.o \
$(top_builddir)/src/sgsn/gprs_gmm.o \
$(top_builddir)/src/sgsn/gprs_gmm_fsm.o \
+ $(top_builddir)/src/sgsn/gprs_gmm_util.o \
$(top_builddir)/src/sgsn/gprs_mm_state_gb_fsm.o \
$(top_builddir)/src/sgsn/gprs_routing_area.o \
$(top_builddir)/src/sgsn/gtp_ggsn.o \
To view, visit change 37868. To unsubscribe, or for help writing mail filters, visit settings.