mirror of git://git.sysmocom.de/ofono
common: add function to validate long numbers
Also, adapt voicecall to use the new function for outgoing calls.
This commit is contained in:
parent
78c1e96bf9
commit
4eda451c03
20
src/common.c
20
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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_phone_number_format(const char *number)
|
||||
{
|
||||
return valid_number_format(number, 20);
|
||||
}
|
||||
|
||||
gboolean valid_long_phone_number_format(const char *number)
|
||||
{
|
||||
return valid_number_format(number, OFONO_MAX_PHONE_NUMBER_LENGTH);
|
||||
}
|
||||
|
||||
gboolean valid_cdma_phone_number_format(const char *number)
|
||||
{
|
||||
int len = strlen(number);
|
||||
|
|
|
@ -137,7 +137,9 @@ enum context_status {
|
|||
|
||||
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_long_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);
|
||||
|
||||
|
|
|
@ -1304,7 +1304,7 @@ static DBusMessage *manager_dial(DBusConnection *conn,
|
|||
DBUS_TYPE_INVALID) == FALSE)
|
||||
return __ofono_error_invalid_args(msg);
|
||||
|
||||
if (!valid_phone_number_format(number))
|
||||
if (!valid_long_phone_number_format(number))
|
||||
return __ofono_error_invalid_format(msg);
|
||||
|
||||
if (clir_string_to_clir(clirstr, &clir) == FALSE)
|
||||
|
|
Loading…
Reference in New Issue