2 Unix SMB/CIFS implementation.
4 server side dcerpc handle code
6 Copyright (C) Andrew Tridgell 2003
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/>.
23 #include "lib/util/dlinklist.h"
24 #include "rpc_server/dcerpc_server.h"
29 static int dcesrv_handle_destructor(struct dcesrv_handle
*h
)
31 DLIST_REMOVE(h
->context
->handles
, h
);
38 allocate a new rpc handle
40 _PUBLIC_
struct dcesrv_handle
*dcesrv_handle_new(struct dcesrv_connection_context
*context
,
43 struct dcesrv_handle
*h
;
45 h
= talloc(context
, struct dcesrv_handle
);
52 h
->wire_handle
.handle_type
= handle_type
;
53 h
->wire_handle
.uuid
= GUID_random();
55 DLIST_ADD(context
->handles
, h
);
57 talloc_set_destructor(h
, dcesrv_handle_destructor
);
63 find an internal handle given a wire handle. If the wire handle is NULL then
66 _PUBLIC_
struct dcesrv_handle
*dcesrv_handle_fetch(
67 struct dcesrv_connection_context
*context
,
68 struct policy_handle
*p
,
71 struct dcesrv_handle
*h
;
73 if (policy_handle_empty(p
)) {
74 return dcesrv_handle_new(context
, handle_type
);
77 for (h
=context
->handles
; h
; h
=h
->next
) {
78 if (h
->wire_handle
.handle_type
== p
->handle_type
&&
79 GUID_equal(&p
->uuid
, &h
->wire_handle
.uuid
)) {
80 if (handle_type
!= DCESRV_HANDLE_ANY
&&
81 p
->handle_type
!= handle_type
) {
82 DEBUG(0,("client gave us the wrong handle type (%d should be %d)\n",
83 p
->handle_type
, handle_type
));