diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-10-13 20:37:13 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-10-13 23:56:01 +0200 |
commit | 69cfa179ef9a1ae787b4e8134cfaef670cd31095 (patch) | |
tree | 9547c594ff0a447eb91edf3e184e9830a31e909d | |
parent | 4d44fc56e782dd0598ddfb8fc963c46c3b1b5a20 (diff) |
nat: Make the write_queue write callback a public function
-rw-r--r-- | openbsc/include/openbsc/bsc_nat.h | 1 | ||||
-rw-r--r-- | openbsc/src/nat/bsc_nat.c | 13 | ||||
-rw-r--r-- | openbsc/src/nat/bsc_nat_utils.c | 13 |
3 files changed, 15 insertions, 12 deletions
diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h index 682447a4b..280fa50f0 100644 --- a/openbsc/include/openbsc/bsc_nat.h +++ b/openbsc/include/openbsc/bsc_nat.h @@ -298,6 +298,7 @@ uint32_t bsc_mgcp_extract_ci(const char *resp); int bsc_write(struct bsc_connection *bsc, struct msgb *msg, int id); int bsc_do_write(struct write_queue *queue, struct msgb *msg, int id); +int bsc_write_cb(struct bsc_fd *bfd, struct msgb *msg); /* IMSI allow/deny handling */ void bsc_parse_reg(void *ctx, regex_t *reg, char **imsi, int argc, const char **argv); diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c index ded05c6c8..fc8b0a952 100644 --- a/openbsc/src/nat/bsc_nat.c +++ b/openbsc/src/nat/bsc_nat.c @@ -984,17 +984,6 @@ static int ipaccess_bsc_read_cb(struct bsc_fd *bfd) return 0; } -static int ipaccess_bsc_write_cb(struct bsc_fd *bfd, struct msgb *msg) -{ - int rc; - - rc = write(bfd->fd, msg->data, msg->len); - if (rc != msg->len) - LOGP(DNAT, LOGL_ERROR, "Failed to write message to the BSC.\n"); - - return rc; -} - static int ipaccess_listen_bsc_cb(struct bsc_fd *bfd, unsigned int what) { struct bsc_connection *bsc; @@ -1049,7 +1038,7 @@ static int ipaccess_listen_bsc_cb(struct bsc_fd *bfd, unsigned int what) bsc->write_queue.bfd.data = bsc; bsc->write_queue.bfd.fd = fd; bsc->write_queue.read_cb = ipaccess_bsc_read_cb; - bsc->write_queue.write_cb = ipaccess_bsc_write_cb; + bsc->write_queue.write_cb = bsc_write_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"); diff --git a/openbsc/src/nat/bsc_nat_utils.c b/openbsc/src/nat/bsc_nat_utils.c index 9c155ccaf..a458afdaa 100644 --- a/openbsc/src/nat/bsc_nat_utils.c +++ b/openbsc/src/nat/bsc_nat_utils.c @@ -40,6 +40,7 @@ #include <netinet/in.h> #include <arpa/inet.h> +#include <unistd.h> static const struct rate_ctr_desc bsc_cfg_ctr_description[] = { [BCFG_CTR_SCCP_CONN] = { "sccp.conn", "SCCP Connections "}, @@ -674,3 +675,15 @@ int bsc_conn_type_to_ctr(struct sccp_connections *conn) { return con_to_ctr[conn->con_type]; } + +int bsc_write_cb(struct bsc_fd *bfd, struct msgb *msg) +{ + int rc; + + rc = write(bfd->fd, msg->data, msg->len); + if (rc != msg->len) + LOGP(DNAT, LOGL_ERROR, "Failed to write message to the BSC.\n"); + + return rc; +} + |