Skip to contentSkip to conversation

Long dial string support

PATCH In review Andras Domokos 3 participants 5 messages Nov 16, 2010 – Nov 22, 2010

lore
Share & tools
lore
#0 lore raw

cover Long dial string support

Dial strings can now be as long as 120 digits (not counting '+'). This feature is going to be needed by the FDN feature.
An FDN may consist of a phone number plus a DTMF string. In order to have the call succeed when FDN is enabled, both parts need to be provided when making a call as a single dial string. For AT modems the long dial string can be and has to be passed as is to the modem, for ISI modems the dial string needs to be split into phone number (dest. address) and DTMF tone (post dest. address) before feeding it to the modem.

Andras Domokos (2):
common: add long dial string support isimodem/voicecall: add long dial string support

 drivers/isimodem/voicecall.c |   83 +++++++++++++++++++++++++++++++++---------
 include/types.h              |    2 +-
 src/common.c                 |   12 +++---
 3 files changed, 72 insertions(+), 25 deletions(-)
#1 lore raw

RFC PATCH 1/2 common: add long dial string support

---
 include/types.h |    2 +-
 src/common.c    |   12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)
include/types.h +1 -1
index ba2481f..b3d2247 100644
@@ -76,7 +76,7 @@ struct ofono_error {
 	int error;
 };
 
