LCOV - code coverage report
Current view: top level - bin/default/librpc/gen_ndr - ndr_backupkey_s.c (source / functions) Hit Total Coverage
Test: coverage report for abartlet/fix-coverage dd10fb34 Lines: 53 89 59.6 %
Date: 2021-09-23 10:06:22 Functions: 8 11 72.7 %

          Line data    Source code
       1             : /* server functions auto-generated by pidl */
       2             : #include "bin/default/librpc/gen_ndr/ndr_backupkey.h"
       3             : #include <util/debug.h>
       4             : 
       5             : NTSTATUS dcerpc_server_backupkey_init(TALLOC_CTX *);
       6             : 
       7             : /* backupkey - dcerpc server boilerplate generated by pidl */
       8             : 
       9             : 
      10           5 : static NTSTATUS backupkey__op_bind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
      11             : {
      12             : #ifdef DCESRV_INTERFACE_BACKUPKEY_BIND
      13           5 :         return DCESRV_INTERFACE_BACKUPKEY_BIND(context,iface);
      14             : #else
      15             :         return NT_STATUS_OK;
      16             : #endif
      17             : }
      18             : 
      19           5 : static void backupkey__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
      20             : {
      21             : #ifdef DCESRV_INTERFACE_BACKUPKEY_UNBIND
      22             :         DCESRV_INTERFACE_BACKUPKEY_UNBIND(context, iface);
      23             : #else
      24           5 :         return;
      25             : #endif
      26             : }
      27             : 
      28          69 : static NTSTATUS backupkey__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r)
      29             : {
      30             :         enum ndr_err_code ndr_err;
      31          69 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
      32             : 
      33          69 :         dce_call->fault_code = 0;
      34             : 
      35          69 :         if (opnum >= ndr_table_backupkey.num_calls) {
      36           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
      37           0 :                 return NT_STATUS_NET_WRITE_FAULT;
      38             :         }
      39             : 
      40         138 :         *r = talloc_named(mem_ctx,
      41          69 :                           ndr_table_backupkey.calls[opnum].struct_size,
      42             :                           "struct %s",
      43          69 :                           ndr_table_backupkey.calls[opnum].name);
      44          69 :         NT_STATUS_HAVE_NO_MEMORY(*r);
      45             : 
      46             :         /* unravel the NDR for the packet */
      47          69 :         ndr_err = ndr_table_backupkey.calls[opnum].ndr_pull(pull, NDR_IN, *r);
      48          69 :         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
      49           0 :                 dce_call->fault_code = DCERPC_FAULT_NDR;
      50           0 :                 return NT_STATUS_NET_WRITE_FAULT;
      51             :         }
      52             : 
      53          69 :         return NT_STATUS_OK;
      54             : }
      55             : 
      56          69 : static NTSTATUS backupkey__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
      57             : {
      58          69 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
      59             : 
      60          69 :         switch (opnum) {
      61          69 :         case 0: {
      62          69 :                 struct bkrp_BackupKey *r2 = (struct bkrp_BackupKey *)r;
      63          69 :                 if (DEBUGLEVEL >= 10) {
      64           0 :                         NDR_PRINT_FUNCTION_DEBUG(bkrp_BackupKey, NDR_IN, r2);
      65             :                 }
      66          69 :                 r2->out.result = dcesrv_bkrp_BackupKey(dce_call, mem_ctx, r2);
      67          69 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
      68           0 :                         DEBUG(5,("function bkrp_BackupKey will reply async\n"));
      69             :                 }
      70          69 :                 break;
      71             :         }
      72             : 
      73           0 :         default:
      74           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
      75           0 :                 break;
      76             :         }
      77             : 
      78          69 :         if (dce_call->fault_code != 0) {
      79           0 :                 return NT_STATUS_NET_WRITE_FAULT;
      80             :         }
      81             : 
      82          69 :         return NT_STATUS_OK;
      83             : }
      84             : 
      85          69 : static NTSTATUS backupkey__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
      86             : {
      87          69 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
      88             : 
      89          69 :         switch (opnum) {
      90          69 :         case 0: {
      91          69 :                 struct bkrp_BackupKey *r2 = (struct bkrp_BackupKey *)r;
      92          69 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
      93           0 :                         DEBUG(5,("function bkrp_BackupKey replied async\n"));
      94             :                 }
      95          69 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
      96           0 :                         NDR_PRINT_FUNCTION_DEBUG(bkrp_BackupKey, NDR_OUT | NDR_SET_VALUES, r2);
      97             :                 }
      98          69 :                 if (dce_call->fault_code != 0) {
      99           0 :                         DEBUG(2,("dcerpc_fault %s in bkrp_BackupKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
     100             :                 }
     101          69 :                 break;
     102             :         }
     103             : 
     104           0 :         default:
     105           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
     106           0 :                 break;
     107             :         }
     108             : 
     109          69 :         if (dce_call->fault_code != 0) {
     110           0 :                 return NT_STATUS_NET_WRITE_FAULT;
     111             :         }
     112             : 
     113          69 :         return NT_STATUS_OK;
     114             : }
     115             : 
     116          69 : static NTSTATUS backupkey__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r)
     117             : {
     118             :         enum ndr_err_code ndr_err;
     119          69 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
     120             : 
     121          69 :         ndr_err = ndr_table_backupkey.calls[opnum].ndr_push(push, NDR_OUT, r);
     122          69 :         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     123           0 :                 dce_call->fault_code = DCERPC_FAULT_NDR;
     124           0 :                 return NT_STATUS_NET_WRITE_FAULT;
     125             :         }
     126             : 
     127          69 :         return NT_STATUS_OK;
     128             : }
     129             : 
     130             : static const struct dcesrv_interface dcesrv_backupkey_interface = {
     131             :         .name               = "backupkey",
     132             :         .syntax_id          = {{0x3dde7c30,0x165d,0x11d1,{0xab,0x8f},{0x00,0x80,0x5f,0x14,0xdb,0x40}},1.0},
     133             :         .bind               = backupkey__op_bind,
     134             :         .unbind             = backupkey__op_unbind,
     135             :         .ndr_pull           = backupkey__op_ndr_pull,
     136             :         .dispatch           = backupkey__op_dispatch,
     137             :         .reply              = backupkey__op_reply,
     138             :         .ndr_push           = backupkey__op_ndr_push,
     139             :         .local              = NULL,
     140             : #ifdef DCESRV_INTERFACE_BACKUPKEY_FLAGS
     141             :         .flags              = DCESRV_INTERFACE_BACKUPKEY_FLAGS
     142             : #else
     143             :         .flags              = 0
     144             : #endif
     145             : };
     146             : 
     147             : 
     148          62 : static NTSTATUS backupkey__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
     149             : {
     150             :         int i;
     151             : #ifdef DCESRV_INTERFACE_BACKUPKEY_NCACN_NP_SECONDARY_ENDPOINT
     152             :         const char *ncacn_np_secondary_endpoint =
     153             :                 DCESRV_INTERFACE_BACKUPKEY_NCACN_NP_SECONDARY_ENDPOINT;
     154             : #else
     155          62 :         const char *ncacn_np_secondary_endpoint = NULL;
     156             : #endif
     157             : 
     158         248 :         for (i=0;i<ndr_table_backupkey.endpoints->count;i++) {
     159             :                 NTSTATUS ret;
     160         186 :                 const char *name = ndr_table_backupkey.endpoints->names[i];
     161             : 
     162         186 :                 ret = dcesrv_interface_register(dce_ctx,
     163             :                                                 name,
     164             :                                                 ncacn_np_secondary_endpoint,
     165             :                                                 &dcesrv_backupkey_interface,
     166             :                                                 NULL);
     167         186 :                 if (!NT_STATUS_IS_OK(ret)) {
     168           0 :                         DEBUG(1,("backupkey_op_init_server: failed to register endpoint '%s'\n",name));
     169           0 :                         return ret;
     170             :                 }
     171             :         }
     172             : 
     173          62 :         return NT_STATUS_OK;
     174             : }
     175             : 
     176           0 : static NTSTATUS backupkey__op_shutdown_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
     177             : {
     178           0 :         return NT_STATUS_OK;
     179             : }
     180             : 
     181           0 : static bool backupkey__op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
     182             : {
     183           0 :         if (dcesrv_backupkey_interface.syntax_id.if_version == if_version &&
     184           0 :                 GUID_equal(&dcesrv_backupkey_interface.syntax_id.uuid, uuid)) {
     185           0 :                 memcpy(iface,&dcesrv_backupkey_interface, sizeof(*iface));
     186           0 :                 return true;
     187             :         }
     188             : 
     189           0 :         return false;
     190             : }
     191             : 
     192           0 : static bool backupkey__op_interface_by_name(struct dcesrv_interface *iface, const char *name)
     193             : {
     194           0 :         if (strcmp(dcesrv_backupkey_interface.name, name)==0) {
     195           0 :                 memcpy(iface, &dcesrv_backupkey_interface, sizeof(*iface));
     196           0 :                 return true;
     197             :         }
     198             : 
     199           0 :         return false;
     200             : }
     201             : 
     202          64 : NTSTATUS dcerpc_server_backupkey_init(TALLOC_CTX *ctx)
     203             : {
     204             :         NTSTATUS ret;
     205             :         static const struct dcesrv_endpoint_server ep_server = {
     206             :             /* fill in our name */
     207             :             .name = "backupkey",
     208             : 
     209             :             /* Initialization flag */
     210             :             .initialized = false,
     211             : 
     212             :             /* fill in all the operations */
     213             : #ifdef DCESRV_INTERFACE_BACKUPKEY_INIT_SERVER
     214             :             .init_server = DCESRV_INTERFACE_BACKUPKEY_INIT_SERVER,
     215             : #else
     216             :             .init_server = backupkey__op_init_server,
     217             : #endif
     218             : #ifdef DCESRV_INTERFACE_BACKUPKEY_SHUTDOWN_SERVER
     219             :             .shutdown_server = DCESRV_INTERFACE_BACKUPKEY_SHUTDOWN_SERVER,
     220             : #else
     221             :             .shutdown_server = backupkey__op_shutdown_server,
     222             : #endif
     223             :             .interface_by_uuid = backupkey__op_interface_by_uuid,
     224             :             .interface_by_name = backupkey__op_interface_by_name
     225             :         };
     226             :         /* register ourselves with the DCERPC subsystem. */
     227          64 :         ret = dcerpc_register_ep_server(&ep_server);
     228             : 
     229          64 :         if (!NT_STATUS_IS_OK(ret)) {
     230           0 :                 DEBUG(0,("Failed to register 'backupkey' endpoint server!\n"));
     231           0 :                 return ret;
     232             :         }
     233             : 
     234          64 :         return ret;
     235             : }
     236             : 

Generated by: LCOV version 1.13