pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/31923 )


Change subject: layer23: modem: Depend on libosmo-gprs-gmm
......................................................................

layer23: modem: Depend on libosmo-gprs-gmm

Related: OS#5501
Change-Id: I82a2b9c043eae42435ca781689fc3381e7a31bea
---
M src/host/layer23/configure.ac
M src/host/layer23/include/osmocom/bb/common/logging.h
M src/host/layer23/include/osmocom/bb/modem/Makefile.am
A src/host/layer23/include/osmocom/bb/modem/gmm.h
M src/host/layer23/src/common/Makefile.am
M src/host/layer23/src/modem/Makefile.am
M src/host/layer23/src/modem/app_modem.c
A src/host/layer23/src/modem/gmm.c
8 files changed, 126 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/23/31923/1

diff --git a/src/host/layer23/configure.ac b/src/host/layer23/configure.ac
index 459065c..1434fbf 100644
--- a/src/host/layer23/configure.ac
+++ b/src/host/layer23/configure.ac
@@ -49,6 +49,7 @@
 PKG_CHECK_MODULES(LIBOSMOGPRSRLCMAC, libosmo-gprs-rlcmac)
 PKG_CHECK_MODULES(LIBOSMOGPRSLLC, libosmo-gprs-llc)
 PKG_CHECK_MODULES(LIBOSMOGPRSSNDCP, libosmo-gprs-sndcp)
+PKG_CHECK_MODULES(LIBOSMOGPRSGMM, libosmo-gprs-gmm)
 AC_CHECK_LIB(gps, gps_waiting, LIBGPS_CFLAGS=" -D_HAVE_GPSD" LIBGPS_LIBS=" 
-lgps ",,)
 AC_SUBST([LIBGPS_CFLAGS])
 AC_SUBST([LIBGPS_LIBS])
diff --git a/src/host/layer23/include/osmocom/bb/common/logging.h 
b/src/host/layer23/include/osmocom/bb/common/logging.h
index 818b149..fc0861e 100644
--- a/src/host/layer23/include/osmocom/bb/common/logging.h
+++ b/src/host/layer23/include/osmocom/bb/common/logging.h
@@ -30,6 +30,7 @@
        DRLCMAC,
        DLLC,
        DSNDCP,
+       DGMM,
 };

 extern const struct log_info log_info;
diff --git a/src/host/layer23/include/osmocom/bb/modem/Makefile.am 
b/src/host/layer23/include/osmocom/bb/modem/Makefile.am
index b2e3059..6dfc98e 100644
--- a/src/host/layer23/include/osmocom/bb/modem/Makefile.am
+++ b/src/host/layer23/include/osmocom/bb/modem/Makefile.am
@@ -1,5 +1,6 @@
 noinst_HEADERS = \
         modem.h \
+        gmm.h \
         grr.h \
         llc.h \
         rlcmac.h \
diff --git a/src/host/layer23/include/osmocom/bb/modem/gmm.h 
b/src/host/layer23/include/osmocom/bb/modem/gmm.h
new file mode 100644
index 0000000..4ec3e8e
--- /dev/null
+++ b/src/host/layer23/include/osmocom/bb/modem/gmm.h
@@ -0,0 +1,7 @@
+#pragma once
+
+#include <stdbool.h>
+
+struct osmocom_ms;
+
+int modem_gmm_init(struct osmocom_ms *ms);
diff --git a/src/host/layer23/src/common/Makefile.am 
b/src/host/layer23/src/common/Makefile.am
index 60af3b8..79a80a1 100644
--- a/src/host/layer23/src/common/Makefile.am
+++ b/src/host/layer23/src/common/Makefile.am
@@ -10,6 +10,7 @@
        $(LIBOSMOGPRSRLCMAC_CFLAGS) \
        $(LIBOSMOGPRSLLC_CFLAGS) \
        $(LIBOSMOGPRSSNDCP_CFLAGS) \
+       $(LIBOSMOGPRSGMM_CFLAGS) \
        $(LIBGPS_CFLAGS) \
        $(NULL)

diff --git a/src/host/layer23/src/modem/Makefile.am 
b/src/host/layer23/src/modem/Makefile.am
index 500b031..086c2f3 100644
--- a/src/host/layer23/src/modem/Makefile.am
+++ b/src/host/layer23/src/modem/Makefile.am
@@ -11,6 +11,7 @@
        $(LIBOSMOGPRSRLCMAC_CFLAGS) \
        $(LIBOSMOGPRSLLC_CFLAGS) \
        $(LIBOSMOGPRSSNDCP_CFLAGS) \
+       $(LIBOSMOGPRSGMM_CFLAGS) \
        $(NULL)

 bin_PROGRAMS = modem
@@ -18,6 +19,7 @@
 modem_SOURCES = \
        $(top_srcdir)/src/common/main.c \
        app_modem.c \
+       gmm.c \
        grr.c \
        llc.c \
        rlcmac.c \
@@ -32,4 +34,5 @@
        $(LIBOSMOGPRSRLCMAC_LIBS) \
        $(LIBOSMOGPRSLLC_LIBS) \
        $(LIBOSMOGPRSSNDCP_LIBS) \
+       $(LIBOSMOGPRSGMM_LIBS) \
        $(NULL)
