summaryrefslogtreecommitdiff
path: root/source4/librpc/rpc/dcerpc.h
blob: 3f9241e9a3f6d1c852b581c135121fc9ad9a5cfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/* 
   Unix SMB/CIFS implementation.
   DCERPC interface structures

   Copyright (C) Tim Potter 2003
   Copyright (C) Andrew Tridgell 2003
   
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
  see http://www.opengroup.org/onlinepubs/9629399/chap12.htm for details
  of these structures

  note that the structure definitions here don't include some of the
  fields that are wire-artifacts. Those are put on the wire by the
  marshalling/unmarshalling routines in decrpc.c
*/

struct dcerpc_pipe {
	TALLOC_CTX *mem_ctx;
	uint16 fnum;
	int reference_count;
	uint32 call_id;
	uint32 srv_max_xmit_frag;
	uint32 srv_max_recv_frag;
	struct cli_tree *tree;
	unsigned flags;
};

/* dcerpc packet types */
#define DCERPC_PKT_REQUEST   0
#define DCERPC_PKT_RESPONSE  2
#define DCERPC_PKT_BIND     11
#define DCERPC_PKT_BIND_ACK 12
#define DCERPC_PKT_BIND_NAK 13

/* hdr.pfc_flags */
#define DCERPC_PFC_FLAG_FIRST   0x01
#define DCERPC_PFC_FLAG_LAST    0x02
#define DCERPC_PFC_FLAG_NOCALL  0x20

/* dcerpc pipe flags */
#define DCERPC_DEBUG_PRINT_IN 1
#define DCERPC_DEBUG_PRINT_OUT 2
#define DCERPC_DEBUG_PRINT_BOTH (DCERPC_DEBUG_PRINT_IN | DCERPC_DEBUG_PRINT_OUT)

/*
  all dcerpc packets use this structure. 
*/
struct dcerpc_packet {
	/* all requests and responses contain a dcerpc header */
	struct dcerpc_hdr {
		uint8 rpc_vers;		/* RPC version */
		uint8 rpc_vers_minor;	/* Minor version */
		uint8 ptype;		/* Packet type */
		uint8 pfc_flags;	/* Fragmentation flags */
		uint8 drep[4];		/* NDR data representation */
		uint16 frag_length;	/* Total length of fragment */
		uint16 auth_length;	/* authenticator length */
		uint32 call_id;		/* Call identifier */
	} hdr;

	union {
		struct dcerpc_bind {
			uint16 max_xmit_frag;
			uint16 max_recv_frag;
			uint32 assoc_group_id;
			uint8 num_contexts;
			struct {
				uint16 context_id;
				uint8 num_transfer_syntaxes;
				struct dcerpc_syntax_id {
					const char *uuid_str;
					uint32 if_version;
				} abstract_syntax;
				const struct dcerpc_syntax_id *transfer_syntaxes;
			} *ctx_list;
			DATA_BLOB auth_verifier;
		} bind;

		struct dcerpc_request {
			uint32 alloc_hint;
			uint16 context_id;
			uint16 opnum;
			DATA_BLOB stub_data;
			DATA_BLOB auth_verifier;
		} request;
	} in;

	union {
		struct dcerpc_bind_ack {
			uint16 max_xmit_frag;
			uint16 max_recv_frag;
			uint32 assoc_group_id;
			const char *secondary_address;
			uint8 num_results;
			struct {
				uint16 result;
				uint16 reason;
				struct dcerpc_syntax_id syntax;
			} *ctx_list;
			DATA_BLOB auth_verifier;
		} bind_ack;

		struct dcerpc_bind_nak {
			uint16 reject_reason;
			uint32 num_versions;
			uint32 *versions;
		} bind_nak;

		struct dcerpc_response {
			uint32 alloc_hint;
			uint16 context_id;
			uint8 cancel_count;
			DATA_BLOB stub_data;
			DATA_BLOB auth_verifier;		
		} response;
	} out;
};