summaryrefslogtreecommitdiffstats
path: root/openbsc/src/libctrl/control_if.c
diff options
context:
space:
mode:
Diffstat (limited to 'openbsc/src/libctrl/control_if.c')
-rw-r--r--openbsc/src/libctrl/control_if.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/openbsc/src/libctrl/control_if.c b/openbsc/src/libctrl/control_if.c
index 91c69e094..d1a3c1c76 100644
--- a/openbsc/src/libctrl/control_if.c
+++ b/openbsc/src/libctrl/control_if.c
@@ -40,11 +40,10 @@
#include <openbsc/control_cmd.h>
#include <openbsc/debug.h>
-#include <openbsc/e1_input.h>
#include <openbsc/gsm_data.h>
#include <openbsc/ipaccess.h>
#include <openbsc/socket.h>
-#include <openbsc/subchan_demux.h>
+#include <osmocom/abis/subchan_demux.h>
#include <openbsc/abis_rsl.h>
#include <openbsc/abis_nm.h>
@@ -60,6 +59,9 @@
#include <osmocom/vty/command.h>
#include <osmocom/vty/vector.h>
+#include <osmocom/abis/e1_input.h>
+#include <osmocom/abis/ipa.h>
+
struct ctrl_handle {
struct osmo_fd listen_fd;
struct gsm_network *gsmnet;
@@ -74,7 +76,7 @@ int ctrl_cmd_send(struct osmo_wqueue *queue, struct ctrl_cmd *cmd)
msg = ctrl_cmd_make(cmd);
if (!msg) {
- LOGP(DINP, LOGL_ERROR, "Could not generate msg\n");
+ LOGP(DLINP, LOGL_ERROR, "Could not generate msg\n");
return -1;
}
@@ -83,7 +85,7 @@ int ctrl_cmd_send(struct osmo_wqueue *queue, struct ctrl_cmd *cmd)
ret = osmo_wqueue_enqueue(queue, msg);
if (ret != 0) {
- LOGP(DINP, LOGL_ERROR, "Failed to enqueue the command.\n");
+ LOGP(DLINP, LOGL_ERROR, "Failed to enqueue the command.\n");
msgb_free(msg);
}
return ret;
@@ -201,7 +203,7 @@ static void control_close_conn(struct ctrl_connection *ccon)
static int handle_control_read(struct osmo_fd * bfd)
{
- int ret = -1, error;
+ int ret = -1;
struct osmo_wqueue *queue;
struct ctrl_connection *ccon;
struct ipaccess_head *iph;
@@ -213,31 +215,30 @@ static int handle_control_read(struct osmo_fd * bfd)
queue = container_of(bfd, struct osmo_wqueue, bfd);
ccon = container_of(queue, struct ctrl_connection, write_queue);
- msg = ipaccess_read_msg(bfd, &error);
-
- if (!msg) {
- if (error == 0)
- LOGP(DINP, LOGL_INFO, "The control connection was closed\n");
+ ret = ipa_msg_recv(bfd->fd, &msg);
+ if (ret <= 0) {
+ if (ret == 0)
+ LOGP(DLINP, LOGL_INFO, "The control connection was closed\n");
else
- LOGP(DINP, LOGL_ERROR, "Failed to parse ip access message: %d\n", error);
+ LOGP(DLINP, LOGL_ERROR, "Failed to parse ip access message: %d\n", ret);
goto err;
}
if (msg->len < sizeof(*iph) + sizeof(*iph_ext)) {
- LOGP(DINP, LOGL_ERROR, "The message is too short.\n");
+ LOGP(DLINP, LOGL_ERROR, "The message is too short.\n");
goto err;
}
iph = (struct ipaccess_head *) msg->data;
if (iph->proto != IPAC_PROTO_OSMO) {
- LOGP(DINP, LOGL_ERROR, "Protocol mismatch. We got 0x%x\n", iph->proto);
+ LOGP(DLINP, LOGL_ERROR, "Protocol mismatch. We got 0x%x\n", iph->proto);
goto err;
}
iph_ext = (struct ipaccess_head_ext *) iph->data;
if (iph_ext->proto != IPAC_PROTO_EXT_CTRL) {
- LOGP(DINP, LOGL_ERROR, "Extended protocol mismatch. We got 0x%x\n", iph_ext->proto);
+ LOGP(DLINP, LOGL_ERROR, "Extended protocol mismatch. We got 0x%x\n", iph_ext->proto);
goto err;
}
@@ -255,7 +256,7 @@ static int handle_control_read(struct osmo_fd * bfd)
cmd = talloc_zero(ccon, struct ctrl_cmd);
if (!cmd)
goto err;
- LOGP(DINP, LOGL_ERROR, "Command parser error.\n");
+ LOGP(DLINP, LOGL_ERROR, "Command parser error.\n");
cmd->type = CTRL_TYPE_ERROR;
cmd->id = "err";
cmd->reply = "Command parser error.";
@@ -278,7 +279,7 @@ static int control_write_cb(struct osmo_fd *bfd, struct msgb *msg)
rc = write(bfd->fd, msg->data, msg->len);
if (rc != msg->len)
- LOGP(DINP, LOGL_ERROR, "Failed to write message to the control connection.\n");
+ LOGP(DLINP, LOGL_ERROR, "Failed to write message to the control connection.\n");
return rc;
}
@@ -312,7 +313,7 @@ static int listen_fd_cb(struct osmo_fd *listen_bfd, unsigned int what)
perror("accept");
return fd;
}
- LOGP(DINP, LOGL_INFO, "accept()ed new control connection from %s\n",
+ LOGP(DLINP, LOGL_INFO, "accept()ed new control connection from %s\n",
inet_ntoa(sa.sin_addr));
on = 1;
@@ -324,7 +325,7 @@ static int listen_fd_cb(struct osmo_fd *listen_bfd, unsigned int what)
}
ccon = ctrl_connection_alloc(listen_bfd->data);
if (!ccon) {
- LOGP(DINP, LOGL_ERROR, "Failed to allocate.\n");
+ LOGP(DLINP, LOGL_ERROR, "Failed to allocate.\n");
close(fd);
return -1;
}
@@ -337,7 +338,7 @@ static int listen_fd_cb(struct osmo_fd *listen_bfd, unsigned int what)
ret = osmo_fd_register(&ccon->write_queue.bfd);
if (ret < 0) {
- LOGP(DINP, LOGL_ERROR, "Could not register FD.\n");
+ LOGP(DLINP, LOGL_ERROR, "Could not register FD.\n");
close(ccon->write_queue.bfd.fd);
talloc_free(ccon);
}