union {
struct {
- uint64_t *start_time; //!< time original request started (network -> worker)
+ fr_time_t *start_time; //!< time original request started (network -> worker)
uint32_t priority; //!< priority of this packet. 0=high, 65535=low.
} request;
struct {
fr_time_t cpu_time; //!< total CPU time, including predicted work, (only worker -> network)
fr_time_t processing_time; //!< actual processing time for this packet (only worker -> network)
+ fr_time_t request_time; //!< timestamp of the request packet
} reply;
};
RCSID("$Id$")
#include <freeradius-devel/util/track.h>
+#include <freeradius-devel/rad_assert.h>
/*
* RADIUS-specific tracking table.
#ifndef NDEBUG
(void) talloc_get_type_abort(ft, fr_tracking_t);
#endif
+
entry = &ft->packet[id];
if (entry->timestamp == 0) return -1;
entry->timestamp = 0;
ft->num_entries--;
+ /*
+ * Mark the reply (if any) as done.
+ */
+ if (entry->reply) {
+ fr_message_done(&entry->reply->m);
+ entry->reply = NULL;
+ }
+
return 0;
}
/** Insert a (possibly new) packet and a timestamp
*
* @param[in] ft the tracking table
- * @param[in] packet the RADIUS packet to insert
+ * @param[in] packet the packet to insert
* @param[in] timestamp when this packet was received
* @param[out] p_entry pointer to newly inserted entry.
* @return
return FR_TRACKING_DIFFERENT;
}
+
+/** Insert a (possibly new) packet and a timestamp
+ *
+ * @param[in] ft the tracking table
+ * @param[in] id the ID of the entry which this reply is for
+ * @param[in] cd the reply message
+ * @return
+ * - <0 on error
+ * - 0 on success
+ */
+int fr_radius_tracking_entry_reply(fr_tracking_t *ft, uint8_t id,
+ fr_channel_data_t *cd)
+{
+ fr_tracking_entry_t *entry;
+
+#ifndef NDEBUG
+ (void) talloc_get_type_abort(ft, fr_tracking_t);
+#endif
+
+ entry = &ft->packet[id];
+
+ if (entry->timestamp != cd->reply.request_time) {
+ fr_message_done(&cd->m);
+ return 0;
+ }
+
+ rad_assert(entry->reply == NULL);
+
+ entry->reply = cd;
+
+ return 0;
+}
*/
RCSIDH(track_h, "$Id$")
-#include <freeradius-devel/util/time.h>
-#include <talloc.h>
+#include <freeradius-devel/util/channel.h>
#ifdef __cplusplus
extern "C" {
* information required to track RADIUS packets.
*/
typedef struct fr_tracking_entry_t {
- fr_time_t timestamp; //!< when received
- uint8_t data[18]; //!< 2 byte length + authentication vector
+ fr_time_t timestamp; //!< when received
+ fr_channel_data_t *reply; //!< the reply (if any)
+ uint8_t data[18]; //!< 2 byte length + authentication vector
} fr_tracking_entry_t;
/**
int fr_radius_tracking_entry_delete(fr_tracking_t *ft, uint8_t id) CC_HINT(nonnull);
fr_tracking_status_t fr_radius_tracking_entry_insert(fr_tracking_t *ft, uint8_t *packet, fr_time_t timestamp,
fr_tracking_entry_t **p_entry) CC_HINT(nonnull);
+int fr_radius_tracking_entry_reply(fr_tracking_t *ft, uint8_t id,
+ fr_channel_data_t *cd) CC_HINT(nonnull);
#ifdef __cplusplus
}