summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2010-12-11 00:44:00 +0100
committerSamuel Ortiz <sameo@linux.intel.com>2010-12-15 20:43:50 +0100
commit74f294fff1c03c1be1263f78aa43a5f84d62fcdd (patch)
tree1e48d8b07e42319b4bd4f979f73f9df458c8e426
parent5a5c46c5d6ed2fe46a162e286fb3ba674c309afc (diff)
downloadconnman-74f294fff1c03c1be1263f78aa43a5f84d62fcdd.tar.gz
connman-74f294fff1c03c1be1263f78aa43a5f84d62fcdd.tar.bz2
connman-74f294fff1c03c1be1263f78aa43a5f84d62fcdd.zip
ofono: Set regulatory domain from network MCC
The regulatory domains can be set based on the GSM Mobile Country Code.
-rw-r--r--Makefile.plugins3
-rw-r--r--plugins/mcc.h475
-rw-r--r--plugins/ofono.c19
3 files changed, 495 insertions, 2 deletions
diff --git a/Makefile.plugins b/Makefile.plugins
index 79edda5a..025e9723 100644
--- a/Makefile.plugins
+++ b/Makefile.plugins
@@ -86,10 +86,11 @@ endif
if OFONO
if OFONO_BUILTIN
builtin_modules += ofono
-builtin_sources += plugins/ofono.c
+builtin_sources += plugins/mcc.h plugins/ofono.c
else
plugin_LTLIBRARIES += plugins/ofono.la
plugin_objects += $(plugins_ofono_la_OBJECTS)
+plugins_ofono_la_SOURCES = plugins/mcc.h plugins/ofono.c
plugins_ofono_la_CFLAGS = $(plugin_cflags)
plugins_ofono_la_LDFLAGS = $(plugin_ldflags)
endif
diff --git a/plugins/mcc.h b/plugins/mcc.h
new file mode 100644
index 00000000..0e0407c9
--- /dev/null
+++ b/plugins/mcc.h
@@ -0,0 +1,475 @@
+/*
+ * Mobile country code list from
+ * "LIST OF MOBILE COUNTRY OR GEOGRAPHICAL AREA CODES"
+ * (http://www.itu.int/publ/T-SP-E.212A-2007)
+ * combined with ISO 3166-1 alpha-2 list for two letter country codes
+ */
+
+char *mcc_country_codes[] = {
+ NULL, /* 200 */
+ NULL,
+ NULL,
+ NULL,
+ "NL",
+ NULL,
+ "BE",
+ NULL,
+ "FR",
+ NULL,
+ NULL,
+ NULL,
+ "MC",
+ "AD",
+ "ES",
+ NULL,
+ "HU",
+ NULL,
+ "BA",
+ "HR",
+ "RS",
+ NULL,
+ "IT",
+ NULL,
+ NULL,
+ "VA",
+ "RO",
+ NULL,
+ "CH",
+ NULL,
+ "CZ",
+ "SK",
+ "AT",
+ NULL,
+ "GB",
+ "GB",
+ NULL,
+ NULL,
+ "DK",
+ NULL,
+ "SE",
+ NULL,
+ "NO",
+ NULL,
+ "FI",
+ NULL,
+ "LT",
+ "LV",
+ "EE",
+ NULL,
+ "RU",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "UA",
+ NULL,
+ "BY",
+ NULL,
+ "MD",
+ "PL",
+ NULL,
+ "DE",
+ NULL,
+ NULL,
+ NULL,
+ "GI",
+ NULL,
+ "PT",
+ NULL,
+ "LU",
+ NULL,
+ "IE",
+ NULL,
+ "IS",
+ NULL,
+ "AL",
+ NULL,
+ "MT",
+ NULL,
+ "CY",
+ NULL,
+ "GE",
+ "AM",
+ "BG",
+ NULL,
+ "TR",
+ NULL,
+ "FO",
+ NULL,
+ "GL",
+ NULL,
+ "SM",
+ "SI",
+ "MK",
+ "LI",
+ NULL,
+ "ME",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "CA",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "PM",
+ NULL,
+ "US",
+ "US",
+ "US",
+ "US",
+ "US",
+ "US",
+ "US",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "PR",
+ NULL,
+ "VI",
+ NULL,
+ "MX",
+ NULL,
+ NULL,
+ NULL,
+ "JM",
+ NULL,
+ "MQ",
+ NULL,
+ "BB",
+ NULL,
+ "AG",
+ NULL,
+ "KY",
+ NULL,
+ "VG",
+ NULL,
+ "BM",
+ NULL,
+ "GD",
+ NULL,
+ "MS",
+ NULL,
+ "KN",
+ NULL,
+ "LC",
+ NULL,
+ "VC",
+ NULL,
+ "AN",
+ "AW",
+ "BS",
+ "AI",
+ "DM",
+ NULL,
+ "CU",
+ NULL,
+ "DO",
+ NULL,
+ "HT",
+ NULL,
+ "TT",
+ NULL,
+ "TC",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "AZ",
+ "KZ",
+ "BT",
+ NULL,
+ "IN",
+ "IN",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "PK",
+ NULL,
+ "AF",
+ "LK",
+ "MM",
+ "LB",
+ "JO",
+ "SY",
+ "IQ",
+ "KW",
+ "SA",
+ "YE",
+ "OM",
+ NULL,
+ "AE",
+ "IL",
+ "BH",
+ "QA",
+ "MN",
+ "NP",
+ "AE",
+ "AE",
+ "IR",
+ NULL,
+ "UZ",
+ NULL,
+ "TJ",
+ "KG",
+ "TM",
+ NULL,
+ "JP",
+ "JP",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "KR",
+ NULL,
+ "VN",
+ NULL,
+ "HK",
+ "MO",
+ "KH",
+ "LA",
+ NULL,
+ NULL,
+ "CN",
+ "CN",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "TW",
+ "KP",
+ NULL,
+ NULL,
+ "BD",
+ NULL,
+ "MV",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 500 */
+ NULL,
+ "MY",
+ NULL,
+ NULL,
+ "AU",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "ID",
+ NULL,
+ NULL,
+ NULL,
+ "TL",
+ "PH",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "TH",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "SG",
+ NULL,
+ NULL,
+ "BN",
+ NULL,
+ "NZ",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "NR",
+ "PG",
+ NULL,
+ "TO",
+ "SB",
+ "VU",
+ "FJ",
+ "WF",
+ "AS",
+ "KI",
+ "NC",
+ "PF",
+ "CK",
+ "WS",
+ "FM",
+ "MH",
+ "PW",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 600 */
+ NULL,
+ "EG",
+ "DZ",
+ "MA",
+ "TN",
+ "LY",
+ "GM",
+ "SN",
+ "MR",
+ "ML",
+ "GN",
+ "CI",
+ "BF",
+ "NE",
+ "TG",
+ "BJ",
+ "MU",
+ "LR",
+ "SL",
+ "GH",
+ "NG",
+ "TD",
+ "CF",
+ "CM",
+ "CV",
+ "ST",
+ "GQ",
+ "GA",
+ "CG",
+ "CD",
+ "AO",
+ "GW",
+ "SC",
+ "SD",
+ "RW",
+ "ET",
+ "SO",
+ "DJ",
+ "KE",
+ "TZ",
+ "UG",
+ "BI",
+ "MZ",
+ NULL,
+ "ZM",
+ "MG",
+ "TF",
+ "ZW",
+ "NA",
+ "MW",
+ "LS",
+ "BW",
+ "SZ",
+ "KM",
+ "ZA",
+ NULL,
+ "ER",
+ NULL,
+ NULL,
+ NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 700 */
+ NULL,
+ "BZ",
+ NULL,
+ "GT",
+ NULL,
+ "SV",
+ NULL,
+ "HN",
+ NULL,
+ "NI",
+ NULL,
+ "CR",
+ NULL,
+ "PA",
+ NULL,
+ "PE",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "AR",
+ NULL,
+ "BR",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "CL",
+ NULL,
+ "CO",
+ NULL,
+ "VE",
+ NULL,
+ "BO",
+ NULL,
+ "GY",
+ NULL,
+ "EC",
+ NULL,
+ "GF",
+ NULL,
+ "PY",
+ NULL,
+ "SR",
+ NULL,
+ "UY",
+ NULL,
+ "FK",
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 799 */
+};
diff --git a/plugins/ofono.c b/plugins/ofono.c
index 1cb0961d..43796255 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -25,6 +25,7 @@
#endif
#include <errno.h>
+#include <stdlib.h>
#include <gdbus.h>
#include <string.h>
@@ -36,8 +37,11 @@
#include <connman/network.h>
#include <connman/dbus.h>
#include <connman/inet.h>
+#include <connman/technology.h>
#include <connman/log.h>
+#include "mcc.h"
+
#define OFONO_SERVICE "org.ofono"
#define OFONO_MANAGER_INTERFACE OFONO_SERVICE ".Manager"
@@ -747,7 +751,7 @@ static void modem_registration_changed(struct modem_data *modem,
const char *key;
int type;
connman_uint8_t strength;
- char const *name, *status;
+ char const *name, *status, *mcc_s;
dbus_message_iter_get_basic(entry, &key);
@@ -770,6 +774,19 @@ static void modem_registration_changed(struct modem_data *modem,
} else if (g_str_equal(key, "Status") && type == DBUS_TYPE_STRING) {
dbus_message_iter_get_basic(&iter, &status);
modem_roaming_changed(modem, status);
+ } else if (g_str_equal(key, "MobileCountryCode") &&
+ type == DBUS_TYPE_STRING) {
+ int mcc;
+ char *alpha2;
+
+ dbus_message_iter_get_basic(&iter, &mcc_s);
+
+ mcc = atoi(mcc_s);
+ if (mcc > 799)
+ return;
+
+ alpha2 = mcc_country_codes[mcc - 200];
+ connman_technology_set_regdom(alpha2);
}
}