--- /dev/null
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+/**
+ * $Id$
+ *
+ * @brief Simple ring buffers for packet contents
+ * @file io/time_tracking.c
+ *
+ * @copyright 2024 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
+ */
+RCSID("$Id$")
+
+#include <freeradius-devel/io/time_tracking.h>
+
+fr_table_num_ordered_t fr_time_tracking_state_table[] = {
+ { L("STOPPED"), FR_TIME_TRACKING_STOPPED },
+ { L("RUNNING"), FR_TIME_TRACKING_RUNNING },
+ { L("YIELDED"), FR_TIME_TRACKING_YIELDED },
+};
+size_t fr_time_tracking_state_table_len = NUM_ELEMENTS(fr_time_tracking_state_table);
#endif
#include <freeradius-devel/util/debug.h>
+#include <freeradius-devel/util/table.h>
#include <freeradius-devel/util/time.h>
+extern fr_table_num_ordered_t fr_time_tracking_state_table[];
+extern size_t fr_time_tracking_state_table_len;
+
typedef enum {
FR_TIME_TRACKING_STOPPED = 0, //!< Time tracking is not running.
FR_TIME_TRACKING_RUNNING, //!< We're currently tracking time in the
static inline CC_HINT(nonnull(2)) void fr_time_tracking_start(fr_time_tracking_t *parent,
fr_time_tracking_t *tt, fr_time_t now)
{
- fr_assert_msg(tt->state == FR_TIME_TRACKING_STOPPED, "Unexpected time tracking state state %i", tt->state);
+
+ fr_assert_msg(tt->state == FR_TIME_TRACKING_STOPPED, "Unexpected time tracking state state %s",
+ fr_table_str_by_value(fr_time_tracking_state_table, tt->state, "<INVALID>"));
fr_assert(!tt->parent);
ASSERT_ON_TIME_TRAVEL(tt, now);
fr_assert(tt->parent);
fr_assert(parent->parent == tt->parent);
- fr_assert_msg(tt->state == FR_TIME_TRACKING_RUNNING, "Unexpected time tracking state state %i", tt->state);
+ fr_assert_msg(tt->state == FR_TIME_TRACKING_RUNNING, "Unexpected time tracking state state %s",
+ fr_table_str_by_value(fr_time_tracking_state_table, tt->state, "<INVALID>"));
run_time = fr_time_sub(now, tt->last_changed);
tt->last_changed = parent->started = now;
{
fr_time_delta_t run_time;
- fr_assert_msg(tt->state == FR_TIME_TRACKING_RUNNING, "Unexpected time tracking state state %i", tt->state);
+ fr_assert_msg(tt->state == FR_TIME_TRACKING_RUNNING, "Unexpected time tracking state state %s",
+ fr_table_str_by_value(fr_time_tracking_state_table, tt->state, "<INVALID>"));
fr_assert(tt->parent);
run_time = fr_time_sub(now, tt->last_changed);
ASSERT_ON_TIME_TRAVEL(tt, now);
- fr_assert_msg(tt->state == FR_TIME_TRACKING_RUNNING, "Unexpected time tracking state state %i", tt->state);
+ fr_assert_msg(tt->state == FR_TIME_TRACKING_RUNNING, "Unexpected time tracking state state %s",
+ fr_table_str_by_value(fr_time_tracking_state_table, tt->state, "<INVALID>"));
tt->state = FR_TIME_TRACKING_YIELDED;
tt->last_yielded = tt->last_changed = now;
ASSERT_ON_TIME_TRAVEL(tt, now);
- fr_assert_msg(tt->state == FR_TIME_TRACKING_YIELDED, "Unexpected time tracking state state %i", tt->state);
+ fr_assert_msg(tt->state == FR_TIME_TRACKING_YIELDED, "Unexpected time tracking state state %s",
+ fr_table_str_by_value(fr_time_tracking_state_table, tt->state, "<INVALID>"));
tt->state = FR_TIME_TRACKING_RUNNING;
tt->last_resumed = tt->last_changed = now;
{
fr_time_delta_t run_time;
- fr_assert_msg(tt->state == FR_TIME_TRACKING_RUNNING, "Unexpected time tracking state state %i", tt->state);
+ fr_assert_msg(tt->state == FR_TIME_TRACKING_RUNNING, "Unexpected time tracking state state %s",
+ fr_table_str_by_value(fr_time_tracking_state_table, tt->state, "<INVALID>"));
ASSERT_ON_TIME_TRAVEL(tt, now);
tt->state = FR_TIME_TRACKING_STOPPED;