NTSTATUS status;
struct interface *ifaces;
- load_interfaces(lp_interfaces(task->lp_ctx), &ifaces);
+ load_interfaces(task, lp_interfaces(task->lp_ctx), &ifaces);
if (iface_count(ifaces) == 0) {
task_server_terminate(task, "cldapd: no network interfaces configured");
lp_workgroup(lp_ctx));
server_site = "Default-First-Site-Name";
client_site = "Default-First-Site-Name";
- load_interfaces(lp_interfaces(lp_ctx), &ifaces);
+ load_interfaces(mem_ctx, lp_interfaces(lp_ctx), &ifaces);
pdc_ip = iface_best_ip(ifaces, src_address);
ZERO_STRUCTP(netlogon);
int i;
struct interface *ifaces;
- load_interfaces(lp_interfaces(global_loadparm), &ifaces);
+ load_interfaces(NULL, lp_interfaces(global_loadparm), &ifaces);
res->len = iface_count(ifaces);
res->val = malloc_array_p(HostAddress, res->len);
if (res->val == NULL) {
+ talloc_free(ifaces);
return ENOMEM;
}
for (i=0;i<res->len;i++) {
res->val[i].address.length = 4;
res->val[i].address.data = malloc(4);
if (res->val[i].address.data == NULL) {
+ talloc_free(ifaces);
return ENOMEM;
}
((struct in_addr *)res->val[i].address.data)->s_addr = inet_addr(ip);
}
+ talloc_free(ifaces);
+
return 0;
}
break;
}
- load_interfaces(lp_interfaces(task->lp_ctx), &ifaces);
+ load_interfaces(task, lp_interfaces(task->lp_ctx), &ifaces);
if (iface_count(ifaces) == 0) {
task_server_terminate(task, "kdc: no network interfaces configured");
int num_interfaces;
int i;
- load_interfaces(lp_interfaces(task->lp_ctx), &ifaces);
+ load_interfaces(task, lp_interfaces(task->lp_ctx), &ifaces);
num_interfaces = iface_count(ifaces);
/* We have been given an interfaces line, and been
/****************************************************************************
add an interface to the linked list of interfaces
****************************************************************************/
-static void add_interface(struct in_addr ip, struct in_addr nmask, struct interface **interfaces)
+static void add_interface(TALLOC_CTX *mem_ctx, struct in_addr ip, struct in_addr nmask, struct interface **interfaces)
{
struct interface *iface;
struct in_addr bcast;
return;
}
- iface = talloc(*interfaces == NULL ? talloc_autofree_context() : *interfaces, struct interface);
+ iface = talloc(*interfaces == NULL ? mem_ctx : *interfaces, struct interface);
if (iface == NULL)
return;
4) ip/mask
5) bcast/mask
**/
-static void interpret_interface(const char *token,
+static void interpret_interface(TALLOC_CTX *mem_ctx,
+ const char *token,
struct iface_struct *probed_ifaces,
int total_probed,
struct interface **local_interfaces)
/* first check if it is an interface name */
for (i=0;i<total_probed;i++) {
if (gen_fnmatch(token, probed_ifaces[i].name) == 0) {
- add_interface(probed_ifaces[i].ip,
+ add_interface(mem_ctx, probed_ifaces[i].ip,
probed_ifaces[i].netmask,
local_interfaces);
added = 1;
ip.s_addr = interpret_addr2(token).s_addr;
for (i=0;i<total_probed;i++) {
if (ip.s_addr == probed_ifaces[i].ip.s_addr) {
- add_interface(probed_ifaces[i].ip,
+ add_interface(mem_ctx, probed_ifaces[i].ip,
probed_ifaces[i].netmask,
local_interfaces);
return;
ip.s_addr == MKNETADDR(ip.s_addr, nmask.s_addr)) {
for (i=0;i<total_probed;i++) {
if (same_net(ip, probed_ifaces[i].ip, nmask)) {
- add_interface(probed_ifaces[i].ip, nmask,
+ add_interface(mem_ctx, probed_ifaces[i].ip, nmask,
local_interfaces);
return;
}
return;
}
- add_interface(ip, nmask, local_interfaces);
+ add_interface(mem_ctx, ip, nmask, local_interfaces);
}
/**
load the list of network interfaces
**/
-void load_interfaces(const char **interfaces, struct interface **local_interfaces)
+void load_interfaces(TALLOC_CTX *mem_ctx, const char **interfaces, struct interface **local_interfaces)
{
const char **ptr = interfaces;
int i;
}
for (i=0;i<total_probed;i++) {
if (ifaces[i].ip.s_addr != loopback_ip.s_addr) {
- add_interface(ifaces[i].ip,
+ add_interface(mem_ctx, ifaces[i].ip,
ifaces[i].netmask, local_interfaces);
}
}
}
while (ptr && *ptr) {
- interpret_interface(*ptr, ifaces, total_probed, local_interfaces);
+ interpret_interface(mem_ctx, *ptr, ifaces, total_probed, local_interfaces);
ptr++;
}
TALLOC_CTX *mem_ctx = tctx;
struct interface *ifaces;
- load_interfaces(lp_interfaces(tctx->lp_ctx), &ifaces);
+ load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
status = socket_create("ip", SOCKET_TYPE_DGRAM, &sock1, 0);
torture_assert_ntstatus_ok(tctx, status, "creating DGRAM IP socket 1");
torture_assert_ntstatus_ok(tctx, status, "creating IP stream socket 1");
talloc_steal(mem_ctx, sock2);
- load_interfaces(lp_interfaces(tctx->lp_ctx), &ifaces);
+ load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
localhost = socket_address_from_strings(sock1, sock1->backend_name,
iface_best_ip(ifaces, "127.0.0.1"), 0);
torture_assert(tctx, localhost, "Localhost not found");
bool resolve_context_add_bcast_method(struct resolve_context *ctx, struct loadparm_context *lp_ctx)
{
struct interface *ifaces;
- load_interfaces(lp_interfaces(lp_ctx), &ifaces);
+ load_interfaces(ctx, lp_interfaces(lp_ctx), &ifaces);
return resolve_context_add_method(ctx, resolve_name_bcast_send, resolve_name_bcast_recv,
ifaces);
}
}
/* favor a local address if possible */
- load_interfaces(lp_interfaces(global_loadparm), &ifaces);
+ load_interfaces(NULL, lp_interfaces(global_loadparm), &ifaces);
state->reply_addr = NULL;
for (i=0;i<q->out.num_addrs;i++) {
if (iface_is_local(ifaces, q->out.reply_addrs[i])) {
break;
}
}
+ talloc_free(ifaces);
if (state->reply_addr == NULL) {
state->reply_addr = talloc_steal(state,
if (!our_ip) {
struct interface *ifaces;
- load_interfaces(lp_interfaces(global_loadparm), &ifaces);
+ load_interfaces(state, lp_interfaces(global_loadparm), &ifaces);
our_ip = iface_best_ip(ifaces, peer_ip);
}
NTSTATUS status;
struct interface *ifaces;
- load_interfaces(lp_interfaces(task->lp_ctx), &ifaces);
+ load_interfaces(task, lp_interfaces(task->lp_ctx), &ifaces);
if (iface_count(ifaces) == 0) {
task_server_terminate(task, "nbtd: no network interfaces configured");
owner = lp_parm_string(lp_ctx, NULL, "winsdb", "local_owner");
if (!owner) {
struct interface *ifaces;
- load_interfaces(lp_interfaces(lp_ctx), &ifaces);
+ load_interfaces(ctx, lp_interfaces(lp_ctx), &ifaces);
owner = iface_n_ip(ifaces, 0);
if (!owner) {
owner = "0.0.0.0";
if (owner == NULL) {
struct interface *ifaces;
- load_interfaces(lp_interfaces(nbtsrv->task->lp_ctx), &ifaces);
+ load_interfaces(nbtsrv->task, lp_interfaces(nbtsrv->task->lp_ctx), &ifaces);
owner = iface_n_ip(ifaces, 0);
}
struct event_context *event_ctx, const struct model_ops *model_ops)
{
NTSTATUS status;
- struct interface *ifaces;
-
- load_interfaces(lp_interfaces(lp_ctx), &ifaces);
/* Add TCP/IP sockets */
if (lp_interfaces(lp_ctx) && lp_bind_interfaces_only(lp_ctx)) {
- int num_interfaces = iface_count(ifaces);
+ int num_interfaces;
int i;
+ struct interface *ifaces;
+
+ load_interfaces(dce_ctx, lp_interfaces(lp_ctx), &ifaces);
+
+ num_interfaces = iface_count(ifaces);
for(i = 0; i < num_interfaces; i++) {
const char *address = iface_n_ip(ifaces, i);
status = add_socket_rpc_tcp_iface(dce_ctx, e, event_ctx, model_ops, address);
struct MprVar ret = mprArray("interfaces");
struct interface *ifaces;
- load_interfaces(lp_interfaces(global_loadparm), &ifaces);
+ load_interfaces(NULL, lp_interfaces(global_loadparm), &ifaces);
count = iface_count(ifaces);
for (i=0;i<count;i++) {
mprAddArray(&ret, i, mprString(iface_n_ip(ifaces, i)));
}
+
+ talloc_free(ifaces);
mpr_Return(eid, ret);
return 0;
}
int i;
struct interface *ifaces;
- load_interfaces(lp_interfaces(task->lp_ctx), &ifaces);
+ load_interfaces(task, lp_interfaces(task->lp_ctx), &ifaces);
num_interfaces = iface_count(ifaces);
resolve_name(lp_resolve_context(tctx->lp_ctx), &name, tctx, &address, event_context_find(tctx)),
talloc_asprintf(tctx, "Failed to resolve %s", name.name));
- load_interfaces(lp_interfaces(tctx->lp_ctx), &ifaces);
+ load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
myaddress = talloc_strdup(dgmsock, iface_best_ip(ifaces, address));
resolve_name(lp_resolve_context(tctx->lp_ctx), &name, tctx, &address, event_context_find(tctx)),
talloc_asprintf(tctx, "Failed to resolve %s", name.name));
- load_interfaces(lp_interfaces(tctx->lp_ctx), &ifaces);
+ load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
myaddress = talloc_strdup(dgmsock, iface_best_ip(ifaces, address));
socket_address = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name,
resolve_name(lp_resolve_context(tctx->lp_ctx), &name, tctx, &address, event_context_find(tctx)),
talloc_asprintf(tctx, "Failed to resolve %s", name.name));
- load_interfaces(lp_interfaces(tctx->lp_ctx), &ifaces);
+ load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
myaddress = talloc_strdup(dgmsock, iface_best_ip(ifaces, address));
socket_address = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name,
if (!torture_nbt_get_name(tctx, &name, &address))
return false;
- load_interfaces(lp_interfaces(tctx->lp_ctx), &ifaces);
+ load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
myaddress = iface_best_ip(ifaces, address);
if (!torture_nbt_get_name(tctx, &name, &address))
return false;
- load_interfaces(lp_interfaces(tctx->lp_ctx), &ifaces);
+ load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
myaddress = iface_best_ip(ifaces, address);
struct socket_address *socket_address;
struct interface *ifaces;
- load_interfaces(lp_interfaces(tctx->lp_ctx), &ifaces);
+ load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
myaddress = talloc_strdup(tctx, iface_best_ip(ifaces, address));
state->registered = talloc_zero_array(state, bool, state->num_names);
state->wins_server = address;
state->wins_port = lp_nbt_port(tctx->lp_ctx);
- load_interfaces(lp_interfaces(tctx->lp_ctx), &ifaces);
+ load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
state->my_ip = talloc_strdup(tctx, iface_best_ip(ifaces, address));
state->ttl = timelimit;
ctx->nbtsock = nbt_name_socket_init(ctx, NULL);
if (!ctx->nbtsock) return NULL;
- load_interfaces(lp_interfaces(tctx->lp_ctx), &ifaces);
+ load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
ctx->myaddr = socket_address_from_strings(tctx, ctx->nbtsock->sock->backend_name, iface_best_ip(ifaces, address), 0);
if (!ctx->myaddr) return NULL;
lp_set_cmdline(tctx->lp_ctx, "dcerpc endpoint servers", "spoolss");
- load_interfaces(lp_interfaces(tctx->lp_ctx), &ifaces);
+ load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
address = iface_n_ip(ifaces, 0);
torture_comment(tctx, "Listening for callbacks on %s\n", address);
status = smbsrv_add_socket(p->conn->event_ctx, tctx->lp_ctx, &single_ops, address);
exit(1);
}
- load_interfaces(lp_interfaces(cmdline_lp_ctx), &ifaces);
+ load_interfaces(NULL, lp_interfaces(cmdline_lp_ctx), &ifaces);
while (poptPeekArg(pc)) {
const char *name = poptGetArg(pc);
ret &= process_one(cmdline_lp_ctx, ifaces, name, lp_nbt_port(cmdline_lp_ctx));
}
+ talloc_free(ifaces);
+
poptFreeContext(pc);
if (!ret) {
int i;
struct interface *ifaces;
- load_interfaces(lp_interfaces(task->lp_ctx), &ifaces);
+ load_interfaces(NULL, lp_interfaces(task->lp_ctx), &ifaces);
num_interfaces = iface_count(ifaces);
for(i = 0; i < num_interfaces; i++) {
task);
if (!NT_STATUS_IS_OK(status)) goto failed;
}
+
+ talloc_free(ifaces);
} else {
status = stream_setup_socket(task->event_ctx, model_ops,
&web_stream_ops,
int i;
struct interface *ifaces;
- load_interfaces(lp_interfaces(lp_ctx), &ifaces);
+ load_interfaces(task, lp_interfaces(lp_ctx), &ifaces);
num_interfaces = iface_count(ifaces);
if (owner == NULL) {
struct interface *ifaces;
- load_interfaces(lp_interfaces(lp_ctx), &ifaces);
+ load_interfaces(service, lp_interfaces(lp_ctx), &ifaces);
owner = iface_n_ip(ifaces, 0);
}