Compare commits

...

13 Commits

Author SHA1 Message Date
Tommi Kenakkala
59449f74a1 Merge pull request #282 from monich/provision
Add ProvisionContext method to ConnectionContext interface
2015-02-25 15:16:31 +02:00
Slava Monich
ff63e9b057 [ofono] Added ProvisionContext method to ConnectionContext interface
Allows to reset connection context properties back to default.
2015-02-25 12:36:04 +02:00
Pasi Sjöholm
7b73f569eb Merge pull request #280 from tigeli/master
[rilmodem] fix issue with only one nameserver being provided
2015-02-23 10:03:55 +01:00
Pasi Sjöholm
5672f7248d [rilmodem] fix issue with only one nameserver being provided
No need to check if we have multiple nameserver provided
by the context, single one is enough.
2015-02-20 22:21:26 +02:00
Tommi Kenakkala
2ed0073bd1 Merge pull request #279 from tkenakka/log
[ofono] Add ril disconnect logging
2015-02-17 12:29:19 +02:00
Tommi Kenakkala
f6ade48648 Merge pull request #278 from tkenakka/sms-tp-oa
Fix received SMS alphanumeric TP-OA handling
2015-02-17 12:28:55 +02:00
Tommi Kenakkala
73ba48c9fb [ofono] Add ril disconnect logging 2015-02-17 11:12:18 +02:00
Tommi Kenakkala
f3611cef21 [ofono] unit: Add test to encode / decode 11 char SMS TP-OA 2015-02-16 10:31:16 +02:00
Tommi Kenakkala
15d682e62a [ofono] sms: Fix alphanumeric TP-OA handling
This fixes the issue of ofono ignoring received SMS if originator address
is a 11-character long alphanumeric string (with ext. ASCII).

TP-OA max length comparisons were incorrect because TP-OA's 7-bit coded
octets transport eleven 8-bit chars. The current code assumed only 10 chars
were possible.
- increases the array size to 23, (max 22 bytes for UTF8 + null terminator)
- Updates the sanity check to account for the correct maximum
- For encoding, checks the maximum length in UTF8 characters instead of bytes
- Make sure after the UTF8 -> GSM conversion that the number of GSM bytes is
not > 11, which is the maximum payload.
2015-02-16 10:30:18 +02:00
Tommi Kenakkala
0c23ed90b7 Merge pull request #276 from tkenakka/sco-sock
[ofono] hfp_hf_bluez5 typo fix
2015-01-27 10:44:12 +02:00
Tommi Kenakkala
54854c44a2 [ofono] hfp_hf_bluez5 typo fix 2015-01-27 10:41:00 +02:00
Tommi Kenakkala
da297d5722 Merge pull request #275 from tkenakka/sco-sock
[ofono] Move handsfree audio manager cleanup to hfp_hf_bluez5 plugin
2015-01-27 10:34:12 +02:00
Tommi Kenakkala
aba76cec73 [ofono] Move handsfree audio manager cleanup to hfp_hf_bluez5 plugin 2015-01-27 10:02:40 +02:00
9 changed files with 257 additions and 16 deletions

View File

@@ -155,6 +155,15 @@ Methods dict GetProperties()
[service].Error.AttachInProgress
[service].Error.NotImplemented
Methods void ProvisionContext()
Resets all properties back to default. Fails to make
any changes to the context if it is active or in the
process of being activated or deactivated.
Possible Errors: [service].Error.Failed
[service].Error.InProgress
[service].Error.NotAvailable
Signals PropertyChanged(string property, variant value)
This signal indicates a changed value of the given

View File

