* [RFC PATCH 0/4] Automatic provisioning of GPRS context settings
@ 2010-12-21 9:01 Jukka Saunamaki
2010-12-21 9:01 ` [RFC PATCH 1/4] operator-settings: Add GPRS context provisioning sources Jukka Saunamaki
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Jukka Saunamaki @ 2010-12-21 9:01 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1424 bytes --]
Hello
Here is a first attempt to implement automatic provisioning of
Internet and MMS GPRS context settings. ("Internet Access Provider
database" TODO item).
In case there are no previously configured contexts found during gprs
atom registration, this code tries to provision Internet and MMS
contexts based on MCC, MNC and SPN (Service Provider Name) values read
from SIM. Settings are read from an operator settings database.
Settings database is CSV (comma separated values) formatted file(s)
with fields for: (type=INTERNET|MMS protocol=ipv4|ipv6)
MCC,MNC,SPN,type,UI name, APN, username, password, protocol, proxy IP address, proxy port, MMS server URL
e.g. file /etc/ofono/operator-settings/50-default.csv:
001,01,test,INTERNET,Network Tester GPRS,internet,,,,,,
246,81,oFono,INTERNET,Phonesim Internet,internet.apn,,,ipv4,,,
246,81,oFono,MMS,Phonesim MMS,mms.apn,mmsuser,mmspass,ipv4,10.10.10.10,8080,http://192.168.0.111:8002
This format is loosely based on what was used in Nokia N900 for
similar use.
Provisioning logic goes, that first we try to find exact match for
type,MCC,MNC and SPN. If that fails (or if SPN read from SIM is
missing/empty), we select first match for type/MCC/MNC. If also that
fails, an empty context is created (as currently).
Patches also add new function ofono_sim_get_mnc_length to SIM atom API
for figuring out MNC value.
--Jukka Saunamäki
^ permalink raw reply [flat|nested] 7+ messages in thread
* [RFC PATCH 1/4] operator-settings: Add GPRS context provisioning sources
2010-12-21 9:01 [RFC PATCH 0/4] Automatic provisioning of GPRS context settings Jukka Saunamaki
@ 2010-12-21 9:01 ` Jukka Saunamaki
2010-12-21 9:01 ` [RFC PATCH 2/4] sim: add ofono_sim_get_mnc_length Jukka Saunamaki
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Jukka Saunamaki @ 2010-12-21 9:01 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 10265 bytes --]
---
Makefile.am | 3 +-
src/operator-settings.c | 292 +++++++++++++++++++++++++++++++++++++++++++++++
src/operator-settings.h | 37 ++++++
3 files changed, 331 insertions(+), 1 deletions(-)
create mode 100644 src/operator-settings.c
create mode 100644 src/operator-settings.h
diff --git a/Makefile.am b/Makefile.am
index 12b3c33..93e4d28 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -319,7 +319,8 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) src/ofono.ver \
src/radio-settings.c src/stkutil.h src/stkutil.c \
src/nettime.c src/stkagent.c src/stkagent.h \
src/simfs.c src/simfs.h src/audio-settings.c \
- src/smsagent.c src/smsagent.h src/ctm.c
+ src/smsagent.c src/smsagent.h src/ctm.c \
+ src/operator-settings.c src/operator-settings.h
src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
diff --git a/src/operator-settings.c b/src/operator-settings.c
new file mode 100644
index 0000000..7b63d94
--- /dev/null
+++ b/src/operator-settings.c
@@ -0,0 +1,292 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <glib.h>
+
+#include "ofono.h"
+#include "operator-settings.h"
+
+#define MAX_PROXY_NAME_LENGTH 255
+
+void gprs_access_settings_free(struct gprs_access_settings *settings)
+{
+ if (settings == NULL)
+ return;
+
+ g_free(settings->name);
+ g_free(settings->apn);
+ g_free(settings->username);
+ g_free(settings->password);
+ g_free(settings->proxy);
+ g_free(settings->mms_server);
+ g_free(settings->spn);
+ g_free(settings);
+}
+
+static enum ofono_gprs_context_type string_to_gprs_context_type(const char *str)
+{
+ if (str) {
+ if (strcasecmp(str, "INTERNET") == 0)
+ return OFONO_GPRS_CONTEXT_TYPE_INTERNET;
+ if (strcasecmp(str, "MMS") == 0)
+ return OFONO_GPRS_CONTEXT_TYPE_MMS;
+ }
+
+ return OFONO_GPRS_CONTEXT_TYPE_ANY;
+}
+
+static gchar *cleanstr(const char *str)
+{
+ return g_strstrip(g_strdup(str));
+}
+
+/*
+ * Parse settings csv-file line. If MCC/MNC matches, return settings
+ *
+ * Settings file format: Comma separated fields (that cannot contain commas) of:
+ * MCC,MNC,SPN,type,UI name, APN, username, password, protocol,\
+ * proxy IP address, proxy port, MMS server URL
+ * where type=INTERNET|MMS, protocol=ipv4|ipv6
+ */
+static struct gprs_access_settings *parse_setting_line(const char *line,
+ const char *mcc,
+ const char *mnc)
+{
+ gchar **columns;
+ int count;
+ struct gprs_access_settings *entry = NULL;
+
+ columns = g_strsplit(line, ",", 0);
+ count = g_strv_length(columns);
+
+ /* mandatory values: mcc, mnc, spn, type, name, apn */
+ if (count < 6)
+ goto finish;
+
+ if (strcmp(mcc, columns[0]) != 0 || strcmp(mnc, columns[1]) != 0)
+ goto finish;
+
+ entry = g_try_malloc0(sizeof(*entry));
+ if (entry == NULL)
+ goto finish;
+
+ entry->spn = cleanstr(columns[2]);
+ entry->type = string_to_gprs_context_type(columns[3]);
+ entry->name = cleanstr(columns[4]);
+ entry->apn = cleanstr(columns[5]);
+
+ if (count > 6)
+ entry->username = cleanstr(columns[6]);
+ else
+ entry->username = g_strdup("");
+
+ if (count > 7)
+ entry->password = cleanstr(columns[7]);
+ else
+ entry->password = g_strdup("");
+
+ if (count > 8 && strcmp(columns[8], "ipv6") == 0)
+ entry->proto = OFONO_GPRS_PROTO_IPV6;
+ else
+ entry->proto = OFONO_GPRS_PROTO_IP;
+
+ if (count > 9) {
+ gchar proxy[MAX_PROXY_NAME_LENGTH + 1];
+ g_strlcpy(proxy, columns[9], MAX_PROXY_NAME_LENGTH);
+
+ if (count > 10 && strlen(columns[10]) > 0) {
+ g_strlcat(proxy, ":", MAX_PROXY_NAME_LENGTH);
+ g_strlcat(proxy, columns[10], MAX_PROXY_NAME_LENGTH);
+ }
+
+ entry->proxy = cleanstr(proxy);
+ }
+
+ if (count > 11)
+ entry->mms_server = cleanstr(columns[11]);
+
+finish:
+ g_strfreev(columns);
+ return entry;
+}
+
+/*
+ * Returns list of candidate settings matching mcc/mnc from operator
+ * settings file
+ */
+static GSList *read_settings_file(const char *filename,
+ const char *mcc, const char *mnc)
+{
+ GSList *entries = NULL;
+ FILE *f;
+ char *line = NULL;
+ size_t len = 0;
+ ssize_t read;
+
+ if (filename == NULL || mcc == NULL || mnc == NULL)
+ return NULL;
+
+ f = fopen(filename, "r");
+ if (f == NULL) {
+ DBG("Error opening settings file %s", filename);
+ return NULL;
+ }
+
+ while ((read = getline(&line, &len, f)) != -1) {
+ struct gprs_access_settings *entry;
+ entry = parse_setting_line(line, mcc, mnc);
+ if (entry != NULL)
+ entries = g_slist_append(entries, entry);
+ }
+
+ free(line);
+ fclose(f);
+
+ return entries;
+}
+
+static gboolean is_match(struct gprs_access_settings *entry,
+ enum ofono_gprs_context_type type,
+ gchar *spn_casefold)
+{
+ gboolean ret = FALSE;
+ gchar *entryspn_casefold = NULL;
+
+ if (entry->spn != NULL && strlen(entry->spn) > 0)
+ entryspn_casefold = g_utf8_casefold(entry->spn, -1);
+
+ if (type == entry->type) {
+ if (spn_casefold != NULL) {
+ if (entryspn_casefold &&
+ strcmp(spn_casefold,
+ entryspn_casefold) == 0) {
+ ret = TRUE;
+ }
+ } else {
+ ret = TRUE;
+ }
+ }
+
+ g_free(entryspn_casefold);
+ return ret;
+}
+
+/*
+ * Find best match from candidate settings based on type and SPN
+ * If there is no candidate matching SPN, take first one matching type.
+ */
+static GSList *match_entry(GSList * candidates,
+ enum ofono_gprs_context_type type,
+ const char *spn)
+{
+ GSList *ret = NULL;
+ GSList *lp = candidates;
+ gchar *spn_casefold = NULL;
+
+ if (spn != NULL && strlen(spn) > 0)
+ spn_casefold = g_utf8_casefold(spn, -1);
+
+ while (lp) {
+ struct gprs_access_settings *entry = lp->data;
+ if (is_match(entry, type, spn_casefold)) {
+ ret = lp;
+ break;
+ }
+
+ lp = lp->next;
+ if (lp == NULL && spn_casefold != NULL) {
+ /* No SPN matches, retry with only type */
+ g_free(spn_casefold);
+ spn_casefold = NULL;
+ lp = candidates;
+ }
+ }
+
+ g_free(spn_casefold);
+ return ret;
+}
+
+/*
+ * Returns GPRS context settings (internet and mms types) based on
+ * SIM provided MCC,MNC and Service Provider Name values.
+ * Operator settings for Internet and MMS access points are stored
+ * in CSV formatted files (*.csv) under $CONDIFDIR/operator-settings
+ */
+GSList *get_operator_settings(const char *mcc, const char *mnc, const char *spn)
+{
+ GSList *ret = NULL;
+ GSList *candidates = NULL;
+ GSList *match;
+ GDir *dir;
+ GSList *files = NULL, *lp;
+ const gchar *filename;
+
+ dir = g_dir_open(CONFIGDIR "/" SETTING_FILE_DIR, 0, NULL);
+ if (dir == NULL) {
+ DBG("Error opening settings directory");
+ return NULL;
+ }
+
+ while ((filename = g_dir_read_name(dir)) != NULL) {
+ if (g_str_has_suffix(filename, ".csv")) {
+ gchar *fn = g_strjoin("/", CONFIGDIR, SETTING_FILE_DIR,
+ filename, NULL);
+ files = g_slist_append(files, fn);
+ }
+ }
+
+ files = g_slist_sort(files, (GCompareFunc) g_strcmp0);
+
+ for (lp = files; lp != NULL; lp = lp->next) {
+ GSList *entries;
+ gchar *fn;
+ fn = lp->data;
+ entries = read_settings_file(fn, mcc, mnc);
+ candidates = g_slist_concat(candidates, entries);
+ g_free(fn);
+ }
+
+ g_slist_free(files);
+ g_dir_close(dir);
+
+ match = match_entry(candidates, OFONO_GPRS_CONTEXT_TYPE_INTERNET, spn);
+ if (match != NULL) {
+ candidates = g_slist_remove_link(candidates, match);
+ ret = g_slist_concat(ret, match);
+ }
+
+ match = match_entry(candidates, OFONO_GPRS_CONTEXT_TYPE_MMS, spn);
+ if (match != NULL) {
+ candidates = g_slist_remove_link(candidates, match);
+ ret = g_slist_concat(ret, match);
+ }
+
+ g_slist_foreach(candidates, (GFunc) gprs_access_settings_free, NULL);
+ g_slist_free(candidates);
+
+ return ret;
+}
diff --git a/src/operator-settings.h b/src/operator-settings.h
new file mode 100644
index 0000000..95f3785
--- /dev/null
+++ b/src/operator-settings.h
@@ -0,0 +1,37 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#define SETTING_FILE_DIR "operator-settings"
+
+struct gprs_access_settings {
+ enum ofono_gprs_context_type type;
+ gchar *name;
+ gchar *apn;
+ gchar *username;
+ gchar *password;
+ enum ofono_gprs_proto proto;
+ gchar *proxy;
+ gchar *mms_server;
+ gchar *spn;
+};
+
+GSList *get_operator_settings(const char *mcc, const char *mnc,
+ const char *spn);
+void gprs_access_settings_free(struct gprs_access_settings *settings);
--
1.7.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [RFC PATCH 2/4] sim: add ofono_sim_get_mnc_length
2010-12-21 9:01 [RFC PATCH 0/4] Automatic provisioning of GPRS context settings Jukka Saunamaki
2010-12-21 9:01 ` [RFC PATCH 1/4] operator-settings: Add GPRS context provisioning sources Jukka Saunamaki
@ 2010-12-21 9:01 ` Jukka Saunamaki
2010-12-21 9:01 ` [RFC PATCH 3/4] gprs: add automatic context settings provisioning Jukka Saunamaki
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Jukka Saunamaki @ 2010-12-21 9:01 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1066 bytes --]
---
include/sim.h | 1 +
src/sim.c | 8 ++++++++
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/include/sim.h b/include/sim.h
index 7860e24..3d0c6b7 100644
--- a/include/sim.h
+++ b/include/sim.h
@@ -173,6 +173,7 @@ void ofono_sim_set_data(struct ofono_sim *sim, void *data);
void *ofono_sim_get_data(struct ofono_sim *sim);
const char *ofono_sim_get_imsi(struct ofono_sim *sim);
+int ofono_sim_get_mnc_length(struct ofono_sim *sim);
enum ofono_sim_phase ofono_sim_get_phase(struct ofono_sim *sim);
enum ofono_sim_cphs_phase ofono_sim_get_cphs_phase(struct ofono_sim *sim);
diff --git a/src/sim.c b/src/sim.c
index 6217a25..4cfce4a 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -1911,6 +1911,14 @@ const char *ofono_sim_get_imsi(struct ofono_sim *sim)
return sim->imsi;
}
+int ofono_sim_get_mnc_length(struct ofono_sim *sim)
+{
+ if (sim == NULL)
+ return 0;
+
+ return sim->mnc_length;
+}
+
enum ofono_sim_phase ofono_sim_get_phase(struct ofono_sim *sim)
{
if (sim == NULL)
--
1.7.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [RFC PATCH 3/4] gprs: add automatic context settings provisioning
2010-12-21 9:01 [RFC PATCH 0/4] Automatic provisioning of GPRS context settings Jukka Saunamaki
2010-12-21 9:01 ` [RFC PATCH 1/4] operator-settings: Add GPRS context provisioning sources Jukka Saunamaki
2010-12-21 9:01 ` [RFC PATCH 2/4] sim: add ofono_sim_get_mnc_length Jukka Saunamaki
@ 2010-12-21 9:01 ` Jukka Saunamaki
2010-12-21 9:01 ` [RFC PATCH 4/4] operator-settings: Example GPRS context settings file Jukka Saunamaki
2010-12-21 14:11 ` [RFC PATCH 0/4] Automatic provisioning of GPRS context settings Marcel Holtmann
4 siblings, 0 replies; 7+ messages in thread
From: Jukka Saunamaki @ 2010-12-21 9:01 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 6296 bytes --]
---
src/gprs.c | 169 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 155 insertions(+), 14 deletions(-)
diff --git a/src/gprs.c b/src/gprs.c
index 58166f8..f2f2c9f 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -43,6 +43,9 @@
#include "common.h"
#include "storage.h"
#include "idmap.h"
+#include "util.h"
+#include "simutil.h"
+#include "operator-settings.h"
#define GPRS_FLAG_ATTACHING 0x1
#define GPRS_FLAG_RECHECK 0x2
@@ -2261,6 +2264,77 @@ static void netreg_watch(struct ofono_atom *atom,
gprs_netreg_update(gprs);
}
+static gboolean provision_contexts(struct ofono_gprs *gprs,
+ const char *mcc,
+ const char *mnc,
+ const char *spn)
+{
+ gboolean ret = FALSE;
+ GSList *settings, *sp;
+
+ settings = get_operator_settings(mcc, mnc, spn);
+
+ for (sp = settings; sp != NULL; sp = sp->next) {
+ unsigned int id;
+ struct pri_context *context = NULL;
+ struct gprs_access_settings *ap = sp->data;
+
+ /* Sanity check */
+ if (ap == NULL || ap->name == NULL || ap->username == NULL ||
+ ap->password == NULL || ap->apn == NULL) {
+ sp = sp->next;
+ continue;
+ }
+
+ if (gprs->last_context_id)
+ id = idmap_alloc_next(gprs->pid_map,
+ gprs->last_context_id);
+ else
+ id = idmap_alloc(gprs->pid_map);
+
+ if (id > idmap_get_max(gprs->pid_map))
+ break;
+
+ context = pri_context_create(gprs, ap->name, ap->type);
+ DBG("Provisioned context %d '%s' %s", id, ap->name,
+ context ? "created" : "creation failed");
+
+ if (context == NULL)
+ continue;
+
+ context->id = id;
+ strncpy(context->context.username, ap->username,
+ OFONO_GPRS_MAX_USERNAME_LENGTH);
+ strncpy(context->context.password, ap->password,
+ OFONO_GPRS_MAX_PASSWORD_LENGTH);
+ strncpy(context->context.apn, ap->apn,
+ OFONO_GPRS_MAX_APN_LENGTH);
+ context->context.proto = ap->proto;
+
+ if (ap->type == OFONO_GPRS_CONTEXT_TYPE_MMS &&
+ ap->proxy != NULL)
+ strncpy(context->message_proxy, ap->proxy,
+ MAX_MESSAGE_PROXY_LENGTH);
+
+ if (ap->type == OFONO_GPRS_CONTEXT_TYPE_MMS &&
+ ap->mms_server != NULL)
+ strncpy(context->message_center, ap->mms_server,
+ MAX_MESSAGE_CENTER_LENGTH);
+
+ if (context_dbus_register(context) == TRUE) {
+ gprs->last_context_id = id;
+ gprs->contexts = g_slist_append(gprs->contexts,
+ context);
+ write_context_settings(gprs, context);
+ ret = TRUE;
+ }
+ }
+ g_slist_foreach(settings, (GFunc) gprs_access_settings_free, NULL);
+ g_slist_free(settings);
+
+ return ret;
+}
+
static gboolean load_context(struct ofono_gprs *gprs, const char *group)
{
char *name = NULL;
@@ -2454,13 +2528,16 @@ remove:
storage_sync(imsi, SETTINGS_STORE, gprs->settings);
}
-void ofono_gprs_register(struct ofono_gprs *gprs)
+static void ofono_gprs_finish_register(struct ofono_gprs *gprs)
{
+
DBusConnection *conn = ofono_dbus_get_connection();
struct ofono_modem *modem = __ofono_atom_get_modem(gprs->atom);
const char *path = __ofono_atom_get_path(gprs->atom);
struct ofono_atom *netreg_atom;
- struct ofono_atom *sim_atom;
+
+ if (gprs->contexts == NULL) /* Automatic provisioning failed */
+ add_context(gprs, NULL, OFONO_GPRS_CONTEXT_TYPE_INTERNET);
if (!g_dbus_register_interface(conn, path,
OFONO_CONNECTION_MANAGER_INTERFACE,
@@ -2475,18 +2552,6 @@ void ofono_gprs_register(struct ofono_gprs *gprs)
ofono_modem_add_interface(modem,
OFONO_CONNECTION_MANAGER_INTERFACE);
- sim_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_SIM);
-
- if (sim_atom) {
- struct ofono_sim *sim = __ofono_atom_get_data(sim_atom);
- const char *imsi = ofono_sim_get_imsi(sim);
-
- gprs_load_settings(gprs, imsi);
- }
-
- if (gprs->contexts == NULL)
- add_context(gprs, NULL, OFONO_GPRS_CONTEXT_TYPE_INTERNET);
-
gprs->netreg_watch = __ofono_modem_add_atom_watch(modem,
OFONO_ATOM_TYPE_NETREG,
netreg_watch, gprs, NULL);
@@ -2498,6 +2563,82 @@ void ofono_gprs_register(struct ofono_gprs *gprs)
OFONO_ATOM_WATCH_CONDITION_REGISTERED, gprs);
__ofono_atom_register(gprs->atom, gprs_unregister);
+
+}
+
+static void sim_spn_read_cb(int ok, int length, int record,
+ const unsigned char *data,
+ int record_length, void *userdata)
+{
+ struct ofono_gprs *gprs = userdata;
+ char *spn = NULL;
+
+ struct ofono_atom *sim_atom;
+ struct ofono_sim *sim;
+ const char *imsi;
+
+ unsigned char mnc_length;
+ char mcc[OFONO_MAX_MCC_LENGTH + 1];
+ char mnc[OFONO_MAX_MNC_LENGTH + 1];
+
+ struct ofono_modem *modem = __ofono_atom_get_modem(gprs->atom);
+
+ sim_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_SIM);
+ if (sim_atom == NULL)
+ goto finish;
+
+ sim = __ofono_atom_get_data(sim_atom);
+ imsi = ofono_sim_get_imsi(sim);
+ if (imsi == NULL)
+ goto finish;
+
+ mnc_length = ofono_sim_get_mnc_length(sim);
+ if (mnc_length == 0)
+ goto finish;
+
+ strncpy(mcc, imsi, OFONO_MAX_MCC_LENGTH);
+ mcc[OFONO_MAX_MCC_LENGTH] = '\0';
+ strncpy(mnc, imsi + OFONO_MAX_MCC_LENGTH, mnc_length);
+ mnc[mnc_length] = '\0';
+
+ if (ok)
+ spn = sim_string_to_utf8(data + 1, length - 1);
+
+ /* TODO: if SPN is missing/empty, use operator name mapped from
+ mcc/mnc (when implemented in oFono) */
+
+ DBG("MCC %s, MNC %s, SPN %s", mcc, mnc, spn);
+ provision_contexts(gprs, mcc, mnc, spn);
+ g_free(spn);
+
+finish:
+ ofono_gprs_finish_register(gprs);
+
+}
+
+void ofono_gprs_register(struct ofono_gprs *gprs)
+{
+ struct ofono_modem *modem = __ofono_atom_get_modem(gprs->atom);
+ struct ofono_atom *sim_atom;
+ struct ofono_sim *sim = NULL;
+
+ sim_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_SIM);
+
+ if (sim_atom != NULL) {
+ const char *imsi = ofono_sim_get_imsi(sim);
+ sim = __ofono_atom_get_data(sim_atom);
+ gprs_load_settings(gprs, imsi);
+ }
+
+ if (gprs->contexts == NULL && sim != NULL) {
+ /* Try reading SPN for automatic context provisioning */
+ ofono_sim_read(sim, SIM_EFSPN_FILEID,
+ OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
+ sim_spn_read_cb, gprs);
+ return;
+ }
+
+ ofono_gprs_finish_register(gprs);
}
void ofono_gprs_remove(struct ofono_gprs *gprs)
--
1.7.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [RFC PATCH 4/4] operator-settings: Example GPRS context settings file
2010-12-21 9:01 [RFC PATCH 0/4] Automatic provisioning of GPRS context settings Jukka Saunamaki
` (2 preceding siblings ...)
2010-12-21 9:01 ` [RFC PATCH 3/4] gprs: add automatic context settings provisioning Jukka Saunamaki
@ 2010-12-21 9:01 ` Jukka Saunamaki
2010-12-21 14:11 ` [RFC PATCH 0/4] Automatic provisioning of GPRS context settings Marcel Holtmann
4 siblings, 0 replies; 7+ messages in thread
From: Jukka Saunamaki @ 2010-12-21 9:01 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1010 bytes --]
---
examples/example-operator-settings.csv | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
create mode 100644 examples/example-operator-settings.csv
diff --git a/examples/example-operator-settings.csv b/examples/example-operator-settings.csv
new file mode 100644
index 0000000..7493894
--- /dev/null
+++ b/examples/example-operator-settings.csv
@@ -0,0 +1,9 @@
+# Example GPRS access point settings
+# Format: (type=INTERNET|MMS protocol=ipv4|ipv6)
+# MCC,MNC,SPN,type,UI name, APN, username, password, protocol, proxy IP address, proxy port, MMS server URL
+#
+001,01,TEST,INTERNET,Network Tester GPRS,internet,,,,,,
+246,81,oFono,INTERNET,Phonesim Internet-GPRS,internet.apn,,,ipv4,,,
+246,81,oFono,MMS,Phonesim MMS-GPRS,mms.apn,mmsuser,mmspass,ipv4,10.10.10.10,8080,http://192.168.0.111:8002
+888,009,Example,INTERNET,Example Operator Internet,internet
+888,009,Example,MMS,Example Operator MMS,mms,,,ipv4,10.11.12.13,8081,http://mms.example.com:8000
--
1.7.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [RFC PATCH 0/4] Automatic provisioning of GPRS context settings
2010-12-21 9:01 [RFC PATCH 0/4] Automatic provisioning of GPRS context settings Jukka Saunamaki
` (3 preceding siblings ...)
2010-12-21 9:01 ` [RFC PATCH 4/4] operator-settings: Example GPRS context settings file Jukka Saunamaki
@ 2010-12-21 14:11 ` Marcel Holtmann
2010-12-22 10:08 ` Jukka Saunamaki
4 siblings, 1 reply; 7+ messages in thread
From: Marcel Holtmann @ 2010-12-21 14:11 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1715 bytes --]
Hi Jukka,
> Here is a first attempt to implement automatic provisioning of
> Internet and MMS GPRS context settings. ("Internet Access Provider
> database" TODO item).
>
> In case there are no previously configured contexts found during gprs
> atom registration, this code tries to provision Internet and MMS
> contexts based on MCC, MNC and SPN (Service Provider Name) values read
> from SIM. Settings are read from an operator settings database.
>
> Settings database is CSV (comma separated values) formatted file(s)
> with fields for: (type=INTERNET|MMS protocol=ipv4|ipv6)
> MCC,MNC,SPN,type,UI name, APN, username, password, protocol, proxy IP address, proxy port, MMS server URL
>
> e.g. file /etc/ofono/operator-settings/50-default.csv:
> 001,01,test,INTERNET,Network Tester GPRS,internet,,,,,,
> 246,81,oFono,INTERNET,Phonesim Internet,internet.apn,,,ipv4,,,
> 246,81,oFono,MMS,Phonesim MMS,mms.apn,mmsuser,mmspass,ipv4,10.10.10.10,8080,http://192.168.0.111:8002
>
> This format is loosely based on what was used in Nokia N900 for
> similar use.
I am really not set on a file format, but my obvious question is if we
don't wanna better use keyfile or XML based database since that are the
file formats we are currently using inside oFono. We have not used CSV
at all so far.
My vote would go for keyfile or XML since it is a bit more self
explanatory with its fields. And the order of values doesn't really
matter.
The one thing that I don't like about CSV is that you have no real
flexibility with its format. Especially coming think about that we might
have to extend this additional information for IMS or operator specific
behavior.
Regards
Marcel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC PATCH 0/4] Automatic provisioning of GPRS context settings
2010-12-21 14:11 ` [RFC PATCH 0/4] Automatic provisioning of GPRS context settings Marcel Holtmann
@ 2010-12-22 10:08 ` Jukka Saunamaki
0 siblings, 0 replies; 7+ messages in thread
From: Jukka Saunamaki @ 2010-12-22 10:08 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2242 bytes --]
Hi
On 21/12/10 16:11, ext Marcel Holtmann wrote:
>> Settings database is CSV (comma separated values) formatted file(s)
>> with fields for: (type=INTERNET|MMS protocol=ipv4|ipv6)
>> MCC,MNC,SPN,type,UI name, APN, username, password, protocol, proxy IP address, proxy port, MMS server URL
>>
>> e.g. file /etc/ofono/operator-settings/50-default.csv:
>> 001,01,test,INTERNET,Network Tester GPRS,internet,,,,,,
>> 246,81,oFono,INTERNET,Phonesim Internet,internet.apn,,,ipv4,,,
>> 246,81,oFono,MMS,Phonesim MMS,mms.apn,mmsuser,mmspass,ipv4,10.10.10.10,8080,http://192.168.0.111:8002
>>
>> This format is loosely based on what was used in Nokia N900 for
>> similar use.
> I am really not set on a file format, but my obvious question is if we
> don't wanna better use keyfile or XML based database since that are the
> file formats we are currently using inside oFono. We have not used CSV
> at all so far.
>
> My vote would go for keyfile or XML since it is a bit more self
> explanatory with its fields. And the order of values doesn't really
> matter.
>
> The one thing that I don't like about CSV is that you have no real
> flexibility with its format. Especially coming think about that we might
> have to extend this additional information for IMS or operator specific
> behavior.
Good points. I suggested csv, because it is very simple and fast to
parse, and it has proven to be "good enough" for this specific purpose.
But, true, it is also very inflexible.
So, how about something like this XML format: (better element name
suggestions welcome)
<?xml version="1.0"?>
<settings>
<access type="internet" mcc="001" mnc="01" spn="test" name="Example
Internet GPRS" apn="internet" protocol="ipv4"/>
<access type="mms" mcc="001" mnc="01" spn="test" name="Example MMS GPRS"
apn="mms" proxy="10.11.12.13:8080" mmsserver="http://mms.example.com:8000"/>
<access ... />
...
</settings>
This would still be quite easy and fast to parse (using glib simple XML
parser), would not be hugely larger in size and would allow easy adding
of new attributes/values.
Also, do you or anybody have comments about the logic of provisioning,
and changes to sim and gprs parts?
--Jukka Saunamäki
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-12-22 10:08 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-21 9:01 [RFC PATCH 0/4] Automatic provisioning of GPRS context settings Jukka Saunamaki
2010-12-21 9:01 ` [RFC PATCH 1/4] operator-settings: Add GPRS context provisioning sources Jukka Saunamaki
2010-12-21 9:01 ` [RFC PATCH 2/4] sim: add ofono_sim_get_mnc_length Jukka Saunamaki
2010-12-21 9:01 ` [RFC PATCH 3/4] gprs: add automatic context settings provisioning Jukka Saunamaki
2010-12-21 9:01 ` [RFC PATCH 4/4] operator-settings: Example GPRS context settings file Jukka Saunamaki
2010-12-21 14:11 ` [RFC PATCH 0/4] Automatic provisioning of GPRS context settings Marcel Holtmann
2010-12-22 10:08 ` Jukka Saunamaki
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.