RCSID("$Id$")
#include <freeradius-devel/server/base.h>
+
+#include <freeradius-devel/util/atexit.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/misc.h>
/** Internal SNMP initialisation function (used for recursion)
*
*/
-static int _fr_snmp_init(fr_snmp_map_t map[], fr_dict_attr_t const *parent)
+static int _fr_snmp_init_r(fr_snmp_map_t map[], fr_dict_attr_t const *parent)
{
unsigned int i;
return -1;
}
- ret = _fr_snmp_init(map[i].child, map[i].da);
+ ret = _fr_snmp_init_r(map[i].child, map[i].da);
if (ret < 0) return -1;
continue;
return 0;
}
-
-/** Initialise the tree of SNMP map structures used to attach callbacks to OIDs
- *
- */
-int fr_snmp_init(void)
+static int _fr_snmp_init(UNUSED void *uctx)
{
start_time = fr_time();
reset_time = start_time;
return -1;
}
- return _fr_snmp_init(snmp_iso, fr_dict_root(dict_snmp)); /* The SNMP root node */
+ return _fr_snmp_init_r(snmp_iso, fr_dict_root(dict_snmp)); /* The SNMP root node */
}
-void fr_snmp_free(void)
+static int _fr_snmp_free(UNUSED void *uctx)
{
fr_dict_autofree(snmp_dict);
+
+ return 0;
+}
+
+/** Initialise the tree of SNMP map structures used to attach callbacks to OIDs
+ *
+ */
+int fr_snmp_init(void)
+{
+ int ret;
+
+ fr_atexit_global_once_ret(&ret, _fr_snmp_init, _fr_snmp_free, NULL);
+
+ return ret;
}
void fr_stats_bins(fr_stats_t *stats, fr_time_t start, fr_time_t end);
int fr_snmp_process(request_t *request);
int fr_snmp_init(void);
-void fr_snmp_free(void);
#define FR_STATS_INC(_x, _y) radius_ ## _x ## _stats._y++;if (listener) listener->stats._y++;if (client) client->_x._y++;