1 /*        $NetBSD: slapi.h,v 1.3 2021/08/14 16:15:02 christos Exp $   */
2 
3 /* $OpenLDAP$ */
4 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5  *
6  * Copyright 2002-2021 The OpenLDAP Foundation.
7  * Portions Copyright 1997,2002-2003 IBM Corporation.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted only as authorized by the OpenLDAP
12  * Public License.
13  *
14  * A copy of this license is available in the file LICENSE in the
15  * top-level directory of the distribution or, alternatively, at
16  * <http://www.OpenLDAP.org/license.html>.
17  */
18 /* ACKNOWLEDGEMENTS:
19  * This work was initially developed by IBM Corporation for use in
20  * IBM products and subsequently ported to OpenLDAP Software by
21  * Steve Omrani.  Additional significant contributors include:
22  *   Luke Howard
23  */
24 
25 #ifdef LDAP_SLAPI /* SLAPI is OPTIONAL */
26 
27 #ifndef _SLAPI_H
28 #define _SLAPI_H
29 
30 LDAP_BEGIN_DECL
31 
32 /*
33  * Quick 'n' dirty to make struct slapi_* in slapi-plugin.h opaque
34  */
35 #define slapi_entry Entry
36 #define slapi_attr  Attribute
37 #define slapi_value berval
38 #define slapi_valueset        berval *
39 #define slapi_filter          Filter
40 
41 LDAP_END_DECL
42 
43 #include <slapi-plugin.h>
44 
45 LDAP_BEGIN_DECL
46 
47 #define SLAPI_OVERLAY_NAME                        "slapi"
48 
49 #define SLAPI_OPERATION_PBLOCK(_op)               ((_op)->o_callback->sc_private)
50 #define SLAPI_BACKEND_PBLOCK(_be)                 ((_be)->be_pb)
51 
52 #define SLAPI_OPERATION_EXTENSIONS(_op)           ((_op)->o_hdr->oh_extensions)
53 #define SLAPI_CONNECTION_EXTENSIONS(_conn)        ((_conn)->c_extensions)
54 
55 #define SLAPI_CONTROL_MANAGEDSAIT_OID             LDAP_CONTROL_MANAGEDSAIT
56 #define SLAPI_CONTROL_SORTEDSEARCH_OID            LDAP_CONTROL_SORTREQUEST
57 #define SLAPI_CONTROL_PAGED_RESULTS_OID           LDAP_CONTROL_PAGEDRESULTS
58 
59 typedef int (*SLAPI_FUNC)( Slapi_PBlock *pb );
60 
61 typedef struct _slapi_control {
62         int                             s_ctrl_num;
63         char                            **s_ctrl_oids;
64         unsigned long                   *s_ctrl_ops;
65 } Slapi_Control;
66 
67 typedef struct _ExtendedOp {
68           struct berval                 ext_oid;
69         SLAPI_FUNC            ext_func;
70         Backend                         *ext_be;
71         struct _ExtendedOp    *ext_next;
72 } ExtendedOp;
73 
74 /* Computed attribute support */
75 struct _computed_attr_context {
76           Slapi_PBlock        *cac_pb;
77           Operation *cac_op;
78           void                *cac_private;
79 };
80 
81 /* for slapi_attr_type_cmp() */
82 #define SLAPI_TYPE_CMP_EXACT  0
83 #define SLAPI_TYPE_CMP_BASE   1
84 #define SLAPI_TYPE_CMP_SUBTYPE          2
85 
86 typedef enum slapi_extension_e {
87           SLAPI_X_EXT_CONNECTION = 0,
88           SLAPI_X_EXT_OPERATION = 1,
89           SLAPI_X_EXT_MAX = 2
90 } slapi_extension_t;
91 
92 struct slapi_dn {
93           unsigned char flag;
94           struct berval dn;
95           struct berval ndn;
96 };
97 
98 struct slapi_rdn {
99           unsigned char flag;
100           struct berval bv;
101           LDAPRDN rdn;
102 };
103 
104 /*
105  * Was: slapi_pblock.h
106  */
107 
108 #ifndef NO_PBLOCK_CLASS                 /* where's this test from? */
109 
110 typedef enum slapi_pblock_class_e {
111           PBLOCK_CLASS_INVALID = 0,
112           PBLOCK_CLASS_INTEGER,
113           PBLOCK_CLASS_LONG_INTEGER,
114           PBLOCK_CLASS_POINTER,
115           PBLOCK_CLASS_FUNCTION_POINTER
116 } slapi_pblock_class_t;
117 
118 #define PBLOCK_SUCCESS                            (0)
119 #define PBLOCK_ERROR                              (-1)
120 #define PBLOCK_MAX_PARAMS               100
121 
122 union slapi_pblock_value {
123           int pv_integer;
124           long pv_long_integer;
125           void *pv_pointer;
126           int (*pv_function_pointer)();
127 };
128 
129 struct slapi_pblock {
130           ldap_pvt_thread_mutex_t       pb_mutex;
131           int                           pb_nParams;
132           int                           pb_params[PBLOCK_MAX_PARAMS];
133           union slapi_pblock_value pb_values[PBLOCK_MAX_PARAMS];
134           /* native types */
135           Connection                    *pb_conn;
136           Operation           *pb_op;
137           SlapReply           *pb_rs;
138           int                           pb_intop;
139           char                          pb_textbuf[ SLAP_TEXT_BUFLEN ];
140 };
141 
142 #endif /* !NO_PBLOCK_CLASS */
143 
144 /*
145  * Was: plugin.h
146  */
147 
148 #define SLAPI_PLUGIN_IS_POST_FN(x) ((x) >= SLAPI_PLUGIN_POST_BIND_FN && (x) <= SLAPI_PLUGIN_BE_POST_DELETE_FN)
149 
150 #define SLAPI_IBM_PBLOCK                          -3
151 
152 #define   SLAPI_ENTRY_PRE_OP                      52
153 #define   SLAPI_ENTRY_POST_OP                     53
154 
155 /* This is the spelling in the SunOne 5.2 docs */
156 #define   SLAPI_RES_CONTROLS  SLAPI_RESCONTROLS
157 
158 #define SLAPI_ABANDON_MSGID                       120
159 
160 #define SLAPI_OPERATION_PARAMETERS                138
161 
162 #define SLAPI_SEQ_TYPE                                      150
163 #define SLAPI_SEQ_ATTRNAME                        151
164 #define SLAPI_SEQ_VAL                                       152
165 
166 #define SLAPI_MR_FILTER_ENTRY                     170
167 #define SLAPI_MR_FILTER_TYPE                      171
168 #define SLAPI_MR_FILTER_VALUE                     172
169 #define SLAPI_MR_FILTER_OID                       173
170 #define SLAPI_MR_FILTER_DNATTRS                             174
171 
172 #define SLAPI_LDIF2DB_FILE                        180
173 #define SLAPI_LDIF2DB_REMOVEDUPVALS               185
174 
175 #define SLAPI_DB2LDIF_PRINTKEY                              183
176 
177 #define   SLAPI_CHANGENUMBER                      197
178 #define   SLAPI_LOG_OPERATION                     198
179 
180 #define SLAPI_DBSIZE                                        199
181 
182 #define   SLAPI_PLUGIN_DB_TEST_FN                           227
183 #define SLAPI_PLUGIN_DB_NO_ACL                    250
184 
185 /* OpenLDAP private parameters */
186 #define SLAPI_PLUGIN_COMPUTE_EVALUATOR_FN         1200
187 #define SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN   1201
188 
189 #define SLAPI_X_CONFIG_ARGV                       1400
190 #define SLAPI_X_INTOP_FLAGS                       1401
191 #define SLAPI_X_INTOP_RESULT_CALLBACK             1402
192 #define SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK       1403
193 #define SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK     1404
194 #define SLAPI_X_INTOP_CALLBACK_DATA               1405
195 #define SLAPI_X_OLD_RESCONTROLS                             1406
196 
197 LDAP_SLAPI_V (ldap_pvt_thread_mutex_t)  slapi_hn_mutex;
198 LDAP_SLAPI_V (ldap_pvt_thread_mutex_t)  slapi_time_mutex;
199 LDAP_SLAPI_V (ldap_pvt_thread_mutex_t)  slapi_printmessage_mutex;
200 LDAP_SLAPI_V (char *)                             slapi_log_file;
201 LDAP_SLAPI_V (int)                      slapi_log_level;
202 
203 #include "proto-slapi.h"
204 
205 #endif /* _SLAPI_H */
206 #endif /* LDAP_SLAPI */
207