diff options
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/socket/interface.c | 26 | ||||
-rw-r--r-- | source4/lib/socket/testsuite.c | 11 |
2 files changed, 19 insertions, 18 deletions
diff --git a/source4/lib/socket/interface.c b/source4/lib/socket/interface.c index a3f6ccc570..79c5673022 100644 --- a/source4/lib/socket/interface.c +++ b/source4/lib/socket/interface.c @@ -235,12 +235,12 @@ void unload_interfaces(void) /** how many interfaces do we have **/ -int iface_count(void) +int iface_count(struct loadparm_context *lp_ctx) { int ret = 0; struct interface *i; - load_interfaces(lp_interfaces(global_loadparm)); + load_interfaces(lp_interfaces(lp_ctx)); for (i=local_interfaces;i;i=i->next) ret++; @@ -250,11 +250,11 @@ int iface_count(void) /** return IP of the Nth interface **/ -const char *iface_n_ip(int n) +const char *iface_n_ip(struct loadparm_context *lp_ctx, int n) { struct interface *i; - load_interfaces(lp_interfaces(global_loadparm)); + load_interfaces(lp_interfaces(lp_ctx)); for (i=local_interfaces;i && n;i=i->next) n--; @@ -268,11 +268,11 @@ const char *iface_n_ip(int n) /** return bcast of the Nth interface **/ -const char *iface_n_bcast(int n) +const char *iface_n_bcast(struct loadparm_context *lp_ctx, int n) { struct interface *i; - load_interfaces(lp_interfaces(global_loadparm)); + load_interfaces(lp_interfaces(lp_ctx)); for (i=local_interfaces;i && n;i=i->next) n--; @@ -286,11 +286,11 @@ const char *iface_n_bcast(int n) /** return netmask of the Nth interface **/ -const char *iface_n_netmask(int n) +const char *iface_n_netmask(struct loadparm_context *lp_ctx, int n) { struct interface *i; - load_interfaces(lp_interfaces(global_loadparm)); + load_interfaces(lp_interfaces(lp_ctx)); for (i=local_interfaces;i && n;i=i->next) n--; @@ -305,29 +305,29 @@ const char *iface_n_netmask(int n) return the local IP address that best matches a destination IP, or our first interface if none match */ -const char *iface_best_ip(const char *dest) +const char *iface_best_ip(struct loadparm_context *lp_ctx, const char *dest) { struct interface *iface; struct in_addr ip; - load_interfaces(lp_interfaces(global_loadparm)); + load_interfaces(lp_interfaces(lp_ctx)); ip.s_addr = interpret_addr(dest); iface = iface_find(ip, true); if (iface) { return iface->ip_s; } - return iface_n_ip(0); + return iface_n_ip(lp_ctx, 0); } /** return true if an IP is one one of our local networks */ -bool iface_is_local(const char *dest) +bool iface_is_local(struct loadparm_context *lp_ctx, const char *dest) { struct in_addr ip; - load_interfaces(lp_interfaces(global_loadparm)); + load_interfaces(lp_interfaces(lp_ctx)); ip.s_addr = interpret_addr(dest); if (iface_find(ip, true)) { diff --git a/source4/lib/socket/testsuite.c b/source4/lib/socket/testsuite.c index 928469dd82..84132c62b8 100644 --- a/source4/lib/socket/testsuite.c +++ b/source4/lib/socket/testsuite.c @@ -48,7 +48,7 @@ static bool test_udp(struct torture_context *tctx) talloc_steal(mem_ctx, sock2); localhost = socket_address_from_strings(sock1, sock1->backend_name, - iface_best_ip("127.0.0.1"), 0); + iface_best_ip(tctx->lp_ctx, "127.0.0.1"), 0); torture_assert(tctx, localhost, "Localhost not found"); @@ -56,10 +56,11 @@ static bool test_udp(struct torture_context *tctx) torture_assert_ntstatus_ok(tctx, status, "listen on socket 1"); srv_addr = socket_get_my_addr(sock1, mem_ctx); - torture_assert(tctx, srv_addr != NULL && strcmp(srv_addr->addr, iface_best_ip("127.0.0.1")) == 0, + torture_assert(tctx, srv_addr != NULL && + strcmp(srv_addr->addr, iface_best_ip(tctx->lp_ctx, "127.0.0.1")) == 0, talloc_asprintf(tctx, "Expected server address of %s but got %s", - iface_best_ip("127.0.0.1"), srv_addr ? srv_addr->addr : NULL)); + iface_best_ip(tctx->lp_ctx, "127.0.0.1"), srv_addr ? srv_addr->addr : NULL)); torture_comment(tctx, "server port is %d\n", srv_addr->port); @@ -129,7 +130,7 @@ static bool test_tcp(struct torture_context *tctx) talloc_steal(mem_ctx, sock2); localhost = socket_address_from_strings(sock1, sock1->backend_name, - iface_best_ip("127.0.0.1"), 0); + iface_best_ip(tctx->lp_ctx, "127.0.0.1"), 0); torture_assert(tctx, localhost, "Localhost not found"); status = socket_listen(sock1, localhost, 0, 0); @@ -139,7 +140,7 @@ static bool test_tcp(struct torture_context *tctx) torture_assert(tctx, srv_addr && srv_addr->addr, "Unexpected socket_get_my_addr NULL\n"); - torture_assert_str_equal(tctx, srv_addr->addr, iface_best_ip("127.0.0.1"), + torture_assert_str_equal(tctx, srv_addr->addr, iface_best_ip(tctx->lp_ctx, "127.0.0.1"), "Unexpected server address"); torture_comment(tctx, "server port is %d\n", srv_addr->port); |