Convert all uses of uint8/16/32 to _t in nmbd and the include file.
[samba.git] / source3 / nmbd / nmbd_namequery.c
index 1b07852f111b9e5415a6285b5049822e80ebef31..ae50a232987fc2073e6d1c07b6a3b0625b8496e2 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 "nmbd/nmbd.h"
 
 /****************************************************************************
  Deal with a response packet when querying a name.
@@ -32,11 +32,11 @@ static void query_name_response( struct subnet_record   *subrec,
                                  struct packet_struct   *p)
 {
        struct nmb_packet *nmb = &p->packet.nmb;
-       BOOL success = False;
+       bool success = False;
        struct nmb_name *question_name = &rrec->packet->packet.nmb.question.question_name;
        struct in_addr answer_ip;
 
-       zero_ip(&answer_ip);
+       zero_ip_v4(&answer_ip);
 
        /* Ensure we don't retry the query but leave the response record cleanup
                to the timeout code. We may get more answer responses in which case
@@ -59,7 +59,15 @@ static void query_name_response( struct subnet_record   *subrec,
   
                        rrec->repeat_count = 0;
                        /* How long we should wait for. */
-                       rrec->repeat_time = p->timestamp + nmb->answers->ttl;
+                       if (nmb->answers) {
+                               rrec->repeat_time = p->timestamp + nmb->answers->ttl;
+                       } else {
+                               /* No answer - this is probably a corrupt
+                                  packet.... */
+                               DEBUG(0,("query_name_response: missing answer record in "
+                                       "NMB_WACK_OPCODE response.\n"));
+                               rrec->repeat_time = p->timestamp + 10;
+                       }
                        rrec->num_msgs--;
                        return;
                } else if(nmb->header.rcode != 0) {
@@ -132,7 +140,7 @@ static void query_name_timeout_response(struct subnet_record *subrec,
 {
        struct nmb_packet *sent_nmb = &rrec->packet->packet.nmb;
        /* We can only fail here, never succeed. */
-       BOOL failed = True;
+       bool failed = True;
        struct nmb_name *question_name = &sent_nmb->question.question_name;
 
        if(rrec->num_msgs != 0) {
@@ -161,7 +169,7 @@ static void query_name_timeout_response(struct subnet_record *subrec,
  name is not there we look for the name on the given subnet.
 ****************************************************************************/
 
-static BOOL query_local_namelists(struct subnet_record *subrec, struct nmb_name *nmbname,
+static bool query_local_namelists(struct subnet_record *subrec, struct nmb_name *nmbname,
                                   struct name_record **namerecp) 
 {
        struct name_record *namerec;
@@ -185,7 +193,7 @@ static BOOL query_local_namelists(struct subnet_record *subrec, struct nmb_name
  Try and query for a name.
 ****************************************************************************/
 
-BOOL query_name(struct subnet_record *subrec, const char *name, int type,
+bool query_name(struct subnet_record *subrec, const char *name, int type,
                    query_name_success_function success_fn,
                    query_name_fail_function fail_fn, 
                    struct userdata_struct *userdata)
@@ -247,7 +255,7 @@ BOOL query_name(struct subnet_record *subrec, const char *name, int type,
  Try and query for a name from nmbd acting as a WINS server.
 ****************************************************************************/
 
-BOOL query_name_from_wins_server(struct in_addr ip_to, 
+bool query_name_from_wins_server(struct in_addr ip_to, 
                    const char *name, int type,
                    query_name_success_function success_fn,
                    query_name_fail_function fail_fn,