r26401: Don't cache interfaces context in libnetif.
[kai/samba-autobuild/.git] / source4 / nbt_server / irpc.c
index b3b168a8c0d86a1a4fa86cf1b94b7ef69593773c..8f2f7fc2c2e98de414f8cf4cc331501748113213 100644 (file)
@@ -8,7 +8,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 "smbd/service_task.h"
+#include "smbd/service.h"
 #include "nbt_server/nbt_server.h"
 #include "nbt_server/wins/winsserver.h"
+#include "librpc/gen_ndr/ndr_irpc.h"
+#include "lib/socket/socket.h"
+#include "libcli/resolve/resolve.h"
+#include "librpc/gen_ndr/ndr_nbt.h"
 
 /*
   serve out the nbt statistics
@@ -57,7 +61,7 @@ struct getdc_state {
 
 static void getdc_recv_ntlogon_reply(struct dgram_mailslot_handler *dgmslot, 
                                     struct nbt_dgram_packet *packet, 
-                                    const struct nbt_peer_socket *src)
+                                    struct socket_address *src)
 {
        struct getdc_state *s =
                talloc_get_type(dgmslot->private, struct getdc_state);
@@ -115,12 +119,12 @@ static NTSTATUS nbtd_getdcname(struct irpc_message *msg,
 {
        struct nbtd_server *server =
                talloc_get_type(msg->private, struct nbtd_server);
-       struct nbtd_interface *iface = nbtd_find_interface(server, req->in.ip_address);
+       struct nbtd_interface *iface = nbtd_find_request_iface(server, req->in.ip_address, true);
        struct getdc_state *s;
        struct nbt_ntlogon_packet p;
        struct nbt_ntlogon_sam_logon *r;
        struct nbt_name src, dst;
-       struct nbt_peer_socket dest;
+       struct socket_address *dest;
        struct dgram_mailslot_handler *handler;
        NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
 
@@ -152,10 +156,12 @@ static NTSTATUS nbtd_getdcname(struct irpc_message *msg,
        make_nbt_name_client(&src, req->in.my_computername);
        make_nbt_name(&dst, req->in.domainname, 0x1c);
 
-       dest.addr = req->in.ip_address;
-       dest.port = 138;
+       dest = socket_address_from_strings(msg, iface->dgmsock->sock->backend_name, 
+                                          req->in.ip_address, 138);
+       NT_STATUS_HAVE_NO_MEMORY(dest);
+
        status = dgram_mailslot_ntlogon_send(iface->dgmsock, DGRAM_DIRECT_GROUP,
-                                            &dst, &dest,
+                                            &dst, dest,
                                             &src, &p);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("dgram_mailslot_ntlogon_send failed: %s\n",
@@ -163,7 +169,7 @@ static NTSTATUS nbtd_getdcname(struct irpc_message *msg,
                return status;
        }
 
-       msg->defer_reply = True;
+       msg->defer_reply = true;
        return NT_STATUS_OK;
 }