summaryrefslogtreecommitdiff
path: root/source4/lib/stream
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-11-10 00:25:57 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:45:59 -0500
commita9d0bf80459a574ac261a635ee9f68caf0e5f3b0 (patch)
treefffbacb658b901a222caecf3b4c8bda0777e4c5a /source4/lib/stream
parenta684ff80b08bb25550f95c57fde76dbb659ad846 (diff)
downloadsamba-a9d0bf80459a574ac261a635ee9f68caf0e5f3b0.tar.gz
r11618: added a generic '32 bit length prefix' full packet helper to the packet code
(This used to be commit b4dbe55105cc2807a17d7e5bf8db9756cc526a3b)
Diffstat (limited to 'source4/lib/stream')
-rw-r--r--source4/lib/stream/packet.c21
-rw-r--r--source4/lib/stream/packet.h4
2 files changed, 21 insertions, 4 deletions
diff --git a/source4/lib/stream/packet.c b/source4/lib/stream/packet.c
index 3a7a938249e..f367368defb 100644
--- a/source4/lib/stream/packet.c
+++ b/source4/lib/stream/packet.c
@@ -388,16 +388,31 @@ NTSTATUS packet_send(struct packet_context *pc, DATA_BLOB blob)
/*
a full request checker for NBT formatted packets (first 3 bytes are length)
*/
-NTSTATUS packet_full_request_nbt(void *private, DATA_BLOB blob, size_t *packet_size)
+NTSTATUS packet_full_request_nbt(void *private, DATA_BLOB blob, size_t *size)
{
if (blob.length < 4) {
return STATUS_MORE_ENTRIES;
}
- *packet_size = 4 + smb_len(blob.data);
- if (*packet_size > blob.length) {
+ *size = 4 + smb_len(blob.data);
+ if (*size > blob.length) {
return STATUS_MORE_ENTRIES;
}
return NT_STATUS_OK;
}
+/*
+ work out if a packet is complete for protocols that use a 32 bit network byte
+ order length
+*/
+NTSTATUS packet_full_request_u32(void *private, DATA_BLOB blob, size_t *size)
+{
+ if (blob.length < 4) {
+ return STATUS_MORE_ENTRIES;
+ }
+ *size = 4 + RIVAL(blob.data, 0);
+ if (*size > blob.length) {
+ return STATUS_MORE_ENTRIES;
+ }
+ return NT_STATUS_OK;
+}
diff --git a/source4/lib/stream/packet.h b/source4/lib/stream/packet.h
index 196e20a3787..bba8a1940f8 100644
--- a/source4/lib/stream/packet.h
+++ b/source4/lib/stream/packet.h
@@ -46,5 +46,7 @@ void packet_queue_run(struct packet_context *pc);
/*
pre-canned handlers
*/
-NTSTATUS packet_full_request_nbt(void *private, DATA_BLOB blob, size_t *packet_size);
+NTSTATUS packet_full_request_nbt(void *private, DATA_BLOB blob, size_t *size);
+NTSTATUS packet_full_request_u32(void *private, DATA_BLOB blob, size_t *size);
+