static fr_dict_attr_t const *attr_packet_src_ip_address;
static fr_dict_attr_t const *attr_packet_src_ipv6_address;
static fr_dict_attr_t const *attr_packet_src_port;
-static fr_dict_attr_t const *attr_packet_authentication_vector;
/** Placeholder attribute for uses of unspecified attribute references
*/
{ .out = &attr_packet_src_ip_address, .name = "Packet-Src-IP-Address", .type = FR_TYPE_IPV4_ADDR, .dict = &dict_freeradius },
{ .out = &attr_packet_src_ipv6_address, .name = "Packet-Src-IPv6-Address", .type = FR_TYPE_IPV6_ADDR, .dict = &dict_freeradius },
{ .out = &attr_packet_src_port, .name = "Packet-Src-Port", .type = FR_TYPE_UINT16, .dict = &dict_freeradius },
-
- { .out = &attr_packet_authentication_vector, .name = "Packet-Authentication-Vector", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
{ NULL }
};
*/
#include <freeradius-devel/radius/radius.h>
#include <freeradius-devel/io/listen.h>
+#include <freeradius-devel/unlang/xlat_func.h>
#include <freeradius-devel/server/module_rlm.h>
#include "proto_radius.h"
return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.dl_inst));
}
+/** Get the authentication vector.
+ *
+ * Note that we don't allow people to get the reply vector, because
+ * it doesn't exist until the reply is sent.
+ *
+ */
+static xlat_action_t packet_vector_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
+ UNUSED xlat_ctx_t const *xctx, request_t *request,
+ UNUSED fr_value_box_list_t *in)
+{
+ fr_value_box_t *vb;
+
+ if (request->dict != dict_radius) return XLAT_ACTION_FAIL;
+
+ MEM(vb = fr_value_box_alloc(ctx, FR_TYPE_OCTETS, NULL));
+ if (fr_value_box_memdup(vb, vb, NULL, request->packet->vector, sizeof(request->packet->vector), true) < 0) {
+ talloc_free(vb);
+ return XLAT_ACTION_FAIL;
+ }
+
+ fr_dcursor_append(out, vb);
+
+ return XLAT_ACTION_DONE;
+}
+
+
static int mod_load(void)
{
+ xlat_t *xlat;
+
if (fr_radius_init() < 0) {
PERROR("Failed initialising protocol library");
return -1;
}
+
+
+ if (!(xlat = xlat_func_register(NULL, "radius.packet.vector", packet_vector_xlat, FR_TYPE_OCTETS))) return -1;
+
return 0;
}
static void mod_unload(void)
{
+ xlat_func_unregister("radius.packet.vector");
+
fr_radius_free();
}