s3: Make nmbd listen on the unexpected socket
authorVolker Lendecke <vl@samba.org>
Tue, 4 Jan 2011 16:58:12 +0000 (17:58 +0100)
committerVolker Lendecke <vl@samba.org>
Fri, 7 Jan 2011 12:28:04 +0000 (13:28 +0100)
source3/nmbd/nmbd.c
source3/nmbd/nmbd_packets.c
source3/nmbd/nmbd_proto.h

index 30bbeaadee23594d5b61a18a5d57610b6cef839a..eaa5055998f0c5be539736bab5d7ced064cef70b 100644 (file)
@@ -1017,6 +1017,11 @@ static bool open_sockets(bool isdaemon, int port)
                exit(1);
        }
 
+       if (!nmbd_init_packet_server()) {
+               kill_async_dns_child();
+                exit(1);
+        }
+
        TALLOC_FREE(frame);
        process();
 
index 1e72c188882ab897edeaae44712847aef1d07d92..ec5225a5ecacbc16c02319fe8885f86529b45f63 100644 (file)
@@ -31,6 +31,22 @@ extern int num_response_packets;
 
 bool rescan_listen_set = False;
 
+static struct nb_packet_server *packet_server;
+
+bool nmbd_init_packet_server(void)
+{
+       NTSTATUS status;
+
+       status = nb_packet_server_create(NULL, nmbd_event_context(), 0,
+                                        &packet_server);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(0, ("ERROR: nb_packet_server_create failed: %s\n",
+                         nt_errstr(status)));
+               return false;
+       }
+       return true;
+}
+
 
 /*******************************************************************
   The global packet linked-list. Incoming entries are 
@@ -1204,6 +1220,7 @@ static void process_dgram(struct packet_struct *p)
 
        /* If we aren't listening to the destination name then ignore the packet */
        if (!listening(p,&dgram->dest_name)) {
+                       nb_packet_dispatch(packet_server, p);
                        unexpected_packet(p);
                        DEBUG(5,("process_dgram: ignoring dgram packet sent to name %s from %s\n",
                                nmb_namestr(&dgram->dest_name), inet_ntoa(p->ip)));
@@ -1211,6 +1228,7 @@ static void process_dgram(struct packet_struct *p)
        }
 
        if (dgram->header.msg_type != 0x10 && dgram->header.msg_type != 0x11 && dgram->header.msg_type != 0x12) {
+               nb_packet_dispatch(packet_server, p);
                unexpected_packet(p);
                /* Don't process error packets etc yet */
                DEBUG(5,("process_dgram: ignoring dgram packet sent to name %s from IP %s as it is \
@@ -1297,6 +1315,7 @@ packet sent to name %s from IP %s\n",
                return;
        }
 
+       nb_packet_dispatch(packet_server, p);
        unexpected_packet(p);
 }
 
@@ -1417,6 +1436,7 @@ static struct subnet_record *find_subnet_for_nmb_packet( struct packet_struct *p
                if(rrec == NULL) {
                        DEBUG(3,("find_subnet_for_nmb_packet: response record not found for response id %hu\n",
                                nmb->header.name_trn_id));
+                       nb_packet_dispatch(packet_server, p);
                        unexpected_packet(p);
                        return NULL;
                }
index e90a90ee7f1806b01b195172571ec876db206eaa..b58ca41e5a0b9171b52b9520379951ecb6b0212f 100644 (file)
@@ -173,6 +173,8 @@ bool node_status(struct subnet_record *subrec, struct nmb_name *nmbname,
 
 /* The following definitions come from nmbd/nmbd_packets.c  */
 
+bool nmbd_init_packet_server(void);
+
 uint16 get_nb_flags(char *buf);
 void set_nb_flags(char *buf, uint16 nb_flags);
 struct response_record *queue_register_name( struct subnet_record *subrec,