rpc_server: Add dcesrv_setup_ncacn_listener()
[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 dcesrv_connection *,
32                                             void *);
33
34 struct dcerpc_ncacn_conn {
35         int sock;
36
37         struct pipes_struct *p;
38         dcerpc_ncacn_termination_fn termination_fn;
39         void *termination_data;
40
41         struct tevent_context *ev_ctx;
42         struct messaging_context *msg_ctx;
43         struct dcesrv_context *dce_ctx;
44         struct dcesrv_endpoint *endpoint;
45
46         struct tstream_context *tstream;
47         struct tevent_queue *send_queue;
48
49         struct tsocket_address *remote_client_addr;
50         char *remote_client_name;
51         struct tsocket_address *local_server_addr;
52         char *local_server_name;
53         struct auth_session_info *session_info;
54
55         struct iovec *iov;
56         size_t count;
57 };
58
59 NTSTATUS dcerpc_ncacn_conn_init(TALLOC_CTX *mem_ctx,
60                                 struct tevent_context *ev_ctx,
61                                 struct messaging_context *msg_ctx,
62                                 struct dcesrv_context *dce_ctx,
63                                 struct dcesrv_endpoint *endpoint,
64                                 dcerpc_ncacn_termination_fn term_fn,
65                                 void *termination_data,
66                                 struct dcerpc_ncacn_conn **out);
67
68 void set_incoming_fault(struct pipes_struct *p);
69 void process_complete_pdu(struct pipes_struct *p, struct ncacn_packet *pkt);
70 NTSTATUS dcesrv_create_ncacn_np_socket(struct dcesrv_endpoint *e, int *out_fd);
71 NTSTATUS dcesrv_setup_ncacn_np_socket(struct tevent_context *ev_ctx,
72                                       struct messaging_context *msg_ctx,
73                                       struct dcesrv_context *dce_ctx,
74                                       struct dcesrv_endpoint *e,
75                                       dcerpc_ncacn_termination_fn term_fn,
76                                       void *term_data);
77
78 NTSTATUS dcesrv_create_ncacn_ip_tcp_socket(const struct sockaddr_storage *ifss,
79                                            uint16_t *port,
80                                            int *out_fd);
81 NTSTATUS dcesrv_setup_ncacn_ip_tcp_socket(struct tevent_context *ev_ctx,
82                                           struct messaging_context *msg_ctx,
83                                           struct dcesrv_context *dce_ctx,
84                                           struct dcesrv_endpoint *e,
85                                           int fd,
86                                           dcerpc_ncacn_termination_fn term_fn,
87                                           void *term_data);
88
89 NTSTATUS dcesrv_create_ncalrpc_socket(struct dcesrv_endpoint *e, int *fd);
90 NTSTATUS dcesrv_setup_ncalrpc_socket(struct tevent_context *ev_ctx,
91                                      struct messaging_context *msg_ctx,
92                                      struct dcesrv_context *dce_ctx,
93                                      struct dcesrv_endpoint *e,
94                                      dcerpc_ncacn_termination_fn term_fn,
95                                      void *termination_data);
96 struct dcerpc_ncacn_listen_state;
97 int dcesrv_setup_ncacn_listener(
98         TALLOC_CTX *mem_ctx,
99         struct dcesrv_context *dce_ctx,
100         struct tevent_context *ev_ctx,
101         struct messaging_context *msg_ctx,
102         struct dcesrv_endpoint *e,
103         int *fd,
104         dcerpc_ncacn_termination_fn term_fn,
105         void *termination_data,
106         struct dcerpc_ncacn_listen_state **listen_state);
107
108 void dcerpc_ncacn_accept(struct tevent_context *ev_ctx,
109                          struct messaging_context *msg_ctx,
110                          struct dcesrv_context *dce_ctx,
111                          struct dcesrv_endpoint *e,
112                          struct tsocket_address **cli_addr,
113                          struct tsocket_address **srv_addr,
114                          int s,
115                          dcerpc_ncacn_termination_fn termination_fn,
116                          void *termination_data);
117
118 NTSTATUS dcesrv_auth_gensec_prepare(TALLOC_CTX *mem_ctx,
119                                     struct dcesrv_call_state *call,
120                                     struct gensec_security **out);
121 void dcesrv_log_successful_authz(struct dcesrv_call_state *call);
122 NTSTATUS dcesrv_assoc_group_find(struct dcesrv_call_state *call);
123
124 NTSTATUS dcesrv_endpoint_by_ncacn_np_name(struct dcesrv_context *dce_ctx,
125                                           const char *endpoint,
126                                           struct dcesrv_endpoint **out);
127
128 struct pipes_struct *dcesrv_get_pipes_struct(struct dcesrv_connection *conn);
129
130 void dcesrv_transport_terminate_connection(struct dcesrv_connection *dce_conn,
131                                            const char *reason);
132
133 #endif /* _PRC_SERVER_H_ */