2003-04-11 04:09:14 +00:00
/*
* Unix SMB / CIFS implementation .
* RPC Pipe client / server routines for rpcecho
* Copyright ( C ) Tim Potter 2003.
2006-09-21 23:57:32 +00:00
* Copyright ( C ) Jelmer Vernooij 2006.
2003-04-11 04:09:14 +00: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 .
*/
/* This is the interface to the rpcecho pipe. */
# include "includes.h"
# include "nterr.h"
# ifdef DEVELOPER
# undef DBGC_CLASS
# define DBGC_CLASS DBGC_RPC_SRV
/* Add one to the input and return it */
2007-01-18 10:18:59 +00:00
void _echo_AddOne ( pipes_struct * p , struct echo_AddOne * r )
2003-04-11 04:09:14 +00:00
{
DEBUG ( 10 , ( " _echo_add_one \n " ) ) ;
2007-01-18 10:18:59 +00:00
* r - > out . out_data = r - > in . in_data + 1 ;
2003-04-11 04:09:14 +00:00
}
/* Echo back an array of data */
2007-01-18 10:18:59 +00:00
void _echo_EchoData ( pipes_struct * p , struct echo_EchoData * r )
2003-04-11 04:09:14 +00:00
{
DEBUG ( 10 , ( " _echo_data \n " ) ) ;
2007-01-18 10:18:59 +00:00
memcpy ( r - > out . out_data , r - > in . in_data , r - > in . len ) ;
2003-04-11 04:09:14 +00:00
}
/* Sink an array of data */
2007-01-18 10:18:59 +00:00
void _echo_SinkData ( pipes_struct * p , struct echo_SinkData * r )
2003-04-11 04:09:14 +00:00
{
DEBUG ( 10 , ( " _sink_data \n " ) ) ;
/* My that was some yummy data! */
}
/* Source an array of data */
2007-01-18 10:18:59 +00:00
void _echo_SourceData ( pipes_struct * p , struct echo_SourceData * r )
2003-04-11 04:09:14 +00:00
{
uint32 i ;
DEBUG ( 10 , ( " _source_data \n " ) ) ;
2007-01-18 10:18:59 +00:00
for ( i = 0 ; i < r - > in . len ; i + + )
r - > out . data [ i ] = i & 0xff ;
2006-09-15 22:49:27 +00:00
}
2003-04-11 04:09:14 +00:00
2007-01-18 10:18:59 +00:00
void _echo_TestCall ( pipes_struct * p , struct echo_TestCall * r )
2006-09-15 22:49:27 +00:00
{
2007-01-18 10:18:59 +00:00
* r - > out . s2 = talloc_strdup ( p - > mem_ctx , r - > in . s1 ) ;
2006-09-15 22:49:27 +00:00
}
2007-01-18 10:18:59 +00:00
NTSTATUS _echo_TestCall2 ( pipes_struct * p , struct echo_TestCall2 * r )
2006-09-15 22:49:27 +00:00
{
2007-01-18 10:18:59 +00:00
switch ( r - > in . level ) {
2006-09-15 22:49:27 +00:00
case 1 :
2007-01-18 10:18:59 +00:00
r - > out . info - > info1 . v = 10 ;
2006-09-15 22:49:27 +00:00
break ;
case 2 :
2007-01-18 10:18:59 +00:00
r - > out . info - > info2 . v = 20 ;
2006-09-15 22:49:27 +00:00
break ;
case 3 :
2007-01-18 10:18:59 +00:00
r - > out . info - > info3 . v = 30 ;
2006-09-15 22:49:27 +00:00
break ;
case 4 :
2007-01-18 10:18:59 +00:00
r - > out . info - > info4 . v = 40 ;
2006-09-15 22:49:27 +00:00
break ;
case 5 :
2007-01-18 10:18:59 +00:00
r - > out . info - > info5 . v1 = 50 ;
r - > out . info - > info5 . v2 = 60 ;
2006-09-15 22:49:27 +00:00
break ;
case 6 :
2007-01-18 10:18:59 +00:00
r - > out . info - > info6 . v1 = 70 ;
r - > out . info - > info6 . info1 . v = 80 ;
2006-09-15 22:49:27 +00:00
break ;
case 7 :
2007-01-18 10:18:59 +00:00
r - > out . info - > info7 . v1 = 80 ;
r - > out . info - > info7 . info4 . v = 90 ;
2006-09-15 22:49:27 +00:00
break ;
default :
return NT_STATUS_INVALID_LEVEL ;
}
return NT_STATUS_OK ;
}
2007-01-18 10:18:59 +00:00
uint32 _echo_TestSleep ( pipes_struct * p , struct echo_TestSleep * r )
2006-09-15 22:49:27 +00:00
{
2007-01-18 10:18:59 +00:00
sleep ( r - > in . seconds ) ;
return r - > in . seconds ;
2006-09-15 22:49:27 +00:00
}
2007-01-18 10:18:59 +00:00
void _echo_TestEnum ( pipes_struct * p , struct echo_TestEnum * r )
2006-09-15 22:49:27 +00:00
{
}
2007-01-18 10:18:59 +00:00
void _echo_TestSurrounding ( pipes_struct * p , struct echo_TestSurrounding * r )
2006-09-15 22:49:27 +00:00
{
2007-01-18 10:18:59 +00:00
r - > out . data - > x * = 2 ;
r - > out . data - > surrounding = talloc_zero_array ( p - > mem_ctx , uint16_t , r - > in . data - > x ) ;
2006-09-15 22:49:27 +00:00
}
2007-01-18 10:18:59 +00:00
uint16 _echo_TestDoublePointer ( pipes_struct * p , struct echo_TestDoublePointer * r )
2006-09-15 22:49:27 +00:00
{
2007-01-18 10:18:59 +00:00
if ( ! * r - > in . data )
2006-09-15 22:49:27 +00:00
return 0 ;
2007-01-18 10:18:59 +00:00
if ( ! * * r - > in . data )
2006-09-15 22:49:27 +00:00
return 0 ;
2007-01-18 10:18:59 +00:00
return * * * r - > in . data ;
2003-04-11 04:09:14 +00:00
}
# endif /* DEVELOPER */