From 20adbe01bb4d7490436d0294de37b6c12624143b Mon Sep 17 00:00:00 2001 From: erin_yueh Date: Mon, 18 Feb 2008 09:42:28 +0000 Subject: gsmd: bug fixed for some changes (Sudharshan S, Paulius Zaleckas) git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@4084 99fdad57-331a-0410-800a-d7fa5415bdb3 --- include/gsmd/gsmd.h | 1 - src/gsmd/usock.c | 29 ++++++++++------------------- src/util/shell.c | 7 +------ 3 files changed, 11 insertions(+), 26 deletions(-) diff --git a/include/gsmd/gsmd.h b/include/gsmd/gsmd.h index fc26875..0521dd5 100644 --- a/include/gsmd/gsmd.h +++ b/include/gsmd/gsmd.h @@ -73,7 +73,6 @@ struct gsmd; #define GSMD_FLAG_SMS_FMT_TEXT 0x0002 /* TODO Use TEXT rather than PDU mode */ #define GSMD_ATCMD_TIMEOUT 60 /* If doesn get respond within 60 secs, discard */ -#define GSMD_MAX_INFO_LEN 64 /* by the standard it should be 2048, way too much :) */ struct gsmd { unsigned int flags; diff --git a/src/gsmd/usock.c b/src/gsmd/usock.c index c371c17..2faf1fc 100644 --- a/src/gsmd/usock.c +++ b/src/gsmd/usock.c @@ -618,12 +618,10 @@ static int gsmd_get_manuf_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) struct gsmd_user *gu = ctx; DEBUGP("cmd = '%s', resp: '%s'\n", cmd->buf, resp); - if (strncmp(resp, "+CGMI: ", 7)) - return -EINVAL; - resp += 7; + if (!strncmp(resp, "+CGMI: ", 7)) + resp += 7; return gsmd_ucmd_submit(gu, GSMD_MSG_PHONE, GSMD_PHONE_GET_MANUF, cmd->id, strlen(resp) + 1, resp); - return 0; } static int gsmd_get_model_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) @@ -631,12 +629,10 @@ static int gsmd_get_model_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) struct gsmd_user *gu = ctx; DEBUGP("cmd = '%s', resp: '%s'\n", cmd->buf, resp); - if (strncmp(resp, "+CGMM: ", 7)) - return -EINVAL; - resp += 7; + if (!strncmp(resp, "+CGMM: ", 7)) + resp += 7; return gsmd_ucmd_submit(gu, GSMD_MSG_PHONE, GSMD_PHONE_GET_MODEL, cmd->id, strlen(resp) + 1, resp); - return 0; } static int gsmd_get_revision_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) @@ -644,12 +640,10 @@ static int gsmd_get_revision_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) struct gsmd_user *gu = ctx; DEBUGP("cmd = '%s', resp: '%s'\n", cmd->buf, resp); - if (strncmp(resp, "+CGMR: ", 7)) - return -EINVAL; - resp += 7; + if (!strncmp(resp, "+CGMR: ", 7)) + resp += 7; return gsmd_ucmd_submit(gu, GSMD_MSG_PHONE, GSMD_PHONE_GET_REVISION, cmd->id, strlen(resp) + 1, resp); - return 0; } static int gsmd_get_serial_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) @@ -657,12 +651,10 @@ static int gsmd_get_serial_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) struct gsmd_user *gu = ctx; DEBUGP("cmd = '%s', resp: '%s'\n", cmd->buf, resp); - if (strncmp(resp, "+CGSN: ", 7)) - return -EINVAL; - resp += 7; + if (!strncmp(resp, "+CGSN: ", 7)) + resp += 7; return gsmd_ucmd_submit(gu, GSMD_MSG_PHONE, GSMD_PHONE_GET_SERIAL, cmd->id, strlen(resp) + 1, resp); - return 0; } static int usock_rcv_phone(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, @@ -868,7 +860,7 @@ static int network_oper_n_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) if ( !er ) return -ENOMEM; - + //extrsp_dump(er); /* Format: [,,] */ @@ -878,12 +870,11 @@ static int network_oper_n_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) /* In case we're not registered, return an empty string */ buf[0] = '\0'; } - else if ( er->num_tokens == 3 && + else if ( er->num_tokens >= 3 && er->tokens[0].type == GSMD_ECMD_RTT_NUMERIC && er->tokens[1].type == GSMD_ECMD_RTT_NUMERIC && er->tokens[2].type == GSMD_ECMD_RTT_STRING ) { - strlcpy(buf, er->tokens[2].u.string, sizeof(buf)); } else { diff --git a/src/util/shell.c b/src/util/shell.c index 0601e6d..1bfff3e 100644 --- a/src/util/shell.c +++ b/src/util/shell.c @@ -392,28 +392,23 @@ static int net_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh) static int phone_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh) { - char *payload; + char *payload = (char *)gmh + sizeof(*gmh); int *intresult = (void *)gmh + sizeof(*gmh); switch (gmh->msg_subtype) { case GSMD_PHONE_GET_IMSI: - payload = (char *)gmh + sizeof(*gmh); printf("imsi <%s>\n", payload); break; case GSMD_PHONE_GET_MANUF: - payload = (char *)gmh + sizeof(*gmh); printf("manufacturer: %s\n", payload); break; case GSMD_PHONE_GET_MODEL: - payload = (char *)gmh + sizeof(*gmh); printf("model: %s\n", payload); break; case GSMD_PHONE_GET_REVISION: - payload = (char *)gmh + sizeof(*gmh); printf("revision: %s\n", payload); break; case GSMD_PHONE_GET_SERIAL: - payload = (char *)gmh + sizeof(*gmh); printf("serial: %s\n", payload); break; case GSMD_PHONE_POWERUP: -- cgit v1.2.3