From 561a8d7fa4a003862b2640bd3458c0188ae2eab8 Mon Sep 17 00:00:00 2001 From: laforge Date: Mon, 9 Oct 2006 21:00:45 +0000 Subject: intermediate state (this shouldn't be a commit) just to move from one machine to the other git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@70 99fdad57-331a-0410-800a-d7fa5415bdb3 --- src/libgsmd/libgsmd.c | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) (limited to 'src/libgsmd/libgsmd.c') diff --git a/src/libgsmd/libgsmd.c b/src/libgsmd/libgsmd.c index e514617..7eb2701 100644 --- a/src/libgsmd/libgsmd.c +++ b/src/libgsmd/libgsmd.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -12,6 +13,29 @@ #include "lgsm_internals.h" +static int lgsm_get_packet(struct lgsm_handle *lh) +{ + static char buf[GSMD_MSGSIZE_MAX]; + struct gsmd_msg_hdr *hdr = (struct gsmd_msg_hdr *) buf; + int rc = read(lh->fd, buf, sizeof(buf)); + if (rc <= 0) + return rc; + + if (hdr->version != GSMD_PROTO_VERSION) + return -EINVAL; + + switch (hdr->msg_type) { + case GSMD_MSG_PASSTHROUGH: + + break; + default: + return -EINVAL; + } + + return 0; +} + + static int lgsm_open_backend(struct lgsm_handle *lh, const char *device) { int rc; @@ -33,16 +57,17 @@ static int lgsm_open_backend(struct lgsm_handle *lh, const char *device) lh->fd = -1; return rc; } - } else { - /* use direct access to device node ([virtual] tty device) */ - lh->fd = open(device, O_RDWR); - if (lh->fd < 0) - return lh->fd; - } - + } else + return -EINVAL; + return 0; } +int lgsm_fd(struct lgsm_handle *lh) +{ + return lh->fd; +} + struct lgsm_handle *lgsm_init(const char *device) { struct lgsm_handle *lh = malloc(sizeof(*lh)); -- cgit v1.2.3