2003-12-11 01:21:04 +03:00
/*
Unix SMB / CIFS implementation .
endpoint server for the echo pipe
Copyright ( C ) Andrew Tridgell 2003
2005-01-11 19:53:02 +03:00
Copyright ( C ) Stefan ( metze ) Metzmacher 2005
2003-12-11 01:21:04 +03:00
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 0213 9 , USA .
*/
# include "includes.h"
2004-11-02 10:42:47 +03:00
# include "rpc_server/dcerpc_server.h"
2004-11-01 13:30:34 +03:00
# include "librpc/gen_ndr/ndr_echo.h"
2005-01-11 19:53:02 +03:00
# include "events.h"
2003-12-11 01:21:04 +03:00
This patch adds a better dcerpc server infastructure.
1.) We now register endpoint servers add startup via register_backend()
and later use the smb.conf 'dcerpc endpoint servers' parameter to setup the dcesrv_context
2.) each endpoint server can register at context creation time as much interfaces as it wants
(multiple interfaces on one endpoint are supported!)
(NOTE: there's a difference between 'endpoint server' and 'endpoint'!
for details look at rpc_server/dcesrv_server.h)
3.) one endpoint can have a security descriptor registered to it self
this will be checked in the future when a client wants to connect
to an smb pipe endpoint.
4.) we now have a 'remote' endpoint server, which works like the ntvfs_cifs module
it takes this options in the [globals] section:
dcerpc remote:interfaces = srvsvc, winreg, w32time, epmapper
dcerpc remote:binding = ...
dcerpc remote:user = ...
dcerpc remote:password = ...
5.) we currently have tree endpoint servers: epmapper, rpcecho and remote
the default for the 'dcerpc endpiont servers = epmapper, rpcecho'
for testing you can also do
dcerpc endpoint servers = rpcecho, remote, epmapper
dcerpc remote:interfaces = srvsvc, samr, netlogon
6,) please notice the the epmapper now only returns NO_ENTRIES
(but I think we'll find a solution for this too:-)
7.) also there're some other stuff left, but step by step :-)
This patch also includes updates for the
register_subsystem() , ntvfs_init(), and some other funtions
to check for duplicate subsystem registration
metze
(hmmm, my first large commit...I hope it works as supposed :-)
(This used to be commit 917e45dafd5be4c2cd90ff425b8d6f8403122349)
2004-01-09 01:55:27 +03:00
static NTSTATUS echo_AddOne ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx , struct echo_AddOne * r )
2003-12-12 06:59:09 +03:00
{
* r - > out . v = * r - > in . v + 1 ;
return NT_STATUS_OK ;
}
This patch adds a better dcerpc server infastructure.
1.) We now register endpoint servers add startup via register_backend()
and later use the smb.conf 'dcerpc endpoint servers' parameter to setup the dcesrv_context
2.) each endpoint server can register at context creation time as much interfaces as it wants
(multiple interfaces on one endpoint are supported!)
(NOTE: there's a difference between 'endpoint server' and 'endpoint'!
for details look at rpc_server/dcesrv_server.h)
3.) one endpoint can have a security descriptor registered to it self
this will be checked in the future when a client wants to connect
to an smb pipe endpoint.
4.) we now have a 'remote' endpoint server, which works like the ntvfs_cifs module
it takes this options in the [globals] section:
dcerpc remote:interfaces = srvsvc, winreg, w32time, epmapper
dcerpc remote:binding = ...
dcerpc remote:user = ...
dcerpc remote:password = ...
5.) we currently have tree endpoint servers: epmapper, rpcecho and remote
the default for the 'dcerpc endpiont servers = epmapper, rpcecho'
for testing you can also do
dcerpc endpoint servers = rpcecho, remote, epmapper
dcerpc remote:interfaces = srvsvc, samr, netlogon
6,) please notice the the epmapper now only returns NO_ENTRIES
(but I think we'll find a solution for this too:-)
7.) also there're some other stuff left, but step by step :-)
This patch also includes updates for the
register_subsystem() , ntvfs_init(), and some other funtions
to check for duplicate subsystem registration
metze
(hmmm, my first large commit...I hope it works as supposed :-)
(This used to be commit 917e45dafd5be4c2cd90ff425b8d6f8403122349)
2004-01-09 01:55:27 +03:00
static NTSTATUS echo_EchoData ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx , struct echo_EchoData * r )
2003-12-12 06:59:09 +03:00
{
2003-12-15 04:06:01 +03:00
if ( ! r - > in . len ) {
return NT_STATUS_OK ;
}
2005-01-06 06:06:58 +03:00
r - > out . out_data = talloc_memdup ( mem_ctx , r - > in . in_data , r - > in . len ) ;
2003-12-12 08:01:41 +03:00
if ( ! r - > out . out_data ) {
return NT_STATUS_NO_MEMORY ;
}
2003-12-12 06:59:09 +03:00
return NT_STATUS_OK ;
}
This patch adds a better dcerpc server infastructure.
1.) We now register endpoint servers add startup via register_backend()
and later use the smb.conf 'dcerpc endpoint servers' parameter to setup the dcesrv_context
2.) each endpoint server can register at context creation time as much interfaces as it wants
(multiple interfaces on one endpoint are supported!)
(NOTE: there's a difference between 'endpoint server' and 'endpoint'!
for details look at rpc_server/dcesrv_server.h)
3.) one endpoint can have a security descriptor registered to it self
this will be checked in the future when a client wants to connect
to an smb pipe endpoint.
4.) we now have a 'remote' endpoint server, which works like the ntvfs_cifs module
it takes this options in the [globals] section:
dcerpc remote:interfaces = srvsvc, winreg, w32time, epmapper
dcerpc remote:binding = ...
dcerpc remote:user = ...
dcerpc remote:password = ...
5.) we currently have tree endpoint servers: epmapper, rpcecho and remote
the default for the 'dcerpc endpiont servers = epmapper, rpcecho'
for testing you can also do
dcerpc endpoint servers = rpcecho, remote, epmapper
dcerpc remote:interfaces = srvsvc, samr, netlogon
6,) please notice the the epmapper now only returns NO_ENTRIES
(but I think we'll find a solution for this too:-)
7.) also there're some other stuff left, but step by step :-)
This patch also includes updates for the
register_subsystem() , ntvfs_init(), and some other funtions
to check for duplicate subsystem registration
metze
(hmmm, my first large commit...I hope it works as supposed :-)
(This used to be commit 917e45dafd5be4c2cd90ff425b8d6f8403122349)
2004-01-09 01:55:27 +03:00
static NTSTATUS echo_SinkData ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx , struct echo_SinkData * r )
2003-12-12 06:59:09 +03:00
{
return NT_STATUS_OK ;
}
This patch adds a better dcerpc server infastructure.
1.) We now register endpoint servers add startup via register_backend()
and later use the smb.conf 'dcerpc endpoint servers' parameter to setup the dcesrv_context
2.) each endpoint server can register at context creation time as much interfaces as it wants
(multiple interfaces on one endpoint are supported!)
(NOTE: there's a difference between 'endpoint server' and 'endpoint'!
for details look at rpc_server/dcesrv_server.h)
3.) one endpoint can have a security descriptor registered to it self
this will be checked in the future when a client wants to connect
to an smb pipe endpoint.
4.) we now have a 'remote' endpoint server, which works like the ntvfs_cifs module
it takes this options in the [globals] section:
dcerpc remote:interfaces = srvsvc, winreg, w32time, epmapper
dcerpc remote:binding = ...
dcerpc remote:user = ...
dcerpc remote:password = ...
5.) we currently have tree endpoint servers: epmapper, rpcecho and remote
the default for the 'dcerpc endpiont servers = epmapper, rpcecho'
for testing you can also do
dcerpc endpoint servers = rpcecho, remote, epmapper
dcerpc remote:interfaces = srvsvc, samr, netlogon
6,) please notice the the epmapper now only returns NO_ENTRIES
(but I think we'll find a solution for this too:-)
7.) also there're some other stuff left, but step by step :-)
This patch also includes updates for the
register_subsystem() , ntvfs_init(), and some other funtions
to check for duplicate subsystem registration
metze
(hmmm, my first large commit...I hope it works as supposed :-)
(This used to be commit 917e45dafd5be4c2cd90ff425b8d6f8403122349)
2004-01-09 01:55:27 +03:00
static NTSTATUS echo_SourceData ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx , struct echo_SourceData * r )
2003-12-12 06:59:09 +03:00
{
int i ;
for ( i = 0 ; i < r - > in . len ; i + + ) {
r - > out . data [ i ] = i ;
}
return NT_STATUS_OK ;
}
This patch adds a better dcerpc server infastructure.
1.) We now register endpoint servers add startup via register_backend()
and later use the smb.conf 'dcerpc endpoint servers' parameter to setup the dcesrv_context
2.) each endpoint server can register at context creation time as much interfaces as it wants
(multiple interfaces on one endpoint are supported!)
(NOTE: there's a difference between 'endpoint server' and 'endpoint'!
for details look at rpc_server/dcesrv_server.h)
3.) one endpoint can have a security descriptor registered to it self
this will be checked in the future when a client wants to connect
to an smb pipe endpoint.
4.) we now have a 'remote' endpoint server, which works like the ntvfs_cifs module
it takes this options in the [globals] section:
dcerpc remote:interfaces = srvsvc, winreg, w32time, epmapper
dcerpc remote:binding = ...
dcerpc remote:user = ...
dcerpc remote:password = ...
5.) we currently have tree endpoint servers: epmapper, rpcecho and remote
the default for the 'dcerpc endpiont servers = epmapper, rpcecho'
for testing you can also do
dcerpc endpoint servers = rpcecho, remote, epmapper
dcerpc remote:interfaces = srvsvc, samr, netlogon
6,) please notice the the epmapper now only returns NO_ENTRIES
(but I think we'll find a solution for this too:-)
7.) also there're some other stuff left, but step by step :-)
This patch also includes updates for the
register_subsystem() , ntvfs_init(), and some other funtions
to check for duplicate subsystem registration
metze
(hmmm, my first large commit...I hope it works as supposed :-)
(This used to be commit 917e45dafd5be4c2cd90ff425b8d6f8403122349)
2004-01-09 01:55:27 +03:00
static NTSTATUS echo_TestCall ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx , struct echo_TestCall * r )
2003-12-12 06:59:09 +03:00
{
2003-12-12 08:40:26 +03:00
r - > out . s2 = " this is a test string " ;
return NT_STATUS_OK ;
2003-12-12 06:59:09 +03:00
}
This patch adds a better dcerpc server infastructure.
1.) We now register endpoint servers add startup via register_backend()
and later use the smb.conf 'dcerpc endpoint servers' parameter to setup the dcesrv_context
2.) each endpoint server can register at context creation time as much interfaces as it wants
(multiple interfaces on one endpoint are supported!)
(NOTE: there's a difference between 'endpoint server' and 'endpoint'!
for details look at rpc_server/dcesrv_server.h)
3.) one endpoint can have a security descriptor registered to it self
this will be checked in the future when a client wants to connect
to an smb pipe endpoint.
4.) we now have a 'remote' endpoint server, which works like the ntvfs_cifs module
it takes this options in the [globals] section:
dcerpc remote:interfaces = srvsvc, winreg, w32time, epmapper
dcerpc remote:binding = ...
dcerpc remote:user = ...
dcerpc remote:password = ...
5.) we currently have tree endpoint servers: epmapper, rpcecho and remote
the default for the 'dcerpc endpiont servers = epmapper, rpcecho'
for testing you can also do
dcerpc endpoint servers = rpcecho, remote, epmapper
dcerpc remote:interfaces = srvsvc, samr, netlogon
6,) please notice the the epmapper now only returns NO_ENTRIES
(but I think we'll find a solution for this too:-)
7.) also there're some other stuff left, but step by step :-)
This patch also includes updates for the
register_subsystem() , ntvfs_init(), and some other funtions
to check for duplicate subsystem registration
metze
(hmmm, my first large commit...I hope it works as supposed :-)
(This used to be commit 917e45dafd5be4c2cd90ff425b8d6f8403122349)
2004-01-09 01:55:27 +03:00
static NTSTATUS echo_TestCall2 ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx , struct echo_TestCall2 * r )
2003-12-12 06:59:09 +03:00
{
2004-12-04 12:30:38 +03:00
r - > out . info = talloc_p ( mem_ctx , union echo_Info ) ;
2003-12-12 08:40:26 +03:00
if ( ! r - > out . info ) {
2004-05-04 10:07:52 +04:00
return NT_STATUS_NO_MEMORY ;
2003-12-12 08:40:26 +03:00
}
switch ( r - > in . level ) {
case 1 :
r - > out . info - > info1 . v = 10 ;
break ;
case 2 :
r - > out . info - > info2 . v = 20 ;
break ;
case 3 :
r - > out . info - > info3 . v = 30 ;
break ;
case 4 :
2004-05-25 17:57:39 +04:00
r - > out . info - > info4 . v = 40 ;
2003-12-12 08:40:26 +03:00
break ;
case 5 :
r - > out . info - > info5 . v1 = 50 ;
2004-05-25 17:57:39 +04:00
r - > out . info - > info5 . v2 = 60 ;
2003-12-12 08:40:26 +03:00
break ;
case 6 :
r - > out . info - > info6 . v1 = 70 ;
r - > out . info - > info6 . info1 . v = 80 ;
break ;
case 7 :
r - > out . info - > info7 . v1 = 80 ;
2004-05-25 17:57:39 +04:00
r - > out . info - > info7 . info4 . v = 90 ;
2003-12-12 08:40:26 +03:00
break ;
default :
2004-05-04 10:07:52 +04:00
return NT_STATUS_INVALID_LEVEL ;
2003-12-12 08:40:26 +03:00
}
return NT_STATUS_OK ;
2003-12-12 06:59:09 +03:00
}
2005-01-05 02:27:12 +03:00
static NTSTATUS echo_TestEnum ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx , struct echo_TestEnum * r )
{
r - > out . foo2 - > e1 = ECHO_ENUM2 ;
return NT_STATUS_OK ;
}
2005-01-11 19:53:02 +03:00
struct echo_TestSleep_private {
struct dcesrv_call_state * dce_call ;
struct echo_TestSleep * r ;
} ;
static void echo_TestSleep_handler ( struct event_context * ev , struct timed_event * te , struct timeval t )
{
struct echo_TestSleep_private * p = te - > private ;
struct echo_TestSleep * r = p - > r ;
NTSTATUS status ;
r - > out . result = r - > in . seconds ;
status = dcesrv_reply ( p - > dce_call ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
DEBUG ( 0 , ( " echo_TestSleep_handler: dcesrv_reply() failed - %s \n " ,
nt_errstr ( status ) ) ) ;
}
}
2004-08-30 11:36:16 +04:00
static long echo_TestSleep ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx , struct echo_TestSleep * r )
{
2005-01-11 19:53:02 +03:00
struct timed_event te ;
struct echo_TestSleep_private * p ;
if ( ! ( dce_call - > state_flags & DCESRV_CALL_STATE_FLAG_MAY_ASYNC ) ) {
/* we're not allowed to reply async */
sleep ( r - > in . seconds ) ;
return r - > in . seconds ;
}
/* we're allowed to reply async */
p = talloc ( mem_ctx , struct echo_TestSleep_private ) ;
if ( ! p ) {
return 0 ;
}
p - > dce_call = dce_call ;
p - > r = r ;
te . handler = echo_TestSleep_handler ;
te . private = p ;
te . next_event = timeval_add ( & dce_call - > time , r - > in . seconds , 0 ) ;
2005-01-23 15:24:36 +03:00
event_add_timed ( dce_call - > event_ctx , & te , p ) ;
2005-01-11 19:53:02 +03:00
dce_call - > state_flags | = DCESRV_CALL_STATE_FLAG_ASYNC ;
return 0 ;
2004-08-30 11:36:16 +04:00
}
2003-12-12 06:59:09 +03:00
2003-12-14 16:22:12 +03:00
/* include the generated boilerplate */
# include "librpc/gen_ndr/ndr_echo_s.c"