LCOV - code coverage report
Current view: top level - bin/default/librpc/gen_ndr - ndr_epmapper_s.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 84 214 39.3 %
Date: 2024-04-21 15:09:00 Functions: 8 11 72.7 %

          Line data    Source code
       1             : /* server functions auto-generated by pidl */
       2             : #include "bin/default/librpc/gen_ndr/ndr_epmapper.h"
       3             : #include <util/debug.h>
       4             : 
       5             : NTSTATUS dcerpc_server_epmapper_init(TALLOC_CTX *);
       6             : 
       7             : /* epmapper - dcerpc server boilerplate generated by pidl */
       8             : 
       9             : 
      10        6276 : static NTSTATUS epmapper__op_bind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
      11             : {
      12             : #ifdef DCESRV_INTERFACE_EPMAPPER_BIND
      13        6276 :         return DCESRV_INTERFACE_EPMAPPER_BIND(context,iface);
      14             : #else
      15             :         return NT_STATUS_OK;
      16             : #endif
      17             : }
      18             : 
      19        6276 : static void epmapper__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
      20             : {
      21             : #ifdef DCESRV_INTERFACE_EPMAPPER_UNBIND
      22             :         DCESRV_INTERFACE_EPMAPPER_UNBIND(context, iface);
      23             : #else
      24        6276 :         return;
      25             : #endif
      26             : }
      27             : 
      28        6983 : static NTSTATUS epmapper__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r)
      29             : {
      30         125 :         enum ndr_err_code ndr_err;
      31        6983 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
      32             : 
      33        6983 :         dce_call->fault_code = 0;
      34             : 
      35        6983 :         if (opnum >= ndr_table_epmapper.num_calls) {
      36           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
      37           0 :                 return NT_STATUS_NET_WRITE_FAULT;
      38             :         }
      39             : 
      40       13966 :         *r = talloc_named(mem_ctx,
      41        6983 :                           ndr_table_epmapper.calls[opnum].struct_size,
      42             :                           "struct %s",
      43        6983 :                           ndr_table_epmapper.calls[opnum].name);
      44        6983 :         NT_STATUS_HAVE_NO_MEMORY(*r);
      45             : 
      46             :         /* unravel the NDR for the packet */
      47        6983 :         ndr_err = ndr_table_epmapper.calls[opnum].ndr_pull(pull, NDR_IN, *r);
      48        6983 :         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        6983 :         return NT_STATUS_OK;
      54             : }
      55             : 
      56        6983 : static NTSTATUS epmapper__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
      57             : {
      58        6983 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
      59             : 
      60        6983 :         switch (opnum) {
      61           0 :         case 0: {
      62           0 :                 struct epm_Insert *r2 = (struct epm_Insert *)r;
      63           0 :                 if (DEBUGLEVEL >= 10) {
      64           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_Insert, NDR_IN, r2);
      65             :                 }
      66           0 :                 r2->out.result = dcesrv_epm_Insert(dce_call, mem_ctx, r2);
      67           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
      68           0 :                         DEBUG(5,("function epm_Insert will reply async\n"));
      69             :                 }
      70           0 :                 break;
      71             :         }
      72           0 :         case 1: {
      73           0 :                 struct epm_Delete *r2 = (struct epm_Delete *)r;
      74           0 :                 if (DEBUGLEVEL >= 10) {
      75           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_Delete, NDR_IN, r2);
      76             :                 }
      77           0 :                 r2->out.result = dcesrv_epm_Delete(dce_call, mem_ctx, r2);
      78           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
      79           0 :                         DEBUG(5,("function epm_Delete will reply async\n"));
      80             :                 }
      81           0 :                 break;
      82             :         }
      83          54 :         case 2: {
      84          54 :                 struct epm_Lookup *r2 = (struct epm_Lookup *)r;
      85          54 :                 if (DEBUGLEVEL >= 10) {
      86           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_Lookup, NDR_IN, r2);
      87             :                 }
      88          54 :                 r2->out.result = dcesrv_epm_Lookup(dce_call, mem_ctx, r2);
      89          54 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
      90           0 :                         DEBUG(5,("function epm_Lookup will reply async\n"));
      91             :                 }
      92          54 :                 break;
      93             :         }
      94        6921 :         case 3: {
      95        6921 :                 struct epm_Map *r2 = (struct epm_Map *)r;
      96        6921 :                 if (DEBUGLEVEL >= 10) {
      97           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_Map, NDR_IN, r2);
      98             :                 }
      99        6921 :                 r2->out.result = dcesrv_epm_Map(dce_call, mem_ctx, r2);
     100        6921 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     101           0 :                         DEBUG(5,("function epm_Map will reply async\n"));
     102             :                 }
     103        6796 :                 break;
     104             :         }
     105           8 :         case 4: {
     106           8 :                 struct epm_LookupHandleFree *r2 = (struct epm_LookupHandleFree *)r;
     107           8 :                 if (DEBUGLEVEL >= 10) {
     108           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_LookupHandleFree, NDR_IN, r2);
     109             :                 }
     110           8 :                 r2->out.result = dcesrv_epm_LookupHandleFree(dce_call, mem_ctx, r2);
     111           8 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     112           0 :                         DEBUG(5,("function epm_LookupHandleFree will reply async\n"));
     113             :                 }
     114           8 :                 break;
     115             :         }
     116           0 :         case 5: {
     117           0 :                 struct epm_InqObject *r2 = (struct epm_InqObject *)r;
     118           0 :                 if (DEBUGLEVEL >= 10) {
     119           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_InqObject, NDR_IN, r2);
     120             :                 }
     121           0 :                 r2->out.result = dcesrv_epm_InqObject(dce_call, mem_ctx, r2);
     122           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     123           0 :                         DEBUG(5,("function epm_InqObject will reply async\n"));
     124             :                 }
     125           0 :                 break;
     126             :         }
     127           0 :         case 6: {
     128           0 :                 struct epm_MgmtDelete *r2 = (struct epm_MgmtDelete *)r;
     129           0 :                 if (DEBUGLEVEL >= 10) {
     130           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_MgmtDelete, NDR_IN, r2);
     131             :                 }
     132           0 :                 r2->out.result = dcesrv_epm_MgmtDelete(dce_call, mem_ctx, r2);
     133           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     134           0 :                         DEBUG(5,("function epm_MgmtDelete will reply async\n"));
     135             :                 }
     136           0 :                 break;
     137             :         }
     138           0 :         case 7: {
     139           0 :                 struct epm_MapAuth *r2 = (struct epm_MapAuth *)r;
     140           0 :                 if (DEBUGLEVEL >= 10) {
     141           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_MapAuth, NDR_IN, r2);
     142             :                 }
     143           0 :                 r2->out.result = dcesrv_epm_MapAuth(dce_call, mem_ctx, r2);
     144           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     145           0 :                         DEBUG(5,("function epm_MapAuth will reply async\n"));
     146             :                 }
     147           0 :                 break;
     148             :         }
     149             : 
     150           0 :         default:
     151           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
     152           0 :                 break;
     153             :         }
     154             : 
     155        6983 :         if (dce_call->fault_code != 0) {
     156           5 :                 return NT_STATUS_NET_WRITE_FAULT;
     157             :         }
     158             : 
     159        6978 :         return NT_STATUS_OK;
     160             : }
     161             : 
     162        6978 : static NTSTATUS epmapper__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
     163             : {
     164        6978 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
     165             : 
     166        6978 :         switch (opnum) {
     167           0 :         case 0: {
     168           0 :                 struct epm_Insert *r2 = (struct epm_Insert *)r;
     169           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     170           0 :                         DEBUG(5,("function epm_Insert replied async\n"));
     171             :                 }
     172           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     173           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_Insert, NDR_OUT | NDR_SET_VALUES, r2);
     174             :                 }
     175           0 :                 if (dce_call->fault_code != 0) {
     176           0 :                         DEBUG(2,("dcerpc_fault %s in epm_Insert\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
     177             :                 }
     178           0 :                 break;
     179             :         }
     180           0 :         case 1: {
     181           0 :                 struct epm_Delete *r2 = (struct epm_Delete *)r;
     182           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     183           0 :                         DEBUG(5,("function epm_Delete replied async\n"));
     184             :                 }
     185           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     186           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_Delete, NDR_OUT | NDR_SET_VALUES, r2);
     187             :                 }
     188           0 :                 if (dce_call->fault_code != 0) {
     189           0 :                         DEBUG(2,("dcerpc_fault %s in epm_Delete\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
     190             :                 }
     191           0 :                 break;
     192             :         }
     193          49 :         case 2: {
     194          49 :                 struct epm_Lookup *r2 = (struct epm_Lookup *)r;
     195          49 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     196           0 :                         DEBUG(5,("function epm_Lookup replied async\n"));
     197             :                 }
     198          49 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     199           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_Lookup, NDR_OUT | NDR_SET_VALUES, r2);
     200             :                 }
     201          49 :                 if (dce_call->fault_code != 0) {
     202           0 :                         DEBUG(2,("dcerpc_fault %s in epm_Lookup\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
     203             :                 }
     204          49 :                 break;
     205             :         }
     206        6921 :         case 3: {
     207        6921 :                 struct epm_Map *r2 = (struct epm_Map *)r;
     208        6921 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     209           0 :                         DEBUG(5,("function epm_Map replied async\n"));
     210             :                 }
     211        6921 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     212           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_Map, NDR_OUT | NDR_SET_VALUES, r2);
     213             :                 }
     214        6921 :                 if (dce_call->fault_code != 0) {
     215           0 :                         DEBUG(2,("dcerpc_fault %s in epm_Map\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
     216             :                 }
     217        6796 :                 break;
     218             :         }
     219           8 :         case 4: {
     220           8 :                 struct epm_LookupHandleFree *r2 = (struct epm_LookupHandleFree *)r;
     221           8 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     222           0 :                         DEBUG(5,("function epm_LookupHandleFree replied async\n"));
     223             :                 }
     224           8 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     225           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_LookupHandleFree, NDR_OUT | NDR_SET_VALUES, r2);
     226             :                 }
     227           8 :                 if (dce_call->fault_code != 0) {
     228           0 :                         DEBUG(2,("dcerpc_fault %s in epm_LookupHandleFree\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
     229             :                 }
     230           8 :                 break;
     231             :         }
     232           0 :         case 5: {
     233           0 :                 struct epm_InqObject *r2 = (struct epm_InqObject *)r;
     234           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     235           0 :                         DEBUG(5,("function epm_InqObject replied async\n"));
     236             :                 }
     237           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     238           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_InqObject, NDR_OUT | NDR_SET_VALUES, r2);
     239             :                 }
     240           0 :                 if (dce_call->fault_code != 0) {
     241           0 :                         DEBUG(2,("dcerpc_fault %s in epm_InqObject\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
     242             :                 }
     243           0 :                 break;
     244             :         }
     245           0 :         case 6: {
     246           0 :                 struct epm_MgmtDelete *r2 = (struct epm_MgmtDelete *)r;
     247           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     248           0 :                         DEBUG(5,("function epm_MgmtDelete replied async\n"));
     249             :                 }
     250           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     251           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_MgmtDelete, NDR_OUT | NDR_SET_VALUES, r2);
     252             :                 }
     253           0 :                 if (dce_call->fault_code != 0) {
     254           0 :                         DEBUG(2,("dcerpc_fault %s in epm_MgmtDelete\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
     255             :                 }
     256           0 :                 break;
     257             :         }
     258           0 :         case 7: {
     259           0 :                 struct epm_MapAuth *r2 = (struct epm_MapAuth *)r;
     260           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     261           0 :                         DEBUG(5,("function epm_MapAuth replied async\n"));
     262             :                 }
     263           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     264           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_MapAuth, NDR_OUT | NDR_SET_VALUES, r2);
     265             :                 }
     266           0 :                 if (dce_call->fault_code != 0) {
     267           0 :                         DEBUG(2,("dcerpc_fault %s in epm_MapAuth\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
     268             :                 }
     269           0 :                 break;
     270             :         }
     271             : 
     272           0 :         default:
     273           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
     274           0 :                 break;
     275             :         }
     276             : 
     277        6978 :         if (dce_call->fault_code != 0) {
     278           0 :                 return NT_STATUS_NET_WRITE_FAULT;
     279             :         }
     280             : 
     281        6978 :         return NT_STATUS_OK;
     282             : }
     283             : 
     284        6978 : static NTSTATUS epmapper__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r)
     285             : {
     286         125 :         enum ndr_err_code ndr_err;
     287        6978 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
     288             : 
     289        6978 :         ndr_err = ndr_table_epmapper.calls[opnum].ndr_push(push, NDR_OUT, r);
     290        6978 :         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     291           0 :                 dce_call->fault_code = DCERPC_FAULT_NDR;
     292           0 :                 return NT_STATUS_NET_WRITE_FAULT;
     293             :         }
     294             : 
     295        6978 :         return NT_STATUS_OK;
     296             : }
     297             : 
     298             : static const struct dcesrv_interface dcesrv_epmapper_interface = {
     299             :         .name               = "epmapper",
     300             :         .syntax_id          = {{0xe1af8308,0x5d1f,0x11c9,{0x91,0xa4},{0x08,0x00,0x2b,0x14,0xa0,0xfa}},3.0},
     301             :         .bind               = epmapper__op_bind,
     302             :         .unbind             = epmapper__op_unbind,
     303             :         .ndr_pull           = epmapper__op_ndr_pull,
     304             :         .dispatch           = epmapper__op_dispatch,
     305             :         .reply              = epmapper__op_reply,
     306             :         .ndr_push           = epmapper__op_ndr_push,
     307             :         .local              = NULL,
     308             : #ifdef DCESRV_INTERFACE_EPMAPPER_FLAGS
     309             :         .flags              = DCESRV_INTERFACE_EPMAPPER_FLAGS
     310             : #else
     311             :         .flags              = 0
     312             : #endif
     313             : };
     314             : 
     315             : 
     316          66 : static NTSTATUS epmapper__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
     317             : {
     318           2 :         int i;
     319             : #ifdef DCESRV_INTERFACE_EPMAPPER_NCACN_NP_SECONDARY_ENDPOINT
     320             :         const char *ncacn_np_secondary_endpoint =
     321             :                 DCESRV_INTERFACE_EPMAPPER_NCACN_NP_SECONDARY_ENDPOINT;
     322             : #else
     323          66 :         const char *ncacn_np_secondary_endpoint = NULL;
     324             : #endif
     325             : 
     326         330 :         for (i=0;i<ndr_table_epmapper.endpoints->count;i++) {
     327           8 :                 NTSTATUS ret;
     328         264 :                 const char *name = ndr_table_epmapper.endpoints->names[i];
     329             : 
     330         264 :                 ret = dcesrv_interface_register(dce_ctx,
     331             :                                                 name,
     332             :                                                 ncacn_np_secondary_endpoint,
     333             :                                                 &dcesrv_epmapper_interface,
     334             :                                                 NULL);
     335         264 :                 if (!NT_STATUS_IS_OK(ret)) {
     336           0 :                         DEBUG(1,("epmapper_op_init_server: failed to register endpoint '%s'\n",name));
     337           0 :                         return ret;
     338             :                 }
     339             :         }
     340             : 
     341          66 :         return NT_STATUS_OK;
     342             : }
     343             : 
     344           0 : static NTSTATUS epmapper__op_shutdown_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
     345             : {
     346           0 :         return NT_STATUS_OK;
     347             : }
     348             : 
     349           0 : static bool epmapper__op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
     350             : {
     351           0 :         if (dcesrv_epmapper_interface.syntax_id.if_version == if_version &&
     352           0 :                 GUID_equal(&dcesrv_epmapper_interface.syntax_id.uuid, uuid)) {
     353           0 :                 memcpy(iface,&dcesrv_epmapper_interface, sizeof(*iface));
     354           0 :                 return true;
     355             :         }
     356             : 
     357           0 :         return false;
     358             : }
     359             : 
     360           0 : static bool epmapper__op_interface_by_name(struct dcesrv_interface *iface, const char *name)
     361             : {
     362           0 :         if (strcmp(dcesrv_epmapper_interface.name, name)==0) {
     363           0 :                 memcpy(iface, &dcesrv_epmapper_interface, sizeof(*iface));
     364           0 :                 return true;
     365             :         }
     366             : 
     367           0 :         return false;
     368             : }
     369             : 
     370          66 : NTSTATUS dcerpc_server_epmapper_init(TALLOC_CTX *ctx)
     371             : {
     372           2 :         NTSTATUS ret;
     373           2 :         static const struct dcesrv_endpoint_server ep_server = {
     374             :             /* fill in our name */
     375             :             .name = "epmapper",
     376             : 
     377             :             /* Initialization flag */
     378             :             .initialized = false,
     379             : 
     380             :             /* fill in all the operations */
     381             : #ifdef DCESRV_INTERFACE_EPMAPPER_INIT_SERVER
     382             :             .init_server = DCESRV_INTERFACE_EPMAPPER_INIT_SERVER,
     383             : #else
     384             :             .init_server = epmapper__op_init_server,
     385             : #endif
     386             : #ifdef DCESRV_INTERFACE_EPMAPPER_SHUTDOWN_SERVER
     387             :             .shutdown_server = DCESRV_INTERFACE_EPMAPPER_SHUTDOWN_SERVER,
     388             : #else
     389             :             .shutdown_server = epmapper__op_shutdown_server,
     390             : #endif
     391             :             .interface_by_uuid = epmapper__op_interface_by_uuid,
     392             :             .interface_by_name = epmapper__op_interface_by_name
     393             :         };
     394             :         /* register ourselves with the DCERPC subsystem. */
     395          66 :         ret = dcerpc_register_ep_server(&ep_server);
     396             : 
     397          66 :         if (!NT_STATUS_IS_OK(ret)) {
     398           0 :                 DEBUG(0,("Failed to register 'epmapper' endpoint server!\n"));
     399           0 :                 return ret;
     400             :         }
     401             : 
     402          66 :         return ret;
     403             : }
     404             : 

Generated by: LCOV version 1.14