summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/dgram/libdgram.h6
-rw-r--r--source4/libcli/dgram/mailslot.c7
-rw-r--r--source4/libcli/dgram/netlogon.c33
3 files changed, 44 insertions, 2 deletions
diff --git a/source4/libcli/dgram/libdgram.h b/source4/libcli/dgram/libdgram.h
index 0b8157f0c6..163cb1e37d 100644
--- a/source4/libcli/dgram/libdgram.h
+++ b/source4/libcli/dgram/libdgram.h
@@ -116,14 +116,20 @@ NTSTATUS dgram_mailslot_send(struct nbt_dgram_socket *dgmsock,
const char *mailslot_name,
struct nbt_name *dest_name,
const char *dest_address,
+ int dest_port,
struct nbt_name *src_name,
DATA_BLOB *request);
NTSTATUS dgram_mailslot_netlogon_send(struct nbt_dgram_socket *dgmsock,
struct nbt_name *dest_name,
const char *dest_address,
+ int dest_port,
struct nbt_name *src_name,
struct nbt_netlogon_packet *request);
+NTSTATUS dgram_mailslot_netlogon_reply(struct nbt_dgram_socket *dgmsock,
+ struct nbt_dgram_packet *request,
+ const char *mailslot_name,
+ struct nbt_netlogon_packet *reply);
NTSTATUS dgram_mailslot_netlogon_parse(struct dgram_mailslot_handler *dgmslot,
TALLOC_CTX *mem_ctx,
struct nbt_dgram_packet *dgram,
diff --git a/source4/libcli/dgram/mailslot.c b/source4/libcli/dgram/mailslot.c
index 3b7fcdcd81..1035853240 100644
--- a/source4/libcli/dgram/mailslot.c
+++ b/source4/libcli/dgram/mailslot.c
@@ -142,6 +142,7 @@ NTSTATUS dgram_mailslot_send(struct nbt_dgram_socket *dgmsock,
const char *mailslot_name,
struct nbt_name *dest_name,
const char *dest_address,
+ int dest_port,
struct nbt_name *src_name,
DATA_BLOB *request)
{
@@ -152,6 +153,10 @@ NTSTATUS dgram_mailslot_send(struct nbt_dgram_socket *dgmsock,
struct smb_trans_body *trans;
NTSTATUS status;
+ if (dest_port == 0) {
+ dest_port = lp_dgram_port();
+ }
+
ZERO_STRUCT(packet);
packet.msg_type = msg_type;
packet.flags = DGRAM_FLAG_FIRST;
@@ -183,7 +188,7 @@ NTSTATUS dgram_mailslot_send(struct nbt_dgram_socket *dgmsock,
trans->mailslot_name = mailslot_name;
trans->data = *request;
- status = nbt_dgram_send(dgmsock, &packet, dest_address, lp_dgram_port());
+ status = nbt_dgram_send(dgmsock, &packet, dest_address, dest_port);
talloc_free(tmp_ctx);
diff --git a/source4/libcli/dgram/netlogon.c b/source4/libcli/dgram/netlogon.c
index 869e99e2fc..138cc0d484 100644
--- a/source4/libcli/dgram/netlogon.c
+++ b/source4/libcli/dgram/netlogon.c
@@ -34,6 +34,7 @@
NTSTATUS dgram_mailslot_netlogon_send(struct nbt_dgram_socket *dgmsock,
struct nbt_name *dest_name,
const char *dest_address,
+ int dest_port,
struct nbt_name *src_name,
struct nbt_netlogon_packet *request)
{
@@ -51,7 +52,37 @@ NTSTATUS dgram_mailslot_netlogon_send(struct nbt_dgram_socket *dgmsock,
status = dgram_mailslot_send(dgmsock, DGRAM_DIRECT_UNIQUE,
NBT_MAILSLOT_NETLOGON,
- dest_name, dest_address, src_name, &blob);
+ dest_name, dest_address, dest_port,
+ src_name, &blob);
+ talloc_free(tmp_ctx);
+ return status;
+}
+
+
+/*
+ send a netlogon mailslot reply
+*/
+NTSTATUS dgram_mailslot_netlogon_reply(struct nbt_dgram_socket *dgmsock,
+ struct nbt_dgram_packet *request,
+ const char *mailslot_name,
+ struct nbt_netlogon_packet *reply)
+{
+ NTSTATUS status;
+ DATA_BLOB blob;
+ TALLOC_CTX *tmp_ctx = talloc_new(dgmsock);
+
+ status = ndr_push_struct_blob(&blob, tmp_ctx, reply,
+ (ndr_push_flags_fn_t)ndr_push_nbt_netlogon_packet);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(tmp_ctx);
+ return status;
+ }
+
+ status = dgram_mailslot_send(dgmsock, DGRAM_DIRECT_UNIQUE,
+ mailslot_name,
+ &request->data.msg.source_name,
+ request->source, request->src_port,
+ &request->data.msg.dest_name, &blob);
talloc_free(tmp_ctx);
return status;
}