summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libgsmd/misc.h12
-rw-r--r--src/libgsmd/Makefile.am2
-rw-r--r--src/util/libgsmd-tool.c3
-rw-r--r--src/util/shell.c63
4 files changed, 72 insertions, 8 deletions
diff --git a/include/libgsmd/misc.h b/include/libgsmd/misc.h
index 95e219d..c919d72 100644
--- a/include/libgsmd/misc.h
+++ b/include/libgsmd/misc.h
@@ -1,5 +1,5 @@
-#ifndef _LIBGSMD_H
-#define _LIBGSMD_H
+#ifndef _MISC_LIBGSMD_H
+#define _MISC_LIBGSMD_H
/* libgsmd.h - Library API for gsmd, the GSM Daemon
* (C) 2006 by Harald Welte <hwelte@hmw-consulting.de>
@@ -25,19 +25,19 @@ extern int lgsm_get_netreg_state(struct lgsm_handle *lh,
extern int lgsm_netreg_register(struct lgsm_handle *lh, int oper);
-enum lgsm_info_type {
+typedef enum _lgsm_info_type {
LGSM_INFO_TYPE_NONE = 0,
LGSM_INFO_TYPE_MANUF = 1,
LGSM_INFO_TYPE_MODEL = 2,
LGSM_INFO_TYPE_REVISION = 3,
LGSM_INFO_TYPE_SERIAL = 4,
LGSM_INFO_TYPE_IMSI = 5,
-};
+}lgsm_info_type;
/* Get some information about the handset */
extern int lgsm_get_info(struct lgsm_handle *lh,
- enum lgsm_info_type type,
- char *ret_string, u_int16_t len);
+ lgsm_info_type type,
+ char *ret_string, unsigned int* len);
/* Authenticate to SIM Card using specified null-terminated pin */
extern int lgsm_pin_auth(struct lgsm_handle *lh, const char *pin);
diff --git a/src/libgsmd/Makefile.am b/src/libgsmd/Makefile.am
index a1ee710..e9cd1a0 100644
--- a/src/libgsmd/Makefile.am
+++ b/src/libgsmd/Makefile.am
@@ -5,6 +5,6 @@ AM_CFLAGS = -std=gnu99
lib_LTLIBRARIES = libgsmd.la
libgsmd_la_LDFLAGS = -Wc,-nostartfiles -version-info $(LIBVERSION)
-libgsmd_la_SOURCES = libgsmd.c libgsmd_input.c libgsmd_voicecall.c libgsmd_passthrough.c libgsmd_event.c libgsmd_phone.c libgsmd_network.c
+libgsmd_la_SOURCES = libgsmd.c libgsmd_input.c libgsmd_voicecall.c libgsmd_passthrough.c libgsmd_event.c libgsmd_phone.c libgsmd_network.c libgsmd_device.c
noinst_HEADERS = lgsm_internals.h
diff --git a/src/util/libgsmd-tool.c b/src/util/libgsmd-tool.c
index c48bf8e..34bb53c 100644
--- a/src/util/libgsmd-tool.c
+++ b/src/util/libgsmd-tool.c
@@ -95,11 +95,14 @@ int main(int argc, char **argv)
printf("libgsm-tool - (C) 2006 by Harald Welte\n"
"This program is Free Software and has ABSOLUTELY NO WARRANTY\n\n");
+
while (1) {
int c, option_index = 0;
c = getopt_long(argc, argv, "vVhm:p:", opts, &option_index);
if (c == -1)
+ {
break;
+ }
switch (c) {
case 'v':
diff --git a/src/util/shell.c b/src/util/shell.c
index 43a0bfe..c7ccc91 100644
--- a/src/util/shell.c
+++ b/src/util/shell.c
@@ -48,6 +48,7 @@ static int shell_help(void)
"\to\tPower Off\n"
"\tR\tRegister Netowrk\n"
"\tT\tSend DTMF Tone\n"
+ "\tI\tDevice Infor\n"
"\tq\tQuit\n"
);
}
@@ -58,6 +59,7 @@ int shell_main(struct lgsm_handle *lgsmh)
char buf[STDIN_BUF_SIZE+1];
char rbuf[STDIN_BUF_SIZE+1];
int rlen = sizeof(rbuf);
+
fd_set readset;
lgsm_register_handler(lgsmh, GSMD_MSG_PASSTHROUGH, &pt_msghandler);
@@ -136,9 +138,68 @@ int shell_main(struct lgsm_handle *lgsmh)
continue;
printf("DTMF: %c\n", buf[1]);
lgsm_voice_dtmf(lgsmh, buf[1]);
- } else {
+ } else if (buf[0] == 'I') {
+ //FIXME: sometimes, lgsm_get_info returns directly, and sometimes the result just gets lost.
+ static int infoindex=LGSM_INFO_TYPE_NONE;//information
+ infoindex=infoindex%LGSM_INFO_TYPE_IMSI+1;
+ rlen = sizeof(rbuf);
+ switch(infoindex){
+ case LGSM_INFO_TYPE_MANUF:
+
+ if(lgsm_get_info(lgsmh,LGSM_INFO_TYPE_MANUF,rbuf,&rlen))
+ {
+ printf("manufacturer:%s\n",rbuf);
+ }
+ else
+ printf("manufacturer information error!\n");
+ break;
+
+ case LGSM_INFO_TYPE_MODEL:
+ if(lgsm_get_info(lgsmh,LGSM_INFO_TYPE_MODEL,rbuf,&rlen))
+ {
+ printf("model:%s\n",rbuf);
+ }
+ else
+ printf("model error!\n");
+ break;
+
+ case LGSM_INFO_TYPE_REVISION:
+ if(lgsm_get_info(lgsmh,LGSM_INFO_TYPE_REVISION,rbuf,&rlen))
+ {
+ printf("revision:%s\n",rbuf);
+ }
+ else
+ printf("revision information error!\n");
+ break;
+
+ case LGSM_INFO_TYPE_IMSI:
+ if(lgsm_get_info(lgsmh,LGSM_INFO_TYPE_IMSI,rbuf,&rlen))
+ {
+ printf("imei:%s\n",rbuf);
+ }
+ else
+ printf("imei information error!\n");
+ break;
+ case LGSM_INFO_TYPE_SERIAL:
+ if(lgsm_get_info(lgsmh,LGSM_INFO_TYPE_SERIAL,rbuf,&rlen))
+ {
+ printf("sn:%s\n",rbuf);
+ }
+ else
+ printf("sn information error!\n");
+ break;
+ default:
+ printf("something is wrong!\n");
+ }
+
+
+
+ }
+ else {
printf("Unknown command `%s'\n", buf);
}
}
}
}
+
+
personal git repositories of Harald Welte. Your mileage may vary