summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source4/libcli/nbt/nbtsocket.c6
-rw-r--r--source4/nbt_server/interfaces.c3
-rw-r--r--source4/utils/nmblookup.c12
3 files changed, 10 insertions, 11 deletions
diff --git a/source4/libcli/nbt/nbtsocket.c b/source4/libcli/nbt/nbtsocket.c
index 3567224deac..f6566e8a6ec 100644
--- a/source4/libcli/nbt/nbtsocket.c
+++ b/source4/libcli/nbt/nbtsocket.c
@@ -309,6 +309,8 @@ struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx,
status = socket_create("ip", SOCKET_TYPE_DGRAM, &nbtsock->sock, 0);
if (!NT_STATUS_IS_OK(status)) goto failed;
+ socket_set_option(nbtsock->sock, "SO_BROADCAST", "1");
+
talloc_steal(nbtsock, nbtsock->sock);
nbtsock->idr = idr_init(nbtsock);
@@ -388,10 +390,6 @@ struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock,
DLIST_ADD_END(nbtsock->send_queue, req, struct nbt_name_request *);
- if (request->operation & NBT_FLAG_BROADCAST) {
- socket_set_option(nbtsock->sock, "SO_BROADCAST", "1");
- }
-
if (DEBUGLVL(10)) {
DEBUG(10,("Queueing nbt packet to %s:%d\n",
req->dest_addr, req->dest_port));
diff --git a/source4/nbt_server/interfaces.c b/source4/nbt_server/interfaces.c
index a75275dec7b..7572e4e336c 100644
--- a/source4/nbt_server/interfaces.c
+++ b/source4/nbt_server/interfaces.c
@@ -141,9 +141,6 @@ static NTSTATUS nbtd_add_socket(struct nbtd_server *nbtsrv,
return status;
}
- /* we need to be able to send broadcasts out */
- socket_set_option(iface->nbtsock->sock, "SO_BROADCAST", "1");
-
nbt_set_incoming_handler(iface->nbtsock, nbtd_request_handler, iface);
if (strcmp(netmask, "0.0.0.0") == 0) {
diff --git a/source4/utils/nmblookup.c b/source4/utils/nmblookup.c
index 3e3a4415d57..f41ab4cc6e3 100644
--- a/source4/utils/nmblookup.c
+++ b/source4/utils/nmblookup.c
@@ -176,6 +176,7 @@ static void process_one(const char *name)
enum nbt_name_type node_type = NBT_NAME_CLIENT;
char *node_name, *p;
struct nbt_name_socket *nbtsock;
+ NTSTATUS status;
if (options.find_master) {
node_type = NBT_NAME_MASTER;
@@ -196,7 +197,6 @@ static void process_one(const char *name)
nbtsock = nbt_name_socket_init(tmp_ctx, NULL);
if (options.root_port) {
- NTSTATUS status;
status = socket_listen(nbtsock->sock, "0.0.0.0", NBT_NAME_SERVICE_PORT, 0, 0);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to bind to local port 137 - %s\n", nt_errstr(status));
@@ -211,18 +211,22 @@ static void process_one(const char *name)
}
if (options.broadcast_address) {
- do_node_query(nbtsock, options.broadcast_address, node_name, node_type, True);
+ status = do_node_query(nbtsock, options.broadcast_address, node_name, node_type, True);
} else if (options.unicast_address) {
- do_node_query(nbtsock, options.unicast_address, node_name, node_type, False);
+ status = do_node_query(nbtsock, options.unicast_address, node_name, node_type, False);
} else {
int i, num_interfaces = iface_count();
for (i=0;i<num_interfaces;i++) {
const char *bcast = sys_inet_ntoa(*iface_n_bcast(i));
- NTSTATUS status = do_node_query(nbtsock, bcast, node_name, node_type, True);
+ status = do_node_query(nbtsock, bcast, node_name, node_type, True);
if (NT_STATUS_IS_OK(status)) break;
}
}
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Lookup failed - %s\n", nt_errstr(status));
+ }
+
talloc_free(tmp_ctx);
}