summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-12-06 23:57:22 +0100
committerStefan Metzmacher <metze@samba.org>2007-12-21 05:48:37 +0100
commitc5bf20c5fe7eaa04cd11a7ce4f365aa6ffd7b124 (patch)
treea8f2d25736e2edb08fc4b03b21f3a2949b1e2117 /source4/lib
parent04304808cabd0f05a5ff5bf23d8fd950eff8d6f3 (diff)
downloadsamba-c5bf20c5fe7eaa04cd11a7ce4f365aa6ffd7b124.tar.gz
samba-c5bf20c5fe7eaa04cd11a7ce4f365aa6ffd7b124.tar.bz2
samba-c5bf20c5fe7eaa04cd11a7ce4f365aa6ffd7b124.zip
r26325: Remove use of global_loadparm in netif.
(This used to be commit e452cb28594f23add7c00247ed39e8323aea78a6)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/socket/interface.c26
-rw-r--r--source4/lib/socket/testsuite.c11
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);