s4:rpc_server: add some const to dcesrv_handle_fetch()
[samba.git] / source4 / rpc_server / dcerpc_server.h
index a1eddbcd5ebc0f055e0abddab490475ffaf4b8d4..39492f6acffd4d8d6f4018594959877e865d0daf 100644 (file)
@@ -67,8 +67,12 @@ struct dcesrv_interface {
 
        /* for any private use by the interface code */
        const void *private_data;
+
+       uint64_t flags;
 };
 
+#define DCESRV_INTERFACE_FLAGS_HANDLES_NOT_USED 0x00000001
+
 enum dcesrv_call_list {
        DCESRV_LIST_NONE,
        DCESRV_LIST_CALL_LIST,
@@ -88,6 +92,11 @@ struct dcesrv_call_state {
        struct dcesrv_connection_context *context;
        struct ncacn_packet pkt;
 
+       /*
+        * Used during async bind/alter_context.
+        */
+       struct ncacn_packet ack_pkt;
+
        /*
          which list this request is in, if any
         */
@@ -145,6 +154,32 @@ struct dcesrv_call_state {
        struct dcerpc_auth *out_auth_info;
 };
 
+/*
+* DCERPC Handles
+* --------------
+* The various handles that are used in the RPC servers should be
+* created and fetch using the dcesrv_handle_* functions.
+*
+* Use
+* dcesrv_handle_new(struct dcesrv_connection \*, uint8 handle_type)
+* to obtain a new handle of the specified type. Handle types are
+* unique within each pipe.
+*
+* The handle can later be fetched again using:
+*
+* struct dcesrv_handle *dcesrv_handle_fetch(
+*         struct dcesrv_connection *dce_conn,
+*         struct policy_handle *p,
+*         uint8 handle_type)
+*
+* and destroyed by:
+*
+*      dcesrv_handle_destroy(struct dcesrv_handle *).
+*
+* User data should be stored in the 'data' member of the dcesrv_handle
+* struct.
+*/
+
 #define DCESRV_HANDLE_ANY 255
 
 /* a dcerpc handle in internal format */
@@ -164,7 +199,7 @@ struct dcesrv_auth {
        uint32_t auth_context_id;
        struct gensec_security *gensec_security;
        struct auth_session_info *session_info;
-       NTSTATUS (*session_key)(struct dcesrv_connection *, DATA_BLOB *session_key);
+       NTSTATUS (*session_key_fn)(struct dcesrv_auth *, DATA_BLOB *session_key);
        bool client_hdr_signing;
        bool hdr_signing;
        bool auth_finished;
@@ -233,9 +268,6 @@ struct dcesrv_connection {
        /* the server_id that will be used for this connection */
        struct server_id server_id;
 
-       /* the transport level session key */
-       DATA_BLOB transport_session_key;
-
        /* is this connection pending termination?  If so, why? */
        const char *terminate;
 
@@ -279,6 +311,16 @@ struct dcesrv_connection {
 
        /* the negotiated bind time features */
        uint16_t bind_time_features;
+
+       /*
+        * This is used to block the connection during
+        * pending authentication.
+        */
+       struct tevent_req *(*wait_send)(TALLOC_CTX *mem_ctx,
+                                       struct tevent_context *ev,
+                                       void *private_data);
+       NTSTATUS (*wait_recv)(struct tevent_req *req);
+       void *wait_private;
 };
 
 
@@ -343,6 +385,12 @@ struct dcesrv_context {
                        struct dcesrv_if_list *next, *prev;
                        struct dcesrv_interface iface;
                } *interface_list;
+
+               /*
+                * Should this service be run in a single process (so far only
+                * NETLOGON is not run in a single process)
+                */
+               bool use_single_process;
        } *endpoint_list;
 
        /* loadparm context to use for this connection */
@@ -377,15 +425,6 @@ NTSTATUS dcerpc_register_ep_server(const struct dcesrv_endpoint_server *ep_serve
 NTSTATUS dcesrv_init_context(TALLOC_CTX *mem_ctx, 
                                      struct loadparm_context *lp_ctx,
                                      const char **endpoint_servers, struct dcesrv_context **_dce_ctx);
-NTSTATUS dcesrv_endpoint_connect(struct dcesrv_context *dce_ctx,
-                                TALLOC_CTX *mem_ctx,
-                                const struct dcesrv_endpoint *ep,
-                                struct auth_session_info *session_info,
-                                struct tevent_context *event_ctx,
-                                struct imessaging_context *msg_ctx,
-                                struct server_id server_id,
-                                uint32_t state_flags,
-                                struct dcesrv_connection **_p);
 
 NTSTATUS dcesrv_reply(struct dcesrv_call_state *call);
 struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_connection_context *context, 
@@ -393,15 +432,29 @@ struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_connection_context *contex
 
 struct dcesrv_handle *dcesrv_handle_fetch(
                                          struct dcesrv_connection_context *context, 
-                                         struct policy_handle *p,
+                                         const struct policy_handle *p,
                                          uint8_t handle_type);
-struct socket_address *dcesrv_connection_get_my_addr(struct dcesrv_connection *conn, TALLOC_CTX *mem_ctx);
 
-struct socket_address *dcesrv_connection_get_peer_addr(struct dcesrv_connection *conn, TALLOC_CTX *mem_ctx);
 const struct tsocket_address *dcesrv_connection_get_local_address(struct dcesrv_connection *conn);
 const struct tsocket_address *dcesrv_connection_get_remote_address(struct dcesrv_connection *conn);
 
-NTSTATUS dcesrv_fetch_session_key(struct dcesrv_connection *p, DATA_BLOB *session_key);
+/*
+ * Fetch the authentication session key if available.
+ *
+ * This is the key generated by a gensec authentication.
+ */
+NTSTATUS dcesrv_auth_session_key(struct dcesrv_call_state *call,
+                                DATA_BLOB *session_key);
+
+/*
+ * Fetch the transport session key if available.
+ * Typically this is the SMB session key
+ * or a fixed key for local transports.
+ *
+ * The key is always truncated to 16 bytes.
+*/
+NTSTATUS dcesrv_transport_session_key(struct dcesrv_call_state *call,
+                                     DATA_BLOB *session_key);
 
 /* a useful macro for generating a RPC fault in the backend code */
 #define DCESRV_FAULT(code) do { \
@@ -444,7 +497,8 @@ NTSTATUS dcesrv_add_ep(struct dcesrv_context *dce_ctx,
                       struct loadparm_context *lp_ctx,
                       struct dcesrv_endpoint *e,
                       struct tevent_context *event_ctx,
-                      const struct model_ops *model_ops);
+                      const struct model_ops *model_ops,
+                      void *process_context);
 
 /**
  * retrieve credentials from a dce_call
@@ -461,6 +515,11 @@ _PUBLIC_ bool dcesrv_call_authenticated(struct dcesrv_call_state *dce_call);
  */
 _PUBLIC_ const char *dcesrv_call_account_name(struct dcesrv_call_state *dce_call);
 
+/**
+ * retrieve session_info from a dce_call
+ */
+_PUBLIC_ struct auth_session_info *dcesrv_call_session_info(struct dcesrv_call_state *dce_call);
+
 _PUBLIC_ NTSTATUS dcesrv_interface_bind_require_integrity(struct dcesrv_call_state *dce_call,
                                                          const struct dcesrv_interface *iface);
 _PUBLIC_ NTSTATUS dcesrv_interface_bind_require_privacy(struct dcesrv_call_state *dce_call,