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 #include +#include 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; +} +