r26426: Remove uses of global_loadparm.
[garming/samba-autobuild/.git] / source4 / torture / nbt / winsbench.c
index 34d27ab4103e6cdfb6b6c52471bee366c43965a8..1488c17757eaf8e13b67a64a1a8953b741721c90 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       = state->wins_port;
        io.in.address         = state->my_ip;
        io.in.nb_flags        = NBT_NODE_H;
        io.in.register_demand = false;
@@ -137,6 +139,7 @@ static void generate_release(struct nbt_name_socket *nbtsock, struct wins_state
        istate->state = state;
 
        io.in.name            = generate_name(tmp_ctx, idx);
+       io.in.dest_port       = state->wins_port;
        io.in.dest_addr       = state->wins_server;
        io.in.address         = state->my_ip;
        io.in.nb_flags        = NBT_NODE_H;
@@ -185,7 +188,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 +235,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 +245,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(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,