* [RFC PATCH 0/3] Long phone numbers
@ 2011-01-17 14:59 Rafael Ignacio Zurita
2011-01-17 14:59 ` [RFC PATCH 1/3] types: change OFONO_MAX_PHONE_NUMBER_LENGTH value to 80 Rafael Ignacio Zurita
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Rafael Ignacio Zurita @ 2011-01-17 14:59 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 946 bytes --]
This is a proposal for the "long phone number" task (80 digits max length).
It changes OFONO_MAX_PHONE_NUMBER_LENGTH and splits
common:valid_phone_number_format(), to make sure long numbers are handled
appropriately for functions that need manage shorter numbers, like
numbers written to the SIM, or sms SCA.
Rafael Ignacio Zurita (3):
types: change OFONO_MAX_PHONE_NUMBER_LENGTH value to 80
common: split valid_phone_number_format and adapt atoms
smart-messaging: Adapt to use new number format validation function
include/types.h | 2 +-
plugins/smart-messaging.c | 4 ++--
src/call-forwarding.c | 4 ++++
src/common.c | 20 ++++++++++++++++++--
src/common.h | 2 ++
src/message-waiting.c | 14 ++++++++++++++
src/sim.c | 2 +-
src/sms.c | 5 +++--
8 files changed, 45 insertions(+), 8 deletions(-)
--
1.7.2.3
^ permalink raw reply [flat|nested] 7+ messages in thread* [RFC PATCH 1/3] types: change OFONO_MAX_PHONE_NUMBER_LENGTH value to 80 2011-01-17 14:59 [RFC PATCH 0/3] Long phone numbers Rafael Ignacio Zurita @ 2011-01-17 14:59 ` Rafael Ignacio Zurita 2011-01-17 14:59 ` [RFC PATCH 2/3] common: split valid_phone_number_format and adapt atoms Rafael Ignacio Zurita ` (2 subsequent siblings) 3 siblings, 0 replies; 7+ messages in thread From: Rafael Ignacio Zurita @ 2011-01-17 14:59 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 450 bytes --] --- include/types.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/include/types.h b/include/types.h index 1b95eaa..e4951e4 100644 --- a/include/types.h +++ b/include/types.h @@ -76,7 +76,7 @@ struct ofono_error { int error; }; -#define OFONO_MAX_PHONE_NUMBER_LENGTH 20 +#define OFONO_MAX_PHONE_NUMBER_LENGTH 80 #define OFONO_MAX_CALLER_NAME_LENGTH 80 struct ofono_phone_number { -- 1.7.2.3 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [RFC PATCH 2/3] common: split valid_phone_number_format and adapt atoms 2011-01-17 14:59 [RFC PATCH 0/3] Long phone numbers Rafael Ignacio Zurita 2011-01-17 14:59 ` [RFC PATCH 1/3] types: change OFONO_MAX_PHONE_NUMBER_LENGTH value to 80 Rafael Ignacio Zurita @ 2011-01-17 14:59 ` Rafael Ignacio Zurita 2011-01-17 14:59 ` [RFC PATCH 3/3] smart-messaging: Adapt to use new validation function Rafael Ignacio Zurita 2011-01-17 21:18 ` [RFC PATCH 0/3] Long phone numbers Pekka Pessi 3 siblings, 0 replies; 7+ messages in thread From: Rafael Ignacio Zurita @ 2011-01-17 14:59 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 4763 bytes --] --- src/call-forwarding.c | 4 ++++ src/common.c | 20 ++++++++++++++++++-- src/common.h | 2 ++ src/message-waiting.c | 14 ++++++++++++++ src/sim.c | 2 +- src/sms.c | 5 +++-- 6 files changed, 42 insertions(+), 5 deletions(-) diff --git a/src/call-forwarding.c b/src/call-forwarding.c index 512f223..9fdfeb5 100644 --- a/src/call-forwarding.c +++ b/src/call-forwarding.c @@ -260,6 +260,10 @@ static void sim_set_cf_indicator(struct ofono_call_forwarding *cf) data[0] = 0x01; if (cfu_voice) { + if (!valid_short_phone_number_format( + cond->phone_number.number)) + return; + number_len = strlen(cond->phone_number.number); /* CFU indicator Status - Voice */ diff --git a/src/common.c b/src/common.c index 4d93488..2096e79 100644 --- a/src/common.c +++ b/src/common.c @@ -234,7 +234,7 @@ struct error_entry ceer_errors[] = { { 127, "Interworking, unspecified" }, }; -gboolean valid_phone_number_format(const char *number) +gboolean valid_number_format(const char *number, int length) { int len = strlen(number); int begin = 0; @@ -246,7 +246,7 @@ gboolean valid_phone_number_format(const char *number) if (number[0] == '+') begin = 1; - if ((len - begin) > OFONO_MAX_PHONE_NUMBER_LENGTH) + if ((len - begin) > length) return FALSE; for (i = begin; i < len; i++) { @@ -262,6 +262,22 @@ gboolean valid_phone_number_format(const char *number) return TRUE; } +gboolean valid_phone_number_format(const char *number) +{ + return valid_number_format(number, OFONO_MAX_PHONE_NUMBER_LENGTH); +} + +/* + * According to 3GPP TS 24.011 or 3GPP TS 31.102, some + * addresses (or numbers), like Service Centre address, + * Destination address, or EFADN (Abbreviated dialling numbers), + * are up 20 digits. + */ +gboolean valid_short_phone_number_format(const char *number) +{ + return valid_number_format(number, 20); +} + gboolean valid_cdma_phone_number_format(const char *number) { int len = strlen(number); diff --git a/src/common.h b/src/common.h index 64f297e..86f97f8 100644 --- a/src/common.h +++ b/src/common.h @@ -131,7 +131,9 @@ enum pin_type { const char *telephony_error_to_str(const struct ofono_error *error); +gboolean valid_number_format(const char *number, int length); gboolean valid_phone_number_format(const char *number); +gboolean valid_short_phone_number_format(const char *number); const char *phone_number_to_string(const struct ofono_phone_number *ph); void string_to_phone_number(const char *str, struct ofono_phone_number *ph); diff --git a/src/message-waiting.c b/src/message-waiting.c index d8bfe34..5322f96 100644 --- a/src/message-waiting.c +++ b/src/message-waiting.c @@ -192,6 +192,13 @@ static DBusMessage *set_cphs_mbdn(struct ofono_message_waiting *mw, return NULL; } + if (!valid_short_phone_number_format(number)) { + if (msg) + return __ofono_error_invalid_format(msg); + + return NULL; + } + req = g_new0(struct mbdn_set_request, 1); req->mw = mw; @@ -291,6 +298,13 @@ static DBusMessage *set_mbdn(struct ofono_message_waiting *mw, int mailbox, return NULL; } + if (!valid_short_phone_number_format(number)) { + if (msg) + return __ofono_error_invalid_format(msg); + + return NULL; + } + req = g_new0(struct mbdn_set_request, 1); req->mw = mw; diff --git a/src/sim.c b/src/sim.c index d627647..6b3a911 100644 --- a/src/sim.c +++ b/src/sim.c @@ -565,7 +565,7 @@ static DBusMessage *sim_set_property(DBusConnection *conn, DBusMessage *msg, dbus_message_iter_get_basic(&var_elem, &value); - if (!valid_phone_number_format(value)) + if (!valid_short_phone_number_format(value)) goto error; own = g_new0(struct ofono_phone_number, 1); diff --git a/src/sms.c b/src/sms.c index 9bb5c93..a6134bd 100644 --- a/src/sms.c +++ b/src/sms.c @@ -654,7 +654,8 @@ static DBusMessage *sms_set_property(DBusConnection *conn, DBusMessage *msg, dbus_message_iter_get_basic(&var, &value); - if (strlen(value) == 0 || !valid_phone_number_format(value)) + if (strlen(value) == 0 || + !valid_short_phone_number_format(value)) return __ofono_error_invalid_format(msg); if (sms->driver->sca_set == NULL || @@ -983,7 +984,7 @@ static DBusMessage *sms_send_message(DBusConnection *conn, DBusMessage *msg, DBUS_TYPE_INVALID)) return __ofono_error_invalid_args(msg); - if (valid_phone_number_format(to) == FALSE) + if (valid_short_phone_number_format(to) == FALSE) return __ofono_error_invalid_format(msg); msg_list = sms_text_prepare(to, text, sms->ref, use_16bit_ref, -- 1.7.2.3 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [RFC PATCH 3/3] smart-messaging: Adapt to use new validation function 2011-01-17 14:59 [RFC PATCH 0/3] Long phone numbers Rafael Ignacio Zurita 2011-01-17 14:59 ` [RFC PATCH 1/3] types: change OFONO_MAX_PHONE_NUMBER_LENGTH value to 80 Rafael Ignacio Zurita 2011-01-17 14:59 ` [RFC PATCH 2/3] common: split valid_phone_number_format and adapt atoms Rafael Ignacio Zurita @ 2011-01-17 14:59 ` Rafael Ignacio Zurita 2011-01-17 21:18 ` [RFC PATCH 0/3] Long phone numbers Pekka Pessi 3 siblings, 0 replies; 7+ messages in thread From: Rafael Ignacio Zurita @ 2011-01-17 14:59 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 1020 bytes --] --- plugins/smart-messaging.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/smart-messaging.c b/plugins/smart-messaging.c index 40af89f..5b77263 100644 --- a/plugins/smart-messaging.c +++ b/plugins/smart-messaging.c @@ -200,7 +200,7 @@ static DBusMessage *smart_messaging_send_vcard(DBusConnection *conn, &bytes, &len, DBUS_TYPE_INVALID)) return __ofono_error_invalid_args(msg); - if (valid_phone_number_format(to) == FALSE) + if (valid_short_phone_number_format(to) == FALSE) return __ofono_error_invalid_format(msg); ref = __ofono_sms_get_next_ref(sm->sms); @@ -243,7 +243,7 @@ static DBusMessage *smart_messaging_send_vcal(DBusConnection *conn, &bytes, &len, DBUS_TYPE_INVALID)) return __ofono_error_invalid_args(msg); - if (valid_phone_number_format(to) == FALSE) + if (valid_short_phone_number_format(to) == FALSE) return __ofono_error_invalid_format(msg); ref = __ofono_sms_get_next_ref(sm->sms); -- 1.7.2.3 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [RFC PATCH 0/3] Long phone numbers 2011-01-17 14:59 [RFC PATCH 0/3] Long phone numbers Rafael Ignacio Zurita ` (2 preceding siblings ...) 2011-01-17 14:59 ` [RFC PATCH 3/3] smart-messaging: Adapt to use new validation function Rafael Ignacio Zurita @ 2011-01-17 21:18 ` Pekka Pessi 2011-01-18 9:39 ` Rafael Ignacio Zurita 3 siblings, 1 reply; 7+ messages in thread From: Pekka Pessi @ 2011-01-17 21:18 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 822 bytes --] Hi Rafael, 2011/1/17 Rafael Ignacio Zurita <rafael.zurita@profusion.mobi>: > This is a proposal for the "long phone number" task (80 digits max length). > It changes OFONO_MAX_PHONE_NUMBER_LENGTH and splits > common:valid_phone_number_format(), to make sure long numbers are handled > appropriately for functions that need manage shorter numbers, like > numbers written to the SIM, or sms SCA. Perhaps a validator and type for long phone numbers is better than for short numbers? I guess long numbers are mostly used when reporting an outgoing call back to oFono. BTW, with call forwarding you could have numbers up to 16 digits or if longForwardedToNumber is supported (by modem and both home and visited networks) even 28 digits. See TS 29.002 for merry details. -- Pekka.Pessi mail at nokia.com ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC PATCH 0/3] Long phone numbers 2011-01-17 21:18 ` [RFC PATCH 0/3] Long phone numbers Pekka Pessi @ 2011-01-18 9:39 ` Rafael Ignacio Zurita 2011-01-19 4:27 ` Denis Kenzior 0 siblings, 1 reply; 7+ messages in thread From: Rafael Ignacio Zurita @ 2011-01-18 9:39 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 1293 bytes --] On Mon, Jan 17, 2011 at 11:18:51PM +0200, Pekka Pessi wrote: > Hi Rafael, > > 2011/1/17 Rafael Ignacio Zurita <rafael.zurita@profusion.mobi>: > > This is a proposal for the "long phone number" task (80 digits max length). > > It changes OFONO_MAX_PHONE_NUMBER_LENGTH and splits > > common:valid_phone_number_format(), to make sure long numbers are handled > > appropriately for functions that need manage shorter numbers, like > > numbers written to the SIM, or sms SCA. > > Perhaps a validator and type for long phone numbers is better than for > short numbers? I guess long numbers are mostly used when reporting an > outgoing call back to oFono. No completely sure if it is better. Maybe it is the same?. With a new type for long number we will have modifications on other parts of the code which use OFONO_MAX_PHONE_NUMBER_LENGTH. The first idea could be simpler because we just have one type and would check for the format and length on the proper places. > BTW, with call forwarding you could have numbers up to 16 digits or if > longForwardedToNumber is supported (by modem and both home and visited > networks) even 28 digits. See TS 29.002 for merry details. Thanks for that. I am checking, and going to add an extra validator surely. Rafael Zurita ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC PATCH 0/3] Long phone numbers 2011-01-18 9:39 ` Rafael Ignacio Zurita @ 2011-01-19 4:27 ` Denis Kenzior 0 siblings, 0 replies; 7+ messages in thread From: Denis Kenzior @ 2011-01-19 4:27 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 2320 bytes --] Hi Rafael, On 01/18/2011 03:39 AM, Rafael Ignacio Zurita wrote: > On Mon, Jan 17, 2011 at 11:18:51PM +0200, Pekka Pessi wrote: >> Hi Rafael, >> >> 2011/1/17 Rafael Ignacio Zurita <rafael.zurita@profusion.mobi>: >>> This is a proposal for the "long phone number" task (80 digits max length). >>> It changes OFONO_MAX_PHONE_NUMBER_LENGTH and splits >>> common:valid_phone_number_format(), to make sure long numbers are handled >>> appropriately for functions that need manage shorter numbers, like >>> numbers written to the SIM, or sms SCA. >> >> Perhaps a validator and type for long phone numbers is better than for >> short numbers? I guess long numbers are mostly used when reporting an >> outgoing call back to oFono. > > No completely sure if it is better. Maybe it is the same?. With a new > type for long number we will have modifications on other parts of the code > which use OFONO_MAX_PHONE_NUMBER_LENGTH. The first idea could be simpler > because we just have one type and would check for the format and length on the > proper places. So I actually agree with Pekka on this one, validating the long phone number might actually be a bit easier. Basically the long phone number only happens when we place an outgoing call. For the rest we can keep the limit to 20. However, do note that this function is being (ab)used for: - Checking valid destination for an SMS (20 chars max) - Checking valid phone number to be written to SIM (currently no extension records, so 20 chars max) - Checking valid phone number to be sent to ATD (80 chars max) - Checking valid phone number to be uses for deflection (? chars max) Perhaps we should use an enumeration of the type of number we want, similar to how is_valid_pin is implemented. > >> BTW, with call forwarding you could have numbers up to 16 digits or if >> longForwardedToNumber is supported (by modem and both home and visited >> networks) even 28 digits. See TS 29.002 for merry details. > > Thanks for that. I am checking, and going to add an extra validator > surely. > This might be a good idea, but keep in mind that if we set a long number into CFU, we might not be able to support writing it out to the SIM's EFcfis record. So 20 characters might be all you have anyway. Regards, -Denis ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-01-19 4:27 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-01-17 14:59 [RFC PATCH 0/3] Long phone numbers Rafael Ignacio Zurita 2011-01-17 14:59 ` [RFC PATCH 1/3] types: change OFONO_MAX_PHONE_NUMBER_LENGTH value to 80 Rafael Ignacio Zurita 2011-01-17 14:59 ` [RFC PATCH 2/3] common: split valid_phone_number_format and adapt atoms Rafael Ignacio Zurita 2011-01-17 14:59 ` [RFC PATCH 3/3] smart-messaging: Adapt to use new validation function Rafael Ignacio Zurita 2011-01-17 21:18 ` [RFC PATCH 0/3] Long phone numbers Pekka Pessi 2011-01-18 9:39 ` Rafael Ignacio Zurita 2011-01-19 4:27 ` Denis Kenzior
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.