pidl:NDR/ServerCompat: Retrieve and setup pipes struct before dispatch
[samba.git] / source3 / rpc_server / rpc_server.h
1 /*
2  *  RPC Server helper headers
3  *  Almost completely rewritten by (C) Jeremy Allison 2005 - 2010
4  *  Copyright (C) Simo Sorce <idra@samba.org> - 2010
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 3 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #ifndef _RPC_SERVER_H_
21 #define _RPC_SERVER_H_
22
23 #include "librpc/rpc/rpc_common.h" /* For enum dcerpc_transport_t */
24
25 #include "librpc/rpc/dcesrv_core.h"
26
27 struct pipes_struct;
28 struct auth_session_info;
29 struct cli_credentials;
30
31 typedef void (*dcerpc_ncacn_termination_fn)(struct pipes_struct *, void *);
32
33 struct dcerpc_ncacn_conn {
34         int sock;
35
36         struct pipes_struct *p;
37         dcerpc_ncacn_termination_fn termination_fn;
38         void *termination_data;
39
40         struct tevent_context *ev_ctx;
41         struct messaging_context *msg_ctx;
42         struct dcesrv_context *dce_ctx;
43         struct dcesrv_endpoint *endpoint;
44
45         struct tstream_context *tstream;
46         struct tevent_queue *send_queue;
47
48         struct tsocket_address *remote_client_addr;
49         char *remote_client_name;
50         struct tsocket_address *local_server_addr;
51         char *local_server_name;
52         struct auth_session_info *session_info;
53
54         struct iovec *iov;
55         size_t count;
56 };
57
58 NTSTATUS dcerpc_ncacn_conn_init(TALLOC_CTX *mem_ctx,
59                                 struct tevent_context *ev_ctx,
60                                 struct messaging_context *msg_ctx,
61                                 struct dcesrv_context *dce_ctx,
62                                 struct dcesrv_endpoint *endpoint,
63                                 dcerpc_ncacn_termination_fn term_fn,
64                                 void *termination_data,
65                                 struct dcerpc_ncacn_conn **out);
66
67 int make_server_pipes_struct(TALLOC_CTX *mem_ctx,
68                              struct messaging_context *msg_ctx,
69                              const char *pipe_name,
70                              enum dcerpc_transport_t transport,
71                              const struct tsocket_address *remote_address,
72                              const struct tsocket_address *local_address,
73                              struct auth_session_info **session_info,
74                              struct pipes_struct **_p,
75                              int *perrno);
76
77 void set_incoming_fault(struct pipes_struct *p);
78 void process_complete_pdu(struct pipes_struct *p, struct ncacn_packet *pkt);
79 NTSTATUS dcesrv_create_ncacn_np_socket(struct dcesrv_endpoint *e, int *out_fd);
80 NTSTATUS dcesrv_setup_ncacn_np_socket(struct tevent_context *ev_ctx,
81                                       struct messaging_context *msg_ctx,
82                                       struct dcesrv_context *dce_ctx,
83                                       struct dcesrv_endpoint *e,
84                                       dcerpc_ncacn_termination_fn term_fn,
85                                       void *term_data);
86
87 NTSTATUS dcesrv_create_ncacn_ip_tcp_socket(const struct sockaddr_storage *ifss,
88                                            uint16_t *port,
89                                            int *out_fd);
90 NTSTATUS dcesrv_setup_ncacn_ip_tcp_socket(struct tevent_context *ev_ctx,
91                                           struct messaging_context *msg_ctx,
92                                           struct dcesrv_context *dce_ctx,
93                                           struct dcesrv_endpoint *e,
94                                           const struct sockaddr_storage *ifss,
95                                           dcerpc_ncacn_termination_fn term_fn,
96                                           void *term_data);
97
98 NTSTATUS dcesrv_create_ncalrpc_socket(struct dcesrv_endpoint *e, int *fd);
99 NTSTATUS dcesrv_setup_ncalrpc_socket(struct tevent_context *ev_ctx,
100                                      struct messaging_context *msg_ctx,
101                                      struct dcesrv_context *dce_ctx,
102                                      struct dcesrv_endpoint *e,
103                                      dcerpc_ncacn_termination_fn term_fn,
104                                      void *termination_data);
105
106 void dcerpc_ncacn_accept(struct tevent_context *ev_ctx,
107                          struct messaging_context *msg_ctx,
108                          struct dcesrv_context *dce_ctx,
109                          struct dcesrv_endpoint *e,
110                          struct tsocket_address *cli_addr,
111                          struct tsocket_address *srv_addr,
112                          int s,
113                          dcerpc_ncacn_termination_fn termination_fn,
114                          void *termination_data);
115 void dcerpc_ncacn_packet_process(struct tevent_req *subreq);
116
117 NTSTATUS dcesrv_auth_gensec_prepare(TALLOC_CTX *mem_ctx,
118                                     struct dcesrv_call_state *call,
119                                     struct gensec_security **out);
120 void dcesrv_log_successful_authz(struct dcesrv_call_state *call);
121 NTSTATUS dcesrv_assoc_group_find(struct dcesrv_call_state *call);
122
123 NTSTATUS dcesrv_endpoint_by_ncacn_np_name(struct dcesrv_context *dce_ctx,
124                                           const char *endpoint,
125                                           struct dcesrv_endpoint **out);
126
127 struct pipes_struct *dcesrv_get_pipes_struct(struct dcesrv_connection *conn);
128
129 #endif /* _PRC_SERVER_H_ */