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