mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
r26437: remove another use of global_loadparm.
(This used to be commit 703f17bc09
)
This commit is contained in:
parent
1167c9d9c6
commit
e8f46760e0
@ -4,6 +4,7 @@
|
||||
broadcast name resolution module
|
||||
|
||||
Copyright (C) Andrew Tridgell 2005
|
||||
Copyright (C) Jelmer Vernooij 2007
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -25,6 +26,11 @@
|
||||
#include "lib/socket/netif.h"
|
||||
#include "param/param.h"
|
||||
|
||||
struct resolve_bcast_data {
|
||||
struct interface *ifaces;
|
||||
uint16_t nbt_port;
|
||||
};
|
||||
|
||||
/**
|
||||
broadcast name resolution method - async send
|
||||
*/
|
||||
@ -37,15 +43,15 @@ struct composite_context *resolve_name_bcast_send(TALLOC_CTX *mem_ctx,
|
||||
const char **address_list;
|
||||
struct composite_context *c;
|
||||
int i, count=0;
|
||||
struct interface *ifaces = userdata;
|
||||
struct resolve_bcast_data *data = talloc_get_type(userdata, struct resolve_bcast_data);
|
||||
|
||||
num_interfaces = iface_count(ifaces);
|
||||
num_interfaces = iface_count(data->ifaces);
|
||||
|
||||
address_list = talloc_array(mem_ctx, const char *, num_interfaces+1);
|
||||
if (address_list == NULL) return NULL;
|
||||
|
||||
for (i=0;i<num_interfaces;i++) {
|
||||
const char *bcast = iface_n_bcast(ifaces, i);
|
||||
const char *bcast = iface_n_bcast(data->ifaces, i);
|
||||
if (bcast == NULL) continue;
|
||||
address_list[count] = talloc_strdup(address_list, bcast);
|
||||
if (address_list[count] == NULL) {
|
||||
@ -56,7 +62,7 @@ struct composite_context *resolve_name_bcast_send(TALLOC_CTX *mem_ctx,
|
||||
}
|
||||
address_list[count] = NULL;
|
||||
|
||||
c = resolve_name_nbtlist_send(mem_ctx, event_ctx, name, address_list, true, false);
|
||||
c = resolve_name_nbtlist_send(mem_ctx, event_ctx, name, address_list, data->ifaces, data->nbt_port, true, false);
|
||||
talloc_free(address_list);
|
||||
|
||||
return c;
|
||||
@ -77,16 +83,29 @@ NTSTATUS resolve_name_bcast_recv(struct composite_context *c,
|
||||
NTSTATUS resolve_name_bcast(struct nbt_name *name,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
struct interface *ifaces,
|
||||
uint16_t nbt_port,
|
||||
const char **reply_addr)
|
||||
{
|
||||
struct composite_context *c = resolve_name_bcast_send(mem_ctx, NULL, ifaces, name);
|
||||
struct resolve_bcast_data *data = talloc(mem_ctx, struct resolve_bcast_data);
|
||||
struct composite_context *c;
|
||||
data->ifaces = talloc_reference(data, ifaces);
|
||||
data->nbt_port = nbt_port;
|
||||
|
||||
c = resolve_name_bcast_send(mem_ctx, NULL, data, name);
|
||||
return resolve_name_bcast_recv(c, mem_ctx, reply_addr);
|
||||
}
|
||||
|
||||
bool resolve_context_add_bcast_method(struct resolve_context *ctx, struct loadparm_context *lp_ctx)
|
||||
bool resolve_context_add_bcast_method(struct resolve_context *ctx, struct interface *ifaces, uint16_t nbt_port)
|
||||
{
|
||||
struct resolve_bcast_data *data = talloc(ctx, struct resolve_bcast_data);
|
||||
data->ifaces = ifaces;
|
||||
data->nbt_port = nbt_port;
|
||||
return resolve_context_add_method(ctx, resolve_name_bcast_send, resolve_name_bcast_recv, data);
|
||||
}
|
||||
|
||||
bool resolve_context_add_bcast_method_lp(struct resolve_context *ctx, struct loadparm_context *lp_ctx)
|
||||
{
|
||||
struct interface *ifaces;
|
||||
load_interfaces(ctx, lp_interfaces(lp_ctx), &ifaces);
|
||||
return resolve_context_add_method(ctx, resolve_name_bcast_send, resolve_name_bcast_recv,
|
||||
ifaces);
|
||||
return resolve_context_add_bcast_method(ctx, ifaces, lp_nbt_port(lp_ctx));
|
||||
}
|
||||
|
@ -100,6 +100,8 @@ struct composite_context *resolve_name_nbtlist_send(TALLOC_CTX *mem_ctx,
|
||||
struct event_context *event_ctx,
|
||||
struct nbt_name *name,
|
||||
const char **address_list,
|
||||
struct interface *ifaces,
|
||||
uint16_t nbt_port,
|
||||
bool broadcast,
|
||||
bool wins_lookup)
|
||||
{
|
||||
@ -127,7 +129,7 @@ struct composite_context *resolve_name_nbtlist_send(TALLOC_CTX *mem_ctx,
|
||||
if (composite_nomem(state->name.scope, c)) return c;
|
||||
}
|
||||
|
||||
load_interfaces(state, lp_interfaces(global_loadparm), &state->ifaces);
|
||||
state->ifaces = talloc_reference(state, ifaces);
|
||||
|
||||
/*
|
||||
* we can't push long names on the wire,
|
||||
@ -154,7 +156,7 @@ struct composite_context *resolve_name_nbtlist_send(TALLOC_CTX *mem_ctx,
|
||||
for (i=0;i<state->num_queries;i++) {
|
||||
state->io_queries[i].in.name = state->name;
|
||||
state->io_queries[i].in.dest_addr = talloc_strdup(state->io_queries, address_list[i]);
|
||||
state->io_queries[i].in.dest_port = lp_nbt_port(global_loadparm);
|
||||
state->io_queries[i].in.dest_port = nbt_port;
|
||||
if (composite_nomem(state->io_queries[i].in.dest_addr, c)) return c;
|
||||
|
||||
state->io_queries[i].in.broadcast = broadcast;
|
||||
@ -197,11 +199,14 @@ NTSTATUS resolve_name_nbtlist_recv(struct composite_context *c,
|
||||
NTSTATUS resolve_name_nbtlist(struct nbt_name *name,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
const char **address_list,
|
||||
struct interface *ifaces,
|
||||
uint16_t nbt_port,
|
||||
bool broadcast, bool wins_lookup,
|
||||
const char **reply_addr)
|
||||
{
|
||||
struct composite_context *c = resolve_name_nbtlist_send(mem_ctx, NULL,
|
||||
name, address_list,
|
||||
ifaces, nbt_port,
|
||||
broadcast, wins_lookup);
|
||||
return resolve_name_nbtlist_recv(c, mem_ctx, reply_addr);
|
||||
}
|
||||
|
@ -32,9 +32,9 @@ struct resolve_context *lp_resolve_context(struct loadparm_context *lp_ctx)
|
||||
|
||||
for (i = 0; methods != NULL && methods[i] != NULL; i++) {
|
||||
if (!strcmp(methods[i], "wins")) {
|
||||
resolve_context_add_wins_method(ret, lp_wins_server_list(lp_ctx));
|
||||
resolve_context_add_wins_method_lp(ret, lp_ctx);
|
||||
} else if (!strcmp(methods[i], "bcast")) {
|
||||
resolve_context_add_bcast_method(ret, lp_ctx);
|
||||
resolve_context_add_bcast_method_lp(ret, lp_ctx);
|
||||
} else if (!strcmp(methods[i], "host")) {
|
||||
resolve_context_add_host_method(ret);
|
||||
} else {
|
||||
|
@ -23,9 +23,12 @@
|
||||
#include "libcli/nbt/libnbt.h"
|
||||
#include "libcli/resolve/resolve.h"
|
||||
#include "param/param.h"
|
||||
#include "lib/socket/netif.h"
|
||||
|
||||
struct resolve_wins_data {
|
||||
const char **address_list;
|
||||
struct interface *ifaces;
|
||||
uint16_t nbt_port;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -39,7 +42,7 @@ struct composite_context *resolve_name_wins_send(
|
||||
{
|
||||
struct resolve_wins_data *wins_data = talloc_get_type(userdata, struct resolve_wins_data);
|
||||
if (wins_data->address_list == NULL) return NULL;
|
||||
return resolve_name_nbtlist_send(mem_ctx, event_ctx, name, wins_data->address_list, false, true);
|
||||
return resolve_name_nbtlist_send(mem_ctx, event_ctx, name, wins_data->address_list, wins_data->ifaces, wins_data->nbt_port, false, true);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -57,19 +60,32 @@ NTSTATUS resolve_name_wins_recv(struct composite_context *c,
|
||||
NTSTATUS resolve_name_wins(struct nbt_name *name,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
const char **address_list,
|
||||
struct interface *ifaces,
|
||||
uint16_t nbt_port,
|
||||
const char **reply_addr)
|
||||
{
|
||||
struct composite_context *c;
|
||||
struct resolve_wins_data *wins_data = talloc(mem_ctx, struct resolve_wins_data);
|
||||
wins_data->address_list = address_list;
|
||||
wins_data->ifaces = ifaces;
|
||||
wins_data->nbt_port = nbt_port;
|
||||
c = resolve_name_wins_send(mem_ctx, NULL, wins_data, name);
|
||||
return resolve_name_wins_recv(c, mem_ctx, reply_addr);
|
||||
}
|
||||
|
||||
bool resolve_context_add_wins_method(struct resolve_context *ctx, const char **address_list)
|
||||
bool resolve_context_add_wins_method(struct resolve_context *ctx, const char **address_list, struct interface *ifaces, uint16_t nbt_port)
|
||||
{
|
||||
struct resolve_wins_data *wins_data = talloc(ctx, struct resolve_wins_data);
|
||||
wins_data->address_list = str_list_copy(wins_data, address_list);
|
||||
wins_data->ifaces = talloc_reference(wins_data, ifaces);
|
||||
wins_data->nbt_port = nbt_port;
|
||||
return resolve_context_add_method(ctx, resolve_name_wins_send, resolve_name_wins_recv,
|
||||
wins_data);
|
||||
}
|
||||
|
||||
bool resolve_context_add_wins_method_lp(struct resolve_context *ctx, struct loadparm_context *lp_ctx)
|
||||
{
|
||||
struct interface *ifaces;
|
||||
load_interfaces(ctx, lp_interfaces(lp_ctx), &ifaces);
|
||||
return resolve_context_add_wins_method(ctx, lp_wins_server_list(lp_ctx), ifaces, lp_nbt_port(lp_ctx));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user