file_server: Move vfs objects initialisation into file_server.c smb.conf wrapper
[sfrench/samba-autobuild/.git] / source4 / nbt_server / nodestatus.c
index 5b79bf315f42ba7d7b886545ac0167842ed57d78..f71746ab300f855c3ee8483570a047a09cd8e35e 100644 (file)
@@ -7,7 +7,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
-#include "dlinklist.h"
+#include "../lib/util/dlinklist.h"
 #include "system/network.h"
 #include "nbt_server/nbt_server.h"
+#include "lib/socket/socket.h"
+#include "librpc/gen_ndr/ndr_nbt.h"
 
 /*
   send a name status reply
 */
 static void nbtd_node_status_reply(struct nbt_name_socket *nbtsock, 
                                   struct nbt_name_packet *request_packet, 
-                                  const char *src_address, int src_port,
+                                  struct socket_address *src,
                                   struct nbt_name *name, 
                                   struct nbtd_interface *iface)
 {
        struct nbt_name_packet *packet;
        uint32_t name_count;
        struct nbtd_iface_name *iname;
+       struct nbtd_server *nbtsrv = iface->nbtsrv;
        
        /* work out how many names to send */
        name_count = 0;
@@ -52,7 +54,7 @@ static void nbtd_node_status_reply(struct nbt_name_socket *nbtsock,
 
        packet->name_trn_id = request_packet->name_trn_id;
        packet->ancount = 1;
-       packet->operation = NBT_OPCODE_QUERY | NBT_FLAG_REPLY | NBT_FLAG_AUTHORITIVE;
+       packet->operation = NBT_OPCODE_QUERY | NBT_FLAG_REPLY | NBT_FLAG_AUTHORITATIVE;
 
        packet->answers = talloc_array(packet, struct nbt_res_rec, 1);
        if (packet->answers == NULL) goto failed;
@@ -82,10 +84,11 @@ static void nbtd_node_status_reply(struct nbt_name_socket *nbtsock,
           it could lead to giving attackers too much information */
        ZERO_STRUCT(packet->answers[0].rdata.status.statistics);
 
-       DEBUG(7,("Sending node status reply for %s<%02x> to %s:%d\n", 
-                name->name, name->type, src_address, src_port));
+       DEBUG(7,("Sending node status reply for %s to %s:%d\n", 
+                nbt_name_string(packet, name), src->addr, src->port));
        
-       nbt_name_reply_send(nbtsock, src_address, src_port, packet);
+       nbtsrv->stats.total_sent++;
+       nbt_name_reply_send(nbtsock, src, packet);
 
 failed:
        talloc_free(packet);
@@ -97,27 +100,27 @@ failed:
 */
 void nbtd_query_status(struct nbt_name_socket *nbtsock, 
                       struct nbt_name_packet *packet, 
-                      const char *src_address, int src_port)
+                      struct socket_address *src)
 {
        struct nbt_name *name;
        struct nbtd_iface_name *iname;
-       struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private
+       struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private_data,
                                                       struct nbtd_interface);
 
-       NBTD_ASSERT_PACKET(packet, src_address, packet->qdcount == 1);
-       NBTD_ASSERT_PACKET(packet, src_address, packet->questions[0].question_type == NBT_QTYPE_STATUS);
-       NBTD_ASSERT_PACKET(packet, src_address, packet->questions[0].question_class == NBT_QCLASS_IP);
+       NBTD_ASSERT_PACKET(packet, src, packet->qdcount == 1);
+       NBTD_ASSERT_PACKET(packet, src, packet->questions[0].question_type == NBT_QTYPE_STATUS);
+       NBTD_ASSERT_PACKET(packet, src, packet->questions[0].question_class == NBT_QCLASS_IP);
 
        /* see if we have the requested name on this interface */
        name = &packet->questions[0].name;
 
        iname = nbtd_find_iname(iface, name, NBT_NM_ACTIVE);
        if (iname == NULL) {
-               DEBUG(7,("Node status query for %s<%02x> from %s - not found on %s\n",
-                        name->name, name->type, src_address, iface->ip_address));
+               DEBUG(7,("Node status query for %s from %s - not found on %s\n",
+                        nbt_name_string(packet, name), src->addr, iface->ip_address));
                return;
        }
 
-       nbtd_node_status_reply(nbtsock, packet, src_address, src_port
+       nbtd_node_status_reply(nbtsock, packet, src, 
                               &iname->name, iface);
 }