Remove use of global_loadparm during initialization of gensec.
[sfrench/samba-autobuild/.git] / source4 / librpc / rpc / dcerpc.h
index a609d17795f770e1ccdc3b4a1da97b4bb64ac0b2..6b9d61dd0fe46a3726d04b377defd1719cce6c6a 100644 (file)
@@ -8,7 +8,7 @@
    
    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
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    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.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+/* This is a public header file that is installed as part of Samba. 
+ * If you remove any functions or change their signature, update 
+ * the so version number. */
+
 #ifndef __DCERPC_H__
 #define __DCERPC_H__
 
-#include "core.h"
+#include "../lib/util/data_blob.h"
 #include "librpc/gen_ndr/dcerpc.h"
-#include "librpc/ndr/libndr.h"
+#include "../librpc/ndr/libndr.h"
 
 enum dcerpc_transport_t {
-       NCACN_NP, NCACN_IP_TCP, NCACN_IP_UDP, NCACN_VNS_IPC, NCACN_VNS_SPP
-       NCACN_AT_DSP, NCADG_AT_DDP, NCALRPC, NCACN_UNIX_STREAM, NCADG_UNIX_DGRAM,
-       NCACN_HTTP, NCADG_IPX, NCACN_SPX };
+       NCA_UNKNOWN, NCACN_NP, NCACN_IP_TCP, NCACN_IP_UDP, NCACN_VNS_IPC
+       NCACN_VNS_SPP, NCACN_AT_DSP, NCADG_AT_DDP, NCALRPC, NCACN_UNIX_STREAM, 
+       NCADG_UNIX_DGRAM, NCACN_HTTP, NCADG_IPX, NCACN_SPX };
 
 /*
   this defines a generic security context for signed/sealed dcerpc pipes.
 */
 struct dcerpc_connection;
