2 Unix SMB/CIFS implementation.
4 handling for netlogon dgram requests
6 Copyright (C) Andrew Tridgell 2005
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "libcli/dgram/libdgram.h"
25 #include "lib/socket/socket.h"
26 #include "libcli/resolve/resolve.h"
29 send a netlogon mailslot request
31 NTSTATUS dgram_mailslot_netlogon_send(struct nbt_dgram_socket *dgmsock,
32 struct nbt_name *dest_name,
33 struct socket_address *dest,
34 struct nbt_name *src_name,
35 struct nbt_netlogon_packet *request)
39 TALLOC_CTX *tmp_ctx = talloc_new(dgmsock);
41 status = ndr_push_struct_blob(&blob, tmp_ctx, request,
42 (ndr_push_flags_fn_t)ndr_push_nbt_netlogon_packet);
43 if (!NT_STATUS_IS_OK(status)) {
49 status = dgram_mailslot_send(dgmsock, DGRAM_DIRECT_UNIQUE,
50 NBT_MAILSLOT_NETLOGON,
59 send a netlogon mailslot reply
61 NTSTATUS dgram_mailslot_netlogon_reply(struct nbt_dgram_socket *dgmsock,
62 struct nbt_dgram_packet *request,
63 const char *mailslot_name,
64 struct nbt_netlogon_packet *reply)
68 TALLOC_CTX *tmp_ctx = talloc_new(dgmsock);
69 struct nbt_name myname;
70 struct socket_address *dest;
72 status = ndr_push_struct_blob(&blob, tmp_ctx, reply,
73 (ndr_push_flags_fn_t)ndr_push_nbt_netlogon_packet);
74 if (!NT_STATUS_IS_OK(status)) {
79 make_nbt_name_client(&myname, lp_netbios_name());
81 dest = socket_address_from_strings(tmp_ctx, dgmsock->sock->backend_name,
82 request->src_addr, request->src_port);
85 return NT_STATUS_NO_MEMORY;
88 status = dgram_mailslot_send(dgmsock, DGRAM_DIRECT_UNIQUE,
90 &request->data.msg.source_name,
99 parse a netlogon response. The packet must be a valid mailslot packet
101 NTSTATUS dgram_mailslot_netlogon_parse(struct dgram_mailslot_handler *dgmslot,
103 struct nbt_dgram_packet *dgram,
104 struct nbt_netlogon_packet *netlogon)
106 DATA_BLOB data = dgram_mailslot_data(dgram);
109 status = ndr_pull_struct_blob(&data, mem_ctx, netlogon,
110 (ndr_pull_flags_fn_t)ndr_pull_nbt_netlogon_packet);
111 if (!NT_STATUS_IS_OK(status)) {
112 DEBUG(0,("Failed to parse netlogon packet of length %d\n",
115 file_save("netlogon.dat", data.data, data.length);