summaryrefslogtreecommitdiff
path: root/src/libgsmd/libgsmd_passthrough.c
diff options
context:
space:
mode:
authorlaforge <laforge@99fdad57-331a-0410-800a-d7fa5415bdb3>2006-10-23 20:28:37 +0000
committerlaforge <laforge@99fdad57-331a-0410-800a-d7fa5415bdb3>2006-10-23 20:28:37 +0000
commitcbffc8d64707828b045b679e8db0269ae362ffcf (patch)
tree9ba71c11b92600548581af9d582a2c1feb18473f /src/libgsmd/libgsmd_passthrough.c
parent7fe163099476937a14dd7a0714de542f7f94f665 (diff)
more gsmd/libgsm implementation
git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@114 99fdad57-331a-0410-800a-d7fa5415bdb3
Diffstat (limited to 'src/libgsmd/libgsmd_passthrough.c')
-rw-r--r--src/libgsmd/libgsmd_passthrough.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/libgsmd/libgsmd_passthrough.c b/src/libgsmd/libgsmd_passthrough.c
index 66f4a82..5362e4e 100644
--- a/src/libgsmd/libgsmd_passthrough.c
+++ b/src/libgsmd/libgsmd_passthrough.c
@@ -12,26 +12,15 @@
#include "lgsm_internals.h"
-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, 0);
-}
-
#define PT_BUF_SIZE 1024
static char passthrough_buf[sizeof(struct gsmd_msg_hdr)+PT_BUF_SIZE];
static char passthrough_rbuf[sizeof(struct gsmd_msg_hdr)+PT_BUF_SIZE];
-int lgsm_passthrough(struct lgsm_handle *lh, const char *tx, char *rx, unsigned int *rx_len)
+int lgsm_passthrough_send(struct lgsm_handle *lh, const char *tx)
{
struct gsmd_msg_hdr *gmh = (struct gsmd_msg_hdr *)passthrough_buf;
- struct gsmd_msg_hdr *rgmh = (struct gsmd_msg_hdr *)passthrough_rbuf;
char *tx_buf = (char *)gmh + sizeof(*gmh);
- char *rx_buf = (char *)rgmh + sizeof(*rgmh);
int len = strlen(tx);
- int rc;
if (len > PT_BUF_SIZE)
return -EINVAL;
@@ -42,13 +31,27 @@ int lgsm_passthrough(struct lgsm_handle *lh, const char *tx, char *rx, unsigned
gmh->len = len+1;
strcpy(tx_buf, tx);
- rc = lgsm_send(lh, gmh);
- if (rc < len+sizeof(*gmh))
+ if (lgsm_send(lh, gmh) < len+sizeof(*gmh))
+ return -EIO;
+
+ return gmh->id;
+}
+
+int lgsm_passthrough(struct lgsm_handle *lh, const char *tx, char *rx, unsigned int *rx_len)
+{
+ struct gsmd_msg_hdr *rgmh = (struct gsmd_msg_hdr *)passthrough_rbuf;
+ char *rx_buf = (char *)rgmh + sizeof(*rgmh);
+ int rc;
+
+ rc = lgsm_passthrough_send(lh, tx);
+ if (rc < 0)
return rc;
- /* since we synchronously want to wait for a response, we need to _internally_ loop over
- * incoming packets and call the callbacks for intermediate messages (if applicable) */
- rc = lgsm_blocking_wait_packet(lh, gmh->id, passthrough_rbuf, sizeof(passthrough_rbuf));
+ /* since we synchronously want to wait for a response, we need to
+ * _internally_ loop over incoming packets and call the callbacks for
+ * intermediate messages (if applicable) */
+ rc = lgsm_blocking_wait_packet(lh, rc, passthrough_rbuf,
+ sizeof(passthrough_rbuf));
if (rc <= 0)
return rc;
personal git repositories of Harald Welte. Your mileage may vary