summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerin_yueh <erin_yueh@99fdad57-331a-0410-800a-d7fa5415bdb3>2008-01-17 08:35:53 +0000
committererin_yueh <erin_yueh@99fdad57-331a-0410-800a-d7fa5415bdb3>2008-01-17 08:35:53 +0000
commit9b7916395e21e4efe3d0fc76adad30c3b1f169be (patch)
tree3a028dee93465cd2a5461055a8300d9db7b56855
parent6274c0663e6b7b634187ace52d2a3b1f4b29584a (diff)
gsmd: fix CMT_parse comma error (Sean Chiang)
git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@3861 99fdad57-331a-0410-800a-d7fa5415bdb3
-rw-r--r--include/gsmd/usock.h7
-rw-r--r--src/gsmd/sms_cb.c45
-rw-r--r--src/util/event.c2
3 files changed, 45 insertions, 9 deletions
diff --git a/include/gsmd/usock.h b/include/gsmd/usock.h
index 2072b54..2591500 100644
--- a/include/gsmd/usock.h
+++ b/include/gsmd/usock.h
@@ -386,6 +386,8 @@ struct gsmd_voicemail {
struct gsmd_addr addr;
} __attribute__ ((packed));
+#define GSMD_ALPHA_MAXLEN 20
+
/* call status from 3GPP TS 07.07 clause 07.17 */
struct gsmd_call_status {
int8_t idx;
@@ -395,7 +397,7 @@ struct gsmd_call_status {
u_int8_t mpty;
char number[GSMD_ADDR_MAXLEN+1];
u_int8_t type;
- char alpha[8+1];
+ char alpha[GSMD_ALPHA_MAXLEN+1];
int is_last;
} __attribute__ ((packed));
@@ -441,6 +443,7 @@ struct gsmd_evt_auxdata {
struct gsmd_addr addr;
} colp;
struct {
+ char alpha[GSMD_ALPHA_MAXLEN+1];
int inlined;
u_int8_t memtype;
int index;
@@ -490,7 +493,7 @@ struct gsmd_evt_auxdata {
struct {
struct gsmd_addr addr;
u_int8_t classx;
- char alpha[16];
+ char alpha[GSMD_ALPHA_MAXLEN+1];
u_int8_t cli;
} ccwa;
} u;
diff --git a/src/gsmd/sms_cb.c b/src/gsmd/sms_cb.c
index 0e97749..7d69f12 100644
--- a/src/gsmd/sms_cb.c
+++ b/src/gsmd/sms_cb.c
@@ -39,6 +39,7 @@
#include <gsmd/unsolicited.h>
#include <gsmd/sms.h>
#include <gsmd/talloc.h>
+#include <gsmd/extrsp.h>
static const char *ts0705_memtype_name[] = {
[GSM0705_MEMTYPE_NONE] = "NONE",
@@ -431,9 +432,10 @@ static int cmt_parse(const char *buf, int len, const char *param,
{
/* TODO: TEXT mode */
u_int8_t pdu[SMS_MAX_PDU_SIZE];
- const char *comma = strchr(param, ',');
- char *cr;
+ const char *cr = NULL;
int i;
+ char tmp[64];
+ struct gsm_extrsp *er;
struct gsmd_evt_auxdata *aux;
struct gsmd_sms_list *msg;
struct gsmd_ucmd *ucmd = usock_build_event(GSMD_MSG_EVENT,
@@ -446,14 +448,43 @@ static int cmt_parse(const char *buf, int len, const char *param,
aux = (struct gsmd_evt_auxdata *) ucmd->buf;
msg = (struct gsmd_sms_list *) aux->data;
- if (!comma) {
+ cr = strchr(param, '\n');
+
+ if (!cr) {
talloc_free(ucmd);
- return -EINVAL;
+ return -EAGAIN;
}
- len = strtoul(comma + 1, &cr, 10);
- if (cr[0] != '\n') {
+
+ strncpy(tmp, param, (cr-param));
+ tmp[(cr-param)] = '\0';
+
+ er = extrsp_parse(gsmd_tallocs, tmp);
+
+ if ( !er ) {
talloc_free(ucmd);
- return -EAGAIN;
+ return -ENOMEM;
+ }
+
+ //extrsp_dump(er);
+
+ if ( er->num_tokens == 2 &&
+ er->tokens[0].type == GSMD_ECMD_RTT_EMPTY &&
+ er->tokens[1].type == GSMD_ECMD_RTT_NUMERIC ) {
+
+ aux->u.sms.alpha[0] = '\0';
+ len = er->tokens[1].u.numeric;
+ }
+ else if ( er->num_tokens == 2 &&
+ er->tokens[0].type == GSMD_ECMD_RTT_STRING &&
+ er->tokens[1].type == GSMD_ECMD_RTT_NUMERIC ) {
+
+ strcpy(aux->u.sms.alpha, er->tokens[0].u.string);
+ len = er->tokens[1].u.numeric;
+ }
+ else {
+ talloc_free(ucmd);
+ talloc_free(er);
+ return -EINVAL;
}
cr ++;
diff --git a/src/util/event.c b/src/util/event.c
index 88f315f..de1da99 100644
--- a/src/util/event.c
+++ b/src/util/event.c
@@ -64,6 +64,8 @@ static int insms_handler(struct lgsm_handle *lh, int evt,
(sms->time_stamp[6] & 8) ? '-' : '+',
(((sms->time_stamp[6] << 4) |
(sms->time_stamp[6] >> 4)) & 0x3f) >> 2);
+ if ( strlen(aux->u.sms.alpha) )
+ printf("From %s\n", aux->u.sms.alpha);
if (sms->payload.coding_scheme == ALPHABET_DEFAULT) {
unpacking_7bit_character(&sms->payload, payload);
printf("\"%s\"\n", payload);
personal git repositories of Harald Welte. Your mileage may vary