@@ -128,7 +128,6 @@ static void ril_gprs_split_dns_by_protocol(char **dns_array, char ***dns_addr,
{
const char ipv6_delimiter = ':';
const char ip_delimiter = '.';
const char dns_delimiter = ',';
char *temp = NULL;
char *temp1 = NULL;
char *dnsip = NULL;
@@ -164,15 +163,11 @@ static void ril_gprs_split_dns_by_protocol(char **dns_array, char ***dns_addr,
}
}
if (dnsip){
if (strchr(dnsip,dns_delimiter))
*dns_addr = g_strsplit(dnsip, ",", dnsip_len);
}
if (dnsip)
*dns_addr = g_strsplit(dnsip, ",", dnsip_len);
if (dnsipv6) {
if (strchr(dnsipv6,dns_delimiter))
*dns_ipv6_addr = g_strsplit(dnsipv6, ",", dnsipv6_len);
}
if (dnsipv6)
*dns_ipv6_addr = g_strsplit(dnsipv6, ",", dnsipv6_len);
g_free(dnsip);
g_free(dnsipv6);

View File

@@ -820,6 +820,8 @@ static void hfp_exit(void)
g_dbus_client_unref(bluez);
ofono_handsfree_audio_unref();
__ofono_handsfree_audio_manager_cleanup();
}
OFONO_PLUGIN_DEFINE(hfp_bluez5, "External Hands-Free Profile Plugin", VERSION,

View File

@@ -432,8 +432,7 @@ static gboolean ril_re_init(gpointer user_data)
static void gril_disconnected(gpointer user_data)
{
/* Signal clients modem going down
*/
ofono_info("gril disconnected");
struct ofono_modem *modem = user_data;
DBusConnection *conn = ofono_dbus_get_connection();

View File

@@ -151,6 +151,8 @@ struct pri_context {
static void gprs_netreg_update(struct ofono_gprs *gprs);
static void gprs_deactivate_next(struct ofono_gprs *gprs);
static void write_context_settings(struct ofono_gprs *gprs,
struct pri_context *context);
static GSList *g_drivers = NULL;
static GSList *g_context_drivers = NULL;
@@ -820,6 +822,185 @@ static void pri_update_mms_context_settings(struct pri_context *ctx)
pri_limit_mtu(settings->interface, MAX_MMS_MTU);
}
static gboolean pri_str_changed(const char *val, const char *newval)
{
return newval ? (strcmp(val, newval) != 0) : (val[0] != 0);
}
static gboolean pri_str_update(char *val, const char *newval)
{
if (newval) {
if (strcmp(val, newval)) {
strcpy(val, newval);
return TRUE;
}
} else {
if (val[0]) {
val[0] = 0;
return TRUE;
}
}
return FALSE;
}
static void pri_str_signal_change(struct pri_context *ctx,
const char *name, const char *value)
{
ofono_dbus_signal_property_changed(ofono_dbus_get_connection(),
ctx->path, OFONO_CONNECTION_CONTEXT_INTERFACE,
name, DBUS_TYPE_STRING, &value);
}
static void pri_reset_context_properties(struct pri_context *ctx,
const struct ofono_gprs_provision_data *ap)
{
struct ofono_gprs *gprs = ctx->gprs;
gboolean changed = FALSE;
DBG("%s", ctx->path);
if (strcmp(ctx->context.apn, ap->apn)) {
changed = TRUE;
strcpy(ctx->context.apn, ap->apn);
pri_str_signal_change(ctx, "AccessPointName", ap->apn);
}
if (ap->name && strncmp(ctx->name, ap->name, MAX_CONTEXT_NAME_LENGTH)) {
changed = TRUE;
strncpy(ctx->name, ap->name, MAX_CONTEXT_NAME_LENGTH);
pri_str_signal_change(ctx, "Name", ap->name);
}
if (pri_str_update(ctx->context.username, ap->username)) {
changed = TRUE;
pri_str_signal_change(ctx, "Username", ap->username);
}
if (pri_str_update(ctx->context.password, ap->password)) {
changed = TRUE;
pri_str_signal_change(ctx, "Password", ap->password);
}
if (ctx->context.proto != ap->proto) {
ctx->context.proto = ap->proto;
changed = TRUE;
pri_str_signal_change(ctx, "Protocol",
gprs_proto_to_string(ap->proto));
}
if (ap->type == OFONO_GPRS_CONTEXT_TYPE_MMS) {
if (pri_str_update(ctx->message_proxy, ap->message_proxy)) {
changed = TRUE;
pri_str_signal_change(ctx, "MessageProxy",
ap->message_proxy);
}
if (pri_str_update(ctx->message_center, ap->message_center)) {
changed = TRUE;
pri_str_signal_change(ctx, "MessageCenter",
ap->message_center);
}
}
if (gprs->settings && changed) {
write_context_settings(gprs, ctx);
storage_sync(gprs->imsi, SETTINGS_STORE, gprs->settings);
}
}
static gboolean ap_valid(const struct ofono_gprs_provision_data *ap)
{
if (!ap->apn || strlen(ap->apn) > OFONO_GPRS_MAX_APN_LENGTH ||
!is_valid_apn(ap->apn))
return FALSE;
if (ap->username &&
strlen(ap->username) > OFONO_GPRS_MAX_USERNAME_LENGTH)
return FALSE;
if (ap->password &&
strlen(ap->password) > OFONO_GPRS_MAX_PASSWORD_LENGTH)
return FALSE;
if (ap->message_proxy &&
strlen(ap->message_proxy) > MAX_MESSAGE_PROXY_LENGTH)
return FALSE;
if (ap->message_center &&
strlen(ap->message_center) > MAX_MESSAGE_CENTER_LENGTH)
return FALSE;
return TRUE;
}
static gboolean pri_deactivation_required(struct pri_context *ctx,
const struct ofono_gprs_provision_data *ap)
{
if (ctx->context.proto != ap->proto)
return TRUE;
if (strcmp(ctx->context.apn, ap->apn))
return TRUE;
if (pri_str_changed(ctx->context.username, ap->username))
return TRUE;
if (pri_str_changed(ctx->context.password, ap->password))
return TRUE;
if (ap->type == OFONO_GPRS_CONTEXT_TYPE_MMS) {
if (pri_str_changed(ctx->message_proxy, ap->message_proxy))
return TRUE;
if (pri_str_changed(ctx->message_center, ap->message_center))
return TRUE;
}
return FALSE;
}
static DBusMessage *pri_provision_context(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct pri_context *ctx = data;
struct ofono_gprs *gprs = ctx->gprs;
struct ofono_modem *modem = __ofono_atom_get_modem(gprs->atom);
struct ofono_sim *sim = __ofono_atom_find(OFONO_ATOM_TYPE_SIM, modem);
struct ofono_gprs_provision_data *settings;
DBusMessage *reply = NULL;
int i, count = 0;
if (sim == NULL)
return __ofono_error_failed(msg);
if (__ofono_gprs_provision_get_settings(ofono_sim_get_mcc(sim),
ofono_sim_get_mnc(sim), ofono_sim_get_spn(sim),
&settings, &count) == FALSE)
return __ofono_error_failed(msg);
for (i = 0; i < count; i++) {
const struct ofono_gprs_provision_data *ap = settings + i;
if (ap->type == ctx->type && ap_valid(ap)) {
if ((!ctx->active &&
!ctx->pending && !ctx->gprs->pending) ||
!pri_deactivation_required(ctx, ap)) {
/* Re-provision the context */
pri_reset_context_properties(ctx, ap);
reply = dbus_message_new_method_return(msg);
} else {
/* Othwise context must be deactivated first */
if (ctx->gprs->pending || ctx->pending)
reply = __ofono_error_busy(msg);
}
break;
}
}
__ofono_gprs_provision_free_settings(settings, count);
return reply ? reply : __ofono_error_not_available(msg);
}
static void append_context_properties(struct pri_context *ctx,
DBusMessageIter *dict)
{
@@ -1337,6 +1518,8 @@ static const GDBusMethodTable context_methods[] = {
{ GDBUS_ASYNC_METHOD("SetProperty",
GDBUS_ARGS({ "property", "s" }, { "value", "v" }),
NULL, pri_set_property) },
{ GDBUS_METHOD("ProvisionContext", NULL, NULL,
pri_provision_context) },
{ }
};

View File

@@ -259,7 +259,7 @@ int main(int argc, char **argv)
__ofono_plugin_cleanup();
__ofono_handsfree_audio_manager_cleanup();
//__ofono_handsfree_audio_manager_cleanup(); See comment above
__ofono_manager_cleanup();

View File

@@ -524,7 +524,8 @@ static gboolean encode_validity_period(const struct sms_validity_period *vp,
gboolean sms_encode_address_field(const struct sms_address *in, gboolean sc,
unsigned char *pdu, int *offset)
{
size_t len = strlen(in->address);
const char *addr = (const char *)&in->address;
size_t len = strlen(addr);
unsigned char addr_len = 0;
unsigned char p[10];
@@ -546,13 +547,19 @@ gboolean sms_encode_address_field(const struct sms_address *in, gboolean sc,
unsigned char *gsm;
unsigned char *r;
if (len > 11)
/* TP-OA's 10 octets transport 11 8-bit chars */
if (g_utf8_strlen(addr, strlen(addr)) > 11)
return FALSE;
gsm = convert_utf8_to_gsm(in->address, len, NULL, &written, 0);
if (gsm == NULL)
return FALSE;
if (written > 11) {
g_free(gsm);
return FALSE;
}
r = pack_7bit_own_buf(gsm, written, 0, FALSE, &packed, 0, p);
g_free(gsm);
@@ -675,7 +682,11 @@ gboolean sms_decode_address_field(const unsigned char *pdu, int len,
if (utf8 == NULL)
return FALSE;
if (strlen(utf8) > 20) {
/*
* TP-OA's 10 octets transport 11 8-bit chars,
* 22 bytes+terminator in UTF-8.
*/
if (strlen(utf8) > 22) {
g_free(utf8);
return FALSE;
}

View File

@@ -220,7 +220,11 @@ enum cbs_geo_scope {
struct sms_address {
enum sms_number_type number_type;
enum sms_numbering_plan numbering_plan;
char address[21]; /* Max 20 in semi-octet, 11 in alnum */
/*
* An alphanum TP-OA is 10 7-bit coded octets, which can carry
* 11 8-bit characters. 22 bytes + terminator in UTF-8.
*/
char address[23];
};
struct sms_scts {

View File

@@ -38,6 +38,12 @@ static const char *simple_deliver = "07911326040000F0"
"040B911346610089F60000208062917314480CC8F71D14969741F977FD07";
static const char *alnum_sender = "0791447758100650"
"040DD0F334FC1CA6970100008080312170224008D4F29CDE0EA7D9";
static const char *unicode_deliver = "04819999990414D0FBFD7EBFDFEFF77BFE1E001"
"9512090801361807E00DC00FC00C400E400D600F600C500E500D800F800C"
"600E600C700E700C900E900CA00EA00DF003100320033003400350036003"
"7003800390030002000540068006900730020006D0065007300730061006"
"7006500200069007300200036003300200075006E00690063006F0064006"
"5002000630068006100720073002E";
static const char *simple_submit = "0011000B916407281553F80000AA"
"0AE8329BFD4697D9EC37";
@@ -362,6 +368,38 @@ static void test_deliver_encode(void)
g_assert(strcmp(alnum_sender, encoded_pdu) == 0);
g_free(encoded_pdu);
/* test unicode_deliver*/
decoded_pdu = decode_hex(unicode_deliver, -1, &pdu_len, 0);
g_assert(decoded_pdu);
g_assert(pdu_len == (long)strlen(unicode_deliver) / 2);
ret = sms_decode(decoded_pdu, pdu_len, FALSE, 149, &sms);
g_free(decoded_pdu);
g_assert(ret);
g_assert(sms.type == SMS_TYPE_DELIVER);
ret = sms_encode(&sms, &encoded_pdu_len, &encoded_tpdu_len, pdu);
if (g_test_verbose()) {
int i;
for (i = 0; i < encoded_pdu_len; i++)
g_print("%02X", pdu[i]);
g_print("\n");
}
g_assert(ret);
g_assert(encoded_tpdu_len == 149);
g_assert(encoded_pdu_len == pdu_len);
encoded_pdu = encode_hex(pdu, encoded_pdu_len, 0);
g_assert(strcmp(unicode_deliver, encoded_pdu) == 0);
g_free(encoded_pdu);
}
static void test_simple_submit(void)