aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-03-26 07:10:22 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-03-26 07:10:22 +0100
commitcbe77e165785977a664e0ee8c1c5e229f8bbe402 (patch)
tree34d936686e26ab8d30f7f76a37a53a6e0f00c55c /openbsc
parent3cedc4738fa862352e34db9863991a6efb4ad01c (diff)
nat: Start using a write_queue for the BSC connection
We are still writing to the BSC directly and don't make real use of this feature right now but we will need to do it.
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/include/openbsc/bsc_nat.h3
-rw-r--r--openbsc/src/nat/bsc_nat.c26
-rw-r--r--openbsc/src/nat/bsc_nat_vty.c2
3 files changed, 16 insertions, 15 deletions
diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h
index d42e489e7..5ac60df87 100644
--- a/openbsc/include/openbsc/bsc_nat.h
+++ b/openbsc/include/openbsc/bsc_nat.h
@@ -28,6 +28,7 @@
#include <osmocore/select.h>
#include <osmocore/msgb.h>
#include <osmocore/timer.h>
+#include <osmocore/write_queue.h>
#define DIR_BSC 1
#define DIR_MSC 2
@@ -77,7 +78,7 @@ struct bsc_connection {
int authenticated;
/* the fd we use to communicate */
- struct bsc_fd bsc_fd;
+ struct write_queue write_queue;
/* the LAC assigned to this connection */
unsigned int lac;
diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c
index 42dd67adb..0972208fa 100644
--- a/openbsc/src/nat/bsc_nat.c
+++ b/openbsc/src/nat/bsc_nat.c
@@ -43,7 +43,6 @@
#include <openbsc/abis_nm.h>
#include <openbsc/telnet_interface.h>
-#include <osmocore/write_queue.h>
#include <osmocore/talloc.h>
#include <vty/vty.h>
@@ -315,7 +314,7 @@ static int forward_sccp_to_bts(struct msgb *msg)
return -1;
}
- return write(bsc->bsc_fd.fd, msg->data, msg->len);
+ return write(bsc->write_queue.bfd.fd, msg->data, msg->len);
send_to_all:
/*
@@ -349,7 +348,7 @@ send_to_all:
if (!bsc->authenticated || _lac != bsc->lac)
continue;
- rc = write(bsc->bsc_fd.fd, msg->data, msg->len);
+ rc = write(bsc->write_queue.bfd.fd, msg->data, msg->len);
if (rc < msg->len)
LOGP(DNAT, LOGL_ERROR,
"Failed to write message to BTS: %d\n", rc);
@@ -363,7 +362,7 @@ send_to_all:
if (!bsc->authenticated)
continue;
- rc = write(bsc->bsc_fd.fd, msg->data, msg->len);
+ rc = write(bsc->write_queue.bfd.fd, msg->data, msg->len);
/* try the next one */
if (rc < msg->len)
@@ -434,8 +433,8 @@ static int ipaccess_msc_write_cb(struct bsc_fd *bfd, struct msgb *msg)
static void remove_bsc_connection(struct bsc_connection *connection)
{
struct sccp_connections *sccp_patch, *tmp;
- bsc_unregister_fd(&connection->bsc_fd);
- close(connection->bsc_fd.fd);
+ bsc_unregister_fd(&connection->write_queue.bfd);
+ close(connection->write_queue.bfd.fd);
llist_del(&connection->list_entry);
/* stop the timeout timer */
@@ -564,7 +563,7 @@ exit2:
return -1;
}
-static int ipaccess_bsc_cb(struct bsc_fd *bfd, unsigned int what)
+static int ipaccess_bsc_read_cb(struct bsc_fd *bfd)
{
int error;
struct msgb *msg = ipaccess_read_msg(bfd, &error);
@@ -620,11 +619,12 @@ static int ipaccess_listen_bsc_cb(struct bsc_fd *bfd, unsigned int what)
}
bsc->nat = nat;
- bsc->bsc_fd.data = bsc;
- bsc->bsc_fd.fd = ret;
- bsc->bsc_fd.cb = ipaccess_bsc_cb;
- bsc->bsc_fd.when = BSC_FD_READ;
- if (bsc_register_fd(&bsc->bsc_fd) < 0) {
+ write_queue_init(&bsc->write_queue, 100);
+ bsc->write_queue.bfd.data = bsc;
+ bsc->write_queue.bfd.fd = ret;
+ bsc->write_queue.read_cb = ipaccess_bsc_read_cb;
+ bsc->write_queue.bfd.when = BSC_FD_READ;
+ if (bsc_register_fd(&bsc->write_queue.bfd) < 0) {
LOGP(DNAT, LOGL_ERROR, "Failed to register BSC fd.\n");
close(ret);
talloc_free(bsc);
@@ -633,7 +633,7 @@ static int ipaccess_listen_bsc_cb(struct bsc_fd *bfd, unsigned int what)
LOGP(DNAT, LOGL_INFO, "Registered new BSC\n");
llist_add(&bsc->list_entry, &nat->bsc_connections);
- ipaccess_send_id_ack(bsc->bsc_fd.fd);
+ ipaccess_send_id_ack(bsc->write_queue.bfd.fd);
ipaccess_send_id_req(ret);
/*
diff --git a/openbsc/src/nat/bsc_nat_vty.c b/openbsc/src/nat/bsc_nat_vty.c
index 5430670c9..695903775 100644
--- a/openbsc/src/nat/bsc_nat_vty.c
+++ b/openbsc/src/nat/bsc_nat_vty.c
@@ -89,7 +89,7 @@ DEFUN(show_bsc, show_bsc_cmd, "show connections bsc",
struct bsc_connection *con;
llist_for_each_entry(con, &_nat->bsc_connections, list_entry) {
vty_out(vty, "BSC lac: %d auth: %d fd: %d%s",
- con->lac, con->authenticated, con->bsc_fd.fd, VTY_NEWLINE);
+ con->lac, con->authenticated, con->write_queue.bfd.fd, VTY_NEWLINE);
}
return CMD_SUCCESS;