xref: /netbsd-src/external/bsd/openldap/dist/servers/lloadd/proto-lload.h (revision 549b59ed3ccf0d36d3097190a0db27b770f3a839)
1*549b59edSchristos /*	$NetBSD: proto-lload.h,v 1.2 2021/08/14 16:14:58 christos Exp $	*/
2e670fd5cSchristos 
3e670fd5cSchristos /* $OpenLDAP$ */
4e670fd5cSchristos /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5e670fd5cSchristos  *
6e670fd5cSchristos  * Copyright 1998-2021 The OpenLDAP Foundation.
7e670fd5cSchristos  * All rights reserved.
8e670fd5cSchristos  *
9e670fd5cSchristos  * Redistribution and use in source and binary forms, with or without
10e670fd5cSchristos  * modification, are permitted only as authorized by the OpenLDAP
11e670fd5cSchristos  * Public License.
12e670fd5cSchristos  *
13e670fd5cSchristos  * A copy of this license is available in the file LICENSE in the
14e670fd5cSchristos  * top-level directory of the distribution or, alternatively, at
15e670fd5cSchristos  * <http://www.OpenLDAP.org/license.html>.
16e670fd5cSchristos  */
17e670fd5cSchristos /* Portions Copyright (c) 1995 Regents of the University of Michigan.
18e670fd5cSchristos  * All rights reserved.
19e670fd5cSchristos  *
20e670fd5cSchristos  * Redistribution and use in source and binary forms are permitted
21e670fd5cSchristos  * provided that this notice is preserved and that due credit is given
22e670fd5cSchristos  * to the University of Michigan at Ann Arbor. The name of the University
23e670fd5cSchristos  * may not be used to endorse or promote products derived from this
24e670fd5cSchristos  * software without specific prior written permission. This software
25e670fd5cSchristos  * is provided ``as is'' without express or implied warranty.
26e670fd5cSchristos  */
27e670fd5cSchristos 
28e670fd5cSchristos #ifndef PROTO_LLOAD_H
29e670fd5cSchristos #define PROTO_LLOAD_H
30e670fd5cSchristos 
31e670fd5cSchristos #include <ldap_cdefs.h>
32e670fd5cSchristos #include "ldap_pvt.h"
33e670fd5cSchristos 
34e670fd5cSchristos #include <event2/event.h>
35e670fd5cSchristos 
36e670fd5cSchristos LDAP_BEGIN_DECL
37e670fd5cSchristos 
38e670fd5cSchristos /*
39e670fd5cSchristos  * backend.c
40e670fd5cSchristos  */
41e670fd5cSchristos 
42e670fd5cSchristos LDAP_SLAPD_F (void) backend_connect( evutil_socket_t s, short what, void *arg );
43e670fd5cSchristos LDAP_SLAPD_F (void *) backend_connect_task( void *ctx, void *arg );
44e670fd5cSchristos LDAP_SLAPD_F (void) backend_retry( LloadBackend *b );
45e670fd5cSchristos LDAP_SLAPD_F (LloadConnection *) backend_select( LloadOperation *op, int *res );
46e670fd5cSchristos LDAP_SLAPD_F (void) backend_reset( LloadBackend *b, int gentle );
47e670fd5cSchristos LDAP_SLAPD_F (void) lload_backend_destroy( LloadBackend *b );
48e670fd5cSchristos LDAP_SLAPD_F (void) lload_backends_destroy( void );
49e670fd5cSchristos 
50e670fd5cSchristos /*
51e670fd5cSchristos  * bind.c
52e670fd5cSchristos  */
53e670fd5cSchristos LDAP_SLAPD_F (int) request_bind( LloadConnection *c, LloadOperation *op );
54e670fd5cSchristos LDAP_SLAPD_F (int) handle_bind_response( LloadConnection *client, LloadOperation *op, BerElement *ber );
55e670fd5cSchristos LDAP_SLAPD_F (int) handle_whoami_response( LloadConnection *client, LloadOperation *op, BerElement *ber );
56e670fd5cSchristos LDAP_SLAPD_F (int) handle_vc_bind_response( LloadConnection *client, LloadOperation *op, BerElement *ber );
57e670fd5cSchristos 
58e670fd5cSchristos /*
59e670fd5cSchristos  * client.c
60e670fd5cSchristos  */
61e670fd5cSchristos LDAP_SLAPD_F (int) request_abandon( LloadConnection *c, LloadOperation *op );
62e670fd5cSchristos LDAP_SLAPD_F (int) request_process( LloadConnection *c, LloadOperation *op );
63e670fd5cSchristos LDAP_SLAPD_F (int) handle_one_request( LloadConnection *c );
64e670fd5cSchristos LDAP_SLAPD_F (void) client_tls_handshake_cb( evutil_socket_t s, short what, void *arg );
65e670fd5cSchristos LDAP_SLAPD_F (LloadConnection *) client_init( ber_socket_t s, const char *peername, struct event_base *base, int use_tls );
66e670fd5cSchristos LDAP_SLAPD_F (void) client_reset( LloadConnection *c );
67e670fd5cSchristos LDAP_SLAPD_F (void) client_destroy( LloadConnection *c );
68e670fd5cSchristos LDAP_SLAPD_F (void) clients_destroy( int gentle );
69e670fd5cSchristos LDAP_SLAPD_V (long) lload_client_max_pending;
70e670fd5cSchristos 
71e670fd5cSchristos /*
72e670fd5cSchristos  * config.c
73e670fd5cSchristos  */
74e670fd5cSchristos LDAP_SLAPD_F (int) lload_read_config( const char *fname, const char *dir );
75e670fd5cSchristos LDAP_SLAPD_F (void) lload_config_destroy( void );
76e670fd5cSchristos LDAP_SLAPD_F (int) verb_to_mask( const char *word, slap_verbmasks *v );
77e670fd5cSchristos LDAP_SLAPD_F (int) lload_tls_get_config( LDAP *ld, int opt, char **val );
78e670fd5cSchristos LDAP_SLAPD_F (void) lload_bindconf_tls_defaults( slap_bindconf *bc );
79e670fd5cSchristos LDAP_SLAPD_F (int) lload_backend_parse( const char *word, LloadBackend *b );
80e670fd5cSchristos LDAP_SLAPD_F (int) lload_bindconf_parse( const char *word, slap_bindconf *bc );
81e670fd5cSchristos LDAP_SLAPD_F (int) lload_bindconf_unparse( slap_bindconf *bc, struct berval *bv );
82e670fd5cSchristos LDAP_SLAPD_F (int) lload_bindconf_tls_set( slap_bindconf *bc, LDAP *ld );
83e670fd5cSchristos LDAP_SLAPD_F (void) lload_bindconf_free( slap_bindconf *bc );
84e670fd5cSchristos #ifdef BALANCER_MODULE
85e670fd5cSchristos LDAP_SLAPD_F (int) lload_back_init_cf( BackendInfo *bi );
86e670fd5cSchristos #endif
87e670fd5cSchristos 
88e670fd5cSchristos /*
89e670fd5cSchristos  * connection.c
90e670fd5cSchristos  */
91e670fd5cSchristos LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) clients_mutex;
92e670fd5cSchristos LDAP_SLAPD_F (void *) handle_pdus( void *ctx, void *arg );
93e670fd5cSchristos LDAP_SLAPD_F (void) connection_write_cb( evutil_socket_t s, short what, void *arg );
94e670fd5cSchristos LDAP_SLAPD_F (void) connection_read_cb( evutil_socket_t s, short what, void *arg );
95e670fd5cSchristos LDAP_SLAPD_F (int) lload_connection_close( LloadConnection *c, void *arg );
96e670fd5cSchristos LDAP_SLAPD_F (LloadConnection *) lload_connection_init( ber_socket_t s, const char *peername, int use_tls );
97e670fd5cSchristos LDAP_SLAPD_F (void) connection_destroy( LloadConnection *c );
98e670fd5cSchristos LDAP_SLAPD_F (void) connections_walk_last( ldap_pvt_thread_mutex_t *cq_mutex,
99e670fd5cSchristos         lload_c_head *cq,
100e670fd5cSchristos         LloadConnection *cq_last,
101e670fd5cSchristos         CONNCB cb,
102e670fd5cSchristos         void *arg );
103e670fd5cSchristos LDAP_SLAPD_F (void) connections_walk( ldap_pvt_thread_mutex_t *cq_mutex, lload_c_head *cq, CONNCB cb, void *arg );
104e670fd5cSchristos 
105e670fd5cSchristos /*
106e670fd5cSchristos  * daemon.c
107e670fd5cSchristos  */
108e670fd5cSchristos LDAP_SLAPD_F (int) lload_open_new_listener( const char *urls, LDAPURLDesc *lud );
109e670fd5cSchristos LDAP_SLAPD_F (int) lloadd_listeners_init( const char *urls );
110e670fd5cSchristos LDAP_SLAPD_F (int) lloadd_daemon_destroy( void );
111e670fd5cSchristos LDAP_SLAPD_F (int) lloadd_daemon( struct event_base *daemon_base );
112e670fd5cSchristos LDAP_SLAPD_F (LloadListener **) lloadd_get_listeners( void );
113e670fd5cSchristos LDAP_SLAPD_F (void) listeners_reactivate( void );
114e670fd5cSchristos LDAP_SLAPD_F (struct event_base *) lload_get_base( ber_socket_t s );
115e670fd5cSchristos LDAP_SLAPD_V (int) lload_daemon_threads;
116e670fd5cSchristos LDAP_SLAPD_V (int) lload_daemon_mask;
117e670fd5cSchristos 
118e670fd5cSchristos LDAP_SLAPD_F (void) lload_sig_shutdown( evutil_socket_t sig, short what, void *arg );
119e670fd5cSchristos 
120e670fd5cSchristos LDAP_SLAPD_F (void) lload_pause_server( void );
121e670fd5cSchristos LDAP_SLAPD_F (void) lload_unpause_server( void );
122e670fd5cSchristos 
123e670fd5cSchristos LDAP_SLAPD_V (struct event_base *) daemon_base;
124e670fd5cSchristos LDAP_SLAPD_V (struct evdns_base *) dnsbase;
125e670fd5cSchristos LDAP_SLAPD_V (volatile sig_atomic_t) slapd_shutdown;
126e670fd5cSchristos LDAP_SLAPD_V (volatile sig_atomic_t) slapd_gentle_shutdown;
127e670fd5cSchristos LDAP_SLAPD_V (int) lloadd_inited;
128e670fd5cSchristos LDAP_SLAPD_V (struct LloadChange) lload_change;
129e670fd5cSchristos 
130e670fd5cSchristos LDAP_SLAPD_V (struct event *) lload_timeout_event;
131e670fd5cSchristos 
132e670fd5cSchristos LDAP_SLAPD_V (LDAP *) lload_tls_backend_ld;
133e670fd5cSchristos LDAP_SLAPD_V (LDAP *) lload_tls_ld;
134e670fd5cSchristos LDAP_SLAPD_V (void *) lload_tls_ctx;
135e670fd5cSchristos #ifdef BALANCER_MODULE
136e670fd5cSchristos LDAP_SLAPD_V (int) lload_use_slap_tls_ctx;
137e670fd5cSchristos #endif /* BALANCER_MODULE */
138e670fd5cSchristos 
139e670fd5cSchristos /*
140e670fd5cSchristos  * extended.c
141e670fd5cSchristos  */
142e670fd5cSchristos LDAP_SLAPD_V (Avlnode *) lload_exop_handlers;
143e670fd5cSchristos LDAP_SLAPD_F (int) exop_handler_cmp( const void *l, const void *r );
144e670fd5cSchristos LDAP_SLAPD_F (int) request_extended( LloadConnection *c, LloadOperation *op );
145e670fd5cSchristos LDAP_SLAPD_F (int) lload_exop_init( void );
146e670fd5cSchristos 
147e670fd5cSchristos /*
148e670fd5cSchristos  * init.c
149e670fd5cSchristos  */
150e670fd5cSchristos LDAP_SLAPD_F (int) lload_global_init( void );
151e670fd5cSchristos LDAP_SLAPD_F (int) lload_tls_init( void );
152e670fd5cSchristos LDAP_SLAPD_F (int) lload_init( int mode, const char *name );
153e670fd5cSchristos LDAP_SLAPD_F (int) lload_destroy( void );
154e670fd5cSchristos LDAP_SLAPD_F (void) lload_counters_init( void );
155e670fd5cSchristos 
156e670fd5cSchristos /*
157e670fd5cSchristos  * libevent_support.c
158e670fd5cSchristos  */
159e670fd5cSchristos LDAP_SLAPD_F (int) lload_libevent_init( void );
160e670fd5cSchristos LDAP_SLAPD_F (void) lload_libevent_destroy( void );
161e670fd5cSchristos 
162e670fd5cSchristos #ifdef BALANCER_MODULE
163e670fd5cSchristos /*
164e670fd5cSchristos  * monitor.c
165e670fd5cSchristos  */
166e670fd5cSchristos LDAP_SLAPD_F (int) lload_monitor_open( void );
167e670fd5cSchristos LDAP_SLAPD_F (int) lload_monitor_backend_init( BackendInfo *bi, LloadBackend *b );
168e670fd5cSchristos #endif /* BALANCER_MODULE */
169e670fd5cSchristos 
170e670fd5cSchristos /*
171e670fd5cSchristos  * operation.c
172e670fd5cSchristos  */
173e670fd5cSchristos LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) lload_pin_mutex;
174e670fd5cSchristos LDAP_SLAPD_V (unsigned long) lload_next_pin;
175e670fd5cSchristos LDAP_SLAPD_F (const char *) lload_msgtype2str( ber_tag_t tag );
176e670fd5cSchristos LDAP_SLAPD_F (int) operation_upstream_cmp( const void *l, const void *r );
177e670fd5cSchristos LDAP_SLAPD_F (int) operation_client_cmp( const void *l, const void *r );
178e670fd5cSchristos LDAP_SLAPD_F (LloadOperation *) operation_init( LloadConnection *c, BerElement *ber );
179e670fd5cSchristos LDAP_SLAPD_F (int) operation_send_abandon( LloadOperation *op, LloadConnection *c );
180e670fd5cSchristos LDAP_SLAPD_F (void) operation_abandon( LloadOperation *op );
181e670fd5cSchristos LDAP_SLAPD_F (void) operation_send_reject( LloadOperation *op, int result, const char *msg, int send_anyway );
182e670fd5cSchristos LDAP_SLAPD_F (int) operation_send_reject_locked( LloadOperation *op, int result, const char *msg, int send_anyway );
183e670fd5cSchristos LDAP_SLAPD_F (void) operation_lost_upstream( LloadOperation *op );
184e670fd5cSchristos LDAP_SLAPD_F (void) operation_destroy( LloadOperation *op );
185e670fd5cSchristos LDAP_SLAPD_F (int) operation_unlink( LloadOperation *op );
186e670fd5cSchristos LDAP_SLAPD_F (int) operation_unlink_client( LloadOperation *op, LloadConnection *client );
187e670fd5cSchristos LDAP_SLAPD_F (int) operation_unlink_upstream( LloadOperation *op, LloadConnection *upstream );
188e670fd5cSchristos LDAP_SLAPD_F (void) operations_timeout( evutil_socket_t s, short what, void *arg );
189e670fd5cSchristos LDAP_SLAPD_F (void) operation_update_conn_counters( LloadOperation *op, LloadConnection *upstream );
190e670fd5cSchristos LDAP_SLAPD_F (void) operation_update_backend_counters( LloadOperation *op, LloadBackend *b );
191e670fd5cSchristos LDAP_SLAPD_F (void) operation_update_global_rejected( LloadOperation *op );
192e670fd5cSchristos /*
193e670fd5cSchristos  * upstream.c
194e670fd5cSchristos  */
195e670fd5cSchristos LDAP_SLAPD_F (int) forward_final_response( LloadConnection *client, LloadOperation *op, BerElement *ber );
196e670fd5cSchristos LDAP_SLAPD_F (int) forward_response( LloadConnection *client, LloadOperation *op, BerElement *ber );
197e670fd5cSchristos LDAP_SLAPD_F (void *) upstream_bind( void *ctx, void *arg );
198e670fd5cSchristos LDAP_SLAPD_F (LloadConnection *) upstream_init( ber_socket_t s, LloadBackend *b );
199e670fd5cSchristos LDAP_SLAPD_F (void) upstream_destroy( LloadConnection *c );
200e670fd5cSchristos 
201e670fd5cSchristos LDAP_SLAPD_V (ber_len_t) sockbuf_max_incoming_client;
202e670fd5cSchristos LDAP_SLAPD_V (ber_len_t) sockbuf_max_incoming_upstream;
203e670fd5cSchristos LDAP_SLAPD_V (int) lload_conn_max_pdus_per_cycle;
204e670fd5cSchristos 
205e670fd5cSchristos LDAP_SLAPD_V (lload_features_t) lload_features;
206e670fd5cSchristos 
207e670fd5cSchristos LDAP_SLAPD_V (slap_mask_t) global_allows;
208e670fd5cSchristos LDAP_SLAPD_V (slap_mask_t) global_disallows;
209e670fd5cSchristos 
210e670fd5cSchristos LDAP_SLAPD_V (const char) Versionstr[];
211e670fd5cSchristos 
212e670fd5cSchristos LDAP_SLAPD_V (int) global_gentlehup;
213e670fd5cSchristos LDAP_SLAPD_V (int) global_idletimeout;
214e670fd5cSchristos 
215e670fd5cSchristos LDAP_SLAPD_V (struct timeval *) lload_timeout_api;
216e670fd5cSchristos LDAP_SLAPD_V (struct timeval *) lload_timeout_net;
217e670fd5cSchristos LDAP_SLAPD_V (struct timeval *) lload_write_timeout;
218e670fd5cSchristos 
219e670fd5cSchristos LDAP_SLAPD_V (char *) global_host;
220e670fd5cSchristos LDAP_SLAPD_V (int) lber_debug;
221e670fd5cSchristos LDAP_SLAPD_V (int) ldap_syslog;
222e670fd5cSchristos 
223e670fd5cSchristos LDAP_SLAPD_V (lload_global_stats_t) lload_stats;
224e670fd5cSchristos LDAP_SLAPD_V (char *) listeners_list;
225e670fd5cSchristos LDAP_END_DECL
226e670fd5cSchristos 
227e670fd5cSchristos #endif /* PROTO_LLOAD_H */
228