Home | History | Annotate | Line # | Download | only in back-monitor
      1  1.3  christos /*	$NetBSD: operational.c,v 1.4 2025/09/05 21:16:28 christos Exp $	*/
      2  1.2  christos 
      3  1.1     lukem /* operational.c - monitor backend operational attributes function */
      4  1.2  christos /* $OpenLDAP$ */
      5  1.1     lukem /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
      6  1.1     lukem  *
      7  1.4  christos  * Copyright 2001-2024 The OpenLDAP Foundation.
      8  1.1     lukem  * Portions Copyright 2001-2003 Pierangelo Masarati.
      9  1.1     lukem  * All rights reserved.
     10  1.1     lukem  *
     11  1.1     lukem  * Redistribution and use in source and binary forms, with or without
     12  1.1     lukem  * modification, are permitted only as authorized by the OpenLDAP
     13  1.1     lukem  * Public License.
     14  1.1     lukem  *
     15  1.1     lukem  * A copy of this license is available in file LICENSE in the
     16  1.1     lukem  * top-level directory of the distribution or, alternatively, at
     17  1.1     lukem  * <http://www.OpenLDAP.org/license.html>.
     18  1.1     lukem  */
     19  1.1     lukem /* ACKNOWLEDGEMENTS:
     20  1.1     lukem  * This work was initially developed by Pierangelo Masarati for inclusion
     21  1.1     lukem  * in OpenLDAP Software.
     22  1.1     lukem  */
     23  1.1     lukem 
     24  1.2  christos #include <sys/cdefs.h>
     25  1.3  christos __RCSID("$NetBSD: operational.c,v 1.4 2025/09/05 21:16:28 christos Exp $");
     26  1.2  christos 
     27  1.1     lukem #include "portable.h"
     28  1.1     lukem 
     29  1.1     lukem #include <stdio.h>
     30  1.1     lukem 
     31  1.1     lukem #include <ac/string.h>
     32  1.1     lukem #include <ac/socket.h>
     33  1.1     lukem 
     34  1.1     lukem #include "slap.h"
     35  1.1     lukem #include "back-monitor.h"
     36  1.1     lukem #include "proto-back-monitor.h"
     37  1.1     lukem 
     38  1.1     lukem /*
     39  1.1     lukem  * sets the supported operational attributes (if required)
     40  1.1     lukem  */
     41  1.1     lukem 
     42  1.1     lukem int
     43  1.1     lukem monitor_back_operational(
     44  1.1     lukem 	Operation	*op,
     45  1.1     lukem 	SlapReply	*rs )
     46  1.1     lukem {
     47  1.1     lukem 	Attribute	**ap;
     48  1.1     lukem 
     49  1.1     lukem 	assert( rs->sr_entry != NULL );
     50  1.1     lukem 
     51  1.2  christos 	for ( ap = &rs->sr_operational_attrs; *ap; ap = &(*ap)->a_next ) {
     52  1.2  christos 		if ( (*ap)->a_desc == slap_schema.si_ad_hasSubordinates ) {
     53  1.2  christos 			break;
     54  1.2  christos 		}
     55  1.2  christos 	}
     56  1.1     lukem 
     57  1.2  christos 	if ( *ap == NULL &&
     58  1.2  christos 		attr_find( rs->sr_entry->e_attrs, slap_schema.si_ad_hasSubordinates ) == NULL &&
     59  1.2  christos 		( SLAP_OPATTRS( rs->sr_attr_flags ) ||
     60  1.2  christos 			ad_inlist( slap_schema.si_ad_hasSubordinates, rs->sr_attrs ) ) )
     61  1.1     lukem 	{
     62  1.1     lukem 		int			hs;
     63  1.1     lukem 		monitor_entry_t	*mp;
     64  1.1     lukem 
     65  1.1     lukem 		mp = ( monitor_entry_t * )rs->sr_entry->e_private;
     66  1.1     lukem 
     67  1.1     lukem 		assert( mp != NULL );
     68  1.1     lukem 
     69  1.1     lukem 		hs = MONITOR_HAS_CHILDREN( mp );
     70  1.1     lukem 		*ap = slap_operational_hasSubordinate( hs );
     71  1.1     lukem 		assert( *ap != NULL );
     72  1.1     lukem 		ap = &(*ap)->a_next;
     73  1.1     lukem 	}
     74  1.1     lukem 
     75  1.1     lukem 	return LDAP_SUCCESS;
     76  1.1     lukem }
     77  1.1     lukem 
     78