1
/* trace.c - traces overlay invocation */
2
/* $OpenLDAP: pkg/ldap/contrib/slapd-modules/trace/trace.c,v 1.2.2.4 2009/01/22 00:00:46 kurt Exp $ */
3
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5
* Copyright 2006-2009 The OpenLDAP Foundation.
8
* Redistribution and use in source and binary forms, with or without
9
* modification, are permitted only as authorized by the OpenLDAP
12
* A copy of this license is available in the file LICENSE in the
13
* top-level directory of the distribution or, alternatively, at
14
* <http://www.OpenLDAP.org/license.html>.
17
* This work was initially developed by Pierangelo Masarati for inclusion in
23
#ifdef SLAPD_OVER_TRACE
27
#include <ac/string.h>
28
#include <ac/socket.h>
34
trace_op2str( Operation *op, char **op_strp )
36
switch ( op->o_tag ) {
65
case LDAP_REQ_COMPARE:
69
case LDAP_REQ_ABANDON:
73
case LDAP_REQ_EXTENDED:
74
*op_strp = "EXTENDED";
85
trace_op_func( Operation *op, SlapReply *rs )
89
(void)trace_op2str( op, &op_str );
91
switch ( op->o_tag ) {
92
case LDAP_REQ_EXTENDED:
93
Log3( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO,
94
"%s trace op=EXTENDED dn=\"%s\" reqoid=%s\n",
96
BER_BVISNULL( &op->o_req_ndn ) ? "(null)" : op->o_req_ndn.bv_val,
97
BER_BVISNULL( &op->ore_reqoid ) ? "" : op->ore_reqoid.bv_val );
101
Log3( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO,
102
"%s trace op=%s dn=\"%s\"\n",
103
op->o_log_prefix, op_str,
104
BER_BVISNULL( &op->o_req_ndn ) ? "(null)" : op->o_req_ndn.bv_val );
108
return SLAP_CB_CONTINUE;
112
trace_response( Operation *op, SlapReply *rs )
116
(void)trace_op2str( op, &op_str );
118
switch ( op->o_tag ) {
119
case LDAP_REQ_EXTENDED:
120
Log5( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO,
121
"%s trace op=EXTENDED RESPONSE dn=\"%s\" reqoid=%s rspoid=%s err=%d\n",
123
BER_BVISNULL( &op->o_req_ndn ) ? "(null)" : op->o_req_ndn.bv_val,
124
BER_BVISNULL( &op->ore_reqoid ) ? "" : op->ore_reqoid.bv_val,
125
rs->sr_rspoid == NULL ? "" : rs->sr_rspoid,
129
case LDAP_REQ_SEARCH:
130
switch ( rs->sr_type ) {
132
Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO,
133
"%s trace op=SEARCH ENTRY dn=\"%s\"\n",
135
rs->sr_entry->e_name.bv_val );
139
Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO,
140
"%s trace op=SEARCH REFERENCE ref=\"%s\"\n",
142
rs->sr_ref[ 0 ].bv_val );
154
Log4( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO,
155
"%s trace op=%s RESPONSE dn=\"%s\" err=%d\n",
158
BER_BVISNULL( &op->o_req_ndn ) ? "(null)" : op->o_req_ndn.bv_val,
164
return SLAP_CB_CONTINUE;
171
Log0( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO,
185
Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO,
186
"trace DB_CONFIG argc=%d argv[0]=\"%s\"\n",
196
Log0( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO,
206
Log0( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO,
207
"trace DB_CLOSE\n" );
216
Log0( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO,
217
"trace DB_DESTROY\n" );
222
static slap_overinst trace;
227
trace.on_bi.bi_type = "trace";
229
trace.on_bi.bi_db_init = trace_db_init;
230
trace.on_bi.bi_db_open = trace_db_open;
231
trace.on_bi.bi_db_config = trace_db_config;
232
trace.on_bi.bi_db_close = trace_db_close;
233
trace.on_bi.bi_db_destroy = trace_db_destroy;
235
trace.on_bi.bi_op_add = trace_op_func;
236
trace.on_bi.bi_op_bind = trace_op_func;
237
trace.on_bi.bi_op_unbind = trace_op_func;
238
trace.on_bi.bi_op_compare = trace_op_func;
239
trace.on_bi.bi_op_delete = trace_op_func;
240
trace.on_bi.bi_op_modify = trace_op_func;
241
trace.on_bi.bi_op_modrdn = trace_op_func;
242
trace.on_bi.bi_op_search = trace_op_func;
243
trace.on_bi.bi_op_abandon = trace_op_func;
244
trace.on_bi.bi_extended = trace_op_func;
246
trace.on_response = trace_response;
248
return overlay_register( &trace );
251
#if SLAPD_OVER_TRACE == SLAPD_MOD_DYNAMIC
253
init_module( int argc, char *argv[] )
255
return trace_initialize();
257
#endif /* SLAPD_OVER_TRACE == SLAPD_MOD_DYNAMIC */
259
#endif /* defined(SLAPD_OVER_TRACE) */