summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/gsmd/gsmd.h6
-rw-r--r--include/gsmd/machineplugin.h4
-rw-r--r--include/gsmd/sms.h3
-rw-r--r--include/gsmd/unsolicited.h8
-rw-r--r--include/gsmd/usock.h4
-rw-r--r--include/gsmd/vendorplugin.h5
-rw-r--r--include/libgsmd/misc.h5
-rw-r--r--src/gsmd/atcmd.c16
-rw-r--r--src/gsmd/ext_response.c3
-rw-r--r--src/gsmd/gsmd.c16
-rw-r--r--src/gsmd/machine.c4
-rw-r--r--src/gsmd/machine_generic.c2
-rw-r--r--src/gsmd/sms_cb.c19
-rw-r--r--src/gsmd/timer.c7
-rw-r--r--src/gsmd/unsolicited.c28
-rw-r--r--src/gsmd/usock.c13
-rw-r--r--src/gsmd/vendor_bcm.c9
-rw-r--r--src/gsmd/vendor_qc.c12
-rw-r--r--src/gsmd/vendor_ti.c20
-rw-r--r--src/gsmd/vendor_tihtc.c23
-rw-r--r--src/libgsmd/libgsmd.c3
-rw-r--r--src/libgsmd/libgsmd_network.c2
-rw-r--r--src/libgsmd/libgsmd_sms.c3
-rw-r--r--src/util/atcmd.c4
-rw-r--r--src/util/event.c4
-rw-r--r--src/util/pin.c4
-rw-r--r--src/util/shell.c12
27 files changed, 130 insertions, 109 deletions
diff --git a/include/gsmd/gsmd.h b/include/gsmd/gsmd.h
index de99238..ff63b58 100644
--- a/include/gsmd/gsmd.h
+++ b/include/gsmd/gsmd.h
@@ -4,6 +4,7 @@
#ifdef __GSMD__
#include <sys/types.h>
+#include <sys/time.h>
#include <common/linux_list.h>
@@ -117,6 +118,8 @@ void __gsmd_log(int level, const char *file, int line, const char *function, con
#define DEBUGP(x, args ...) gsmd_log(GSMD_DEBUG, x, ## args)
extern int gsmd_simplecmd(struct gsmd *gsmd, char *cmdtxt);
+extern int gsmd_initsettings(struct gsmd *gsmd);
+extern int gsmd_alive_start(struct gsmd *gsmd);
/***********************************************************************
* timer handling
@@ -130,8 +133,7 @@ struct gsmd_timer {
};
int gsmd_timer_init(void);
-void gmsd_timer_check_n_run(void);
-
+void gsmd_timer_check_n_run(void);
struct gsmd_timer *gsmd_timer_alloc(void);
int gsmd_timer_register(struct gsmd_timer *timer);
void gsmd_timer_unregister(struct gsmd_timer *timer);
diff --git a/include/gsmd/machineplugin.h b/include/gsmd/machineplugin.h
index c3ed801..8185fb6 100644
--- a/include/gsmd/machineplugin.h
+++ b/include/gsmd/machineplugin.h
@@ -10,13 +10,15 @@ struct gsmd;
struct gsmd_machine_plugin {
struct llist_head list;
- unsigned char *name;
+ char *name;
int (*power)(struct gsmd *g, int power);
int (*ex_submit)(struct gsmd *g);
int (*detect)(struct gsmd *g);
int (*init)(struct gsmd *g, int fd);
};
+extern int gsmd_machine_plugin_init(struct gsmd *g,
+ char *machine_name, char *vendor_name);
extern int gsmd_machine_plugin_register(struct gsmd_machine_plugin *pl);
extern void gsmd_machine_plugin_unregister(struct gsmd_machine_plugin *pl);
extern int gsmd_machine_plugin_find(struct gsmd *g);
diff --git a/include/gsmd/sms.h b/include/gsmd/sms.h
index c5ee0d8..2519daf 100644
--- a/include/gsmd/sms.h
+++ b/include/gsmd/sms.h
@@ -18,7 +18,8 @@ int cbs_pdu_to_msg(struct gsmd_cbm *dst, u_int8_t *src, int pdulen, int len);
int usock_rcv_sms(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, int len);
int usock_rcv_cb(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, int len);
-
+int sms_pdu_decode_dcs(struct gsmd_sms_datacodingscheme *dcs,
+ const u_int8_t *data);
#endif /* __GSMD__ */
#endif
diff --git a/include/gsmd/unsolicited.h b/include/gsmd/unsolicited.h
index fa0ee32..49bdcde 100644
--- a/include/gsmd/unsolicited.h
+++ b/include/gsmd/unsolicited.h
@@ -7,14 +7,18 @@
struct gsmd_unsolicit {
const char *prefix;
- int (*parse)(char *unsol, int len, const char *param, struct gsmd *gsmd);
+ int (*parse)(const char *unsol,
+ int len, const char *param, struct gsmd *gsmd);
};
-extern int unsolicited_parse(struct gsmd *g, char *buf, int len, const char *param);
+extern void unsolicited_init(struct gsmd *g);
+extern int unsolicited_parse(struct gsmd *g,
+ const char *buf, int len, const char *param);
extern int generate_event_from_cme(struct gsmd *g, unsigned int cme_error);
extern void unsolicited_generic_init(struct gsmd *g);
extern int unsolicited_register_array(const struct gsmd_unsolicit *arr,
int len);
+extern int generate_event_from_cms(struct gsmd *g, unsigned int cms_error);
extern const int pintype_from_cme[];
#endif /* __GSMD__ */
diff --git a/include/gsmd/usock.h b/include/gsmd/usock.h
index 8bd5686..6200118 100644
--- a/include/gsmd/usock.h
+++ b/include/gsmd/usock.h
@@ -741,7 +741,9 @@ extern struct gsmd_ucmd *usock_build_event(u_int8_t type, u_int8_t subtype, u_in
extern int usock_evt_send(struct gsmd *gsmd, struct gsmd_ucmd *ucmd, u_int32_t evt);
extern int gsmd_ucmd_submit(struct gsmd_user *gu, u_int8_t msg_type,
u_int8_t msg_subtype, u_int16_t id, int len, const void *data);
-
+extern int gsmd_opname_init(struct gsmd *g);
+extern int gsmd_opname_add(struct gsmd *g, const char *numeric_bcd_string,
+ const char *alnum_long);
#endif /* __GSMD__ */
#endif
diff --git a/include/gsmd/vendorplugin.h b/include/gsmd/vendorplugin.h
index 1911fef..8669bb7 100644
--- a/include/gsmd/vendorplugin.h
+++ b/include/gsmd/vendorplugin.h
@@ -11,14 +11,15 @@ struct gsmd_unsolicit;
struct gsmd_vendor_plugin {
struct llist_head list;
- unsigned char *name;
- unsigned char *ext_chars;
+ char *name;
+ char *ext_chars;
unsigned int num_unsolicit;
const struct gsmd_unsolicit *unsolicit;
int (*detect)(struct gsmd *g);
int (*initsettings)(struct gsmd *g);
};
+extern int gsmd_vendor_plugin_load(char *name);
extern int gsmd_vendor_plugin_register(struct gsmd_vendor_plugin *pl);
extern void gsmd_vendor_plugin_unregister(struct gsmd_vendor_plugin *pl);
extern int gsmd_vendor_plugin_find(struct gsmd *g);
diff --git a/include/libgsmd/misc.h b/include/libgsmd/misc.h
index 088f624..5ac9bdb 100644
--- a/include/libgsmd/misc.h
+++ b/include/libgsmd/misc.h
@@ -71,5 +71,8 @@ extern int lgsm_get_subscriber_num(struct lgsm_handle *lh);
/* Retrieve IMSI information */
extern int lgsm_get_imsi(struct lgsm_handle *lh);
-
+/* Set voice mail number */
+extern int lgsm_voicemail_set(struct lgsm_handle *lh, const char *number);
+/* Get currently configured voice mail number */
+extern int lgsm_voicemail_get(struct lgsm_handle *lh);
#endif
diff --git a/src/gsmd/atcmd.c b/src/gsmd/atcmd.c
index 356b637..8d71268 100644
--- a/src/gsmd/atcmd.c
+++ b/src/gsmd/atcmd.c
@@ -49,12 +49,14 @@ enum final_result_codes {
NUM_FINAL_RESULTS,
};
+#if 0
static const char *final_results[] = {
"OK",
"ERROR",
"+CME ERROR:",
"+CMS ERROR:",
};
+#endif
/* we basically implement a parse that can deal with
* - receiving and queueing commands from higher level of libgmsd
@@ -188,6 +190,7 @@ static int llparse_init(struct llparser *llp)
return 0;
}
+#if 0
/* mid-level parser */
static int parse_final_result(const char *res)
@@ -200,6 +203,7 @@ static int parse_final_result(const char *res)
return -1;
}
+#endif
void atcmd_wake_pending_queue (struct gsmd *g)
{
@@ -224,10 +228,10 @@ static int atcmd_done(struct gsmd *g, struct gsmd_atcmd *cmd, const char *buf)
/* send final result code if there is no information
* response in mlbuf */
if (g->mlbuf_len) {
- cmd->resp = g->mlbuf;
+ cmd->resp = (char *) g->mlbuf;
g->mlbuf[g->mlbuf_len] = 0;
} else {
- cmd->resp = buf;
+ cmd->resp = (char *) buf;
}
rc = cmd->cb(cmd, cmd->ctx, cmd->resp);
DEBUGP("Clearing mlbuf\n");
@@ -367,7 +371,7 @@ static int ml_parse(const char *buf, int len, void *ctx)
gsmd_log(GSMD_NOTICE, "command without cb!!!\n");
} else {
DEBUGP("Calling cmd->cb()\n");
- cmd->resp = g->mlbuf;
+ cmd->resp = (char *) g->mlbuf;
rc = cmd->cb(cmd, cmd->ctx, cmd->resp);
DEBUGP("Clearing mlbuf\n");
memset(g->mlbuf, 0, MLPARSE_BUF_SIZE);
@@ -429,8 +433,8 @@ static int ml_parse(const char *buf, int len, void *ctx)
g->mlbuf_len += len;
if (g->mlunsolicited) {
- rc = unsolicited_parse(g, g->mlbuf, g->mlbuf_len,
- strchr(g->mlbuf, ':') + 1);
+ rc = unsolicited_parse(g, (const char*) g->mlbuf, (int) g->mlbuf_len,
+ strchr((const char*)g->mlbuf, ':') + 1);
if (rc == -EAGAIN) {
/* The parser wants one more line of
* input. Wait for the next line, concatenate
@@ -464,6 +468,7 @@ static int atcmd_prompt(void *data)
struct gsmd *g = data;
atcmd_wake_pending_queue(g);
+ return 0;
}
/* callback to be called if [virtual] UART has some data for us */
@@ -642,7 +647,6 @@ static int remove_timer(struct gsmd_atcmd * cmd)
/* submit an atcmd in the global queue of pending atcmds */
int atcmd_submit(struct gsmd *g, struct gsmd_atcmd *cmd)
{
- int empty;
if (g->machinepl->ex_submit) {
DEBUGP("extra-submiting command\n");
diff --git a/src/gsmd/ext_response.c b/src/gsmd/ext_response.c
index f2a94a7..e8b2ab3 100644
--- a/src/gsmd/ext_response.c
+++ b/src/gsmd/ext_response.c
@@ -67,7 +67,6 @@ struct gsm_extrsp *extrsp_parse(const void *ctx, const char *input)
{
const char *cur = input;
struct gsm_extrsp *er;
- int cur_tok = 0;
enum parser_state state = IDLE;
char buf[512];
char *cur_buf = buf;
@@ -166,6 +165,8 @@ struct gsm_extrsp *extrsp_parse(const void *ctx, const char *input)
/* ERROR */
}
break;
+ default:
+ break;
}
cur++;
}
diff --git a/src/gsmd/gsmd.c b/src/gsmd/gsmd.c
index 53b43a8..c83deff 100644
--- a/src/gsmd/gsmd.c
+++ b/src/gsmd/gsmd.c
@@ -44,6 +44,8 @@
#include <gsmd/usock.h>
#include <gsmd/vendorplugin.h>
#include <gsmd/talloc.h>
+#include <gsmd/sms.h>
+#include <gsmd/unsolicited.h>
#define GSMD_ALIVECMD "AT"
#define GSMD_ALIVE_INTERVAL 5*60
@@ -157,7 +159,7 @@ int gsmd_simplecmd(struct gsmd *gsmd, char *cmdtxt)
static int gsmd_initsettings2(struct gsmd *gsmd)
{
- int rc;
+ int rc = 0;
/* echo on, verbose */
rc |= gsmd_simplecmd(gsmd, "ATE0V1");
@@ -215,19 +217,10 @@ static int firstcmd_atcb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
return gsmd_initsettings2(gsmd);
}
-static void firstcmd_tmr_cb(struct gsmd_timer *tmr, void *data)
-{
- if (firstcmd_response == 0) {
- gsmd_log(GSMD_FATAL, "No response from GSM Modem");
- exit(4);
- }
- gsmd_timer_free(tmr);
-}
int gsmd_initsettings(struct gsmd *gsmd)
{
struct gsmd_atcmd *cmd;
- struct timeval tv;
cmd = atcmd_fill("ATZ", strlen("ATZ")+1, &firstcmd_atcb, gsmd, 0, NULL);
if (!cmd)
@@ -366,7 +359,6 @@ int main(int argc, char **argv)
int bps = 115200;
int hwflow = 0;
char *device = NULL;
- char *logfile = "syslog";
char *vendor_name = NULL;
char *machine_name = NULL;
int wait = -1;
@@ -475,7 +467,7 @@ int main(int argc, char **argv)
exit(1);
}
- write(fd,'\r',1);
+ write(fd,"\r",1);
atcmd_drain(fd);
if (usock_init(&g) < 0) {
diff --git a/src/gsmd/machine.c b/src/gsmd/machine.c
index 0909928..33551b2 100644
--- a/src/gsmd/machine.c
+++ b/src/gsmd/machine.c
@@ -117,7 +117,7 @@ int gsmd_machine_plugin_init(struct gsmd *g, char *machine_name, char *vendor_na
buf[sizeof(buf)-1] = '\0';
line = strtok(buf, "\n");
- while (line = strtok(NULL, "\n")) {
+ while ((line = strtok(NULL, "\n"))) {
if (strncmp(line, "Hardware\t: ", 11) == 0) {
hw = line+11;
break;
@@ -138,7 +138,7 @@ int gsmd_machine_plugin_init(struct gsmd *g, char *machine_name, char *vendor_na
if (vendor_name)
DEBUGP("wanring: auto-detected vendor '%s', "
- "but user override to '%s'\m",
+ "but user override to '%s'\n",
machines[i].vendor, vendor_name);
else
vendor_name = machines[i].vendor;
diff --git a/src/gsmd/machine_generic.c b/src/gsmd/machine_generic.c
index 536192d..b46c118 100644
--- a/src/gsmd/machine_generic.c
+++ b/src/gsmd/machine_generic.c
@@ -41,8 +41,6 @@ static int generic_detect(struct gsmd *g)
static int generic_init(struct gsmd *g, int fd)
{
- int rc;
-
/*
* We assume that the GSM chipset can take
* input immediately, so we don't have to
diff --git a/src/gsmd/sms_cb.c b/src/gsmd/sms_cb.c
index ea622fc..0e97749 100644
--- a/src/gsmd/sms_cb.c
+++ b/src/gsmd/sms_cb.c
@@ -38,6 +38,7 @@
#include <gsmd/usock.h>
#include <gsmd/unsolicited.h>
#include <gsmd/sms.h>
+#include <gsmd/talloc.h>
static const char *ts0705_memtype_name[] = {
[GSM0705_MEMTYPE_NONE] = "NONE",
@@ -402,7 +403,8 @@ int usock_rcv_cb(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, int len)
}
/* Unsolicited messages related to SMS / CB */
-static int cmti_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
+static int cmti_parse(const char *buf, int len, const char *param,
+ struct gsmd *gsmd)
{
char memstr[3];
struct gsmd_evt_auxdata *aux;
@@ -424,7 +426,8 @@ static int cmti_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
return usock_evt_send(gsmd, ucmd, GSMD_EVT_IN_SMS);
}
-static int cmt_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
+static int cmt_parse(const char *buf, int len, const char *param,
+ struct gsmd *gsmd)
{
/* TODO: TEXT mode */
u_int8_t pdu[SMS_MAX_PDU_SIZE];
@@ -474,7 +477,8 @@ static int cmt_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
return usock_evt_send(gsmd, ucmd, GSMD_EVT_IN_SMS);
}
-static int cbmi_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
+static int cbmi_parse(const char *buf, int len, const char *param,
+ struct gsmd *gsmd)
{
char memstr[3];
struct gsmd_evt_auxdata *aux;
@@ -496,7 +500,8 @@ static int cbmi_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
return usock_evt_send(gsmd, ucmd, GSMD_EVT_IN_CBM);
}
-static int cbm_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
+static int cbm_parse(const char *buf, int len, const char *param,
+ struct gsmd *gsmd)
{
/* TODO: TEXT mode */
u_int8_t pdu[CBM_MAX_PDU_SIZE];
@@ -541,7 +546,8 @@ static int cbm_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
return usock_evt_send(gsmd, ucmd, GSMD_EVT_IN_CBM);
}
-static int cdsi_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
+static int cdsi_parse(const char *buf, int len, const char *param,
+ struct gsmd *gsmd)
{
char memstr[3];
struct gsmd_evt_auxdata *aux;
@@ -563,7 +569,8 @@ static int cdsi_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
return usock_evt_send(gsmd, ucmd, GSMD_EVT_IN_DS);
}
-static int cds_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
+static int cds_parse(const char *buf, int len, const char *param,
+ struct gsmd *gsmd)
{
/* TODO: TEXT mode */
u_int8_t pdu[SMS_MAX_PDU_SIZE];
diff --git a/src/gsmd/timer.c b/src/gsmd/timer.c
index 5200690..648676f 100644
--- a/src/gsmd/timer.c
+++ b/src/gsmd/timer.c
@@ -37,12 +37,13 @@
static LLIST_HEAD(gsmd_timers);
static void *__tmr_ctx;
+#if 0
static void tv_normalize(struct timeval *out)
{
out->tv_sec += (out->tv_usec / 1000000);
out->tv_usec = (out->tv_usec % 1000000);
}
-
+#endif
/* subtract two struct timevals */
static int tv_sub(struct timeval *res, const struct timeval *from,
const struct timeval *sub)
@@ -57,7 +58,7 @@ static int tv_sub(struct timeval *res, const struct timeval *from,
return 0;
}
-
+#if 0
static int tv_add(struct timeval *res, const struct timeval *a1,
const struct timeval *a2)
{
@@ -68,7 +69,7 @@ static int tv_add(struct timeval *res, const struct timeval *a1,
tv_normalize(res);
}
-
+#endif
static int tv_later(const struct timeval *expires, const struct timeval *now)
{
if (expires->tv_sec < now->tv_sec)
diff --git a/src/gsmd/unsolicited.c b/src/gsmd/unsolicited.c
index 8c99183..537e16a 100644
--- a/src/gsmd/unsolicited.c
+++ b/src/gsmd/unsolicited.c
@@ -35,6 +35,7 @@
#include <gsmd/ts0707.h>
#include <gsmd/unsolicited.h>
#include <gsmd/talloc.h>
+#include <gsmd/sms.h>
struct gsmd_ucmd *usock_build_event(u_int8_t type, u_int8_t subtype, u_int16_t len)
{
@@ -147,7 +148,7 @@ static void state_ringing_update(struct gsmd *gsmd)
&state_ringing_timeout, gsmd);
}
-static int ring_parse(char *buf, int len, const char *param,
+static int ring_parse(const char *buf, int len, const char *param,
struct gsmd *gsmd)
{
struct gsmd_ucmd *ucmd;
@@ -167,7 +168,7 @@ static int ring_parse(char *buf, int len, const char *param,
return usock_evt_send(gsmd, ucmd, GSMD_EVT_IN_CALL);
}
-static int cring_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
+static int cring_parse(const char *buf, int len, const char *param, struct gsmd *gsmd)
{
struct gsmd_ucmd *ucmd = usock_build_event(GSMD_MSG_EVENT, GSMD_EVT_IN_CALL,
sizeof(struct gsmd_evt_auxdata));
@@ -201,7 +202,7 @@ static int cring_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
}
/* Chapter 7.2, network registration */
-static int creg_parse(char *buf, int len, const char *param,
+static int creg_parse(const char *buf, int len, const char *param,
struct gsmd *gsmd)
{
const char *comma = strchr(param, ',');
@@ -250,7 +251,7 @@ static int creg_parse(char *buf, int len, const char *param,
}
/* Chapter 7.11, call waiting */
-static int ccwa_parse(char *buf, int len, const char *param,
+static int ccwa_parse(const char *buf, int len, const char *param,
struct gsmd *gsmd)
{
struct gsmd_evt_auxdata *aux;
@@ -309,7 +310,7 @@ static int ccwa_parse(char *buf, int len, const char *param,
}
/* Chapter 7.14, unstructured supplementary service data */
-static int cusd_parse(char *buf, int len, const char *param,
+static int cusd_parse(const char *buf, int len, const char *param,
struct gsmd *gsmd)
{
/* FIXME: parse */
@@ -317,7 +318,7 @@ static int cusd_parse(char *buf, int len, const char *param,
}
/* Chapter 7.15, advise of charge */
-static int cccm_parse(char *buf, int len, const char *param,
+static int cccm_parse(const char *buf, int len, const char *param,
struct gsmd *gsmd)
{
/* FIXME: parse */
@@ -325,7 +326,7 @@ static int cccm_parse(char *buf, int len, const char *param,
}
/* Chapter 10.1.13, GPRS event reporting */
-static int cgev_parse(char *buf, int len, const char *param,
+static int cgev_parse(const char *buf, int len, const char *param,
struct gsmd *gsmd)
{
/* FIXME: parse */
@@ -333,7 +334,7 @@ static int cgev_parse(char *buf, int len, const char *param,
}
/* Chapter 10.1.14, GPRS network registration status */
-static int cgreg_parse(char *buf, int len, const char *param,
+static int cgreg_parse(const char *buf, int len, const char *param,
struct gsmd *gsmd)
{
/* FIXME: parse */
@@ -341,7 +342,7 @@ static int cgreg_parse(char *buf, int len, const char *param,
}
/* Chapter 7.6, calling line identification presentation */
-static int clip_parse(char *buf, int len, const char *param,
+static int clip_parse(const char *buf, int len, const char *param,
struct gsmd *gsmd)
{
struct gsmd_ucmd *ucmd = usock_build_event(GSMD_MSG_EVENT, GSMD_EVT_IN_CLIP,
@@ -369,7 +370,7 @@ static int clip_parse(char *buf, int len, const char *param,
}
/* Chapter 7.9, calling line identification presentation */
-static int colp_parse(char *buf, int len, const char *param,
+static int colp_parse(const char *buf, int len, const char *param,
struct gsmd *gsmd)
{
struct gsmd_ucmd *ucmd = usock_build_event(GSMD_MSG_EVENT, GSMD_EVT_OUT_COLP,
@@ -395,7 +396,7 @@ static int colp_parse(char *buf, int len, const char *param,
return usock_evt_send(gsmd, ucmd, GSMD_EVT_OUT_COLP);
}
-static int ctzv_parse(char *buf, int len, const char *param,
+static int ctzv_parse(const char *buf, int len, const char *param,
struct gsmd *gsmd)
{
struct gsmd_ucmd *ucmd = usock_build_event(GSMD_MSG_EVENT, GSMD_EVT_TIMEZONE,
@@ -419,7 +420,7 @@ static int ctzv_parse(char *buf, int len, const char *param,
return usock_evt_send(gsmd, ucmd, GSMD_EVT_TIMEZONE);
}
-static int copn_parse(char *buf, int len, const char *param,
+static int copn_parse(const char *buf, int len, const char *param,
struct gsmd *gsmd)
{
struct gsm_extrsp *er = extrsp_parse(gsmd_tallocs, param);
@@ -468,11 +469,10 @@ static const struct gsmd_unsolicit gsm0707_unsolicit[] = {
static struct gsmd_unsolicit unsolicit[256] = {{ 0, 0 }};
/* called by midlevel parser if a response seems unsolicited */
-int unsolicited_parse(struct gsmd *g, char *buf, int len, const char *param)
+int unsolicited_parse(struct gsmd *g, const char *buf, int len, const char *param)
{
struct gsmd_unsolicit *i;
int rc;
- struct gsmd_vendor_plugin *vpl = g->vendorpl;
/* call unsolicited code parser */
for (i = unsolicit; i->prefix; i ++) {
diff --git a/src/gsmd/usock.c b/src/gsmd/usock.c
index a45a6b0..fffe7a2 100644
--- a/src/gsmd/usock.c
+++ b/src/gsmd/usock.c
@@ -43,7 +43,7 @@
#include <gsmd/ts0707.h>
#include <gsmd/sms.h>
-static void *__ucmd_ctx, *__gu_ctx, *__pb_ctx;
+static void *__ucmd_ctx, *__gu_ctx;
struct gsmd_ucmd *ucmd_alloc(int extra_size)
{
@@ -112,6 +112,7 @@ static int usock_rcv_event(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, int l
return -EINVAL;
gu->subscriptions = *evtmask;
+ return 0;
}
static int voicecall_get_stat_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
@@ -222,7 +223,6 @@ static int voicecall_fwd_stat_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
struct gsmd_user *gu = ctx;
struct gsm_extrsp *er;
struct gsmd_call_fwd_stat gcfs;
- int ret = 0;
DEBUGP("resp: %s\n", resp);
@@ -955,7 +955,7 @@ static int usock_rcv_network(struct gsmd_user *gu, struct gsmd_msg_hdr *gph,
case GSMD_NETWORK_REGISTER:
if ((*oper)[0])
cmdlen = sprintf(buffer, "AT+COPS=1,2,\"%.*s\"",
- sizeof(gsmd_oper_numeric), oper);
+ sizeof(gsmd_oper_numeric), (char *)oper);
else
cmdlen = sprintf(buffer, "AT+COPS=0");
cmd = atcmd_fill(buffer, cmdlen + 1, &null_cmd_cb, gu, 0, NULL);
@@ -996,7 +996,7 @@ static int usock_rcv_network(struct gsmd_user *gu, struct gsmd_msg_hdr *gph,
break;
case GSMD_NETWORK_PREF_ADD:
cmdlen = sprintf(buffer, "AT+CPOL=,2,\"%.*s\"",
- sizeof(gsmd_oper_numeric), oper);
+ sizeof(gsmd_oper_numeric), (char *)oper);
cmd = atcmd_fill(buffer, cmdlen + 1, &null_cmd_cb, gu, 0, NULL);
break;
case GSMD_NETWORK_PREF_SPACE:
@@ -1253,9 +1253,8 @@ static int usock_rcv_phonebook(struct gsmd_user *gu,
struct gsmd_phonebook_readrg *gpr;
struct gsmd_phonebook *gp;
struct gsmd_phonebook_find *gpf;
- struct gsmd_phonebooks *cur, *cur2;
- int *index, *num;
- int atcmd_len, i, ret;
+ int *index;
+ int atcmd_len;
char *storage;
char buf[1024];
diff --git a/src/gsmd/vendor_bcm.c b/src/gsmd/vendor_bcm.c
index 9bcfa1a..6ccc2e2 100644
--- a/src/gsmd/vendor_bcm.c
+++ b/src/gsmd/vendor_bcm.c
@@ -35,7 +35,7 @@
#include <gsmd/vendorplugin.h>
#include <gsmd/unsolicited.h>
-static int mrdy_parse(char *buf, int len, const char *param,
+static int mrdy_parse(const char *buf, int len, const char *param,
struct gsmd *g)
{
int status = atoi(param);
@@ -70,11 +70,9 @@ static int mrdy_parse(char *buf, int len, const char *param,
return 0;
}
-static int mtsmenu_parse(char *buf, int len, const char *param,
+static int mtsmenu_parse(const char *buf, int len, const char *param,
struct gsmd *g)
{
- char *tok, *param_tmp;
- struct mtsmenu *mtsmenu;
DEBUGP("mtsmenu_parse param=`%s'\n", param);
return 0;
@@ -95,8 +93,7 @@ static int bcm_detect(struct gsmd *g)
static int bcm_initsettings(struct gsmd *g)
{
- int rc;
- struct gsmd_atcmd *cmd;
+ int rc = 0;
/* bcm sometimes sends LFCR instead of CRLF (eg *MTSMENU message) */
g->llp.flags |= LGSM_ATCMD_F_LFCR;
diff --git a/src/gsmd/vendor_qc.c b/src/gsmd/vendor_qc.c
index 7b2f44b..98ed9d8 100644
--- a/src/gsmd/vendor_qc.c
+++ b/src/gsmd/vendor_qc.c
@@ -36,10 +36,9 @@
#include <gsmd/vendorplugin.h>
#include <gsmd/unsolicited.h>
-static int htccsq_parse(char *buf, int len, const char *param,
+static int htccsq_parse(const char *buf, int len, const char *param,
struct gsmd *gsmd)
{
- char *tok;
struct gsmd_evt_auxdata *aux;
struct gsmd_ucmd *ucmd = usock_build_event(GSMD_MSG_EVENT, GSMD_EVT_SIGNAL,
sizeof(*aux));
@@ -63,13 +62,9 @@ static int htccsq_parse(char *buf, int len, const char *param,
usock_evt_send(gsmd, ucmd, GSMD_EVT_SIGNAL);
return 0;
-
-out_free_io:
- free(ucmd);
- return -EIO;
}
-static int wcdma_parse(char *buf, int len, const char *param,
+static int wcdma_parse(const char *buf, int len, const char *param,
struct gsmd *gsmd)
{
return 0;
@@ -96,8 +91,7 @@ static int qc_detect(struct gsmd *g)
static int qc_initsettings(struct gsmd *g)
{
- int rc;
- struct gsmd_atcmd *cmd;
+ int rc = 0;
/* enable @HTCCSQ: signal quality reports */
rc |= gsmd_simplecmd(g, "AT@HTCCSQ=1");
diff --git a/src/gsmd/vendor_ti.c b/src/gsmd/vendor_ti.c
index e34cbaf..219f23e 100644
--- a/src/gsmd/vendor_ti.c
+++ b/src/gsmd/vendor_ti.c
@@ -38,7 +38,7 @@
#include <gsmd/unsolicited.h>
-static int csq_parse(char *buf, int len, const char *param,
+static int csq_parse(const char *buf, int len, const char *param,
struct gsmd *gsmd)
{
struct gsmd_evt_auxdata *aux;
@@ -63,11 +63,13 @@ out_free_io:
return -EIO;
}
-static int cpri_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
+static int cpri_parse(const char *buf, int len, const char *param, struct gsmd *gsmd)
{
char *tok1, *tok2;
-
- tok1 = strtok(buf, ",");
+ char tx_buf[20];
+
+ strcpy(tx_buf, buf);
+ tok1 = strtok(tx_buf, ",");
if (!tok1)
return -EIO;
@@ -103,7 +105,7 @@ static int cpri_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
return 0;
}
-static int ctzv_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
+static int ctzv_parse(const char *buf, int len, const char *param, struct gsmd *gsmd)
{
/* FIXME: decide what to do with it. send as event to clients? or keep
* locally? Offer option to sync system RTC? */
@@ -111,14 +113,16 @@ static int ctzv_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
}
/* Call Progress Information */
-static int cpi_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
+static int cpi_parse(const char *buf, int len, const char *param, struct gsmd *gsmd)
{
char *tok;
struct gsmd_evt_auxdata *aux;
struct gsmd_ucmd *ucmd = usock_build_event(GSMD_MSG_EVENT,
GSMD_EVT_OUT_STATUS,
sizeof(*aux));
-
+ char tx_buf[64];
+
+ strcpy(tx_buf, buf);
DEBUGP("entering cpi_parse param=`%s'\n", param);
if (!ucmd)
return -EINVAL;
@@ -128,7 +132,7 @@ static int cpi_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
/* Format: cId, msgType, ibt, tch, dir,[mode],[number],[type],[alpha],[cause],line */
/* call ID */
- tok = strtok(buf, ",");
+ tok = strtok(tx_buf, ",");
if (!tok)
goto out_free_io;
diff --git a/src/gsmd/vendor_tihtc.c b/src/gsmd/vendor_tihtc.c
index 7e51851..b7c284c 100644
--- a/src/gsmd/vendor_tihtc.c
+++ b/src/gsmd/vendor_tihtc.c
@@ -52,10 +52,9 @@ int gsmd_simplecmd(struct gsmd *gsmd, char *cmdtxt)
return atcmd_submit(gsmd, cmd);
}
-static int htccsq_parse(char *buf, int len, const char *param,
+static int htccsq_parse(const char *buf, int len, const char *param,
struct gsmd *gsmd)
{
- char *tok;
struct gsmd_evt_auxdata *aux;
struct gsmd_ucmd *ucmd = usock_build_event(GSMD_MSG_EVENT, GSMD_EVT_SIGNAL,
sizeof(*aux));
@@ -79,17 +78,15 @@ static int htccsq_parse(char *buf, int len, const char *param,
usock_evt_send(gsmd, ucmd, GSMD_EVT_SIGNAL);
return 0;
-
-out_free_io:
- free(ucmd);
- return -EIO;
}
-static int cpri_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
+static int cpri_parse(const char *buf, int len, const char *param, struct gsmd *gsmd)
{
char *tok1, *tok2;
-
- tok1 = strtok(buf, ",");
+ char tx_buf[20];
+
+ strcpy(tx_buf, buf);
+ tok1 = strtok(tx_buf, ",");
if (!tok1)
return -EIO;
@@ -126,14 +123,16 @@ static int cpri_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
}
/* Call Progress Information */
-static int cpi_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
+static int cpi_parse(const char *buf, int len, const char *param, struct gsmd *gsmd)
{
char *tok;
struct gsmd_evt_auxdata *aux;
struct gsmd_ucmd *ucmd = usock_build_event(GSMD_MSG_EVENT,
GSMD_EVT_OUT_STATUS,
sizeof(*aux));
+ char tx_buf[64];
+ strcpy(tx_buf, buf);
DEBUGP("entering cpi_parse param=`%s'\n", param);
if (!ucmd)
return -EINVAL;
@@ -143,7 +142,7 @@ static int cpi_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
/* Format: cId, msgType, ibt, tch, dir,[mode],[number],[type],[alpha],[cause],line */
/* call ID */
- tok = strtok(buf, ",");
+ tok = strtok(tx_buf, ",");
if (!tok)
goto out_free_io;
@@ -248,7 +247,7 @@ static int tihtc_detect(struct gsmd *g)
static int tihtc_initsettings(struct gsmd *g)
{
- int rc;
+ int rc = 0;
struct gsmd_atcmd *cmd;
/* use %CGREG */
diff --git a/src/libgsmd/libgsmd.c b/src/libgsmd/libgsmd.c
index b9db59a..36e49a6 100644
--- a/src/libgsmd/libgsmd.c
+++ b/src/libgsmd/libgsmd.c
@@ -32,9 +32,11 @@
#include <gsmd/usock.h>
#include <libgsmd/libgsmd.h>
+#include <libgsmd/event.h>
#include "lgsm_internals.h"
+#if 0
static int lgsm_get_packet(struct lgsm_handle *lh)
{
static char buf[GSMD_MSGSIZE_MAX];
@@ -56,6 +58,7 @@ static int lgsm_get_packet(struct lgsm_handle *lh)
return 0;
}
+#endif
static int lgsm_open_backend(struct lgsm_handle *lh, const char *device)
{
diff --git a/src/libgsmd/libgsmd_network.c b/src/libgsmd/libgsmd_network.c
index 5551de3..eb45169 100644
--- a/src/libgsmd/libgsmd_network.c
+++ b/src/libgsmd/libgsmd_network.c
@@ -38,6 +38,7 @@ int lgsm_get_netreg_state(struct lgsm_handle *lh,
enum lgsm_netreg_state *state)
{
*state = lh->netreg_state;
+ return 0;
}
int lgsm_oper_get(struct lgsm_handle *lh)
@@ -139,7 +140,6 @@ int lgsm_voicemail_set(struct lgsm_handle *lh, const char *number)
{
struct gsmd_msg_hdr *gmh;
struct gsmd_voicemail *vmail;
- int rc;
gmh = lgsm_gmh_fill(GSMD_MSG_NETWORK,
GSMD_NETWORK_VMAIL_SET, sizeof(*vmail));
diff --git a/src/libgsmd/libgsmd_sms.c b/src/libgsmd/libgsmd_sms.c
index 81293ee..b13dacb 100644
--- a/src/libgsmd/libgsmd_sms.c
+++ b/src/libgsmd/libgsmd_sms.c
@@ -135,7 +135,7 @@ int lgsm_sms_send(struct lgsm_handle *lh,
/* FIXME: only support PDU mode */
struct gsmd_msg_hdr *gmh;
struct gsmd_sms_submit *gss;
- int i, rc;
+ int rc;
gmh = lgsm_gmh_fill(GSMD_MSG_SMS,
GSMD_SMS_SEND, sizeof(*gss));
@@ -258,7 +258,6 @@ int packing_7bit_character(const char *src, struct lgsm_sms *dest)
{
int i,j = 0;
unsigned char ch1, ch2;
- char tmp[2];
int shift = 0;
dest->alpha = ALPHABET_DEFAULT;
diff --git a/src/util/atcmd.c b/src/util/atcmd.c
index 36984b5..88703d0 100644
--- a/src/util/atcmd.c
+++ b/src/util/atcmd.c
@@ -35,6 +35,7 @@ static int pt_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh)
{
char *payload = (char *)gmh + sizeof(*gmh);
printf("RSTR=`%s'\n", payload);
+ return 0;
}
int atcmd_main(struct lgsm_handle *lgsmh)
@@ -42,7 +43,7 @@ int atcmd_main(struct lgsm_handle *lgsmh)
int rc;
char buf[STDIN_BUF_SIZE+1];
char rbuf[STDIN_BUF_SIZE+1];
- int rlen = sizeof(rbuf);
+ unsigned int rlen = sizeof(rbuf);
fd_set readset;
lgsm_register_handler(lgsmh, GSMD_MSG_PASSTHROUGH, &pt_msghandler);
@@ -99,4 +100,5 @@ int atcmd_main(struct lgsm_handle *lgsmh)
fflush(stdout);
}
}
+ return 0;
}
diff --git a/src/util/event.c b/src/util/event.c
index d063642..88f315f 100644
--- a/src/util/event.c
+++ b/src/util/event.c
@@ -115,7 +115,7 @@ static int incbm_handler(struct lgsm_handle *lh, int evt,
msg->page, msg->pages);
if (msg->coding_scheme == ALPHABET_DEFAULT) {
- cbm_unpacking_7bit_character(msg->data, payload);
+ cbm_unpacking_7bit_character((char *)msg->data, payload);
printf("\"%s\"\n", payload);
} else if (msg->coding_scheme == ALPHABET_8BIT)
printf("8-bit encoded data\n");
@@ -176,6 +176,8 @@ static int netreg_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxda
case GSMD_NETREG_REG_ROAMING:
printf("registered (roaming) ");
break;
+ default:
+ break;
}
if (aux->u.netreg.lac)
diff --git a/src/util/pin.c b/src/util/pin.c
index b873535..47602b6 100644
--- a/src/util/pin.c
+++ b/src/util/pin.c
@@ -52,7 +52,7 @@ static int pin_handler(struct lgsm_handle *lh,
} else {
do {
printf("Please enter %s: ", lgsm_pin_name(type));
- rc = fscanf(stdin, "%8s", &pinbuf);
+ rc = fscanf(stdin, "%8s", pinbuf);
} while (rc < 1);
switch (type) {
@@ -60,7 +60,7 @@ static int pin_handler(struct lgsm_handle *lh,
case GSMD_PIN_SIM_PUK2:
do {
printf("Please enter new PIN: ");
- rc = fscanf(stdin, "%8s", &pinbuf2);
+ rc = fscanf(stdin, "%8s", pinbuf2);
newpin = pinbuf2;
} while (rc < 1);
break;
diff --git a/src/util/shell.c b/src/util/shell.c
index 976acc2..f5f8fd3 100644
--- a/src/util/shell.c
+++ b/src/util/shell.c
@@ -31,6 +31,7 @@
#include <libgsmd/misc.h>
#include <libgsmd/phonebook.h>
#include <libgsmd/sms.h>
+#include <libgsmd/pin.h>
#include <gsmd/usock.h>
#include <gsmd/ts0705.h>
@@ -49,6 +50,7 @@ static int pt_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh)
{
char *payload = (char *)gmh + sizeof(*gmh);
printf("RSTR=`%s'\n", payload);
+ return 0;
}
/* this is the handler for receiving phonebook responses */
@@ -135,7 +137,8 @@ static int pb_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh)
break;
default:
return -EINVAL;
- }
+ }
+ return 0;
}
/* this is the handler for receiving sms responses */
@@ -273,6 +276,7 @@ static int sms_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh)
pending_responses --;
return -EINVAL;
}
+ return 0;
}
/* this is the handler for responses to network/operator commands */
@@ -359,6 +363,7 @@ static int net_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh)
default:
return -EINVAL;
}
+ return 0;
}
static int phone_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh)
@@ -482,7 +487,7 @@ static const struct msghandler_s {
{ 0, 0 }
};
-static int shell_help(void)
+static void shell_help(void)
{
printf( "\tA\tAnswer incoming call\n"
"\tD\tDial outgoing number\n"
@@ -542,8 +547,6 @@ int shell_main(struct lgsm_handle *lgsmh, int sync)
{
int rc;
char buf[STDIN_BUF_SIZE+1];
- char rbuf[STDIN_BUF_SIZE+1];
- int rlen = sizeof(rbuf);
fd_set readset;
char *ptr, *fcomma, *lcomma;
int gsm_fd = lgsm_fd(lgsmh);
@@ -923,4 +926,5 @@ int shell_main(struct lgsm_handle *lgsmh, int sync)
}
fflush(stdout);
}
+ return 0;
}
personal git repositories of Harald Welte. Your mileage may vary