LCOV - code coverage report
Current view: top level - source3/rpc_server/echo - srv_echo_nt.c (source / functions) Hit Total Coverage
Test: coverage report for fix-15632 9995c5c2 Lines: 35 43 81.4 %
Date: 2024-04-13 12:30:31 Functions: 9 10 90.0 %

          Line data    Source code
       1             : /*
       2             :  *  Unix SMB/CIFS implementation.
       3             :  *  RPC Pipe client / server routines for rpcecho
       4             :  *  Copyright (C) Tim Potter                   2003
       5             :  *  Copyright (C) Jelmer Vernooij              2006
       6             :  *  Copyright (C) Gerald (Jerry) Carter        2007
       7             :  *
       8             :  *  This program is free software; you can redistribute it and/or modify
       9             :  *  it under the terms of the GNU General Public License as published by
      10             :  *  the Free Software Foundation; either version 3 of the License, or
      11             :  *  (at your option) any later version.
      12             :  *
      13             :  *  This program is distributed in the hope that it will be useful,
      14             :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16             :  *  GNU General Public License for more details.
      17             :  *
      18             :  *  You should have received a copy of the GNU General Public License
      19             :  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
      20             :  */
      21             : 
      22             : /* This is the interface to the rpcecho pipe. */
      23             : 
      24             : #include "includes.h"
      25             : #include "ntdomain.h"
      26             : #include "librpc/gen_ndr/ndr_echo.h"
      27             : #include "librpc/gen_ndr/ndr_echo_scompat.h"
      28             : 
      29             : #undef DBGC_CLASS
      30             : #define DBGC_CLASS DBGC_RPC_SRV
      31             : 
      32             : /* Add one to the input and return it */
      33             : 
      34          56 : void _echo_AddOne(struct pipes_struct *p, struct echo_AddOne *r )
      35             : {
      36          56 :         DEBUG(10, ("_echo_AddOne\n"));
      37             : 
      38          56 :         *r->out.out_data = r->in.in_data + 1;
      39          56 : }
      40             : 
      41             : /* Echo back an array of data */
      42             : 
      43           4 : void _echo_EchoData(struct pipes_struct *p, struct echo_EchoData *r)
      44             : {
      45           4 :         DEBUG(10, ("_echo_EchoData\n"));
      46             : 
      47           4 :         if ( r->in.len == 0 ) {
      48           0 :                 r->out.out_data = NULL;
      49           0 :                 return;
      50             :         }
      51             : 
      52           4 :         r->out.out_data = talloc_array(p->mem_ctx, uint8_t, r->in.len);
      53           4 :         memcpy( r->out.out_data, r->in.in_data, r->in.len );
      54           4 :         return;
      55             : }
      56             : 
      57             : /* Sink an array of data */
      58             : 
      59           4 : void _echo_SinkData(struct pipes_struct *p, struct echo_SinkData *r)
      60             : {
      61           4 :         DEBUG(10, ("_echo_SinkData\n"));
      62             : 
      63             :         /* My that was some yummy data! */
      64           4 :         return;
      65             : }
      66             : 
      67             : /* Source an array of data */
      68             : 
      69           4 : void _echo_SourceData(struct pipes_struct *p, struct echo_SourceData *r)
      70             : {
      71           0 :         uint32_t i;
      72             : 
      73           4 :         DEBUG(10, ("_echo_SourceData\n"));
      74             : 
      75           4 :         if ( r->in.len == 0 ) {
      76           0 :                 r->out.data = NULL;
      77           0 :                 return;
      78             :         }
      79             : 
      80           4 :         r->out.data = talloc_array(p->mem_ctx, uint8_t, r->in.len );
      81             : 
      82      811881 :         for (i = 0; i < r->in.len; i++ ) {
      83      811877 :                 r->out.data[i] = i & 0xff;
      84             :         }
      85             : 
      86           4 :         return;
      87             : }
      88             : 
      89           4 : void _echo_TestCall(struct pipes_struct *p, struct echo_TestCall *r)
      90             : {
      91           4 :         p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
      92           4 :         return;
      93             : }
      94             : 
      95           4 : NTSTATUS _echo_TestCall2(struct pipes_struct *p, struct echo_TestCall2 *r)
      96             : {
      97           4 :         p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
      98           4 :         return NT_STATUS_OK;
      99             : }
     100             : 
     101           0 : uint32_t _echo_TestSleep(struct pipes_struct *p, struct echo_TestSleep *r)
     102             : {
     103           0 :         smb_msleep(r->in.seconds * 1000);
     104           0 :         return 0;
     105             : }
     106             : 
     107           4 : void _echo_TestEnum(struct pipes_struct *p, struct echo_TestEnum *r)
     108             : {
     109           4 :         p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
     110           4 :         return;
     111             : }
     112             : 
     113           4 : void _echo_TestSurrounding(struct pipes_struct *p, struct echo_TestSurrounding *r)
     114             : {
     115           4 :         p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
     116           4 :         return;
     117             : }
     118             : 
     119           4 : uint16_t _echo_TestDoublePointer(struct pipes_struct *p, struct echo_TestDoublePointer *r)
     120             : {
     121           4 :         p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
     122           4 :         return 0;
     123             : }
     124             : 
     125             : /* include the generated boilerplate */
     126             : #include "librpc/gen_ndr/ndr_echo_scompat.c"

Generated by: LCOV version 1.14