diff options
author | laforge <laforge@99fdad57-331a-0410-800a-d7fa5415bdb3> | 2006-10-22 23:17:15 +0000 |
---|---|---|
committer | laforge <laforge@99fdad57-331a-0410-800a-d7fa5415bdb3> | 2006-10-22 23:17:15 +0000 |
commit | 7fe163099476937a14dd7a0714de542f7f94f665 (patch) | |
tree | 7e1c703f7f30efd941591d35e51cc57616f60cec /src/libgsmd | |
parent | 1cfa84da8e1defe1a9d138c82afa80374eace8ab (diff) |
gsmd passthrough mode now working
git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@109 99fdad57-331a-0410-800a-d7fa5415bdb3
Diffstat (limited to 'src/libgsmd')
-rw-r--r-- | src/libgsmd/Makefile.am | 2 | ||||
-rw-r--r-- | src/libgsmd/libgsmd.c | 12 | ||||
-rw-r--r-- | src/libgsmd/libgsmd_passthrough.c | 7 |
3 files changed, 13 insertions, 8 deletions
diff --git a/src/libgsmd/Makefile.am b/src/libgsmd/Makefile.am index 2e8988f..a718116 100644 --- a/src/libgsmd/Makefile.am +++ b/src/libgsmd/Makefile.am @@ -5,5 +5,5 @@ 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_la_SOURCES = libgsmd.c libgsmd_input.c libgsmd_voicecall.c libgsmd_passthrough.c diff --git a/src/libgsmd/libgsmd.c b/src/libgsmd/libgsmd.c index 104a8b3..b916898 100644 --- a/src/libgsmd/libgsmd.c +++ b/src/libgsmd/libgsmd.c @@ -68,6 +68,8 @@ static int lgsm_open_backend(struct lgsm_handle *lh, const char *device) int lgsm_handle_packet(struct lgsm_handle *lh, char *buf, int len) { struct gsmd_msg_hdr *gmh = (struct gsmd_msg_hdr *)buf; + lgsm_msg_handler *handler; + if (len < sizeof(*gmh)) return -EINVAL; @@ -77,7 +79,12 @@ int lgsm_handle_packet(struct lgsm_handle *lh, char *buf, int len) if (gmh->msg_type >= __NUM_GSMD_MSGS) return -EINVAL; - return lh->handler[gmh->msg_type](lh, gmh); + handler = lh->handler[gmh->msg_type]; + + if (handler) + handler(lh, gmh); + else + fprintf(stderr, "unable to handle packet type=%u\n", gmh->msg_type); } /* blocking read and processing of packets until packet matching 'id' is found */ @@ -124,9 +131,6 @@ struct lgsm_handle *lgsm_init(const char *device) return NULL; } - /* send some initial commands, such as ATV1 (verbose response) - * and +CRC=1 (which we currently require!) */ - return lh; } diff --git a/src/libgsmd/libgsmd_passthrough.c b/src/libgsmd/libgsmd_passthrough.c index 45ce066..66f4a82 100644 --- a/src/libgsmd/libgsmd_passthrough.c +++ b/src/libgsmd/libgsmd_passthrough.c @@ -5,6 +5,7 @@ #include <errno.h> #include <sys/types.h> +#include <sys/socket.h> #include <gsmd/usock.h> #include <libgsmd/libgsmd.h> @@ -16,7 +17,7 @@ static u_int16_t next_msg_id; static int lgsm_send(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh) { gmh->id = next_msg_id++; - return send(lh->fd, (char *) gmh, sizeof(*gmh) + gmh->len); + return send(lh->fd, (char *) gmh, sizeof(*gmh) + gmh->len, 0); } #define PT_BUF_SIZE 1024 @@ -37,8 +38,8 @@ int lgsm_passthrough(struct lgsm_handle *lh, const char *tx, char *rx, unsigned gmh->version = GSMD_PROTO_VERSION; gmh->msg_type = GSMD_MSG_PASSTHROUGH; - gmh->msg_subtype = GSMD_PASSTHROUGH_REQUEST; - gmh->len = len; + gmh->msg_subtype = GSMD_PASSTHROUGH_REQ; + gmh->len = len+1; strcpy(tx_buf, tx); rc = lgsm_send(lh, gmh); |