*/
typedef void (*fr_io_data_vnode_t)(fr_listen_t *li, uint32_t fflags);
+typedef struct fr_io_track_s fr_io_track_t; /* in master.h */
+
/** Convert a raw packet to a tracking structure
*
* For passing to fr_io_track_cmp_t
* @param[in] instance the context for this function
* @param[in] thread_instance the thread instance for this function
* @param[in] client the client associated with this packet
- * @param[in] ctx The parent talloc ctx
+ * @param[in] track The parent tracking structure
* @param[in] packet The packet being summarized
* @param[in] packet_len Length of the packet being summarized
* @return
* - NULL on error
* - !NULL the packet tracking structure
*/
-typedef void *(*fr_io_track_create_t)(void const *instance, void *thread_instance, RADCLIENT *client, TALLOC_CTX *ctx, uint8_t const *packet, size_t packet_len);
+typedef void *(*fr_io_track_create_t)(void const *instance, void *thread_instance, RADCLIENT *client, fr_io_track_t *track, uint8_t const *packet, size_t packet_len);
/** Compare two tracking structures for storing in a duplicate detection tree.
*
typedef struct fr_io_client_s fr_io_client_t;
-typedef struct {
+typedef struct fr_io_track_s {
fr_rb_node_t node; //!< rbtree node in the tracking tree.
fr_event_timer_t const *ev; //!< when we clean up this tracking entry
fr_time_t timestamp; //!< when this packet was received
static void *mod_track_create(UNUSED void const *instance, UNUSED void *thread_instance, UNUSED RADCLIENT *client,
- TALLOC_CTX *ctx, uint8_t const *packet, size_t packet_len)
+ fr_io_track_t *track, uint8_t const *packet, size_t packet_len)
{
- proto_dhcpv4_track_t *track;
+ proto_dhcpv4_track_t *t;
dhcp_packet_t const *dhcp = (dhcp_packet_t const *) packet;
uint8_t const *option;
return NULL;
}
- track = talloc_zero(ctx, proto_dhcpv4_track_t);
- if (!track) return NULL;
+ t = talloc_zero(track, proto_dhcpv4_track_t);
+ if (!t) return NULL;
- memcpy(&track->xid, &dhcp->xid, sizeof(track->xid));
+ memcpy(&t->xid, &dhcp->xid, sizeof(t->xid));
- track->message_type = option[2];
+ t->message_type = option[2];
/*
* Track most packets by chaddr. For lease queries, that
* exist according to RFC 4388 Section 6.3
*/
if (option[2] != FR_DHCP_LEASE_QUERY) {
- if (dhcp->hlen == 6) memcpy(&track->chaddr, &dhcp->chaddr, 6);
+ if (dhcp->hlen == 6) memcpy(&t->chaddr, &dhcp->chaddr, 6);
}
- track->broadcast = ((dhcp->flags & FR_FLAGS_VALUE_BROADCAST) != 0);
- track->hops = dhcp->hops;
- memcpy(&track->ciaddr, &dhcp->ciaddr, sizeof(track->ciaddr));
- memcpy(&track->giaddr, &dhcp->giaddr, sizeof(track->giaddr));
+ t->broadcast = ((dhcp->flags & FR_FLAGS_VALUE_BROADCAST) != 0);
+ t->hops = dhcp->hops;
+ memcpy(&t->ciaddr, &dhcp->ciaddr, sizeof(t->ciaddr));
+ memcpy(&t->giaddr, &dhcp->giaddr, sizeof(t->giaddr));
- return track;
+ return t;
}
static int mod_track_compare(UNUSED void const *instance, UNUSED void *thread_instance, UNUSED RADCLIENT *client,
}
static void *mod_track_create(UNUSED void const *instance, UNUSED void *thread_instance, UNUSED RADCLIENT *client,
- TALLOC_CTX *ctx, uint8_t const *packet, size_t packet_len)
+ fr_io_track_t *track, uint8_t const *packet, size_t packet_len)
{
- proto_dhcpv6_track_t *track;
+ proto_dhcpv6_track_t *t;
uint8_t const *option;
- size_t track_size = sizeof(*track);
+ size_t t_size = sizeof(*t);
size_t option_len;
/*
option_len = (option[2] << 8) | option[3];
- track = (proto_dhcpv6_track_t *) talloc_zero_array(ctx, uint8_t, track_size + option_len);
- if (!track) return NULL;
+ t = (proto_dhcpv6_track_t *) talloc_zero_array(track, uint8_t, t_size + option_len);
+ if (!t) return NULL;
- talloc_set_name_const(track, "proto_dhcpv6_track_t");
+ talloc_set_name_const(t, "proto_dhcpv6_track_t");
- memcpy(&track->header, packet, 4); /* packet code + 24-bit transaction ID */
+ memcpy(&t->header, packet, 4); /* packet code + 24-bit transaction ID */
- memcpy(&track->client_id[0], option + 4, option_len);
- track->client_id_len = option_len;
+ memcpy(&t->client_id[0], option + 4, option_len);
+ t->client_id_len = option_len;
- return track;
+ return t;
}
return 0;
}
-static void *mod_track_create(void const *instance, UNUSED void *thread_instance, UNUSED RADCLIENT *client,
- TALLOC_CTX *ctx, uint8_t const *packet, UNUSED size_t packet_len)
+static void *mod_track_create(UNUSED void const *instance, UNUSED void *thread_instance, UNUSED RADCLIENT *client,
+ fr_io_track_t *track, uint8_t const *packet, UNUSED size_t packet_len)
{
- return talloc_memdup(ctx, packet, RADIUS_HEADER_LENGTH);
+ return talloc_memdup(track, packet, RADIUS_HEADER_LENGTH);
}
static int mod_track_compare(void const *instance, UNUSED void *thread_instance, UNUSED RADCLIENT *client,
}
static void *mod_track_create(UNUSED void const *instance, UNUSED void *thread_instance, UNUSED RADCLIENT *client,
- TALLOC_CTX *ctx, uint8_t const *buffer, UNUSED size_t buffer_len)
+ fr_io_track_t *track, uint8_t const *buffer, UNUSED size_t buffer_len)
{
fr_tacacs_packet_t const *pkt = (fr_tacacs_packet_t const *) buffer;
- proto_tacacs_track_t *track;
+ proto_tacacs_track_t *t;
- track = talloc_zero(ctx, proto_tacacs_track_t);
+ t = talloc_zero(track, proto_tacacs_track_t);
+ if (!t) return NULL;
- if (!track) return NULL;
-
- talloc_set_name_const(track, "proto_tacacs_track_t");
+ talloc_set_name_const(t, "proto_tacacs_track_t");
switch (pkt->hdr.type) {
case FR_TAC_PLUS_AUTHEN:
if (packet_is_authen_start_request(pkt)) {
- track->type = FR_PACKET_TYPE_VALUE_AUTHENTICATION_START;
+ t->type = FR_PACKET_TYPE_VALUE_AUTHENTICATION_START;
} else {
- track->type = FR_PACKET_TYPE_VALUE_AUTHENTICATION_CONTINUE;
+ t->type = FR_PACKET_TYPE_VALUE_AUTHENTICATION_CONTINUE;
}
break;
case FR_TAC_PLUS_AUTHOR:
- track->type = FR_PACKET_TYPE_VALUE_AUTHORIZATION_REQUEST;
+ t->type = FR_PACKET_TYPE_VALUE_AUTHORIZATION_REQUEST;
break;
case FR_TAC_PLUS_ACCT:
- track->type = FR_PACKET_TYPE_VALUE_ACCOUNTING_REQUEST;
+ t->type = FR_PACKET_TYPE_VALUE_ACCOUNTING_REQUEST;
break;
default:
- talloc_free(track);
+ talloc_free(t);
fr_assert(0);
return NULL;
}
- track->session_id = pkt->hdr.session_id;
+ t->session_id = pkt->hdr.session_id;
- return track;
+ return t;
}
static int mod_track_compare(UNUSED void const *instance, UNUSED void *thread_instance, UNUSED RADCLIENT *client,
}
static void *mod_track_create(UNUSED void const *instance, UNUSED void *thread_instance, UNUSED RADCLIENT *client,
- TALLOC_CTX *ctx, uint8_t const *buffer, size_t buffer_len)
+ fr_io_track_t *track, uint8_t const *buffer, size_t buffer_len)
{
- proto_vmps_track_t *track;
+ proto_vmps_track_t *t;
if (buffer_len < 4) {
ERROR("VMPS packet is too small. (%zu < 4)", buffer_len);
return NULL;
}
- track = talloc_zero(ctx, proto_vmps_track_t);
+ t = talloc_zero(track, proto_vmps_track_t);
- if (!track) return NULL;
+ if (!t) return NULL;
- talloc_set_name_const(track, "proto_vmps_track_t");
+ talloc_set_name_const(t, "proto_vmps_track_t");
- memcpy(&track->transaction_id, buffer, sizeof(track->transaction_id));
+ memcpy(&t->transaction_id, buffer, sizeof(t->transaction_id));
- track->opcode = buffer[1];
+ t->opcode = buffer[1];
- return track;
+ return t;
}
static int mod_track_compare(UNUSED void const *instance, UNUSED void *thread_instance, UNUSED RADCLIENT *client,