summaryrefslogtreecommitdiff
path: root/source4/nbt_server/dgram
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-04-10 23:09:38 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:11:29 -0500
commitb708e87a63947bc963d17592ac88022b708816c3 (patch)
tree5d48fc3384ab53abd4639b842de2ac9e8d1001e8 /source4/nbt_server/dgram
parente7dd6a12913464fd752ddb94bd2f553f14007c74 (diff)
downloadsamba-b708e87a63947bc963d17592ac88022b708816c3.tar.gz
samba-b708e87a63947bc963d17592ac88022b708816c3.tar.bz2
samba-b708e87a63947bc963d17592ac88022b708816c3.zip
r6288: the nbt dgram server now responds to GETDC requests. It works with our
test suite, but doesn't yet seem to satisfy a nt4 client. I'm investigating. (This used to be commit 406217262dff5adb5d0cb0028198e08f66cc85f4)
Diffstat (limited to 'source4/nbt_server/dgram')
-rw-r--r--source4/nbt_server/dgram/netlogon.c65
1 files changed, 64 insertions, 1 deletions
diff --git a/source4/nbt_server/dgram/netlogon.c b/source4/nbt_server/dgram/netlogon.c
index 471145c4ac..e013742f0a 100644
--- a/source4/nbt_server/dgram/netlogon.c
+++ b/source4/nbt_server/dgram/netlogon.c
@@ -27,6 +27,44 @@
#include "lib/socket/socket.h"
/*
+ reply to a GETDC request
+ */
+static void nbtd_netlogon_getdc(struct dgram_mailslot_handler *dgmslot,
+ struct nbt_dgram_packet *packet,
+ const char *src_address, int src_port,
+ struct nbt_netlogon_packet *netlogon)
+{
+ struct nbt_name *name = &packet->data.msg.dest_name;
+ struct nbt_netlogon_packet reply;
+ struct nbt_netlogon_response_from_pdc *pdc;
+
+ /* only answer getdc requests on the PDC or LOGON names */
+ if (name->type != NBT_NAME_PDC && name->type != NBT_NAME_LOGON) {
+ return;
+ }
+
+ /* setup a GETDC reply */
+ reply.command = NETLOGON_RESPONSE_FROM_PDC;
+ pdc = &reply.req.response;
+
+ pdc->pdc_name = lp_netbios_name();
+ pdc->unicode_pdc_name = pdc->pdc_name;
+ pdc->domain_name = lp_workgroup();
+ pdc->nt_version = 1;
+ pdc->lmnt_token = 0xFFFF;
+ pdc->lm20_token = 0xFFFF;
+
+
+ packet->data.msg.dest_name.type = 0;
+
+ dgram_mailslot_netlogon_reply(dgmslot->dgmsock,
+ packet,
+ netlogon->req.pdc.mailslot_name,
+ &reply);
+}
+
+
+/*
handle incoming netlogon mailslot requests
*/
void nbtd_mailslot_netlogon_handler(struct dgram_mailslot_handler *dgmslot,
@@ -34,16 +72,41 @@ void nbtd_mailslot_netlogon_handler(struct dgram_mailslot_handler *dgmslot,
const char *src_address, int src_port)
{
NTSTATUS status = NT_STATUS_NO_MEMORY;
+ struct nbtd_interface *iface =
+ talloc_get_type(dgmslot->private, struct nbtd_interface);
struct nbt_netlogon_packet *netlogon =
talloc(dgmslot, struct nbt_netlogon_packet);
+ struct nbtd_iface_name *iname;
+ struct nbt_name *name = &packet->data.msg.dest_name;
+
if (netlogon == NULL) goto failed;
- DEBUG(2,("netlogon request from %s:%d\n", src_address, src_port));
+ /*
+ see if the we are listening on the destination netbios name
+ */
+ iname = nbtd_find_iname(iface, name, 0);
+ if (iname == NULL) {
+ status = NT_STATUS_BAD_NETWORK_NAME;
+ goto failed;
+ }
+
+ DEBUG(2,("netlogon request to %s from %s:%d\n",
+ nbt_name_string(netlogon, name), src_address, src_port));
status = dgram_mailslot_netlogon_parse(dgmslot, netlogon, packet, netlogon);
if (!NT_STATUS_IS_OK(status)) goto failed;
NDR_PRINT_DEBUG(nbt_netlogon_packet, netlogon);
+ switch (netlogon->command) {
+ case NETLOGON_QUERY_FOR_PDC:
+ nbtd_netlogon_getdc(dgmslot, packet, src_address, src_port, netlogon);
+ break;
+ default:
+ DEBUG(2,("unknown netlogon op %d from %s:%d\n",
+ netlogon->command, src_address, src_port));
+ break;
+ }
+
talloc_free(netlogon);
return;