summaryrefslogtreecommitdiff
path: root/source4/librpc/ndr
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2003-11-26 01:16:41 +0000
committerAndrew Tridgell <tridge@samba.org>2003-11-26 01:16:41 +0000
commite0ac659917066dbf7f8fdbcc7684ce2b49dd04d9 (patch)
tree349f47df69b41ca0c9a11452e7f56e6c6c3647ce /source4/librpc/ndr
parent06942f3ddbb897c66644c253d1d2a7a21a31702e (diff)
downloadsamba-e0ac659917066dbf7f8fdbcc7684ce2b49dd04d9.tar.gz
samba-e0ac659917066dbf7f8fdbcc7684ce2b49dd04d9.tar.bz2
samba-e0ac659917066dbf7f8fdbcc7684ce2b49dd04d9.zip
signed DCERPC over TCP now works !
* moved ntlmssp code into libcli/auth/, and updated to latest ntlmssp code from samba3 (thanks Andrew! the new interface is great) * added signing/ntlmssp support in the dcerpc code * added a dcerpc_auth.c module for the various dcerpc auth mechanisms (This used to be commit c18c9b5585a3e5f7868562820c14f7cb529cdbcd)
Diffstat (limited to 'source4/librpc/ndr')
-rw-r--r--source4/librpc/ndr/ndr.c51
-rw-r--r--source4/librpc/ndr/ndr_basic.c64
2 files changed, 38 insertions, 77 deletions
diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c
index 6116150cea..9915ba4212 100644
--- a/source4/librpc/ndr/ndr.c
+++ b/source4/librpc/ndr/ndr.c
@@ -31,12 +31,14 @@
#define NDR_BASE_MARSHALL_SIZE 1024
+/*
+ only include interfaces that contain callable dcerpc functions here
+*/
const struct dcerpc_interface_table *dcerpc_pipes[] = {
&dcerpc_table_samr,
&dcerpc_table_lsarpc,
&dcerpc_table_netdfs,
&dcerpc_table_atsvc,
- &dcerpc_table_dcerpc,
&dcerpc_table_rpcecho,
&dcerpc_table_epmapper,
&dcerpc_table_eventlog,
@@ -93,31 +95,6 @@ NTSTATUS ndr_pull_subcontext(struct ndr_pull *ndr, struct ndr_pull *ndr2, uint32
}
-/* limit the remaining size of the current ndr parse structure to the
- given size, starting at the given offset
-
- this is used when a ndr packet has an explicit size on the wire, and we
- need to make sure that we don't use more data than is indicated
-
- the 'ofs' parameter indicates how many bytes back from the current
- offset in the buffer the 'size' number of bytes starts
-*/
-NTSTATUS ndr_pull_limit_size(struct ndr_pull *ndr, uint32 size, uint32 ofs)
-{
- uint32 new_size;
- new_size = ndr->offset + size - ofs;
-
- if (new_size > ndr->data_size) {
- return ndr_pull_error(ndr, NDR_ERR_BUFSIZE,
- "ndr_pull_limit_size %s %u failed",
- size, ofs);
- }
- ndr->data_size = new_size;
-
- return NT_STATUS_OK;
-}
-
-
/*
advance by 'size' bytes
*/
@@ -780,7 +757,7 @@ NTSTATUS ndr_pull_union_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, uint32 level,
pull a struct from a blob using NDR
*/
NTSTATUS ndr_pull_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p,
- NTSTATUS (*fn)(struct ndr_pull *, int ndr_flags, void *))
+ NTSTATUS (*fn)(struct ndr_pull *, int , void *))
{
struct ndr_pull *ndr;
ndr = ndr_pull_init_blob(blob, mem_ctx);
@@ -790,4 +767,24 @@ NTSTATUS ndr_pull_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p,
return fn(ndr, NDR_SCALARS|NDR_BUFFERS, p);
}
+/*
+ push a struct to a blob using NDR
+*/
+NTSTATUS ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p,
+ NTSTATUS (*fn)(struct ndr_push *, int , void *))
+{
+ NTSTATUS status;
+ struct ndr_push *ndr;
+ ndr = ndr_push_init_ctx(mem_ctx);
+ if (!ndr) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ status = fn(ndr, NDR_SCALARS|NDR_BUFFERS, p);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ *blob = ndr_push_blob(ndr);
+
+ return NT_STATUS_OK;
+}
diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c
index 1f78bc17b6..52f4d29428 100644
--- a/source4/librpc/ndr/ndr_basic.c
+++ b/source4/librpc/ndr/ndr_basic.c
@@ -257,6 +257,17 @@ NTSTATUS ndr_push_bytes(struct ndr_push *ndr, const char *data, uint32 n)
}
/*
+ push some zero bytes
+*/
+NTSTATUS ndr_push_zero(struct ndr_push *ndr, uint32 n)
+{
+ NDR_PUSH_NEED_BYTES(ndr, n);
+ memset(ndr->data + ndr->offset, 0, n);
+ ndr->offset += n;
+ return NT_STATUS_OK;
+}
+
+/*
push an array of uint8
*/
NTSTATUS ndr_push_array_uint8(struct ndr_push *ndr, int ndr_flags, const char *data, uint32 n)
@@ -299,27 +310,6 @@ void ndr_push_restore(struct ndr_push *ndr, struct ndr_push_save *save)
}
/*
- this is used when a packet has a 4 byte length field. We remember the start position
- and come back to it later to fill in the size
-*/
-NTSTATUS ndr_push_length4_start(struct ndr_push *ndr, struct ndr_push_save *save)
-{
- NDR_PUSH_ALIGN(ndr, 4);
- ndr_push_save(ndr, save);
- return ndr_push_uint32(ndr, 0);
-}
-
-NTSTATUS ndr_push_length4_end(struct ndr_push *ndr, struct ndr_push_save *save)
-{
- struct ndr_push_save save2;
- ndr_push_save(ndr, &save2);
- ndr_push_restore(ndr, save);
- NDR_CHECK(ndr_push_uint32(ndr, save2.offset - ndr->offset));
- ndr_push_restore(ndr, &save2);
- return NT_STATUS_OK;
-}
-
-/*
push a 1 if a pointer is non-NULL, otherwise 0
*/
NTSTATUS ndr_push_ptr(struct ndr_push *ndr, const void *p)
@@ -577,34 +567,6 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s)
}
/*
- push a 4 byte offset pointer, remembering where we are so we can later fill
- in the correct value
-*/
-NTSTATUS ndr_push_offset(struct ndr_push *ndr, struct ndr_push_save *ofs)
-{
- NDR_PUSH_ALIGN(ndr, 4);
- ndr_push_save(ndr, ofs);
- return ndr_push_uint32(ndr, 0);
-}
-
-/*
- fill in the correct offset in a saved offset pointer
- the offset is taken relative to 'save'
-*/
-NTSTATUS ndr_push_offset_ptr(struct ndr_push *ndr,
- struct ndr_push_save *ofs,
- struct ndr_push_save *save)
-{
- struct ndr_push_save save2;
- ndr_push_save(ndr, &save2);
- ndr_push_restore(ndr, ofs);
- NDR_CHECK(ndr_push_uint32(ndr, save2.offset - save->offset));
- ndr_push_restore(ndr, &save2);
- return NT_STATUS_OK;
-}
-
-
-/*
push a GUID
*/
NTSTATUS ndr_push_GUID(struct ndr_push *ndr, int ndr_flags, GUID *guid)
@@ -761,7 +723,9 @@ NTSTATUS GUID_from_string(const char *s, struct GUID *guid)
return NT_STATUS_OK;
}
-
+/*
+ its useful to be able to display these in debugging messages
+*/
const char *GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid)
{
return talloc_asprintf(mem_ctx,