2 Unix SMB/CIFS implementation.
4 handling for ntlogon 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 3 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, see <http://www.gnu.org/licenses/>.
23 #include "libcli/dgram/libdgram.h"
24 #include "lib/socket/socket.h"
25 #include "libcli/resolve/resolve.h"
26 #include "librpc/gen_ndr/ndr_nbt.h"
27 #include "param/param.h"
30 send a ntlogon mailslot request
32 NTSTATUS dgram_mailslot_ntlogon_send(struct nbt_dgram_socket *dgmsock,
33 enum dgram_msg_type msg_type,
34 struct nbt_name *dest_name,
35 struct socket_address *dest,
36 struct nbt_name *src_name,
37 struct nbt_ntlogon_packet *request)
40 enum ndr_err_code ndr_err;
42 TALLOC_CTX *tmp_ctx = talloc_new(dgmsock);
44 ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, request,
45 (ndr_push_flags_fn_t)ndr_push_nbt_ntlogon_packet);
46 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
48 return ndr_map_error2ntstatus(ndr_err);
52 status = dgram_mailslot_send(dgmsock, msg_type,
62 send a ntlogon mailslot reply
64 NTSTATUS dgram_mailslot_ntlogon_reply(struct nbt_dgram_socket *dgmsock,
65 struct nbt_dgram_packet *request,
66 const char *mailslot_name,
67 struct nbt_ntlogon_packet *reply)
70 enum ndr_err_code ndr_err;
72 TALLOC_CTX *tmp_ctx = talloc_new(dgmsock);
73 struct nbt_name myname;
74 struct socket_address *dest;
76 ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, reply,
77 (ndr_push_flags_fn_t)ndr_push_nbt_ntlogon_packet);
78 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
80 return ndr_map_error2ntstatus(ndr_err);
83 make_nbt_name_client(&myname, lp_netbios_name(global_loadparm));
85 dest = socket_address_from_strings(tmp_ctx,
86 dgmsock->sock->backend_name,
87 request->src_addr, request->src_port);
90 return NT_STATUS_NO_MEMORY;
93 status = dgram_mailslot_send(dgmsock, DGRAM_DIRECT_UNIQUE,
95 &request->data.msg.source_name,
104 parse a ntlogon response. The packet must be a valid mailslot packet
106 NTSTATUS dgram_mailslot_ntlogon_parse(struct dgram_mailslot_handler *dgmslot,
108 struct nbt_dgram_packet *dgram,
109 struct nbt_ntlogon_packet *ntlogon)
111 DATA_BLOB data = dgram_mailslot_data(dgram);
112 enum ndr_err_code ndr_err;
114 ndr_err = ndr_pull_struct_blob(&data, mem_ctx, ntlogon,
115 (ndr_pull_flags_fn_t)ndr_pull_nbt_ntlogon_packet);
116 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
117 NTSTATUS status = ndr_map_error2ntstatus(ndr_err);
118 DEBUG(0,("Failed to parse ntlogon packet of length %d: %s\n",
119 (int)data.length, nt_errstr(status)));
121 file_save("ntlogon.dat", data.data, data.length);