r11618: added a generic '32 bit length prefix' full packet helper to the packet code
authorAndrew Tridgell <tridge@samba.org>
Thu, 10 Nov 2005 00:25:57 +0000 (00:25 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:45:59 +0000 (13:45 -0500)
(This used to be commit b4dbe55105cc2807a17d7e5bf8db9756cc526a3b)

source4/lib/stream/packet.c
source4/lib/stream/packet.h

index 3a7a938249e4612d0b82ea4136f36b20550db570..f367368defb7fb2649ef4301a5b83a25b4d0bfa6 100644 (file)
@@ -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;
+}
index 196e20a378725dff0a996f0d9b96723b6e5fb89b..bba8a1940f8b011ef8b1ffa6916dd0927ebdc9b7 100644 (file)
@@ -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);
+