2 Unix SMB/CIFS implementation.
4 handling for browsing dgram requests
6 Copyright (C) Jelmer Vernooij 2005
7 Heavily based on ntlogon.c
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include "lib/events/events.h"
26 #include "libcli/nbt/libnbt.h"
27 #include "libcli/dgram/libdgram.h"
28 #include "lib/socket/socket.h"
29 #include "librpc/gen_ndr/ndr_nbt.h"
31 NTSTATUS dgram_mailslot_browse_send(struct nbt_dgram_socket *dgmsock,
32 struct nbt_name *dest_name, const struct nbt_peer_socket *dest,
33 struct nbt_name *src_name, struct nbt_browse_packet *request)
37 TALLOC_CTX *tmp_ctx = talloc_new(dgmsock);
39 status = ndr_push_struct_blob(&blob, tmp_ctx, request,
40 (ndr_push_flags_fn_t)ndr_push_nbt_browse_packet);
41 if (!NT_STATUS_IS_OK(status)) {
46 status = dgram_mailslot_send(dgmsock, DGRAM_DIRECT_UNIQUE,
54 NTSTATUS dgram_mailslot_browse_reply(struct nbt_dgram_socket *dgmsock,
55 struct nbt_dgram_packet *request, const char *mailslot_name,
56 struct nbt_browse_packet *reply)
60 TALLOC_CTX *tmp_ctx = talloc_new(dgmsock);
61 struct nbt_name myname;
62 struct nbt_peer_socket dest;
64 status = ndr_push_struct_blob(&blob, tmp_ctx, reply,
65 (ndr_push_flags_fn_t)ndr_push_nbt_browse_packet);
66 if (!NT_STATUS_IS_OK(status)) {
71 make_nbt_name_client(&myname, lp_netbios_name());
73 dest.port = request->src_port;
74 dest.addr = request->src_addr;
75 status = dgram_mailslot_send(dgmsock, DGRAM_DIRECT_UNIQUE,
77 &request->data.msg.source_name,
84 NTSTATUS dgram_mailslot_browse_parse(struct dgram_mailslot_handler *dgmslot,
85 TALLOC_CTX *mem_ctx, struct nbt_dgram_packet *dgram,
86 struct nbt_browse_packet *pkt)
88 DATA_BLOB data = dgram_mailslot_data(dgram);
91 status = ndr_pull_struct_blob(&data, mem_ctx, pkt,
92 (ndr_pull_flags_fn_t)ndr_pull_nbt_browse_packet);
93 if (!NT_STATUS_IS_OK(status)) {
94 DEBUG(0,("Failed to parse browse packet of length %d\n",
97 file_save("browse.dat", data.data, data.length);