summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Neira Ayuso2011-06-21 14:15:46 +0200
committerPablo Neira Ayuso2011-06-21 14:15:46 +0200
commit7a249408056c5375030cd0cf171caa17a6715cb8 (patch)
treefd39dd0eae1dca201d8602ac3035eefb83c44158
parenthsl: add support for BTS-mode (diff)
downloadlibosmo-abis-7a249408056c5375030cd0cf171caa17a6715cb8.tar.gz
libosmo-abis-7a249408056c5375030cd0cf171caa17a6715cb8.tar.xz
libosmo-abis-7a249408056c5375030cd0cf171caa17a6715cb8.zip
input: use generic ipa_msg_recv() instead of ipaccess_read_msg()
We use the new generic function to receive messages, instead of ipaccess_read_msg. It's a mere renaming, but it's the first step before the rework that will happen soon to avoid calling read() twice.
-rw-r--r--src/input/hsl.c4
-rw-r--r--src/input/ipaccess.c59
2 files changed, 4 insertions, 59 deletions
diff --git a/src/input/hsl.c b/src/input/hsl.c
index e6388c8..cb1aa51 100644
--- a/src/input/hsl.c
+++ b/src/input/hsl.c
@@ -84,8 +84,8 @@ static int handle_ts1_read(struct osmo_fd *bfd)
struct msgb *msg;
int ret = 0, error;
- msg = ipaccess_read_msg(bfd, &error);
- if (!msg) {
+ error = ipa_msg_recv(bfd->fd, &msg);
+ if (error <= 0) {
if (e1i_ts->line->ops.error)
e1i_ts->line->ops.error(NULL, error);
if (error == 0) {
diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c
index 38e942f..e5c00a1 100644
--- a/src/input/ipaccess.c
+++ b/src/input/ipaccess.c
@@ -117,61 +117,6 @@ int ipaccess_send_id_req(int fd)
return ipaccess_send(fd, ipa_id_req_msg, sizeof(ipa_id_req_msg));
}
-/*
- * read one ipa message from the socket
- * return NULL in case of error
- */
-struct msgb *ipaccess_read_msg(struct osmo_fd *bfd, int *error)
-{
- struct msgb *msg = msgb_alloc(TS1_ALLOC_SIZE, "Abis/IP");
- struct ipaccess_head *hh;
- int len, ret = 0;
-
- if (!msg) {
- *error = -ENOMEM;
- return NULL;
- }
-
- /* first read our 3-byte header */
- hh = (struct ipaccess_head *) msg->data;
- ret = recv(bfd->fd, msg->data, sizeof(*hh), 0);
- if (ret == 0) {
- msgb_free(msg);
- *error = ret;
- return NULL;
- } else if (ret != sizeof(*hh)) {
- if (errno != EAGAIN)
- LOGP(DINP, LOGL_ERROR, "recv error %d %s\n", ret, strerror(errno));
- msgb_free(msg);
- *error = ret;
- return NULL;
- }
-
- msgb_put(msg, ret);
-
- /* then read te length as specified in header */
- msg->l2h = msg->data + sizeof(*hh);
- len = ntohs(hh->len);
-
- if (len < 0 || TS1_ALLOC_SIZE < len + sizeof(*hh)) {
- LOGP(DINP, LOGL_ERROR, "Can not read this packet. %d avail\n", len);
- msgb_free(msg);
- *error = -EIO;
- return NULL;
- }
-
- ret = recv(bfd->fd, msg->l2h, len, 0);
- if (ret < len) {
- LOGP(DINP, LOGL_ERROR, "short read! Got %d from %d\n", ret, len);
- msgb_free(msg);
- *error = -EIO;
- return NULL;
- }
- msgb_put(msg, ret);
-
- return msg;
-}
-
/* base handling of the ip.access protocol */
int ipaccess_rcvmsg_base(struct msgb *msg,
struct osmo_fd *bfd)
@@ -227,8 +172,8 @@ static int handle_ts1_read(struct osmo_fd *bfd)
struct msgb *msg;
int ret = 0, error;
- msg = ipaccess_read_msg(bfd, &error);
- if (!msg) {
+ error = ipa_msg_recv(bfd->fd, &msg);
+ if (error <= 0) {
if (e1i_ts->line->ops.error)
e1i_ts->line->ops.error(NULL, error);
if (error == 0) {