r4640: first stage in the server side support for multiple context_ids on one pipe
[Samba/gebeck_regimport.git] / source4 / rpc_server / common / common.h
blob67c758a698982d45976958087fa67c518b9cf91d
1 /*
2 Unix SMB/CIFS implementation.
4 common macros for the dcerpc server interfaces
6 Copyright (C) Stefan (metze) Metzmacher 2004
7 Copyright (C) Andrew Tridgell 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 2 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, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #define NTSTATUS_TALLOC_CHECK(x) do {\
25 if (!(x)) return NT_STATUS_NO_MEMORY;\
26 } while (0)
28 #define WERR_TALLOC_CHECK(x) do {\
29 if (!(x)) return WERR_NOMEM;\
30 } while (0)
32 /* a useful macro for generating a RPC fault in the backend code */
33 #define DCESRV_FAULT(code) do { \
34 dce_call->fault_code = code; \
35 return r->out.result; \
36 } while(0)
38 /* a useful macro for checking the validity of a dcerpc policy handle
39 and giving the right fault code if invalid */
40 #define DCESRV_CHECK_HANDLE(h) do {if (!(h)) DCESRV_FAULT(DCERPC_FAULT_CONTEXT_MISMATCH); } while (0)
42 /* this checks for a valid policy handle, and gives a fault if an
43 invalid handle or retval if the handle is of the
44 wrong type */
45 #define DCESRV_PULL_HANDLE_RETVAL(h, inhandle, t, retval) do { \
46 (h) = dcesrv_handle_fetch(dce_call->context, (inhandle), DCESRV_HANDLE_ANY); \
47 DCESRV_CHECK_HANDLE(h); \
48 if ((t) != DCESRV_HANDLE_ANY && (h)->wire_handle.handle_type != (t)) { \
49 return retval; \
50 } \
51 } while (0)
53 /* this checks for a valid policy handle and gives a dcerpc fault
54 if its the wrong type of handle */
55 #define DCESRV_PULL_HANDLE_FAULT(h, inhandle, t) do { \
56 (h) = dcesrv_handle_fetch(dce_call->context, (inhandle), t); \
57 DCESRV_CHECK_HANDLE(h); \
58 } while (0)
60 #define DCESRV_PULL_HANDLE(h, inhandle, t) DCESRV_PULL_HANDLE_RETVAL(h, inhandle, t, NT_STATUS_INVALID_HANDLE)
61 #define DCESRV_PULL_HANDLE_WERR(h, inhandle, t) DCESRV_PULL_HANDLE_RETVAL(h, inhandle, t, WERR_BADFID)