include/ntdomain.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    Copyright (C) Jeremy Allison 2000-2004
00008    
00009    This program is free software; you can redistribute it and/or modify
00010    it under the terms of the GNU General Public License as published by
00011    the Free Software Foundation; either version 2 of the License, or
00012    (at your option) any later version.
00013    
00014    This program is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017    GNU General Public License for more details.
00018    
00019    You should have received a copy of the GNU General Public License
00020    along with this program; if not, write to the Free Software
00021    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00022 */
00023 
00024 #ifndef _NT_DOMAIN_H /* _NT_DOMAIN_H */
00025 #define _NT_DOMAIN_H 
00026 
00027 /*
00028  * A bunch of stuff that was put into smb.h
00029  * in the NTDOM branch - it didn't belong there.
00030  */
00031  
00032 typedef struct _prs_struct {
00033         BOOL io; /* parsing in or out of data stream */
00034         /* 
00035          * If the (incoming) data is big-endian. On output we are
00036          * always little-endian.
00037          */ 
00038         BOOL bigendian_data;
00039         uint8 align; /* data alignment */
00040         BOOL is_dynamic; /* Do we own this memory or not ? */
00041         uint32 data_offset; /* Current working offset into data. */
00042         uint32 buffer_size; /* Current allocated size of the buffer. */
00043         uint32 grow_size; /* size requested via prs_grow() calls */
00044         char *data_p; /* The buffer itself. */
00045         TALLOC_CTX *mem_ctx; /* When unmarshalling, use this.... */
00046         const char *sess_key; /* If we have to do encrypt/decrypt on the fly. */
00047 } prs_struct;
00048 
00049 /*
00050  * Defines for io member of prs_struct.
00051  */
00052 
00053 #define MARSHALL 0
00054 #define UNMARSHALL 1
00055 
00056 #define MARSHALLING(ps) (!(ps)->io)
00057 #define UNMARSHALLING(ps) ((ps)->io)
00058 
00059 #define RPC_BIG_ENDIAN          1
00060 #define RPC_LITTLE_ENDIAN       0
00061 
00062 #define RPC_PARSE_ALIGN 4
00063 
00064 typedef struct _output_data {
00065         /*
00066          * Raw RPC output data. This does not include RPC headers or footers.
00067          */
00068         prs_struct rdata;
00069 
00070         /* The amount of data sent from the current rdata struct. */
00071         uint32 data_sent_length;
00072 
00073         /*
00074          * The current PDU being returned. This inclues
00075          * headers, data and authentication footer.
00076          */
00077         unsigned char current_pdu[RPC_MAX_PDU_FRAG_LEN];
00078 
00079         /* The amount of data in the current_pdu buffer. */
00080         uint32 current_pdu_len;
00081 
00082         /* The amount of data sent from the current PDU. */
00083         uint32 current_pdu_sent;
00084 } output_data;
00085 
00086 typedef struct _input_data {
00087         /*
00088          * This is the current incoming pdu. The data here
00089          * is collected via multiple writes until a complete
00090          * pdu is seen, then the data is copied into the in_data
00091          * structure. The maximum size of this is 0x1630 (RPC_MAX_PDU_FRAG_LEN).
00092          */
00093         unsigned char current_in_pdu[RPC_MAX_PDU_FRAG_LEN];
00094 
00095         /*
00096          * The amount of data needed to complete the in_pdu.
00097          * If this is zero, then we are at the start of a new
00098          * pdu.
00099          */
00100         uint32 pdu_needed_len;
00101 
00102         /*
00103          * The amount of data received so far in the in_pdu.
00104          * If this is zero, then we are at the start of a new
00105          * pdu.
00106          */
00107         uint32 pdu_received_len;
00108 
00109         /*
00110          * This is the collection of input data with all
00111          * the rpc headers and auth footers removed.
00112          * The maximum length of this (1Mb) is strictly enforced.
00113          */
00114         prs_struct data;
00115 } input_data;
00116 
00117 /*
00118  * Handle database - stored per pipe.
00119  */
00120 
00121 struct policy {
00122         struct policy *next, *prev;
00123 
00124         POLICY_HND pol_hnd;
00125 
00126         void *data_ptr;
00127         void (*free_fn)(void *);
00128 };
00129 
00130 struct handle_list {
00131         struct policy *Policy;  /* List of policies. */
00132         size_t count;                   /* Current number of handles. */
00133         size_t pipe_ref_count;  /* Number of pipe handles referring to this list. */
00134 };
00135 
00136 /* Domain controller authentication protocol info */
00137 struct dcinfo {
00138         uint32 sequence; /* "timestamp" from client. */
00139         DOM_CHAL seed_chal; 
00140         DOM_CHAL clnt_chal; /* Client credential */
00141         DOM_CHAL srv_chal;  /* Server credential */
00142  
00143         unsigned char  sess_key[16]; /* Session key - 8 bytes followed by 8 zero bytes */
00144         unsigned char  mach_pw[16];   /* md4(machine password) */
00145 
00146         fstring mach_acct;  /* Machine name we've authenticated. */
00147 
00148         fstring remote_machine;  /* Machine name we've authenticated. */
00149         fstring domain;
00150 
00151         BOOL challenge_sent;
00152         BOOL authenticated;
00153 };
00154 
00155 typedef struct pipe_rpc_fns {
00156 
00157         struct pipe_rpc_fns *next, *prev;
00158         
00159         /* RPC function table associated with the current rpc_bind (associated by context) */
00160         
00161         struct api_struct *cmds;
00162         int n_cmds;
00163         uint32 context_id;
00164         
00165 } PIPE_RPC_FNS;
00166 
00167 /*
00168  * Different auth types we support.
00169  * Can't keep in sync with wire values as spnego wraps different auth methods.
00170  */
00171 
00172 enum pipe_auth_type { PIPE_AUTH_TYPE_NONE = 0, PIPE_AUTH_TYPE_NTLMSSP, PIPE_AUTH_TYPE_SCHANNEL,
00173                         PIPE_AUTH_TYPE_SPNEGO_NTLMSSP, PIPE_AUTH_TYPE_KRB5, PIPE_AUTH_TYPE_SPNEGO_KRB5 };
00174 
00175 /* Possible auth levels - keep these in sync with the wire values. */
00176 enum pipe_auth_level { PIPE_AUTH_LEVEL_NONE = 0,
00177                         PIPE_AUTH_LEVEL_CONNECT = 1,    /* We treat as NONE. */
00178                         PIPE_AUTH_LEVEL_INTEGRITY = 5,  /* Sign. */
00179                         PIPE_AUTH_LEVEL_PRIVACY = 6     /* Seal. */
00180 };
00181 
00182 /* auth state for krb5. */
00183 struct kerberos_auth_struct {
00184         const char *service_principal;
00185         DATA_BLOB session_key;
00186 };
00187 
00188 /* auth state for schannel. */
00189 struct schannel_auth_struct {
00190         unsigned char sess_key[16];
00191         uint32 seq_num;
00192 };
00193 
00194 /* auth state for all bind types. */
00195 
00196 struct pipe_auth_data {
00197         enum pipe_auth_type auth_type; /* switch for union below. */
00198         enum pipe_auth_level auth_level;
00199         union {
00200                 struct schannel_auth_struct *schannel_auth;
00201                 AUTH_NTLMSSP_STATE *auth_ntlmssp_state;
00202 /*              struct kerberos_auth_struct *kerberos_auth; TO BE ADDED... */
00203         } a_u;
00204         void (*auth_data_free_func)(struct pipe_auth_data *);
00205 };
00206 
00207 /*
00208  * DCE/RPC-specific samba-internal-specific handling of data on
00209  * NamedPipes.
00210  */
00211 
00212 typedef struct pipes_struct {
00213         struct pipes_struct *next, *prev;
00214 
00215         connection_struct *conn;
00216         uint16 vuid; /* points to the unauthenticated user that opened this pipe. */
00217 
00218         fstring name;
00219         fstring pipe_srv_name;
00220         
00221         /* linked list of rpc dispatch tables associated 
00222            with the open rpc contexts */
00223            
00224         PIPE_RPC_FNS *contexts;
00225         
00226         RPC_HDR hdr; /* Incoming RPC header. */
00227         RPC_HDR_REQ hdr_req; /* Incoming request header. */
00228 
00229         /* This context is used for pipe state storage and is freed when the pipe is closed. */
00230         TALLOC_CTX *pipe_state_mem_ctx;
00231 
00232         struct pipe_auth_data auth;
00233 
00234         struct dcinfo *dc; /* Keeps the creds data from netlogon. */
00235 
00236         /*
00237          * Windows user info.
00238          */
00239         fstring user_name;
00240         fstring domain;
00241         fstring wks;
00242 
00243         /*
00244          * Unix user name and credentials used when a pipe is authenticated.
00245          */
00246 
00247         fstring pipe_user_name;
00248         struct current_user pipe_user;
00249         DATA_BLOB session_key;
00250  
00251         /*
00252          * Set to true when an RPC bind has been done on this pipe.
00253          */
00254         
00255         BOOL pipe_bound;
00256         
00257         /*
00258          * Set to true when we should return fault PDU's for everything.
00259          */
00260         
00261         BOOL fault_state;
00262 
00263         /*
00264          * Set to true when we should return fault PDU's for a bad handle.
00265          */
00266 
00267         BOOL bad_handle_fault_state;
00268         
00269         /*
00270          * Set to true when the backend does not support a call.
00271          */
00272 
00273         BOOL rng_fault_state;
00274         
00275         /*
00276          * Set to RPC_BIG_ENDIAN when dealing with big-endian PDU's
00277          */
00278         
00279         BOOL endian;
00280         
00281         /*
00282          * Struct to deal with multiple pdu inputs.
00283          */
00284 
00285         input_data in_data;
00286 
00287         /*
00288          * Struct to deal with multiple pdu outputs.
00289          */
00290 
00291         output_data out_data;
00292 
00293         /* This context is used for PDU data and is freed between each pdu.
00294                 Don't use for pipe state storage. */
00295         TALLOC_CTX *mem_ctx;
00296 
00297         /* handle database to use on this pipe. */
00298         struct handle_list *pipe_handles;
00299 
00300 } pipes_struct;
00301 
00302 typedef struct smb_np_struct {
00303         struct smb_np_struct *next, *prev;
00304         int pnum;
00305         connection_struct *conn;
00306         uint16 vuid; /* points to the unauthenticated user that opened this pipe. */
00307         BOOL open; /* open connection */
00308         uint16 device_state;
00309         uint16 priority;
00310         fstring name;
00311 
00312         /* When replying to an SMBtrans, this is the maximum amount of
00313            data that can be sent in the initial reply. */
00314         int max_trans_reply;
00315 
00316         /*
00317          * NamedPipe state information.
00318          *
00319          * (e.g. typecast a np_struct, above).
00320          */
00321         void *np_state;
00322 
00323         /*
00324          * NamedPipe functions, to be called to perform
00325          * Named Pipe transactions on request from an
00326          * SMB client.
00327          */
00328 
00329         /* call to create a named pipe connection.
00330          * returns: state information representing the connection.
00331          *          is stored in np_state, above.
00332          */
00333         void *   (*namedpipe_create)(char *pipe_name, 
00334                                           connection_struct *conn, uint16 vuid);
00335 
00336         /* call to perform a write / read namedpipe transaction.
00337          * TransactNamedPipe is weird: it returns whether there
00338          * is more data outstanding to be read, and the
00339          * caller is expected to take note and follow up with
00340          * read requests.
00341          */
00342         ssize_t  (*namedpipe_transact)(void *np_state,
00343                                        char *data, int len,
00344                                        char *rdata, int rlen,
00345                                        BOOL *pipe_outstanding);
00346 
00347         /* call to perform a write namedpipe operation
00348          */
00349         ssize_t  (*namedpipe_write)(void * np_state,
00350                                     char *data, size_t n);
00351 
00352         /* call to perform a read namedpipe operation.
00353          *
00354          * NOTE: the only reason that the pipe_outstanding
00355          * argument is here is because samba does not use
00356          * the namedpipe_transact function yet: instead,
00357          * it performs the same as what namedpipe_transact
00358          * does - a write, followed by a read.
00359          *
00360          * when samba is modified to use namedpipe_transact,
00361          * the pipe_outstanding argument may be removed.
00362          */
00363         ssize_t  (*namedpipe_read)(void * np_state,
00364                                    char *data, size_t max_len,
00365                                    BOOL *pipe_outstanding);
00366 
00367         /* call to close a namedpipe.
00368          * function is expected to perform all cleanups
00369          * necessary, free all memory etc.
00370          *
00371          * returns True if cleanup was successful (not that
00372          * we particularly care).
00373          */
00374         BOOL     (*namedpipe_close)(void * np_state);
00375 
00376 } smb_np_struct;
00377 
00378 struct api_struct {  
00379         const char *name;
00380         uint8 opnum;
00381         BOOL (*fn) (pipes_struct *);
00382 };
00383 
00384 typedef struct {  
00385         uint32 rid;
00386         const char *name;
00387 } rid_name;
00388 
00389 /*
00390  * higher order functions for use with msrpc client code
00391  */
00392 
00393 #define PRINT_INFO_FN(fn)\
00394         void (*fn)(const char*, uint32, uint32, void  *const *const)
00395 #define JOB_INFO_FN(fn)\
00396         void (*fn)(const char*, const char*, uint32, uint32, void *const *const)
00397 
00398 /* end higher order functions */
00399 
00400 typedef struct {
00401         uint32 size;
00402         prs_struct prs;
00403         uint32 struct_start;
00404         uint32 string_at_end;
00405 } RPC_BUFFER;
00406 
00407 #endif /* _NT_DOMAIN_H */

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