include/rpc_dce.h

説明を見る。
00001 /* 
00002    Unix SMB/CIFS implementation.
00003    SMB parameters and setup
00004    Copyright (C) Andrew Tridgell 1992-1997
00005    Copyright (C) Luke Kenneth Casson Leighton 1996-1997
00006    Copyright (C) Paul Ashton 1997
00007    
00008    This program is free software; you can redistribute it and/or modify
00009    it under the terms of the GNU General Public License as published by
00010    the Free Software Foundation; either version 2 of the License, or
00011    (at your option) any later version.
00012    
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017    
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the Free Software
00020    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00021 */
00022 
00023 #ifndef _DCE_RPC_H /* _DCE_RPC_H */
00024 #define _DCE_RPC_H 
00025 
00026 /* DCE/RPC packet types */
00027 
00028 enum RPC_PKT_TYPE {
00029         RPC_REQUEST  = 0x00,    /* Ordinary request. */
00030         RPC_PING     = 0x01,    /* Connectionless is server alive ? */
00031         RPC_RESPONSE = 0x02,    /* Ordinary reply. */
00032         RPC_FAULT    = 0x03,    /* Fault in processing of call. */
00033         RPC_WORKING  = 0x04,    /* Connectionless reply to a ping when server busy. */
00034         RPC_NOCALL   = 0x05,    /* Connectionless reply to a ping when server has lost part of clients call. */
00035         RPC_REJECT   = 0x06,    /* Refuse a request with a code. */
00036         RPC_ACK      = 0x07,    /* Connectionless client to server code. */
00037         RPC_CL_CANCEL= 0x08,    /* Connectionless cancel. */
00038         RPC_FACK     = 0x09,    /* Connectionless fragment ack. Both client and server send. */
00039         RPC_CANCEL_ACK = 0x0A,  /* Server ACK to client cancel request. */
00040         RPC_BIND     = 0x0B,    /* Bind to interface. */
00041         RPC_BINDACK  = 0x0C,    /* Server ack of bind. */
00042         RPC_BINDNACK = 0x0D,    /* Server nack of bind. */
00043         RPC_ALTCONT  = 0x0E,    /* Alter auth. */
00044         RPC_ALTCONTRESP = 0x0F, /* Reply to alter auth. */
00045         RPC_AUTH3    = 0x10,    /* not the real name!  this is undocumented! */
00046         RPC_SHUTDOWN = 0x11,    /* Server to client request to shutdown. */
00047         RPC_CO_CANCEL= 0x12,    /* Connection-oriented cancel request. */
00048         RPC_ORPHANED = 0x13     /* Client telling server it's aborting a partially sent request or telling
00049                                    server to stop sending replies. */
00050 };
00051 
00052 /* DCE/RPC flags */
00053 #define RPC_FLG_FIRST 0x01
00054 #define RPC_FLG_LAST  0x02
00055 #define RPC_FLG_NOCALL 0x20
00056 
00057 
00058 #define SMBD_NTLMSSP_NEG_FLAGS 0x000082b1 /* ALWAYS_SIGN|NEG_NTLM|NEG_LM|NEG_SEAL|NEG_SIGN|NEG_UNICODE */
00059 
00060 /* NTLMSSP signature version */
00061 #define NTLMSSP_SIGN_VERSION 0x01
00062 
00063 /* DCE RPC auth types - extended by Microsoft. */
00064 #define RPC_ANONYMOUS_AUTH_TYPE    0
00065 #define RPC_AUTH_TYPE_KRB5_1       1
00066 #define RPC_SPNEGO_AUTH_TYPE       9 
00067 #define RPC_NTLMSSP_AUTH_TYPE     10
00068 #define RPC_KRB5_AUTH_TYPE        16 /* Not yet implemented. */ 
00069 #define RPC_SCHANNEL_AUTH_TYPE    68 /* 0x44 */
00070 
00071 /* DCE-RPC standard identifiers to indicate 
00072    signing or sealing of an RPC pipe */
00073 #define RPC_AUTH_LEVEL_NONE      1
00074 #define RPC_AUTH_LEVEL_CONNECT   2
00075 #define RPC_AUTH_LEVEL_CALL      3
00076 #define RPC_AUTH_LEVEL_PACKET    4
00077 #define RPC_AUTH_LEVEL_INTEGRITY 5
00078 #define RPC_AUTH_LEVEL_PRIVACY   6
00079 
00080 #if 0
00081 #define RPC_PIPE_AUTH_SIGN_LEVEL 0x5
00082 #define RPC_PIPE_AUTH_SEAL_LEVEL 0x6
00083 #endif
00084 
00085 #define DCERPC_FAULT_OP_RNG_ERROR       0x1c010002
00086 #define DCERPC_FAULT_UNK_IF             0x1c010003
00087 #define DCERPC_FAULT_INVALID_TAG        0x1c000006
00088 #define DCERPC_FAULT_CONTEXT_MISMATCH   0x1c00001a
00089 #define DCERPC_FAULT_OTHER              0x00000001
00090 #define DCERPC_FAULT_ACCESS_DENIED      0x00000005
00091 #define DCERPC_FAULT_CANT_PERFORM       0x000006d8
00092 #define DCERPC_FAULT_NDR                0x000006f7
00093 
00094 
00095 /* Netlogon schannel auth type and level */
00096 #define SCHANNEL_SIGN_SIGNATURE { 0x77, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00 }
00097 #define SCHANNEL_SEAL_SIGNATURE { 0x77, 0x00, 0x7a, 0x00, 0xff, 0xff, 0x00, 0x00 }
00098 
00099 #define RPC_AUTH_SCHANNEL_SIGN_OR_SEAL_CHK_LEN  0x20
00100 #define RPC_AUTH_SCHANNEL_SIGN_ONLY_CHK_LEN     0x18
00101 
00102 
00103 #define NETLOGON_NEG_ARCFOUR                    0x00000004
00104 #define NETLOGON_NEG_128BIT                     0x00004000
00105 #define NETLOGON_NEG_SCHANNEL                   0x40000000
00106 
00107 #define NETLOGON_NEG_PASSWORD_SET2              0x00020000
00108 
00109 /* The 7 here seems to be required to get Win2k not to downgrade us
00110    to NT4.  Actually, anything other than 1ff would seem to do... */
00111 #define NETLOGON_NEG_AUTH2_FLAGS 0x000701ff
00112 #define NETLOGON_NEG_DOMAIN_TRUST_ACCOUNT       0x2010b000
00113 
00114 /* these are the flags that ADS clients use */
00115 #define NETLOGON_NEG_AUTH2_ADS_FLAGS 0x600fffff
00116 
00117 enum schannel_direction {
00118         SENDER_IS_INITIATOR,
00119         SENDER_IS_ACCEPTOR
00120 };
00121 
00122 /* Maximum size of the signing data in a fragment. */
00123 #define RPC_MAX_SIGN_SIZE 0x20 /* 32 */
00124 
00125 /* Maximum PDU fragment size. */
00126 /* #define MAX_PDU_FRAG_LEN 0x1630              this is what wnt sets */
00127 #define RPC_MAX_PDU_FRAG_LEN 0x10b8                     /* this is what w2k sets */
00128 
00129 /* RPC_IFACE */
00130 typedef struct rpc_iface_info {
00131         struct GUID uuid;  /* 16 bytes of rpc interface identification */
00132         uint32 version;    /* the interface version number */
00133 } RPC_IFACE;
00134 
00135 #define RPC_IFACE_LEN (UUID_SIZE + 4)
00136 
00137 struct pipe_id_info {
00138         /* the names appear not to matter: the syntaxes _do_ matter */
00139 
00140         const char *client_pipe;
00141         RPC_IFACE abstr_syntax; /* this one is the abstract syntax id */
00142 
00143         const char *server_pipe;  /* this one is the secondary syntax name */
00144         RPC_IFACE trans_syntax; /* this one is the primary syntax id */
00145 };
00146 
00147 /* RPC_HDR - dce rpc header */
00148 typedef struct rpc_hdr_info {
00149         uint8  major; /* 5 - RPC major version */
00150         uint8  minor; /* 0 - RPC minor version */
00151         uint8  pkt_type; /* RPC_PKT_TYPE - RPC response packet */
00152         uint8  flags; /* DCE/RPC flags */
00153         uint8  pack_type[4]; /* 0x1000 0000 - little-endian packed data representation */
00154         uint16 frag_len; /* fragment length - data size (bytes) inc header and tail. */
00155         uint16 auth_len; /* 0 - authentication length  */
00156         uint32 call_id; /* call identifier.  matches 12th uint32 of incoming RPC data. */
00157 } RPC_HDR;
00158 
00159 #define RPC_HEADER_LEN 16
00160 
00161 /* RPC_HDR_REQ - ms request rpc header */
00162 typedef struct rpc_hdr_req_info {
00163         uint32 alloc_hint;   /* allocation hint - data size (bytes) minus header and tail. */
00164         uint16 context_id;   /* presentation context identifier */
00165         uint16  opnum;       /* opnum */
00166 } RPC_HDR_REQ;
00167 
00168 #define RPC_HDR_REQ_LEN 8
00169 
00170 /* RPC_HDR_RESP - ms response rpc header */
00171 typedef struct rpc_hdr_resp_info {
00172         uint32 alloc_hint;   /* allocation hint - data size (bytes) minus header and tail. */
00173         uint16 context_id;   /* 0 - presentation context identifier */
00174         uint8  cancel_count; /* 0 - cancel count */
00175         uint8  reserved;     /* 0 - reserved. */
00176 } RPC_HDR_RESP;
00177 
00178 #define RPC_HDR_RESP_LEN 8
00179 
00180 /* RPC_HDR_FAULT - fault rpc header */
00181 typedef struct rpc_hdr_fault_info {
00182         NTSTATUS status;
00183         uint32 reserved; /* 0x0000 0000 */
00184 } RPC_HDR_FAULT;
00185 
00186 #define RPC_HDR_FAULT_LEN 8
00187 
00188 /* this seems to be the same string name depending on the name of the pipe,
00189  * but is more likely to be linked to the interface name
00190  * "srvsvc", "\\PIPE\\ntsvcs"
00191  * "samr", "\\PIPE\\lsass"
00192  * "wkssvc", "\\PIPE\\wksvcs"
00193  * "NETLOGON", "\\PIPE\\NETLOGON"
00194  */
00195 /* RPC_ADDR_STR */
00196 typedef struct rpc_addr_info {
00197         uint16 len;   /* length of the string including null terminator */
00198         fstring str; /* the string above in single byte, null terminated form */
00199 } RPC_ADDR_STR;
00200 
00201 /* RPC_HDR_BBA - bind acknowledge, and alter context response. */
00202 typedef struct rpc_hdr_bba_info {
00203         uint16 max_tsize;       /* maximum transmission fragment size (0x1630) */
00204         uint16 max_rsize;       /* max receive fragment size (0x1630) */
00205         uint32 assoc_gid;       /* associated group id (0x0) */
00206 } RPC_HDR_BBA;
00207 
00208 #define RPC_HDR_BBA_LEN 8
00209 
00210 /* RPC_HDR_AUTH */
00211 typedef struct rpc_hdr_auth_info {
00212         uint8 auth_type; /* See XXX_AUTH_TYPE above. */
00213         uint8 auth_level; /* See RPC_PIPE_AUTH_XXX_LEVEL above. */
00214         uint8 auth_pad_len;
00215         uint8 auth_reserved;
00216         uint32 auth_context_id;
00217 } RPC_HDR_AUTH;
00218 
00219 #define RPC_HDR_AUTH_LEN 8
00220 
00221 /* this is TEMPORARILY coded up as a specific structure */
00222 /* this structure comes after the bind request */
00223 /* RPC_AUTH_SCHANNEL_NEG */
00224 typedef struct rpc_auth_schannel_neg_info {
00225         uint32 type1;   /* Always zero ? */
00226         uint32 type2;   /* Types 0x3 and 0x13 seen. Check AcquireSecurityContext() docs.... */
00227         fstring domain; /* calling workstations's domain */
00228         fstring myname; /* calling workstation's name */
00229 } RPC_AUTH_SCHANNEL_NEG;
00230 
00231 /* attached to the end of encrypted rpc requests and responses */
00232 /* RPC_AUTH_SCHANNEL_CHK */
00233 typedef struct rpc_auth_schannel_chk_info {
00234         uint8 sig  [8]; /* 77 00 7a 00 ff ff 00 00 */
00235         uint8 packet_digest[8]; /* checksum over the packet, MD5'ed with session key */
00236         uint8 seq_num[8]; /* verifier, seq num */
00237         uint8 confounder[8]; /* random 8-byte nonce */
00238 } RPC_AUTH_SCHANNEL_CHK;
00239 
00240 typedef struct rpc_context {
00241         uint16 context_id;              /* presentation context identifier. */
00242         uint8 num_transfer_syntaxes;    /* the number of syntaxes */
00243         RPC_IFACE abstract;             /* num and vers. of interface client is using */
00244         RPC_IFACE *transfer;            /* Array of transfer interfaces. */
00245 } RPC_CONTEXT;
00246 
00247 /* RPC_BIND_REQ - ms req bind */
00248 typedef struct rpc_bind_req_info {
00249         RPC_HDR_BBA bba;
00250         uint8 num_contexts;    /* the number of contexts */
00251         RPC_CONTEXT *rpc_context;
00252 } RPC_HDR_RB;
00253 
00254 /* 
00255  * The following length is 8 bytes RPC_HDR_BBA_LEN + 
00256  * 4 bytes size of context count +
00257  * (context_count * (4 bytes of context_id, size of transfer syntax count + RPC_IFACE_LEN bytes +
00258  *                    (transfer_syntax_count * RPC_IFACE_LEN bytes)))
00259  */
00260 
00261 #define RPC_HDR_RB_LEN(rpc_hdr_rb) (RPC_HDR_BBA_LEN + 4 + \
00262         ((rpc_hdr_rb)->num_contexts) * (4 + RPC_IFACE_LEN + (((rpc_hdr_rb)->rpc_context->num_transfer_syntaxes)*RPC_IFACE_LEN)))
00263 
00264 /* RPC_RESULTS - can only cope with one reason, right now... */
00265 typedef struct rpc_results_info {
00266         /* uint8[] # 4-byte alignment padding, against SMB header */
00267 
00268         uint8 num_results; /* the number of results (0x01) */
00269 
00270         /* uint8[] # 4-byte alignment padding, against SMB header */
00271 
00272         uint16 result; /* result (0x00 = accept) */
00273         uint16 reason; /* reason (0x00 = no reason specified) */
00274 } RPC_RESULTS;
00275 
00276 /* RPC_HDR_BA */
00277 typedef struct rpc_hdr_ba_info {
00278         RPC_HDR_BBA bba;
00279 
00280         RPC_ADDR_STR addr    ;  /* the secondary address string, as described earlier */
00281         RPC_RESULTS  res     ; /* results and reasons */
00282         RPC_IFACE    transfer; /* the transfer syntax from the request */
00283 } RPC_HDR_BA;
00284 
00285 /* RPC_AUTH_VERIFIER */
00286 typedef struct rpc_auth_verif_info {
00287         fstring signature; /* "NTLMSSP".. Ok, not quite anymore */
00288         uint32  msg_type; /* NTLMSSP_MESSAGE_TYPE (1,2,3) and 5 for schannel */
00289 } RPC_AUTH_VERIFIER;
00290 
00291 #endif /* _DCE_RPC_H */

Sambaに対してSat Aug 29 21:22:55 2009に生成されました。  doxygen 1.4.7