@@ -726,7 +726,8 @@ src_ofonod_SOURCES = $(builtin_sources) $(gatchat_sources) src/ofono.ver \
src/netmon.c src/lte.c src/ims.c \
src/netmonagent.c src/netmonagent.h \
src/module.c \
- src/provisiondb.h src/provisiondb.c
+ src/provisiondb.h src/provisiondb.c \
+ src/provision.c
src_ofonod_LDADD = gdbus/libgdbus-internal.la $(builtin_libadd) $(ell_ldadd) \
@GLIB_LIBS@ @DBUS_LIBS@ -ldl
@@ -582,6 +582,11 @@ void __ofono_nettime_info_received(struct ofono_modem *modem,
#include <ofono/sim-auth.h>
#include <ofono/gprs-provision.h>
+bool __ofono_provision_get_settings(const char *mcc,
+ const char *mnc, const char *spn,
+ 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,
new file mode 100644
@@ -0,0 +1,73 @@
+/*
+ * oFono - Open Source Telephony
+ * Copyright (C) 2023 Cruise, LLC
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stddef.h>
+
+#include "provisiondb.h"
+#include "ofono.h"
+
+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,
+ size_t *count)
+{
+ size_t n_contexts;
+ struct ofono_gprs_provision_data *contexts;
+ int r;
+ size_t i;
+
+ if (mcc == NULL || strlen(mcc) == 0 || mnc == NULL || strlen(mnc) == 0)
+ return false;
+
+ r = provision_db_lookup(pdb, mcc, mnc, spn, &contexts, &n_contexts);
+ if (r < 0)
+ return false;
+
+ DBG("Obtained %zd contexts for %s%s, spn: %s",
+ n_contexts, mcc, mnc, spn);
+
+ for (i = 0; i < n_contexts; i++) {
+ struct ofono_gprs_provision_data *ap = contexts + i;
+
+ DBG("APN: %s, Type: %x, Proto: %x",
+ ap->apn, ap->type, ap->proto);
+
+ if (ap->type & OFONO_GPRS_CONTEXT_TYPE_MMS)
+ DBG("MMS Proxy: %s, MMSC: %s", ap->message_proxy,
+ ap->message_center);
+ }
+
+ *count = n_contexts;
+ *settings = contexts;
+
+ return true;
+}
+
+static int provision_init(void)
+{
+ DBG("");
+
+ pdb = provision_db_new_default();
+
+ if (!pdb)
+ l_warn("Unable to open provisioning database!");
+
+ return 0;
+}
+
+static void provision_exit(void)
+{
+ provision_db_free(pdb);
+}
+
+OFONO_MODULE(provision, provision_init, provision_exit)