~zulcss/samba/server-dailies-3.4

« back to all changes in this revision

Viewing changes to source4/lib/com/dcom/tables.c

  • Committer: Chuck Short
  • Date: 2010-09-28 20:38:39 UTC
  • Revision ID: zulcss@ubuntu.com-20100928203839-pgjulytsi9ue63x1
Initial version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
   Unix SMB/CIFS implementation.
 
3
   DCOM proxy tables functionality
 
4
   Copyright (C) 2005 Jelmer Vernooij <jelmer@samba.org>
 
5
   Copyright (C) 2006 Andrzej Hajda <andrzej.hajda@wp.pl>
 
6
 
 
7
   This program is free software; you can redistribute it and/or modify
 
8
   it under the terms of the GNU General Public License as published by
 
9
   the Free Software Foundation; either version 2 of the License, or
 
10
   (at your option) any later version.
 
11
 
 
12
   This program is distributed in the hope that it will be useful,
 
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
   GNU General Public License for more details.
 
16
 
 
17
   You should have received a copy of the GNU General Public License
 
18
   along with this program; if not, write to the Free Software
 
19
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
20
*/
 
21
 
 
22
#include "includes.h"
 
23
#include "../lib/util/dlinklist.h"
 
24
#include "librpc/gen_ndr/com_dcom.h"
 
25
#include "lib/com/dcom/dcom.h"
 
26
 
 
27
static struct dcom_proxy {
 
28
        struct IUnknown_vtable *vtable;
 
29
        struct dcom_proxy *prev, *next;
 
30
}  *proxies = NULL;
 
31
 
 
32
NTSTATUS dcom_register_proxy(struct IUnknown_vtable *proxy_vtable)
 
33
{
 
34
        struct dcom_proxy *proxy = talloc(talloc_autofree_context(), struct dcom_proxy);
 
35
 
 
36
        proxy->vtable = proxy_vtable;
 
37
        DLIST_ADD(proxies, proxy);
 
38
 
 
39
        return NT_STATUS_OK;
 
40
}
 
41
 
 
42
struct IUnknown_vtable *dcom_proxy_vtable_by_iid(struct GUID *iid)
 
43
{
 
44
        struct dcom_proxy *p;
 
45
        for (p = proxies; p; p = p->next) {
 
46
                if (GUID_equal(&p->vtable->iid, iid)) {
 
47
                        return p->vtable;
 
48
                }
 
49
        }
 
50
        return NULL;
 
51
}
 
52
 
 
53
static struct dcom_marshal {
 
54
        struct GUID clsid;
 
55
        marshal_fn marshal;
 
56
        unmarshal_fn unmarshal;
 
57
        struct dcom_marshal *prev, *next;
 
58
}  *marshals = NULL;
 
59
 
 
60
NTSTATUS dcom_register_marshal(struct GUID *clsid, marshal_fn marshal, unmarshal_fn unmarshal)
 
61
{
 
62
        struct dcom_marshal *p = talloc(talloc_autofree_context(), struct dcom_marshal);
 
63
 
 
64
        p->clsid = *clsid;
 
65
        p->marshal = marshal;
 
66
        p->unmarshal = unmarshal;
 
67
        DLIST_ADD(marshals, p);
 
68
        return NT_STATUS_OK;
 
69
}
 
70
 
 
71
_PUBLIC_ marshal_fn dcom_marshal_by_clsid(struct GUID *clsid)
 
72
{
 
73
        struct dcom_marshal *p;
 
74
        for (p = marshals; p; p = p->next) {
 
75
                if (GUID_equal(&p->clsid, clsid)) {
 
76
                        return p->marshal;
 
77
                }
 
78
        }
 
79
        return NULL;
 
80
}
 
81
 
 
82
_PUBLIC_ unmarshal_fn dcom_unmarshal_by_clsid(struct GUID *clsid)
 
83
{
 
84
        struct dcom_marshal *p;
 
85
        for (p = marshals; p; p = p->next) {
 
86
                if (GUID_equal(&p->clsid, clsid)) {
 
87
                        return p->unmarshal;
 
88
                }
 
89
        }
 
90
        return NULL;
 
91
}
 
92