2 Unix SMB/CIFS implementation.
4 dcerpc utility functions
6 Copyright (C) Andrew Tridgell 2003
7 Copyright (C) Jelmer Vernooij 2004
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "lib/util/dlinklist.h"
25 #include "librpc/ndr/libndr.h"
26 #include "librpc/ndr/ndr_table.h"
28 static struct ndr_interface_list *ndr_interfaces;
31 register a ndr interface table
33 NTSTATUS ndr_table_register(const struct ndr_interface_table *table)
35 struct ndr_interface_list *l;
37 for (l = ndr_interfaces; l; l = l->next) {
38 if (GUID_equal(&table->syntax_id.uuid, &l->table->syntax_id.uuid)) {
39 DEBUG(0, ("Attempt to register interface %s which has the "
40 "same UUID as already registered interface %s\n",
41 table->name, l->table->name));
42 return NT_STATUS_OBJECT_NAME_COLLISION;
46 l = talloc(talloc_autofree_context(), struct ndr_interface_list);
49 DLIST_ADD(ndr_interfaces, l);
55 find the pipe name for a local IDL interface
57 const char *ndr_interface_name(const struct GUID *uuid, uint32_t if_version)
59 const struct ndr_interface_list *l;
60 for (l=ndr_table_list();l;l=l->next) {
61 if (GUID_equal(&l->table->syntax_id.uuid, uuid) &&
62 l->table->syntax_id.if_version == if_version) {
63 return l->table->name;
70 find the number of calls defined by local IDL
72 int ndr_interface_num_calls(const struct GUID *uuid, uint32_t if_version)
74 const struct ndr_interface_list *l;
75 for (l=ndr_interfaces;l;l=l->next){
76 if (GUID_equal(&l->table->syntax_id.uuid, uuid) &&
77 l->table->syntax_id.if_version == if_version) {
78 return l->table->num_calls;
86 find a dcerpc interface by name
88 const struct ndr_interface_table *ndr_table_by_name(const char *name)
90 const struct ndr_interface_list *l;
91 for (l=ndr_interfaces;l;l=l->next) {
92 if (strcasecmp(l->table->name, name) == 0) {
100 find a dcerpc interface by uuid
102 const struct ndr_interface_table *ndr_table_by_uuid(const struct GUID *uuid)
104 const struct ndr_interface_list *l;
105 for (l=ndr_interfaces;l;l=l->next) {
106 if (GUID_equal(&l->table->syntax_id.uuid, uuid)) {
114 return the list of registered dcerpc_pipes
116 const struct ndr_interface_list *ndr_table_list(void)
118 return ndr_interfaces;
122 NTSTATUS ndr_table_register_builtin_tables(void);
124 NTSTATUS ndr_table_init(void)
126 static bool initialized = false;
128 if (initialized) return NT_STATUS_OK;
131 ndr_table_register_builtin_tables();