summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gsmd/sms_cb.c45
-rw-r--r--src/util/event.c2
2 files changed, 40 insertions, 7 deletions
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