summaryrefslogtreecommitdiff
path: root/source4/lib/stream/packet.h
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-11-09 08:11:50 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:45:55 -0500
commit8752e38c05779b6ff72bb0bf49940ef6afe55184 (patch)
tree407d3443b924213821979611e5761ba76f7bc8c7 /source4/lib/stream/packet.h
parentf613e18d1e587782e94ae614a88ee1df4aa0503e (diff)
downloadsamba-8752e38c05779b6ff72bb0bf49940ef6afe55184.tar.gz
samba-8752e38c05779b6ff72bb0bf49940ef6afe55184.tar.bz2
samba-8752e38c05779b6ff72bb0bf49940ef6afe55184.zip
r11595: added a helper layer to parse streams into individual packets. This is
something that Andrew Bartlett has been asking for for a while, and when I started having to re-invent this packet parsing code yet again for SMB2 I decided it was time to do it generically you use it by providing a "is this a full packet yet?" helper function to the packet_*() functions, which then handle all the logic of partial packet buffering. This also goes to great lengths to operate efficiently, minimising the number of recv system calls. (This used to be commit e6c47b954a6f09c53ea419800ce873295fcd0be9)
Diffstat (limited to 'source4/lib/stream/packet.h')
-rw-r--r--source4/lib/stream/packet.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/source4/lib/stream/packet.h b/source4/lib/stream/packet.h
new file mode 100644
index 0000000000..6d29264a28
--- /dev/null
+++ b/source4/lib/stream/packet.h
@@ -0,0 +1,47 @@
+/*
+ Unix SMB/CIFS mplementation.
+
+ helper layer for breaking up streams into discrete requests
+
+ Copyright (C) Andrew Tridgell 2005
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "lib/tls/tls.h"
+
+typedef NTSTATUS (*packet_full_request_fn_t)(void *private,
+ DATA_BLOB blob, size_t *packet_size);
+typedef NTSTATUS (*packet_callback_fn_t)(void *private, DATA_BLOB blob);
+typedef void (*packet_error_handler_fn_t)(void *private, NTSTATUS status);
+
+
+
+struct packet_context *packet_init(TALLOC_CTX *mem_ctx);
+void packet_set_callback(struct packet_context *pc, packet_callback_fn_t callback);
+void packet_set_error_handler(struct packet_context *pc, packet_error_handler_fn_t handler);
+void packet_set_private(struct packet_context *pc, void *private);
+void packet_set_full_request(struct packet_context *pc, packet_full_request_fn_t callback);
+void packet_set_tls(struct packet_context *pc, struct tls_context *tls);
+void packet_set_socket(struct packet_context *pc, struct socket_context *sock);
+void packet_set_event_context(struct packet_context *pc, struct event_context *ev);
+void packet_recv(struct packet_context *pc);
+
+/*
+ pre-canned handlers
+*/
+NTSTATUS packet_full_request_nbt(void *private, DATA_BLOB blob, size_t *packet_size);
+