tests/krb5: Fix method for creating invalid length zeroed checksum
[Samba.git] / source3 / rpc_server / rpc_modules.c
blobbe678eb5f812e809e8d4779f8bc40adc16beb58a
1 /*
2 * Unix SMB/CIFS implementation.
4 * SMBD RPC modules
6 * Copyright (c) 2015 Ralph Boehme <slow@samba.org>
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.
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.
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/>.
22 #include "includes.h"
23 #include "rpc_server/rpc_modules.h"
25 #undef DBGC_CLASS
26 #define DBGC_CLASS DBGC_RPC_SRV
28 static struct rpc_module *rpc_modules;
30 struct rpc_module {
31 struct rpc_module *prev, *next;
32 char *name;
33 struct rpc_module_fns *fns;
36 static struct rpc_module *find_rpc_module(const char *name)
38 struct rpc_module *module = NULL;
40 for (module = rpc_modules; module != NULL; module = module->next) {
41 if (strequal(module->name, name)) {
42 return module;
46 return NULL;
49 NTSTATUS register_rpc_module(struct rpc_module_fns *fns,
50 const char *name)
52 struct rpc_module *module = find_rpc_module(name);
54 if (module != NULL) {
55 DBG_ERR("RPC module %s already loaded!\n", name);
56 return NT_STATUS_OBJECT_NAME_COLLISION;
59 module = SMB_XMALLOC_P(struct rpc_module);
60 module->name = smb_xstrdup(name);
61 module->fns = fns;
63 DLIST_ADD(rpc_modules, module);
64 DBG_NOTICE("Successfully added RPC module '%s'\n", name);
66 return NT_STATUS_OK;
69 bool setup_rpc_module(struct tevent_context *ev_ctx,
70 struct messaging_context *msg_ctx,
71 const char *name)
73 bool ok;
74 struct rpc_module *module = find_rpc_module(name);
76 if (module == NULL) {
77 return false;
80 ok = module->fns->setup(ev_ctx, msg_ctx);
81 if (!ok) {
82 DBG_ERR("calling setup for %s failed\n", name);
85 return true;
88 bool setup_rpc_modules(struct tevent_context *ev_ctx,
89 struct messaging_context *msg_ctx)
91 bool ok;
92 struct rpc_module *module = rpc_modules;
94 for (module = rpc_modules; module; module = module->next) {
95 ok = module->fns->setup(ev_ctx, msg_ctx);
96 if (!ok) {
97 DBG_ERR("calling setup for %s failed\n", module->name);
101 return true;