aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bsc_nat
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-02-13 17:37:39 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2018-02-14 12:15:40 +0100
commit978f58cd2e41212d5e1f1543e9f05137831304e1 (patch)
tree5519a7dc74d5b6edad2039d41b5dba6b9b7476d7 /src/osmo-bsc_nat
parent7997bf4bed15fa8c6807820b1a9b379a2ae0c61e (diff)
libcommon: eliminate socket.c
Replace calls to make_sock() with osmo_sock_init_ofd(). Shame on me for not testing every single one in practice, I hope for peer review to confirm that this should be correct... Read closely please! The IPPROTO_GRE define seems to be unused (at least in osmo-bsc.git), drop it completely. Change-Id: Ia6e4e0e1eed3328fa25b3b90be376d532ad0e56b
Diffstat (limited to 'src/osmo-bsc_nat')
-rw-r--r--src/osmo-bsc_nat/bsc_nat.c14
-rw-r--r--src/osmo-bsc_nat/bsc_ussd.c14
2 files changed, 13 insertions, 15 deletions
diff --git a/src/osmo-bsc_nat/bsc_nat.c b/src/osmo-bsc_nat/bsc_nat.c
index c1c791392..2f8d32563 100644
--- a/src/osmo-bsc_nat/bsc_nat.c
+++ b/src/osmo-bsc_nat/bsc_nat.c
@@ -46,7 +46,6 @@
#include <osmocom/bsc/bsc_msg_filter.h>
#include <osmocom/bsc/ipaccess.h>
#include <osmocom/bsc/abis_nm.h>
-#include <osmocom/bsc/socket.h>
#include <osmocom/bsc/vty.h>
#include <osmocom/ctrl/control_cmd.h>
@@ -59,6 +58,7 @@
#include <osmocom/core/application.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/stats.h>
+#include <osmocom/core/socket.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/gsm/gsm0808.h>
@@ -80,7 +80,7 @@
#define SCCP_CLOSE_TIME_TIMEOUT 19
static const char *config_file = "bsc-nat.cfg";
-static struct in_addr local_addr;
+static const char *local_addr;
static struct osmo_fd bsc_listen;
static const char *msc_ip = NULL;
static struct osmo_timer_list sccp_close;
@@ -1507,7 +1507,7 @@ static void handle_options(int argc, char **argv)
msc_ip = optarg;
break;
case 'l':
- inet_aton(optarg, &local_addr);
+ local_addr = optarg;
break;
default:
/* ignore */
@@ -1693,7 +1693,7 @@ int main(int argc, char **argv)
/* parse options */
- local_addr.s_addr = INADDR_ANY;
+ local_addr = NULL;
handle_options(argc, argv);
nat->include_base = dirname(talloc_strdup(tall_bsc_ctx, config_file));
@@ -1757,8 +1757,10 @@ int main(int argc, char **argv)
bsc_msc_connect(nat->msc_con);
/* wait for the BSC */
- rc = make_sock(&bsc_listen, IPPROTO_TCP, ntohl(local_addr.s_addr),
- 5000, 0, ipaccess_listen_bsc_cb, nat);
+ bsc_listen.cb = ipaccess_listen_bsc_cb;
+ bsc_listen.data = nat;
+ rc = osmo_sock_init_ofd(&bsc_listen, AF_INET, SOCK_STREAM, IPPROTO_TCP,
+ local_addr, 5000, OSMO_SOCK_F_BIND);
if (rc != 0) {
fprintf(stderr, "Failed to listen for BSC.\n");
exit(1);
diff --git a/src/osmo-bsc_nat/bsc_ussd.c b/src/osmo-bsc_nat/bsc_ussd.c
index 20df8d1ed..985a558dc 100644
--- a/src/osmo-bsc_nat/bsc_ussd.c
+++ b/src/osmo-bsc_nat/bsc_ussd.c
@@ -20,11 +20,12 @@
*
*/
+#include <osmocom/core/socket.h>
+
#include <osmocom/bsc/bsc_nat.h>
#include <osmocom/bsc/bsc_nat_sccp.h>
#include <osmocom/bsc/bsc_msg_filter.h>
#include <osmocom/bsc/ipaccess.h>
-#include <osmocom/bsc/socket.h>
#include <osmocom/bsc/debug.h>
#include <osmocom/gsm/protocol/gsm_08_08.h>
@@ -282,15 +283,10 @@ static int ussd_listen_cb(struct osmo_fd *bfd, unsigned int what)
int bsc_ussd_init(struct bsc_nat *nat)
{
- struct in_addr addr;
-
- addr.s_addr = INADDR_ANY;
- if (nat->ussd_local)
- inet_aton(nat->ussd_local, &addr);
-
+ nat->ussd_listen.cb = ussd_listen_cb;
nat->ussd_listen.data = nat;
- return make_sock(&nat->ussd_listen, IPPROTO_TCP,
- ntohl(addr.s_addr), 5001, 0, ussd_listen_cb, nat);
+ return osmo_sock_init_ofd(&nat->ussd_listen, AF_INET, SOCK_STREAM, IPPROTO_TCP,
+ nat->ussd_local, 5001, OSMO_SOCK_F_BIND);
}
static int forward_ussd_simple(struct nat_sccp_connection *con, struct msgb *input)