r26309: Move specification of port higher up the all stack.
authorJelmer Vernooij <jelmer@samba.org>
Thu, 6 Dec 2007 15:26:56 +0000 (16:26 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 21 Dec 2007 04:48:21 +0000 (05:48 +0100)
source/libcli/nbt/libnbt.h
source/libcli/nbt/namequery.c
source/libcli/resolve/nbtlist.c
source/nbt_server/wins/winswack.c
source/torture/nbt/query.c
source/torture/nbt/wins.c
source/torture/nbt/winsbench.c
source/utils/nmblookup.c

index e383591089d2273ff9ddf69be69fe0a8ccaf3cda..2f7ce8d1b4d8c284b9c9819745ab5812e4889875 100644 (file)
@@ -128,6 +128,7 @@ struct nbt_name_query {
        struct {
                struct nbt_name name;
                const char *dest_addr;
+               uint16_t dest_port;
                bool broadcast;
                bool wins_lookup;
                int timeout; /* in seconds */
index 755e06e88091b9eb6d95b297332ce978da6ddbf9..6bc6878194c279a862483a5e9bad32da254df24c 100644 (file)
@@ -54,7 +54,7 @@ _PUBLIC_ struct nbt_name_request *nbt_name_query_send(struct nbt_name_socket *nb
        packet->questions[0].question_class = NBT_QCLASS_IP;
 
        dest = socket_address_from_strings(packet, nbtsock->sock->backend_name,
-                                          io->in.dest_addr, lp_nbt_port(global_loadparm));
+                                          io->in.dest_addr, io->in.dest_port);
        if (dest == NULL) goto failed;
        req = nbt_name_request_send(nbtsock, dest, packet,
                                    io->in.timeout, io->in.retries, false);
index baf3874aa4fad1a8a76ea3e678339d9147af9f5b..13010eec3ef3d66ee91157039b920cc08ec8de77 100644 (file)
@@ -151,6 +151,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);
                if (composite_nomem(state->io_queries[i].in.dest_addr, c)) return c;
 
                state->io_queries[i].in.broadcast   = broadcast;
index 304edcf8de5c8dee9cb4c079172abcddda6f947d..82b16bb20dc899ebef84749ec4f06e10e2ec99a2 100644 (file)
@@ -26,6 +26,7 @@
 #include "nbt_server/wins/winsserver.h"
 #include "system/time.h"
 #include "libcli/composite/composite.h"
+#include "param/param.h"
 
 struct wins_challenge_state {
        struct wins_challenge_io *io;
@@ -46,6 +47,7 @@ static void wins_challenge_handler(struct nbt_name_request *req)
                if (state->current_address < state->io->in.num_addresses) {
                        struct nbtd_interface *iface;
 
+                       state->query.in.dest_port = lp_nbt_port(global_loadparm);
                        state->query.in.dest_addr = state->io->in.addresses[state->current_address];
                        
                        iface = nbtd_find_request_iface(state->io->in.nbtd_server, state->query.in.dest_addr, true);
@@ -103,6 +105,7 @@ struct composite_context *wins_challenge_send(TALLOC_CTX *mem_ctx, struct wins_c
 
        /* setup a name query to the first address */
        state->query.in.name        = *state->io->in.name;
+       state->query.in.dest_port   = lp_nbt_port(global_loadparm);
        state->query.in.dest_addr   = state->io->in.addresses[state->current_address];
        state->query.in.broadcast   = false;
        state->query.in.wins_lookup = true;
index 1040335227c8d8d55f765622b86618f94458fb6f..c5104f5f065683da68cbd222415104cec7b2effa 100644 (file)
@@ -24,6 +24,7 @@
 #include "libcli/resolve/resolve.h"
 #include "torture/torture.h"
 #include "torture/nbt/proto.h"
+#include "param/param.h"
 
 struct result_struct {
        int num_pass;
@@ -61,6 +62,7 @@ static bool bench_namequery(struct torture_context *tctx)
 
        io.in.name = name;
        io.in.dest_addr = address;
+       io.in.dest_port = lp_nbt_port(global_loadparm);
        io.in.broadcast = false;
        io.in.wins_lookup = false;
        io.in.timeout = 1;
index e25c3e78f093413b59ea2e0897eebc8d100933ae..fe87d7f9710552d34e345583936938c9505bef27 100644 (file)
@@ -27,6 +27,7 @@
 #include "librpc/gen_ndr/ndr_nbt.h"
 #include "torture/torture.h"
 #include "torture/nbt/proto.h"
+#include "param/param.h"
 
 #define CHECK_VALUE(tctx, v, correct) \
        torture_assert_int_equal(tctx, v, correct, "Incorrect value")
@@ -113,6 +114,7 @@ static bool nbt_test_wins_name(struct torture_context *tctx, const char *address
        torture_comment(tctx, "query the name to make sure its there\n");
        query.in.name = *name;
        query.in.dest_addr = address;
+       query.in.dest_port = lp_nbt_port(tctx->lp_ctx);
        query.in.broadcast = false;
        query.in.wins_lookup = true;
        query.in.timeout = 3;
index 27edd572068dfdafc3c02fbd26de52f14ce85116..34d27ab4103e6cdfb6b6c52471bee366c43965a8 100644 (file)
@@ -27,6 +27,7 @@
 #include "lib/socket/netif.h"
 #include "torture/torture.h"
 #include "torture/nbt/proto.h"
+#include "param/param.h"
 
 struct wins_state {
        int num_names;
@@ -184,6 +185,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.broadcast       = false;
        io.in.wins_lookup     = true;
        io.in.timeout         = 2;
index ada5b839b7082430a1e649eb1d1a823cb15920bc..2ff758d3b066c5d4b39b57c61462b95f5c61021a 100644 (file)
@@ -29,6 +29,7 @@
 #include "lib/socket/netif.h"
 #include "librpc/gen_ndr/nbt.h"
 #include "libcli/nbt/libnbt.h"
+#include "param/param.h"
 
 /* command line options */
 static struct {
@@ -142,6 +143,7 @@ static bool do_node_status(struct nbt_name_socket *nbtsock,
 /* do a single node query */
 static NTSTATUS do_node_query(struct nbt_name_socket *nbtsock,
                              const char *addr, 
+                             uint16_t port,
                              const char *node_name, 
                              enum nbt_name_type node_type,
                              bool broadcast)
@@ -154,6 +156,7 @@ static NTSTATUS do_node_query(struct nbt_name_socket *nbtsock,
        io.in.name.type = node_type;
        io.in.name.scope = NULL;
        io.in.dest_addr = addr;
+       io.in.dest_port = port;
        io.in.broadcast = broadcast;
        io.in.wins_lookup = options.wins_lookup;
        io.in.timeout = 1;
@@ -232,15 +235,18 @@ static bool process_one(const char *name)
        }
 
        if (options.broadcast_address) {
-               status = do_node_query(nbtsock, options.broadcast_address, node_name, node_type, true);
+               status = do_node_query(nbtsock, options.broadcast_address, lp_nbt_port(global_loadparm),
+                                      node_name, node_type, true);
        } else if (options.unicast_address) {
-               status = do_node_query(nbtsock, options.unicast_address, node_name, node_type, false);
+               status = do_node_query(nbtsock, options.unicast_address, 
+                                      lp_nbt_port(global_loadparm), node_name, node_type, false);
        } else {
                int i, num_interfaces = iface_count();
                for (i=0;i<num_interfaces;i++) {
                        const char *bcast = iface_n_bcast(i);
                        if (bcast == NULL) continue;
-                       status = do_node_query(nbtsock, bcast, node_name, node_type, true);
+                       status = do_node_query(nbtsock, bcast, lp_nbt_port(global_loadparm),
+                                              node_name, node_type, true);
                        if (NT_STATUS_IS_OK(status)) break;
                }
        }