diff options
-rw-r--r-- | include/libgsmd/phonebook.h | 13 | ||||
-rw-r--r-- | src/gsmd/usock.c | 368 | ||||
-rw-r--r-- | src/gsmd/vendor_ti.c | 29 | ||||
-rw-r--r-- | src/gsmd/vendor_tihtc.c | 31 | ||||
-rw-r--r-- | src/util/atcmd.c | 2 |
5 files changed, 0 insertions, 443 deletions
diff --git a/include/libgsmd/phonebook.h b/include/libgsmd/phonebook.h index d17b006..4bcae6c 100644 --- a/include/libgsmd/phonebook.h +++ b/include/libgsmd/phonebook.h @@ -49,19 +49,6 @@ struct lgsm_phonebook_find { char findtext[LGSM_PB_TEXT_MAXLEN+1]; }; -#if 0 -/* Get a bitmask of supported phonebook types */ -extern int lgsm_pb_get_types(struct lgsm_handle *lh, u_int32 *typemask); - -/* Get a range of supported indexes in given phonebook type, Chapter 8.12 */ -extern int lgsm_pb_get_range(struct lgsm_handle *lh, - enum lgsm_pbook_type type, - u_int32_t *from, u_int32_t *to, - u_int32_t *nlength, *u_int32_t tlength); - -#define LGSM_PB_TEXT_MAXLEN 31 -#endif - struct lgsm_pb_entry { struct lgsm_pb_entry *next; enum lgsm_pbook_type type; diff --git a/src/gsmd/usock.c b/src/gsmd/usock.c index 5b7edd4..5f6389f 100644 --- a/src/gsmd/usock.c +++ b/src/gsmd/usock.c @@ -671,374 +671,6 @@ static int usock_rcv_network(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, return atcmd_submit(gu->gsmd, cmd); } -#if 0 -static int sms_list_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) -{ - struct gsmd_user *gu = ctx; - struct gsmd_ucmd *ucmd; - struct gsmd_sms_list msg; - int i, idx, stat, len, cr; - u_int8_t pdu[180]; - - if (cmd->ret && cmd->ret != -255) - return 0; - - /* FIXME: TEXT mode */ - if ( - sscanf(resp, "+CMGL: %i,%i,,%i\n%n", - &idx, &stat, &len, &cr) < 3 && - sscanf(resp, "+CMGL: %i,%i,\"%*[^\"]\",%i\n%n", - &idx, &stat, &len, &cr) < 3) - return -EINVAL; - if (len > 164) - return -EINVAL; - - msg.index = idx; - msg.stat = stat; - msg.is_last = (cmd->ret == 0); - for (i = 0; resp[cr] >= '0' && resp[cr + 1] >= '0' && i < 180; i ++) { - if (sscanf(resp + cr, "%2hhX", &pdu[i]) < 1) { - gsmd_log(GSMD_DEBUG, "malformed input (%i)\n", i); - return -EINVAL; - } - cr += 2; - } - if (sms_pdu_to_msg(&msg, pdu, len, i)) { - gsmd_log(GSMD_DEBUG, "malformed PDU\n"); - return -EINVAL; - } - - ucmd = gsmd_ucmd_fill(sizeof(msg), GSMD_MSG_SMS, - GSMD_SMS_LIST, cmd->id); - if (!ucmd) - return -ENOMEM; - memcpy(ucmd->buf, &msg, sizeof(msg)); - - usock_cmd_enqueue(ucmd, gu); - - return 0; -} - -static int sms_read_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) -{ - struct gsmd_user *gu = ctx; - struct gsmd_ucmd *ucmd; - struct gsmd_sms_list msg; - int i, stat, len, cr; - u_int8_t pdu[180]; - - if (cmd->ret) - return 0; - - /* FIXME: TEXT mode */ - if ( - sscanf(resp, "+CMGR: %i,,%i\n%n", - &stat, &len, &cr) < 2 && - sscanf(resp, "+CMGR: %i,%*i,%i\n%n", - &stat, &len, &cr) < 2) - return -EINVAL; - if (len > 164) - return -EINVAL; - - msg.index = 0; - msg.stat = stat; - msg.is_last = 1; - for (i = 0; resp[cr] >= '0' && resp[cr + 1] >= '0' && i < 180; i ++) { - if (sscanf(resp + cr, "%2hhX", &pdu[i]) < 1) { - gsmd_log(GSMD_DEBUG, "malformed input (%i)\n", i); - return -EINVAL; - } - cr += 2; - } - if (sms_pdu_to_msg(&msg, pdu, len, i)) { - gsmd_log(GSMD_DEBUG, "malformed PDU\n"); - return -EINVAL; - } - - ucmd = gsmd_ucmd_fill(sizeof(msg), GSMD_MSG_SMS, - GSMD_SMS_READ, cmd->id); - if (!ucmd) - return -ENOMEM; - memcpy(ucmd->buf, &msg, sizeof(msg)); - - usock_cmd_enqueue(ucmd, gu); - - return 0; -} - -static int sms_send_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) -{ - struct gsmd_user *gu = ctx; - struct gsmd_ucmd *ucmd; - int msgref; - - if (cmd->ret == 0 || cmd->ret == -255) { - if (sscanf(resp, "+CMGS: %i", &msgref) < 1) - return -EINVAL; - } else - msgref = -cmd->ret; - - ucmd = gsmd_ucmd_fill(sizeof(int), GSMD_MSG_SMS, - GSMD_SMS_SEND, cmd->id); - if (!ucmd) - return -ENOMEM; - *(int *) ucmd->buf = msgref; - - usock_cmd_enqueue(ucmd, gu); - - return 0; -} - -static int sms_write_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) -{ - struct gsmd_user *gu = ctx; - struct gsmd_ucmd *ucmd; - int result; - - if (cmd->ret == 0) { - if (sscanf(resp, "+CMGW: %i", &result) < 1) - return -EINVAL; - } else - result = -cmd->ret; - - ucmd = gsmd_ucmd_fill(sizeof(int), GSMD_MSG_SMS, - GSMD_SMS_WRITE, cmd->id); - if (!ucmd) - return -ENOMEM; - *(int *) ucmd->buf = result; - - usock_cmd_enqueue(ucmd, gu); - - return 0; -} - -static int sms_delete_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) -{ - struct gsmd_user *gu = ctx; - struct gsmd_ucmd *ucmd; - int *result; - - ucmd = gsmd_ucmd_fill(sizeof(int), GSMD_MSG_SMS, - GSMD_SMS_DELETE, cmd->id); - if (!ucmd) - return -ENOMEM; - - result = (int *) ucmd->buf; - *result = cmd->ret; - - usock_cmd_enqueue(ucmd, gu); - - return 0; -} - -static int usock_cpms_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) -{ - struct gsmd_user *gu = ctx; - struct gsmd_ucmd *ucmd = ucmd_alloc(sizeof(struct gsmd_sms_storage)); - struct gsmd_sms_storage *gss = (typeof(gss)) ucmd->buf; - char buf[3][3]; - - DEBUGP("entering(cmd=%p, gu=%p)\n", cmd, gu); - - if (!ucmd) - return -ENOMEM; - - ucmd->hdr.version = GSMD_PROTO_VERSION; - ucmd->hdr.msg_type = GSMD_MSG_SMS; - ucmd->hdr.msg_subtype = GSMD_SMS_GET_MSG_STORAGE; - ucmd->hdr.len = sizeof(struct gsmd_sms_storage); - ucmd->hdr.id = cmd->id; - - if (sscanf(resp, "+CPMS: \"%2[A-Z]\",%hi,%hi," - "\"%2[A-Z]\",%hi,%hi,\"%2[A-Z]\",%hi,%hi", - buf[0], &gss->mem[0].used, &gss->mem[0].total, - buf[1], &gss->mem[1].used, &gss->mem[1].total, - buf[2], &gss->mem[2].used, &gss->mem[2].total) - < 9) { - talloc_free(ucmd); - return -EINVAL; - } - - gss->mem[0].memtype = parse_memtype(buf[0]); - gss->mem[1].memtype = parse_memtype(buf[1]); - gss->mem[2].memtype = parse_memtype(buf[2]); - - usock_cmd_enqueue(ucmd, gu); - - return 0; -} - -static int usock_get_smsc_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) -{ - struct gsmd_user *gu = ctx; - struct gsmd_ucmd *ucmd; - struct gsmd_addr *ga; - - ucmd = gsmd_ucmd_fill(sizeof(struct gsmd_addr), GSMD_MSG_SMS, - GSMD_SMS_GET_SERVICE_CENTRE, cmd->id); - if (!ucmd) - return -ENOMEM; - - ga = (struct gsmd_addr *) ucmd->buf; - if (sscanf(resp, "+CSCA: \"%31[^\"]\",%hhi", - ga->number, &ga->type) < 2) { - talloc_free(ucmd); - return -EINVAL; - } - - usock_cmd_enqueue(ucmd, gu); - return 0; -} - -static const char *gsmd_cmgl_stat[] = { - "REC UNREAD", "REC READ", "STO UNSENT", "STO SENT", "ALL", -}; - -static int usock_rcv_sms(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, - int len) -{ - /* FIXME: TEXT mode support!! */ - struct gsmd_atcmd *cmd = NULL; - struct gsmd_sms_delete *gsd; - struct gsmd_sms_submit *gss; - struct gsmd_sms_write *gsw; - struct gsmd_addr *ga; - enum ts0705_mem_type *storage; - int *stat, *index; - int atcmd_len; - char buf[1024]; - - switch (gph->msg_subtype) { - case GSMD_SMS_LIST: - if(len < sizeof(*gph) + sizeof(int)) - return -EINVAL; - stat = (int *) ((void *)gph + sizeof(*gph)); - if (*stat < 0 || *stat > 4) - return -EINVAL; - - if (gu->gsmd->flags & GSMD_FLAG_SMS_FMT_TEXT) - atcmd_len = sprintf(buf, "AT+CMGL=\"%s\"", - gsmd_cmgl_stat[*stat]); - else - atcmd_len = sprintf(buf, "AT+CMGL=%i", *stat); - - cmd = atcmd_fill(buf, atcmd_len + 1, - &sms_list_cb, gu, gph->id); - break; - - case GSMD_SMS_READ: - if(len < sizeof(*gph) + sizeof(int)) - return -EINVAL; - index = (int *) ((void *)gph + sizeof(*gph)); - - atcmd_len = sprintf(buf, "AT+CMGR=%i", *index); - - cmd = atcmd_fill(buf, atcmd_len + 1, - &sms_read_cb, gu, gph->id); - break; - - case GSMD_SMS_SEND: - if (len < sizeof(*gph) + sizeof(*gss)) - return -EINVAL; - gss = (struct gsmd_sms_submit *) ((void *) gph + sizeof(*gph)); - - if (gu->gsmd->flags & GSMD_FLAG_SMS_FMT_TEXT) { - atcmd_len = sprintf(buf, "AT+CMGS=\"%s\"\n%.*s", - gss->addr.number, - gss->payload.length, - gss->payload.data); /* FIXME */ - } else { - atcmd_len = sprintf(buf, "AT+CMGS=%i\n", - sms_pdu_make_smssubmit(NULL, gss) - 1); - atcmd_len += sms_pdu_make_smssubmit(buf + atcmd_len, - gss) * 2; - } - buf[atcmd_len ++] = 26; /* ^Z ends the message */ - buf[atcmd_len ++] = 0; - - cmd = atcmd_fill(buf, atcmd_len, &sms_send_cb, gu, gph->id); - break; - - case GSMD_SMS_WRITE: - if (len < sizeof(*gph) + sizeof(*gsw)) - return -EINVAL; - gsw = (struct gsmd_sms_write *) ((void *) gph + sizeof(*gph)); - if (gsw->stat > 4) - return -EINVAL; - - if (gu->gsmd->flags & GSMD_FLAG_SMS_FMT_TEXT) { - atcmd_len = sprintf(buf, "AT+CMGW=\"%s\"\n%.*s", - gsw->sms.addr.number, - gsw->sms.payload.length, - gsw->sms.payload.data); /* FIXME */ - } else { - atcmd_len = sprintf(buf, "AT+CMGW=%i,%i\n", - sms_pdu_make_smssubmit(NULL, - &gsw->sms) - 1, gsw->stat); - atcmd_len += sms_pdu_make_smssubmit(buf + atcmd_len, - &gsw->sms) * 2; - } - buf[atcmd_len ++] = 26; /* ^Z ends the message */ - buf[atcmd_len ++] = 0; - - cmd = atcmd_fill(buf, atcmd_len, &sms_write_cb, gu, gph->id); - break; - - case GSMD_SMS_DELETE: - if(len < sizeof(*gph) + sizeof(*gsd)) - return -EINVAL; - gsd = (struct gsmd_sms_delete *) ((void *)gph + sizeof(*gph)); - - atcmd_len = sprintf(buf, "AT+CMGD=%d,%d", - gsd->index, gsd->delflg); - - cmd = atcmd_fill(buf, atcmd_len + 1, - &sms_delete_cb, gu, gph->id); - break; - - case GSMD_SMS_GET_MSG_STORAGE: - cmd = atcmd_fill("AT+CPMS?", 8 + 1, usock_cpms_cb, gu, 0); - break; - - case GSMD_SMS_SET_MSG_STORAGE: - if (len < sizeof(*gph) + 3 * sizeof(enum ts0705_mem_type)) - return -EINVAL; - storage = (enum ts0705_mem_type *) - ((void *) gph + sizeof(*gph)); - atcmd_len = sprintf(buf, "AT+CPMS=\"%s\",\"%s\",\"%s\"", - ts0705_memtype_name[storage[0]], - ts0705_memtype_name[storage[1]], - ts0705_memtype_name[storage[2]]); - cmd = atcmd_fill(buf, atcmd_len + 1, - &null_cmd_cb, gu, gph->id); - break; - - case GSMD_SMS_GET_SERVICE_CENTRE: - cmd = atcmd_fill("AT+CSCA?", 8 + 1, &usock_get_smsc_cb, gu, 0); - break; - - case GSMD_SMS_SET_SERVICE_CENTRE: - if (len < sizeof(*gph) + sizeof(struct gsmd_addr)) - return -EINVAL; - ga = (struct gsmd_addr *) ((void *) gph + sizeof(*gph)); - atcmd_len = sprintf(buf, "AT+CSCA=\"%s\",%i", - ga->number, ga->type); - cmd = atcmd_fill(buf, atcmd_len + 1, - &null_cmd_cb, gu, gph->id); - break; - - default: - return -EINVAL; - } - - if (!cmd) - return -ENOMEM; - - gsmd_log(GSMD_DEBUG, "%s\n", cmd ? cmd->buf : 0); - return atcmd_submit(gu->gsmd, cmd); -} -#endif - static int phonebook_find_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) { struct gsmd_user *gu = ctx; diff --git a/src/gsmd/vendor_ti.c b/src/gsmd/vendor_ti.c index c90f10c..52fbb70 100644 --- a/src/gsmd/vendor_ti.c +++ b/src/gsmd/vendor_ti.c @@ -37,35 +37,6 @@ #include <gsmd/vendorplugin.h> #include <gsmd/unsolicited.h> -#if 0 -#include "vendorplugin.h" - -static int -ti_getopt(struct gsmd *gh, int optname, void *optval, int *optlen) -{ - switch (optname) { - case GSMD_OPT_CIPHER_IND: - /* FIXME: send AT%CPRI=? */ - break; - default: - return -EINVAL; - } -} - -static int -ti_setopt(struct gsmd *gh, int optname, const void *optval, int optlen) -{ - switch (optname) { - case GSMD_OPT_CIPHER_IND: - /* FIXME: send AT%CPRI= */ - break; - default: - return -EINVAL; - } -} - -#endif - static int csq_parse(char *buf, int len, const char *param, struct gsmd *gsmd) diff --git a/src/gsmd/vendor_tihtc.c b/src/gsmd/vendor_tihtc.c index 5ec257c..98f6a12 100644 --- a/src/gsmd/vendor_tihtc.c +++ b/src/gsmd/vendor_tihtc.c @@ -52,37 +52,6 @@ int gsmd_simplecmd(struct gsmd *gsmd, char *cmdtxt) return atcmd_submit(gsmd, cmd); } - -#if 0 -#include "vendorplugin.h" - -static int -ti_getopt(struct gsmd *gh, int optname, void *optval, int *optlen) -{ - switch (optname) { - case GSMD_OPT_CIPHER_IND: - /* FIXME: send AT%CPRI=? */ - break; - default: - return -EINVAL; - } -} - -static int -ti_setopt(struct gsmd *gh, int optname, const void *optval, int optlen) -{ - switch (optname) { - case GSMD_OPT_CIPHER_IND: - /* FIXME: send AT%CPRI= */ - break; - default: - return -EINVAL; - } -} - -#endif - - static int htccsq_parse(char *buf, int len, const char *param, struct gsmd *gsmd) { diff --git a/src/util/atcmd.c b/src/util/atcmd.c index 011d112..e31f81f 100644 --- a/src/util/atcmd.c +++ b/src/util/atcmd.c @@ -47,12 +47,10 @@ int atcmd_main(struct lgsm_handle *lgsmh) lgsm_register_handler(lgsmh, GSMD_MSG_PASSTHROUGH, &pt_msghandler); -#if 1 fcntl(0, F_SETFD, O_NONBLOCK); fcntl(1, F_SETFD, O_NONBLOCK); fcntl(2, F_SETFD, O_NONBLOCK); fcntl(lgsm_fd(lgsmh), F_SETFD, O_NONBLOCK); -#endif FD_ZERO(&readset); |