r26402: Require a talloc context in libnetif.
[kai/samba.git] / source4 / torture / nbt / winsbench.c
index 1c79b5eb75899f081e8c60a7e7983df830641a73..db9371977e38dfa1a49d2125bf3e8d5a5a69e54c 100644 (file)
@@ -35,6 +35,7 @@ struct wins_state {
        int pass_count;
        int fail_count;
        const char *wins_server;
+       uint16_t wins_port;
        const char *my_ip;
        uint32_t ttl;
 };
@@ -86,6 +87,7 @@ static void generate_register(struct nbt_name_socket *nbtsock, struct wins_state
 
        io.in.name            = generate_name(tmp_ctx, idx);
        io.in.dest_addr       = state->wins_server;
+       io.in.dest_port       = lp_nbt_port(global_loadparm);
        io.in.address         = state->my_ip;
        io.in.nb_flags        = NBT_NODE_H;
        io.in.register_demand = false;
@@ -185,7 +187,7 @@ static void generate_query(struct nbt_name_socket *nbtsock, struct wins_state *s
 
        io.in.name            = generate_name(tmp_ctx, idx);
        io.in.dest_addr       = state->wins_server;
-       io.in.dest_port       = lp_nbt_port(global_loadparm);
+       io.in.dest_port       = state->wins_port;
        io.in.broadcast       = false;
        io.in.wins_lookup     = true;
        io.in.timeout         = 2;
@@ -232,6 +234,7 @@ static bool bench_wins(struct torture_context *tctx)
        struct socket_address *my_ip;
        struct nbt_name name;
        const char *address;
+       struct interface *ifaces;
 
        if (!torture_nbt_get_name(tctx, &name, &address))
                return false;
@@ -241,7 +244,9 @@ static bool bench_wins(struct torture_context *tctx)
        state->num_names = torture_entries;
        state->registered = talloc_zero_array(state, bool, state->num_names);
        state->wins_server = address;
-       state->my_ip = talloc_strdup(tctx, iface_best_ip(tctx->lp_ctx, address));
+       state->wins_port = lp_nbt_port(tctx->lp_ctx);
+       load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
+       state->my_ip = talloc_strdup(tctx, iface_best_ip(ifaces, address));
        state->ttl = timelimit;
 
        my_ip = socket_address_from_strings(nbtsock, nbtsock->sock->backend_name,