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