svn commit: samba r5260 - in branches/SAMBA_4_0/source: libcli/nbt nbt_server utils

tridge at samba.org tridge at samba.org
Mon Feb 7 11:56:35 GMT 2005


Author: tridge
Date: 2005-02-07 11:56:34 +0000 (Mon, 07 Feb 2005)
New Revision: 5260

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5260

Log:
- show an error message on nmblookup failure

- always try to enable broadcast on nbt name sockets (this matches
  samba3 behaviour better)

Modified:
   branches/SAMBA_4_0/source/libcli/nbt/nbtsocket.c
   branches/SAMBA_4_0/source/nbt_server/interfaces.c
   branches/SAMBA_4_0/source/utils/nmblookup.c


Changeset:
Modified: branches/SAMBA_4_0/source/libcli/nbt/nbtsocket.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/nbt/nbtsocket.c	2005-02-07 11:49:55 UTC (rev 5259)
+++ branches/SAMBA_4_0/source/libcli/nbt/nbtsocket.c	2005-02-07 11:56:34 UTC (rev 5260)
@@ -309,6 +309,8 @@
 	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 @@
 
 	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));

Modified: branches/SAMBA_4_0/source/nbt_server/interfaces.c
===================================================================
--- branches/SAMBA_4_0/source/nbt_server/interfaces.c	2005-02-07 11:49:55 UTC (rev 5259)
+++ branches/SAMBA_4_0/source/nbt_server/interfaces.c	2005-02-07 11:56:34 UTC (rev 5260)
@@ -141,9 +141,6 @@
 		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) {

Modified: branches/SAMBA_4_0/source/utils/nmblookup.c
===================================================================
--- branches/SAMBA_4_0/source/utils/nmblookup.c	2005-02-07 11:49:55 UTC (rev 5259)
+++ branches/SAMBA_4_0/source/utils/nmblookup.c	2005-02-07 11:56:34 UTC (rev 5260)
@@ -176,6 +176,7 @@
 	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 @@
 	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 @@
 	}
 
 	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);
  }
 



More information about the samba-cvs mailing list