diff --git a/src/host/layer23/src/modem/app_modem.c 
b/src/host/layer23/src/modem/app_modem.c
index e33ad6a..58328c2 100644
--- a/src/host/layer23/src/modem/app_modem.c
+++ b/src/host/layer23/src/modem/app_modem.c
@@ -50,6 +50,7 @@
 #include <osmocom/bb/modem/rlcmac.h>
 #include <osmocom/bb/modem/llc.h>
 #include <osmocom/bb/modem/sndcp.h>
+#include <osmocom/bb/modem/gmm.h>
 #include <osmocom/bb/modem/vty.h>
 #include <osmocom/bb/modem/grr.h>

@@ -174,6 +175,11 @@
                return rc;
        }

+       if ((rc = modem_gmm_init(app_data.ms))) {
+               LOGP(DGMM, LOGL_FATAL, "Failed initializing GMM layer\n");
+               return rc;
+       }
+
        osmo_signal_register_handler(SS_L1CTL, &signal_cb, NULL);
        lapdm_channel_set_l3(&app_data.ms->lapdm_channel, &modem_grr_rslms_cb, 
app_data.ms);
        return 0;
diff --git a/src/host/layer23/src/modem/gmm.c b/src/host/layer23/src/modem/gmm.c
new file mode 100644
index 0000000..6a84909
--- /dev/null
+++ b/src/host/layer23/src/modem/gmm.c
@@ -0,0 +1,96 @@
+/* GPRS GMM interfaces as per 3GPP TS 24.008, TS 24.007 */
+/* (C) 2023 by sysmocom - s.m.f.c. GmbH <[email protected]>
+ * All Rights Reserved
+ * Author: Pau Espin Pedrol <[email protected]>
+ *
+ * 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/lienses/>.
+ *
+ */
+
+#include <stdbool.h>
+#include <string.h>
+#include <stdint.h>
+#include <errno.h>
+#include <stdio.h>
+
+#include <osmocom/core/msgb.h>
+#include <osmocom/core/prim.h>
+#include <osmocom/core/utils.h>
+#include <osmocom/core/linuxlist.h>
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/tun.h>
+
+#include <osmocom/gprs/llc/llc.h>
+#include <osmocom/gprs/llc/llc_prim.h>
+#include <osmocom/gprs/gmm/gmm_prim.h>
+#include <osmocom/gprs/gmm/gmm.h>
+
+#include <osmocom/bb/common/settings.h>
+#include <osmocom/bb/common/logging.h>
+#include <osmocom/bb/common/apn.h>
+#include <osmocom/bb/common/ms.h>
+#include <osmocom/bb/modem/gmm.h>
+
+
+static int modem_gmm_prim_up_cb(struct osmo_gprs_gmm_prim *gmm_prim, void 
*user_data)
+{
+       const char *pdu_name = osmo_gprs_gmm_prim_name(gmm_prim);
+       int rc = 0;
+
+       switch (gmm_prim->oph.sap) {
+       case OSMO_GPRS_GMM_SAP_GMMREG:
+               switch (OSMO_PRIM_HDR(&gmm_prim->oph)) {
+               case OSMO_PRIM(OSMO_GPRS_GMM_GMMREG_ATTACH, PRIM_OP_CONFIRM):
+               case OSMO_PRIM(OSMO_GPRS_GMM_GMMREG_DETACH, PRIM_OP_CONFIRM):
+               case OSMO_PRIM(OSMO_GPRS_GMM_GMMREG_DETACH, PRIM_OP_INDICATION):
+               default:
+                       LOGP(DGMM, LOGL_ERROR, "%s(): Rx %s UNIMPLEMENTED\n", 
__func__, pdu_name);
+                       break;
+               };
+       default:
+               LOGP(DGMM, LOGL_ERROR, "%s(): Unexpected Rx %s\n", __func__, 
pdu_name);
+               OSMO_ASSERT(0);
+       }
+
+       return rc;
+}
+
+static int modem_gmm_prim_down_cb(struct osmo_gprs_gmm_prim *gmm_prim, void 
*user_data)
+{
+       const char *pdu_name = osmo_gprs_gmm_prim_name(gmm_prim);
+       int rc = 0;
+
+       switch (gmm_prim->oph.sap) {
+       case OSMO_GPRS_GMM_SAP_GMMREG:
+       default:
+               LOGP(DGMM, LOGL_ERROR, "%s(): Unexpected Rx %s\n", __func__, 
pdu_name);
+               OSMO_ASSERT(0);
+       }
+
+       return rc;
+}
+
+int modem_gmm_init(struct osmocom_ms *ms)
+{
+       int rc;
+       rc = osmo_gprs_gmm_init(OSMO_GPRS_GMM_LOCATION_MS);
+       if (rc != 0)
+               return rc;
+
+       osmo_gprs_gmm_set_log_cat(OSMO_GPRS_GMM_LOGC_GMM, DGMM);
+
+       osmo_gprs_gmm_prim_set_up_cb(modem_gmm_prim_up_cb, ms);
+       osmo_gprs_gmm_prim_set_down_cb(modem_gmm_prim_down_cb, ms);
+       return rc;
+}

-- 
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/31923
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: I82a2b9c043eae42435ca781689fc3381e7a31bea
Gerrit-Change-Number: 31923
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>
Gerrit-MessageType: newchange

Reply via email to