-#define OFONO_MAX_PHONE_NUMBER_LENGTH 20
+#define OFONO_MAX_PHONE_NUMBER_LENGTH 120
 
 struct ofono_phone_number {
 	char number[OFONO_MAX_PHONE_NUMBER_LENGTH + 1];
src/common.c +6 -6
index b5b9a6f..de5a508 100644
@@ -253,7 +253,7 @@ gboolean valid_phone_number_format(const char *number)
 		if (number[i] >= '0' && number[i] <= '9')
 			continue;
 
-		if (number[i] == '*' || number[i] == '#')
+		if (number[i] == '*' || number[i] == '#' || number[i] == 'p')
 			continue;
 
 		return FALSE;
@@ -379,18 +379,18 @@ int mmi_service_code_to_bearer_class(int code)
 
 const char *phone_number_to_string(const struct ofono_phone_number *ph)
 {
-	static char buffer[64];
+	static char buffer[(OFONO_MAX_PHONE_NUMBER_LENGTH + 1) + 1];
 
 	if (ph->type == 145 && (strlen(ph->number) > 0) &&
 			ph->number[0] != '+') {
 		buffer[0] = '+';
-		strncpy(buffer + 1, ph->number, 62);
-		buffer[63] = '\0';
+		strncpy(buffer + 1, ph->number, sizeof(buffer) - 2);
 	} else {
-		strncpy(buffer, ph->number, 63);
-		buffer[63] = '\0';
+		strncpy(buffer, ph->number, sizeof(buffer) - 1);
 	}
 
+	buffer[sizeof(buffer) - 1] = '\0';
+
 	return buffer;
 }
 
Signature · 1 line
1.7.0.4
#4 lore raw

RFC PATCH 2/2 isimodem/voicecall: add long dial string support

In reply to Andras Domokos
---
 drivers/isimodem/voicecall.c |   83 +++++++++++++++++++++++++++++++++---------
 1 files changed, 65 insertions(+), 18 deletions(-)
drivers/isimodem/voicecall.c +65 -18
index c3365f6..b0dad72 100644
@@ -49,7 +49,7 @@ struct isi_call {
 	uint8_t id, call_id, status, mode, mode_info, cause_type, cause;
 	uint8_t addr_type, presentation;
 	uint8_t reason;
-	char address[20], addr_pad[4];
+	char address[OFONO_MAX_PHONE_NUMBER_LENGTH + 1], addr_pad[4];
 };
 
 struct isi_voicecall {
@@ -244,6 +244,28 @@ static void isi_call_destination_address_sb_proc(struct isi_voicecall *ivc,
 		isi_call_any_address_sb_proc(ivc, call, sb);
 }
 
+static void isi_call_destination_post_address_sb_proc(struct isi_voicecall *ivc,
+						struct isi_call *call,
+						GIsiSubBlockIter const *sb)
+{
+	uint8_t addr_info, addr_len;
+	char *address;
+
+	if (!call->address[0] ||
+		strlen(call->address) >= OFONO_MAX_PHONE_NUMBER_LENGTH)
+		return;
+
+	if (!g_isi_sb_iter_get_byte(sb, &addr_info, 2) ||
+		!g_isi_sb_iter_get_byte(sb, &addr_len, 3) ||
+		!g_isi_sb_iter_get_alpha_tag(sb, &address, 2 * addr_len, 4))
+		return;
+
+	strncat(call->address, address,
+		OFONO_MAX_PHONE_NUMBER_LENGTH - strlen(call->address));
+	g_free(address);
+
+}
+
 static void isi_call_mode_sb_proc(struct isi_voicecall *ivc,
 					struct isi_call *call,
 					GIsiSubBlockIter const *sb)
@@ -371,40 +393,61 @@ static struct isi_call_req_context *
 isi_call_create_req(struct ofono_voicecall *ovc,
 			uint8_t presentation,
 			uint8_t addr_type,
-			char const address[21],
+			char const address[OFONO_MAX_PHONE_NUMBER_LENGTH + 1],
 			ofono_voicecall_cb_t cb,
 			void *data)
 {
-	size_t addr_len = strlen(address);
-	size_t sub_len = (6 + 2 * addr_len + 3) & ~3;
-	size_t i, offset = 3 + 4 + 8 + 6;
-	uint8_t req[3 + 4 + 8 + 6 + 40] = {
+	uint8_t req[3 + 4 + 8 + 10 + 2 * OFONO_MAX_PHONE_NUMBER_LENGTH + 4] = {
 		CALL_CREATE_REQ,
 		0,		/* No id */
-		3,		/* Mode, Clir, Number */
+		4,		/* Mode, Clir, Number, Postfix */
 		/* MODE SB */
 		CALL_MODE, 4, CALL_MODE_SPEECH, CALL_MODE_INFO_NONE,
 		/* ORIGIN_INFO SB */
 		CALL_ORIGIN_INFO, 8, presentation, 0, 0, 0, 0, 0,
 		/* DESTINATION_ADDRESS SB */
 		CALL_DESTINATION_ADDRESS,
-		sub_len,
+		0,		/* sub_len */
 		addr_type & 0x7F,
 		0, 0,
-		addr_len,
-		/* uint16_t addr[20] */
+		0,		/* addr_len */
+		/* uint16_t addr[OFONO_MAX_PHONE_NUMBER_LENGTH] */
 	};
-	size_t rlen = 3 + 4 + 8 + sub_len;
+	size_t i, j, offset;
 
-	if (addr_len > 20) {
-		CALLBACK_WITH_FAILURE(cb, data);
-		return NULL;
+	offset = 3 + 4 + 8;
+	for (i = 0, j = 0; address[i]; i++, j++) {
+		if (i > OFONO_MAX_PHONE_NUMBER_LENGTH)
+			goto out;
+		if (address[i] != '*')
+			break;
+		req[offset + 6 + 2 * j + 1] = address[i];
 	}
 
-	for (i = 0; i < addr_len; i++)
-		req[offset + 2 * i + 1] = address[i];
+	for (; address[i]; i++, j++) {
+		if (i > OFONO_MAX_PHONE_NUMBER_LENGTH)
+			goto out;
+		if (address[i] == '*' || address[i] == 'p' || address[i] == '#')
+			break;
+		req[offset + 6 + 2 * j + 1] = address[i];
+	}
+	req[offset + 5] = j;
+	offset += (req[offset + 1] = (6 + 2 * j + 3) & ~3);
+
+	req[offset + 0] = CALL_DESTINATION_POST_ADDRESS;
+	for (j = 0; address[i]; i++, j++) {
+		if (i > OFONO_MAX_PHONE_NUMBER_LENGTH)
+			goto out;
+		req[offset + 4 + 2 * j + 1] = address[i];
+	}
+	req[offset + 3] = j;
+	offset += (req[offset + 1] = (4 + 2 * j + 3) & ~3);
 
-	return isi_call_req(ovc, req, rlen, isi_call_create_resp, cb, data);
+	return isi_call_req(ovc, req, offset, isi_call_create_resp, cb, data);
+
+out:
+	CALLBACK_WITH_FAILURE(cb, data);
+	return NULL;
 }
 
 static gboolean isi_call_create_resp(GIsiClient *client,
@@ -477,13 +520,17 @@ static void isi_call_status_ind_cb(GIsiClient *client,
 			isi_call_destination_address_sb_proc(ivc, call, sb);
 			break;
 
+		case CALL_DESTINATION_POST_ADDRESS:
+			isi_call_destination_post_address_sb_proc(ivc,
+								call, sb);
+			break;
+
 		case CALL_ORIGIN_ADDRESS:
 			isi_call_origin_address_sb_proc(ivc, call, sb);
 			break;
 
 		case CALL_GSM_DETAILED_CAUSE:
 		case CALL_DESTINATION_PRE_ADDRESS:
-		case CALL_DESTINATION_POST_ADDRESS:
 		case CALL_DESTINATION_SUBADDRESS:
 		case CALL_GSM_EVENT_INFO:
 		case CALL_NW_CAUSE:
Signature · 1 line
1.7.0.4
#2 lore raw

Re: [RFC PATCH 1/2] common: add long dial string support

In reply to Andras Domokos

Hi Denis, Marcel, Andras,

Quoted 22 lines
  include/types.h |    2 +-
  src/common.c    |   12 ++++++------
  2 files changed, 7 insertions(+), 7 deletions(-)
include/types.h +1 -1
index ba2481f..b3d2247 100644
@@ -76,7 +76,7 @@ struct ofono_error {
  	int error;
  };
 
-#define OFONO_MAX_PHONE_NUMBER_LENGTH 20
+#define OFONO_MAX_PHONE_NUMBER_LENGTH 120
 
  struct ofono_phone_number {
  	char number[OFONO_MAX_PHONE_NUMBER_LENGTH + 1];
src/common.c +0 -0
index b5b9a6f..de5a508 100644

src/common.c gboolean valid_phone_number_format(const char *number) · line 258

Quoted 7 lines
src/common.c +1 -1
@@ -253,7 +253,7 @@ gboolean valid_phone_number_format(const char *number)
  		if (number[i]>= '0'&&  number[i]<= '9')
  			continue;
 
-		if (number[i] == '*' || number[i] == '#')
+		if (number[i] == '*' || number[i] == '#' || number[i] == 'p')
  			continue;
 

This function is used to check the phone number as valid in other places too.

Is it right to allow sms sending to numbers with '*', '#' and 'p' in it? I think ofono should return an error for the sms case.

Regards
Arun

#3 lore raw

Re: [RFC PATCH 1/2] common: add long dial string support

Hi Andras,

Quoted 35 lines · Arun Ravindran

Hi Denis, Marcel, Andras,

Quoted 22 lines
  include/types.h |    2 +-
  src/common.c    |   12 ++++++------
  2 files changed, 7 insertions(+), 7 deletions(-)
include/types.h +1 -1
index ba2481f..b3d2247 100644
@@ -76,7 +76,7 @@ struct ofono_error {
      int error;
  };
 
-#define OFONO_MAX_PHONE_NUMBER_LENGTH 20
+#define OFONO_MAX_PHONE_NUMBER_LENGTH 120
 
  struct ofono_phone_number {
      char number[OFONO_MAX_PHONE_NUMBER_LENGTH + 1];
src/common.c +0 -0
index b5b9a6f..de5a508 100644

src/common.c gboolean valid_phone_number_format(const char · line 259

Quoted 8 lines
src/common.c +1 -1
@@ -253,7 +253,7 @@ gboolean valid_phone_number_format(const char
 *number)
          if (number[i]>= '0'&&  number[i]<= '9')
              continue;
 
-        if (number[i] == '*' || number[i] == '#')
+        if (number[i] == '*' || number[i] == '#' || number[i] == 'p')
              continue;
 

This function is used to check the phone number as valid in other places too.

Quoted 3 lines

Is it right to allow sms sending to numbers with '*', '#' and 'p' in it? I think ofono should return an error for the sms case.

Arun has nailed it, hacking valid_phone_number_format is not the right way to go. You need to separate this out a bit for the particular usecase.

Regards,
-Denis