+struct gensec_settings;
 struct dcerpc_security {
        struct dcerpc_auth *auth_info;
        struct gensec_security *generic_state;
@@ -56,19 +60,26 @@ struct dcerpc_connection {
        struct dcerpc_security security_state;
        const char *binding_string;
        struct event_context *event_ctx;
+       struct smb_iconv_convenience *iconv_convenience;
+
+       /** Directory in which to save ndrdump-parseable files */
+       const char *packet_log_dir;
+
+       bool dead;
+       bool free_skipped;
 
        struct dcerpc_transport {
                enum dcerpc_transport_t transport;
-               void *private;
+               void *private_data;
 
-               NTSTATUS (*shutdown_pipe)(struct dcerpc_connection *);
+               NTSTATUS (*shutdown_pipe)(struct dcerpc_connection *, NTSTATUS status);
 
                const char *(*peer_name)(struct dcerpc_connection *);
 
                const char *(*target_hostname)(struct dcerpc_connection *);
 
                /* send a request to the server */
-               NTSTATUS (*send_request)(struct dcerpc_connection *, DATA_BLOB *, BOOL trigger_read);
+               NTSTATUS (*send_request)(struct dcerpc_connection *, DATA_BLOB *, bool trigger_read);
 
                /* send a read request to the server */
                NTSTATUS (*send_read)(struct dcerpc_connection *);
@@ -94,16 +105,18 @@ struct dcerpc_connection {
 struct dcerpc_pipe {
        uint32_t context_id;
 
-       struct dcerpc_syntax_id syntax;
-       struct dcerpc_syntax_id transfer_syntax;
+       uint32_t assoc_group_id;
+
+       struct ndr_syntax_id syntax;
+       struct ndr_syntax_id transfer_syntax;
 
        struct dcerpc_connection *conn;
        struct dcerpc_binding *binding;
 
-       /* the last fault code from a DCERPC fault */
+       /** the last fault code from a DCERPC fault */
        uint32_t last_fault_code;
 
-       /* timeout for individual rpc requests, in seconds */
+       /** timeout for individual rpc requests, in seconds */
        uint32_t request_timeout;
 };
 
@@ -151,51 +164,22 @@ struct dcerpc_pipe {
 /* select NTLM auth */
 #define DCERPC_AUTH_NTLM               (1<<18)
 
-/*
-  this is used to find pointers to calls
-*/
-struct dcerpc_interface_call {
-       const char *name;
-       size_t struct_size;
-       ndr_push_flags_fn_t ndr_push;
-       ndr_pull_flags_fn_t ndr_pull;
-       ndr_print_function_t ndr_print;
-       BOOL async;
-};
-
-struct dcerpc_endpoint_list {
-       uint32_t count;
-       const char * const *names;
-};
-
-struct dcerpc_authservice_list {
-       uint32_t count;
-       const char * const *names;
-};
+/* this triggers the DCERPC_PFC_FLAG_CONC_MPX flag in the bind request */
+#define DCERPC_CONCURRENT_MULTIPLEX     (1<<19)
 
-struct dcerpc_interface_table {
-       const char *name;
-       struct dcerpc_syntax_id syntax_id;
-       const char *helpstring;
-       uint32_t num_calls;
-       const struct dcerpc_interface_call *calls;
-       const struct dcerpc_endpoint_list *endpoints;
-       const struct dcerpc_authservice_list *authservices;
-};
-
-struct dcerpc_interface_list {
-       struct dcerpc_interface_list *prev, *next;
-       const struct dcerpc_interface_table *table;
-};
+/* this triggers the DCERPC_PFC_FLAG_SUPPORT_HEADER_SIGN flag in the bind request */
+#define DCERPC_HEADER_SIGNING          (1<<20)
 
 /* this describes a binding to a particular transport/pipe */
 struct dcerpc_binding {
        enum dcerpc_transport_t transport;
-       struct dcerpc_syntax_id object;
+       struct ndr_syntax_id object;
        const char *host;
+       const char *target_hostname;
        const char *endpoint;
        const char **options;
        uint32_t flags;
+       uint32_t assoc_group_id;
 };
 
 
@@ -203,12 +187,14 @@ struct dcerpc_pipe_connect {
        struct dcerpc_pipe *pipe;
        struct dcerpc_binding *binding;
        const char *pipe_name;
-       const struct dcerpc_interface_table *interface;
+       const struct ndr_interface_table *interface;
        struct cli_credentials *creds;
+       struct resolve_context *resolve_ctx;
 };
 
 
 enum rpc_request_state {
+       RPC_REQUEST_QUEUED,
        RPC_REQUEST_PENDING,
        RPC_REQUEST_DONE
 };
@@ -234,11 +220,12 @@ struct rpc_request {
        const struct GUID *object;
        uint16_t opnum;
        DATA_BLOB request_data;
-       BOOL async_call;
+       bool async_call;
+       bool ignore_timeout;
 
        /* use by the ndr level async recv call */
        struct {
-               const struct dcerpc_interface_table *table;
+               const struct ndr_interface_table *table;
                uint32_t opnum;
                void *struct_ptr;
                TALLOC_CTX *mem_ctx;
@@ -246,7 +233,7 @@ struct rpc_request {
 
        struct {
                void (*callback)(struct rpc_request *);
-               void *private;
+               void *private_data;
        } async;
 };
 
@@ -257,6 +244,142 @@ struct smbcli_tree;
 struct smb2_tree;
 struct socket_address;
 
-#include "librpc/rpc/dcerpc_proto.h"
+NTSTATUS dcerpc_pipe_connect(TALLOC_CTX *parent_ctx, 
+                            struct dcerpc_pipe **pp, 
+                            const char *binding,
+                            const struct ndr_interface_table *table,
+                            struct cli_credentials *credentials,
+                            struct event_context *ev,
+                            struct loadparm_context *lp_ctx);
+NTSTATUS dcerpc_ndr_request_recv(struct rpc_request *req);
+struct rpc_request *dcerpc_ndr_request_send(struct dcerpc_pipe *p,
+                                               const struct GUID *object,
+                                               const struct ndr_interface_table *table,
+                                               uint32_t opnum, 
+                                               TALLOC_CTX *mem_ctx, 
+                                               void *r);
+const char *dcerpc_server_name(struct dcerpc_pipe *p);
+struct dcerpc_pipe *dcerpc_pipe_init(TALLOC_CTX *mem_ctx, struct event_context *ev,
+                                    struct smb_iconv_convenience *ic);
+NTSTATUS dcerpc_pipe_open_smb(struct dcerpc_pipe *p,
+                             struct smbcli_tree *tree,
+                             const char *pipe_name);
+NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p,
+                              const struct ndr_interface_table *table);
+NTSTATUS dcerpc_fetch_session_key(struct dcerpc_pipe *p,
+                                 DATA_BLOB *session_key);
+struct composite_context;
+NTSTATUS dcerpc_secondary_connection_recv(struct composite_context *c,
+                                         struct dcerpc_pipe **p2);
+NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *s, struct dcerpc_binding **b_out);
+
+struct composite_context* dcerpc_pipe_connect_b_send(TALLOC_CTX *parent_ctx,
+                                                    struct dcerpc_binding *binding,
+                                                    const struct ndr_interface_table *table,
+                                                    struct cli_credentials *credentials,
+                                                    struct event_context *ev,
+                                                    struct loadparm_context *lp_ctx);
+
+NTSTATUS dcerpc_pipe_connect_b_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
+                                   struct dcerpc_pipe **p);
+
+NTSTATUS dcerpc_pipe_connect_b(TALLOC_CTX *parent_ctx,
+                              struct dcerpc_pipe **pp,
+                              struct dcerpc_binding *binding,
+                              const struct ndr_interface_table *table,
+                              struct cli_credentials *credentials,
+                              struct event_context *ev,
+                              struct loadparm_context *lp_ctx);
+const char *dcerpc_errstr(TALLOC_CTX *mem_ctx, uint32_t fault_code);
+
+NTSTATUS dcerpc_pipe_auth(TALLOC_CTX *mem_ctx,
+                         struct dcerpc_pipe **p, 
+                         struct dcerpc_binding *binding,
+                         const struct ndr_interface_table *table,
+                         struct cli_credentials *credentials,
+                         struct loadparm_context *lp_ctx);
+char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, const struct dcerpc_binding *b);
+NTSTATUS dcerpc_secondary_connection(struct dcerpc_pipe *p,
+                                    struct dcerpc_pipe **p2,
+                                    struct dcerpc_binding *b);
+NTSTATUS dcerpc_bind_auth_schannel(TALLOC_CTX *tmp_ctx, 
+                                  struct dcerpc_pipe *p,
+                                  const struct ndr_interface_table *table,
+                                  struct cli_credentials *credentials,
+                                  struct loadparm_context *lp_ctx,
+                                  uint8_t auth_level);
+struct event_context *dcerpc_event_context(struct dcerpc_pipe *p);
+NTSTATUS dcerpc_init(struct loadparm_context *lp_ctx);
+struct smbcli_tree *dcerpc_smb_tree(struct dcerpc_connection *c);
+uint16_t dcerpc_smb_fnum(struct dcerpc_connection *c);
+NTSTATUS dcerpc_secondary_context(struct dcerpc_pipe *p, 
+                                 struct dcerpc_pipe **pp2,
+                                 const struct ndr_interface_table *table);
+NTSTATUS dcerpc_alter_context(struct dcerpc_pipe *p, 
+                             TALLOC_CTX *mem_ctx,
+                             const struct ndr_syntax_id *syntax,
+                             const struct ndr_syntax_id *transfer_syntax);
+
+NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p,
+                         const struct ndr_interface_table *table,
+                         struct cli_credentials *credentials,
+                         struct gensec_settings *gensec_settings,
+                         uint8_t auth_type, uint8_t auth_level,
+                         const char *service);
+struct composite_context* dcerpc_pipe_connect_send(TALLOC_CTX *parent_ctx,
+                                                  const char *binding,
+                                                  const struct ndr_interface_table *table,
+                                                  struct cli_credentials *credentials,
+                                                  struct event_context *ev, struct loadparm_context *lp_ctx);
+NTSTATUS dcerpc_pipe_connect_recv(struct composite_context *c,
+                                 TALLOC_CTX *mem_ctx,
+                                 struct dcerpc_pipe **pp);
+
+NTSTATUS dcerpc_epm_map_binding(TALLOC_CTX *mem_ctx, struct dcerpc_binding *binding,
+                               const struct ndr_interface_table *table, struct event_context *ev,
+                               struct loadparm_context *lp_ctx);
+struct composite_context* dcerpc_secondary_auth_connection_send(struct dcerpc_pipe *p,
+                                                               struct dcerpc_binding *binding,
+                                                               const struct ndr_interface_table *table,
+                                                               struct cli_credentials *credentials,
+                                                               struct loadparm_context *lp_ctx);
+NTSTATUS dcerpc_secondary_auth_connection_recv(struct composite_context *c, 
+                                              TALLOC_CTX *mem_ctx,
+                                              struct dcerpc_pipe **p);
+
+struct composite_context* dcerpc_secondary_connection_send(struct dcerpc_pipe *p,
+                                                          struct dcerpc_binding *b);
+void dcerpc_log_packet(const char *lockdir, 
+                                          const struct ndr_interface_table *ndr,
+                                          uint32_t opnum, uint32_t flags, 
+                                          DATA_BLOB *pkt);
+NTSTATUS dcerpc_binding_build_tower(TALLOC_CTX *mem_ctx, struct dcerpc_binding *binding, struct epm_tower *tower);
+
+NTSTATUS dcerpc_floor_get_lhs_data(struct epm_floor *epm_floor, struct ndr_syntax_id *syntax);
+
+enum dcerpc_transport_t dcerpc_transport_by_tower(struct epm_tower *tower);
+
+NTSTATUS dcerpc_ndr_request(struct dcerpc_pipe *p,
+                           const struct GUID *object,
+                           const struct ndr_interface_table *table,
+                           uint32_t opnum, 
+                           TALLOC_CTX *mem_ctx, 
+                           void *r);
+
+NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx, 
+                                  struct epm_tower *tower, 
+                                  struct dcerpc_binding **b_out);
+
+NTSTATUS dcerpc_request(struct dcerpc_pipe *p, 
+                       struct GUID *object,
+                       uint16_t opnum,
+                       bool async,
+                       TALLOC_CTX *mem_ctx,
+                       DATA_BLOB *stub_data_in,
+                       DATA_BLOB *stub_data_out);
+
+typedef NTSTATUS (*dcerpc_call_fn) (struct dcerpc_pipe *, TALLOC_CTX *, void *);
+
+enum dcerpc_transport_t dcerpc_transport_by_endpoint_protocol(int prot);
 
 #endif /* __DCERPC_H__ */