From 3177580cc17fa5752b5939e5647064172ec7d0b3 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Fri, 26 Mar 2010 07:20:59 +0100 Subject: [PATCH] nat: Move BSC msg sending to a new method. Move all writes into one place so we can switch to the write queue more easily in the future. --- openbsc/src/nat/bsc_nat.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c index 0972208fa..4694788e4 100644 --- a/openbsc/src/nat/bsc_nat.c +++ b/openbsc/src/nat/bsc_nat.c @@ -269,6 +269,11 @@ static void initialize_msc_if_needed() /* do we need to send a GSM 08.08 message here? */ } +static int bsc_write(struct bsc_connection *bsc, u_int8_t *data, unsigned int length) +{ + return write(bsc->write_queue.bfd.fd, data, length); +} + static int forward_sccp_to_bts(struct msgb *msg) { struct bsc_connection *bsc = NULL; @@ -314,7 +319,7 @@ static int forward_sccp_to_bts(struct msgb *msg) return -1; } - return write(bsc->write_queue.bfd.fd, msg->data, msg->len); + return bsc_write(bsc, msg->data, msg->len); send_to_all: /* @@ -348,7 +353,7 @@ send_to_all: if (!bsc->authenticated || _lac != bsc->lac) continue; - rc = write(bsc->write_queue.bfd.fd, msg->data, msg->len); + rc = bsc_write(bsc, msg->data, msg->len); if (rc < msg->len) LOGP(DNAT, LOGL_ERROR, "Failed to write message to BTS: %d\n", rc); @@ -362,7 +367,7 @@ send_to_all: if (!bsc->authenticated) continue; - rc = write(bsc->write_queue.bfd.fd, msg->data, msg->len); + rc = bsc_write(bsc, msg->data, msg->len); /* try the next one */ if (rc < msg->len)