Skip to contentSkip to conversation

core: Remove unused declarations from ofono.h

PATCH Applied Denis Kenzior 2 participants 5 messages Jan 24, 2024 – Jan 25, 2024 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 core: Remove unused declarations from ofono.h

Fixes 36a11599 ("gprs-provision: Remove no longer used atom/driver")
---
 src/ofono.h | 8 --------
 1 file changed, 8 deletions(-)
src/ofono.h +0 -8
index 6a8c53a1..42298e43 100644
@@ -587,14 +587,6 @@ bool __ofono_provision_get_settings(const char *mcc,
 				struct ofono_gprs_provision_data **settings,
 				size_t *count);
 
-ofono_bool_t __ofono_gprs_provision_get_settings(const char *mcc,
-				const char *mnc, const char *spn,
-				struct ofono_gprs_provision_data **settings,
-				int *count);
-void __ofono_gprs_provision_free_settings(
-				struct ofono_gprs_provision_data *settings,
-				int count);
-
 #include <ofono/emulator.h>
 
 enum ofono_emulator_slc_condition {
Signature · 1 line
2.43.0
#1 lore raw

PATCH 2/4 provision: Remove use of ofono_gprs_provision_data

Switch to using struct provisiondb_entry instead of struct ofono_gprs_provision_data. For now, mark all string attributes of this structure as const. Strings are currently not allocated and instead point to loations in the provisiondb memory mapped region. Since the provisioning database is only opened at startup and never unmapped during oFono's runtime, returning const pointers to such strings is safe.

While here, mark __get_string() as returning a pointer to a const char.

---
 Makefile.am              |  2 +-
 include/gprs-provision.h | 49 ----------------------------------------
 src/gprs.c               |  5 ++--
 src/ofono.h              |  4 ++--
 src/provision.c          | 10 ++++----
 src/provisiondb.c        | 16 ++++++-------
 src/provisiondb.h        | 17 ++++++++++++--
 tools/lookup-apn.c       |  8 +++----
 8 files changed, 38 insertions(+), 73 deletions(-)
 delete mode 100644 include/gprs-provision.h
Makefile.am +1 -1
index 15d220f7..280653f3 100644
@@ -144,7 +144,7 @@ pkginclude_HEADERS = include/log.h include/plugin.h include/history.h \
 			include/audio-settings.h include/nettime.h \
 			include/ctm.h \
 			include/sim-auth.h \
-			include/gprs-provision.h include/emulator.h \
+			include/emulator.h \
 			include/location-reporting.h \
 			include/gnss.h \
 			include/private-network.h \
include/gprs-provision.h deleted +0 -49

49 lines not on this page · raw message

src/gprs.c +3 -2
index 40642324..f8b6fd3c 100644
@@ -43,6 +43,7 @@
 #include "ofono.h"
 
 #include "common.h"
+#include "provisiondb.h"
 #include "storage.h"
 #include "simutil.h"
 #include "util.h"
@@ -2371,7 +2372,7 @@ static DBusMessage *gprs_get_contexts(DBusConnection *conn,
 	return reply;
 }
 
-static void provision_context(const struct ofono_gprs_provision_data *ap,
+static void provision_context(const struct provision_db_entry *ap,
 				struct ofono_gprs *gprs)
 {
 	unsigned int id;
@@ -2463,7 +2464,7 @@ static void provision_context(const struct ofono_gprs_provision_data *ap,
 static void provision_contexts(struct ofono_gprs *gprs, const char *mcc,
 				const char *mnc, const char *spn)
 {
-	struct ofono_gprs_provision_data *settings;
+	struct provision_db_entry *settings;
 	size_t count;
 	size_t i;
 
src/ofono.h +2 -2
index 42298e43..a243d3fb 100644
@@ -581,10 +581,10 @@ void __ofono_nettime_info_received(struct ofono_modem *modem,
 
 #include <ofono/sim-auth.h>
 
-#include <ofono/gprs-provision.h>
+struct provision_db_entry;
 bool __ofono_provision_get_settings(const char *mcc,
 				const char *mnc, const char *spn,
-				struct ofono_gprs_provision_data **settings,
+				struct provision_db_entry **settings,
 				size_t *count);
 
 #include <ofono/emulator.h>
src/provision.c +6 -4
index cd5cf569..a2dfcf6c 100644
@@ -11,6 +11,8 @@
 
 #include <stddef.h>
 
+#include <ofono/gprs-context.h>
+
 #include "provisiondb.h"
 #include "ofono.h"
 
@@ -18,11 +20,11 @@ static struct provision_db *pdb;
 
 bool __ofono_provision_get_settings(const char *mcc,
 				const char *mnc, const char *spn,
-				struct ofono_gprs_provision_data **settings,
+				struct provision_db_entry **settings,
 				size_t *count)
 {
 	size_t n_contexts;
-	struct ofono_gprs_provision_data *contexts;
+	struct provision_db_entry *contexts;
 	int r;
 	size_t i;
 	uint32_t type;
@@ -38,7 +40,7 @@ bool __ofono_provision_get_settings(const char *mcc,
 			n_contexts, mcc, mnc, spn);
 
 	for (i = 0; i < n_contexts; i++) {
-		struct ofono_gprs_provision_data *ap = contexts + i;
+		struct provision_db_entry *ap = contexts + i;
 
 		DBG("APN: %s, Type: %x, Proto: %x",
 				ap->apn, ap->type, ap->proto);
@@ -50,7 +52,7 @@ bool __ofono_provision_get_settings(const char *mcc,
 
 	/* Make sure there are no duplicates */
 	for (i = 0, type = 0; i < n_contexts; i++) {
-		struct ofono_gprs_provision_data *ap = contexts + i;
+		struct provision_db_entry *ap = contexts + i;
 
 		if (type & ap->type) {
 			ofono_warn("Duplicate detected for %s%s, spn: %s",
src/provisiondb.c +7 -9
index 6b864dec..53305eab 100644
@@ -21,8 +21,7 @@
 #include <ell/ell.h>
 
 #define OFONO_API_SUBJECT_TO_CHANGE
-#include <ofono/modem.h>
-#include <ofono/gprs-provision.h>
+#include <ofono/gprs-context.h>
 
 #include "provisiondb.h"
 
@@ -205,7 +204,7 @@ static struct provision_data *__get_provision_data(struct node *node)
 }
 
 static int __get_string(struct provision_db *pdb, uint64_t offset,
-				char **out_str)
+				const char **out_str)
 {
 	if (!offset) {
 		*out_str = NULL;
@@ -220,13 +219,13 @@ static int __get_string(struct provision_db *pdb, uint64_t offset,
 }
 
 static int __get_contexts(struct provision_db *pdb, uint64_t offset,
-				struct ofono_gprs_provision_data **contexts,
+				struct provision_db_entry **contexts,
 				size_t *n_contexts)
 {
 	void *start = pdb->addr + pdb->contexts_offset;
 	uint64_t num;
 	uint64_t i;
-	struct ofono_gprs_provision_data *ret;
+	struct provision_db_entry *ret;
 	int r;
 
 	if (offset + sizeof(__le64) >= pdb->contexts_size)
@@ -238,7 +237,7 @@ static int __get_contexts(struct provision_db *pdb, uint64_t offset,
 	if (offset + num * sizeof(struct context) > pdb->contexts_size)
 		return -EPROTO;
 
-	ret = l_new(struct ofono_gprs_provision_data, num);
+	ret = l_new(struct provision_db_entry, num);
 
 	for (i = 0; i < num; i++, offset += sizeof(struct context)) {
 		struct context *context = start + offset;
@@ -375,8 +374,7 @@ static int key_from_mcc_mnc(const char *mcc, const char *mnc, uint32_t *key)
 
 int provision_db_lookup(struct provision_db *pdb,
 			const char *mcc, const char *mnc, const char *match_spn,
-			struct ofono_gprs_provision_data **items,
-			size_t *n_items)
+			struct provision_db_entry **items, size_t *n_items)
 {
 	int r;
 	uint32_t key;
@@ -422,7 +420,7 @@ int provision_db_lookup(struct provision_db *pdb,
 	}
 
 	for (i = 0; i < count; i++) {
-		char *spn;
+		const char *spn;
 
 		r = __get_string(pdb, L_LE64_TO_CPU(data[i].spn_offset), &spn);
 		if (r < 0)
src/provisiondb.h +15 -2
index d7381b94..ee203c61 100644
@@ -5,14 +5,27 @@
  * SPDX-License-Identifier: LGPL-2.1-or-later
  */
 
-struct ofono_gprs_provision_data;
+#include <stdint.h>
+
 struct provision_db;
 
+struct provision_db_entry {
+	uint32_t type; /* Multiple types can be set in a bitmap */
+	enum ofono_gprs_proto proto;
+	const char *name;
+	const char *apn;
+	const char *username;
+	const char *password;
+	enum ofono_gprs_auth_method auth_method;
+	const char *message_proxy;
+	const char *message_center;
+};
+
 struct provision_db *provision_db_new(const char *pathname);
 struct provision_db *provision_db_new_default(void);
 void provision_db_free(struct provision_db *pdb);
 
 int provision_db_lookup(struct provision_db *pdb,
 			const char *mcc, const char *mnc, const char *spn,
-			struct ofono_gprs_provision_data **items,
+			struct provision_db_entry **items,
 			size_t *n_items);
tools/lookup-apn.c +4 -4
index ff791993..34d689a4 100644
@@ -18,8 +18,8 @@
 #include <ell/ell.h>
 
 #define OFONO_API_SUBJECT_TO_CHANGE
-#include <ofono/modem.h>
-#include <ofono/gprs-provision.h>
+#include <ofono/types.h>
+#include <ofono/gprs-context.h>
 
 #include "provisiondb.h"
 
@@ -29,7 +29,7 @@ static int lookup_apn(const char *match_mcc, const char *match_mnc,
 							const char *match_spn)
 {
 	struct provision_db *pdb;
-	struct ofono_gprs_provision_data *contexts;
+	struct provision_db_entry *contexts;
 	size_t n_contexts;
 	int r;
 	size_t i;
@@ -58,7 +58,7 @@ static int lookup_apn(const char *match_mcc, const char *match_mnc,
 	}
 
 	for (i = 0; i < n_contexts; i++) {
-		struct ofono_gprs_provision_data *ap = contexts + i;
+		struct provision_db_entry *ap = contexts + i;
 
 		fprintf(stdout, "\nName: %s\n", ap->name);
 		fprintf(stdout, "APN: %s\n", ap->apn);
Signature · 1 line
2.43.0
#2 lore raw

PATCH 3/4 gprs: Add some additional context types

In reply to Denis Kenzior

These context types are currently unused, but supported by the provisioning database. Add them to the enumeration and update some utility functions to handle them.

In the case of SUPL, the context type can now be set via D-Bus API. IA context types will be handled specially by lte atom.

---
 include/gprs-context.h |  2 ++
 src/gprs.c             | 11 +++++++++++
 2 files changed, 13 insertions(+)
include/gprs-context.h +2 -0
index 81055d89..5d5f0be1 100644
@@ -37,6 +37,8 @@ enum ofono_gprs_context_type {
 	OFONO_GPRS_CONTEXT_TYPE_MMS		= 0x0002,
 	OFONO_GPRS_CONTEXT_TYPE_WAP		= 0x0004,
 	OFONO_GPRS_CONTEXT_TYPE_IMS		= 0x0008,
+	OFONO_GPRS_CONTEXT_TYPE_SUPL		= 0x0010,
+	OFONO_GPRS_CONTEXT_TYPE_IA		= 0x0020,
 };
 
 struct ofono_gprs_primary_context {
src/gprs.c +11 -0
index f8b6fd3c..7b681d85 100644
@@ -177,6 +177,10 @@ static const char *gprs_context_default_name(enum ofono_gprs_context_type type)
 		return "WAP";
 	case OFONO_GPRS_CONTEXT_TYPE_IMS:
 		return "IMS";
+	case OFONO_GPRS_CONTEXT_TYPE_SUPL:
+		return "SUPL";
+	case OFONO_GPRS_CONTEXT_TYPE_IA:
+		return "Initial Attach";
 	}
 
 	return NULL;
@@ -196,6 +200,10 @@ static const char *gprs_context_type_to_string(
 		return "wap";
 	case OFONO_GPRS_CONTEXT_TYPE_IMS:
 		return "ims";
+	case OFONO_GPRS_CONTEXT_TYPE_SUPL:
+		return "supl";
+	case OFONO_GPRS_CONTEXT_TYPE_IA:
+		return "ia";
 	}
 
 	return NULL;
@@ -216,6 +224,9 @@ static gboolean gprs_context_string_to_type(const char *str,
 	} else if (g_str_equal(str, "ims")) {
 		*out = OFONO_GPRS_CONTEXT_TYPE_IMS;
 		return TRUE;
+	} else if (g_str_equal(str, "supl")) {
+		*out = OFONO_GPRS_CONTEXT_TYPE_SUPL;
+		return TRUE;
 	}
 
 	return FALSE;
Signature · 1 line
2.43.0
#3 lore raw

PATCH 4/4 unit: Add provisioning database tests

In reply to Denis Kenzior
---
 .gitignore               |   2 +
 Makefile.am              |  25 +++-
 unit/test-provision.c    | 280 +++++++++++++++++++++++++++++++++++++++
 unit/test-provision.json |  92 +++++++++++++
 4 files changed, 395 insertions(+), 4 deletions(-)
 create mode 100644 unit/test-provision.c
 create mode 100644 unit/test-provision.json
.gitignore +2 -0
index 87405231..0cfe5283 100644
@@ -47,6 +47,8 @@ unit/test-rilmodem-cs
 unit/test-rilmodem-gprs
 unit/test-rilmodem-sms
 unit/test-mbim
+unit/test-provision
+unit/test-provision.db
 unit/test-*.log
 unit/test-*.trs
 test-driver
Makefile.am +21 -4
index 280653f3..79645e76 100644
@@ -8,10 +8,12 @@ noinst_LTLIBRARIES =
 if EXTERNAL_ELL
 ell_cflags = @ELL_CFLAGS@
 ell_ldadd = @ELL_LIBS@
+ell_dependencies =
 ell_built_sources = ell/shared
 else
 ell_cflags =
 ell_ldadd = ell/libell-internal.la
+ell_dependencies = $(ell_ldadd)
 ell_built_sources = ell/shared ell/internal ell/ell.h
 
 noinst_LTLIBRARIES += ell/libell-internal.la
@@ -736,7 +738,8 @@ endif
 
 AM_CFLAGS = @DBUS_CFLAGS@ @GLIB_CFLAGS@ $(ell_cflags) $(builtin_cflags) \
 					-DOFONO_PLUGIN_BUILTIN \
-					-DPLUGINDIR=\""$(build_plugindir)"\"
+					-DPLUGINDIR=\""$(build_plugindir)"\" \
+					-DUNITDIR=\""$(top_builddir)/unit/"\"
 
 AM_CPPFLAGS = -I$(builddir)/include -I$(builddir)/src -I$(srcdir)/src \
 			-I$(srcdir)/gdbus -I$(srcdir)/gisi -I$(srcdir)/gatchat \
@@ -876,7 +879,9 @@ test_SCRIPTS = $(test_scripts)
 endif
 
 EXTRA_DIST = src/genbuiltin plugins/ofono.rules plugins/ofono-speedup.rules \
-				$(doc_files) $(test_scripts)
+		tools/provisiontool \
+		unit/test-provision.json \
+		$(doc_files) $(test_scripts)
 
 dist_man_MANS = doc/ofonod.8
 
@@ -890,7 +895,8 @@ unit_tests = unit/test-common unit/test-util \
 				unit/test-rilmodem-cs \
 				unit/test-rilmodem-sms \
 				unit/test-rilmodem-cb \
-				unit/test-rilmodem-gprs
+				unit/test-rilmodem-gprs \
+				unit/test-provision
 
 noinst_PROGRAMS = $(unit_tests) \
 			unit/test-sms-root unit/test-mux unit/test-caif
@@ -981,6 +987,17 @@ unit_test_mbim_SOURCES = unit/test-mbim.c \
 unit_test_mbim_LDADD = $(ell_ldadd)
 unit_objects += $(unit_test_mbim_OBJECTS)
 
+unit/test-provision.db: unit/test-provision.json
+	$(AM_V_GEN)$(srcdir)/tools/provisiontool generate \
+		--infile $< --outfile $@
+
+unit_test_provision_SOURCES = unit/test-provision.c \
+				src/provisiondb.h src/provisiondb.c
+unit_test_provision_LDADD = $(ell_ldadd)
+unit_test_provision_DEPENDENCIES = $(ell_dependencies) \
+					unit/test-provision.db
+unit_objects += $(unit_test_provision_OBJECTS)
+
 TESTS = $(unit_tests)
 
 if TOOLS
@@ -1103,4 +1120,4 @@ maintainer-clean-local:
 	-rm -rf build-aux ell
 
 clean-local:
-	@$(RM) -rf include/ofono
+	@$(RM) -rf include/ofono unit/test-provision.db
unit/test-provision.c new file +280 -0

280 lines not on this page · raw message

unit/test-provision.json new file +92 -0

92 lines not on this page · raw message

Signature · 1 line
2.43.0
#4 lore raw
In reply to Denis Kenzior
This series was applied to ofono.git (master) by Denis Kenzior <[email protected]>:

Hello:

This series was applied to ofono.git (master)
by Denis Kenzior <[email protected]>:

Quoted 4 lines · On Wed, 24 Jan 2024 15:12:59 -0600 you wrote:
Fixes 36a11599 ("gprs-provision: Remove no longer used atom/driver")
---
 src/ofono.h | 8 --------
 1 file changed, 8 deletions(-)

Here is the summary with links:
- [1/4] core: Remove unused declarations from ofono.h

    https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=aaff4978a495
  - [2/4] provision: Remove use of ofono_gprs_provision_data
    https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=b4cf3298dea2
  - [3/4] gprs: Add some additional context types
    https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=e6a08a1098b0
  - [4/4] unit: Add provisioning database tests
    https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=f1999cff1c7e

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html