From ad6303f82fa862111c239b32b39f299e563a0802 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 28 Jan 2006 12:58:38 +0000 Subject: r13208: Clearly separate named pipes from the IPC$ NTVFS type. This allows the easy addition of additional named pipes and removes the circular dependencies between the CIFS, RPC and RAP servers. Simple tests for a custom named pipe included. (This used to be commit 898d15acbd18e3b302a856c847e08c22c5024792) --- source4/ntvfs/ipc/np_echo.c | 77 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 source4/ntvfs/ipc/np_echo.c (limited to 'source4/ntvfs/ipc/np_echo.c') diff --git a/source4/ntvfs/ipc/np_echo.c b/source4/ntvfs/ipc/np_echo.c new file mode 100644 index 0000000000..bfa0083b79 --- /dev/null +++ b/source4/ntvfs/ipc/np_echo.c @@ -0,0 +1,77 @@ +/* + Unix SMB/CIFS implementation. + DCE/RPC over named pipes support (glue between dcerpc and smb servers) + + Copyright (C) Jelmer Vernooij 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 "includes.h" +#include "lib/socket/socket.h" +#include "lib/events/events.h" +#include "rpc_server/dcerpc_server.h" +#include "ntvfs/ipc/ipc.h" + +static NTSTATUS echo_pipe_open (void *context_data, const char *path, struct auth_session_info *session_info, struct stream_connection *srv_conn, TALLOC_CTX *mem_ctx, void **private_data) +{ + *private_data = talloc_zero(mem_ctx, DATA_BLOB); + + return NT_STATUS_OK; +} + +static NTSTATUS echo_pipe_trans(void *private_data, DATA_BLOB *in, DATA_BLOB *out) +{ + memcpy(out->data, in->data, MIN(out->length,in->length)); + + return NT_STATUS_OK; +} + +static NTSTATUS echo_pipe_write(void *private_data, DATA_BLOB *out) +{ + DATA_BLOB *cache = private_data; + return data_blob_append(cache, cache, out->data, out->length); +} + +static NTSTATUS echo_pipe_read(void *private_data, DATA_BLOB *in) +{ + uint8_t *newdata; + DATA_BLOB *cache = private_data; + uint32_t numread = MIN(in->length, cache->length); + + memcpy(in->data, cache->data, numread); + + cache->length -= numread; + newdata = talloc_memdup(cache, cache+numread, cache->length); + if (newdata == NULL) + return NT_STATUS_NO_MEMORY; + + talloc_free(cache->data); + cache->data = newdata; + + return NT_STATUS_OK; +} + +const struct named_pipe_ops echo_pipe_ops = { + .open = echo_pipe_open, + .write = echo_pipe_write, + .read = echo_pipe_read, + .trans = echo_pipe_trans +}; + +NTSTATUS np_echo_init(void) +{ + return named_pipe_listen("\\PIPE\\NPECHO", &echo_pipe_ops, NULL); +} -- cgit From 713b296441ec8b1447a0bc451720a8b84fd7e1fc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 28 Jan 2006 20:08:03 +0000 Subject: r13210: Revert my named pipes patch until it passes not just 'make quicktest' but also 'make test' (This used to be commit e3d0676aee84e96e5c87bed4cd0cde75a4191953) --- source4/ntvfs/ipc/np_echo.c | 77 --------------------------------------------- 1 file changed, 77 deletions(-) (limited to 'source4/ntvfs/ipc/np_echo.c') diff --git a/source4/ntvfs/ipc/np_echo.c b/source4/ntvfs/ipc/np_echo.c index bfa0083b79..e69de29bb2 100644 --- a/source4/ntvfs/ipc/np_echo.c +++ b/source4/ntvfs/ipc/np_echo.c @@ -1,77 +0,0 @@ -/* - Unix SMB/CIFS implementation. - DCE/RPC over named pipes support (glue between dcerpc and smb servers) - - Copyright (C) Jelmer Vernooij 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 "includes.h" -#include "lib/socket/socket.h" -#include "lib/events/events.h" -#include "rpc_server/dcerpc_server.h" -#include "ntvfs/ipc/ipc.h" - -static NTSTATUS echo_pipe_open (void *context_data, const char *path, struct auth_session_info *session_info, struct stream_connection *srv_conn, TALLOC_CTX *mem_ctx, void **private_data) -{ - *private_data = talloc_zero(mem_ctx, DATA_BLOB); - - return NT_STATUS_OK; -} - -static NTSTATUS echo_pipe_trans(void *private_data, DATA_BLOB *in, DATA_BLOB *out) -{ - memcpy(out->data, in->data, MIN(out->length,in->length)); - - return NT_STATUS_OK; -} - -static NTSTATUS echo_pipe_write(void *private_data, DATA_BLOB *out) -{ - DATA_BLOB *cache = private_data; - return data_blob_append(cache, cache, out->data, out->length); -} - -static NTSTATUS echo_pipe_read(void *private_data, DATA_BLOB *in) -{ - uint8_t *newdata; - DATA_BLOB *cache = private_data; - uint32_t numread = MIN(in->length, cache->length); - - memcpy(in->data, cache->data, numread); - - cache->length -= numread; - newdata = talloc_memdup(cache, cache+numread, cache->length); - if (newdata == NULL) - return NT_STATUS_NO_MEMORY; - - talloc_free(cache->data); - cache->data = newdata; - - return NT_STATUS_OK; -} - -const struct named_pipe_ops echo_pipe_ops = { - .open = echo_pipe_open, - .write = echo_pipe_write, - .read = echo_pipe_read, - .trans = echo_pipe_trans -}; - -NTSTATUS np_echo_init(void) -{ - return named_pipe_listen("\\PIPE\\NPECHO", &echo_pipe_ops, NULL); -} -- cgit