FR_VALUE_BOX(uint64_t, date_microseconds, FR_TYPE_DATE_MICROSECONDS)
FR_VALUE_BOX(uint64_t, date_nanoseconds, FR_TYPE_DATE_NANOSECONDS)
-FR_VALUE_BOX(size_t, size, FR_TYPE_SIZE)
-
/** Automagically fill in a box, determining the value type from the type of the C variable
*
* Simplify boxing for simple C types using the _Generic macro to emit code that
int32_t : fr_value_box_int32, \
int64_t : fr_value_box_int64, \
float : fr_value_box_float32, \
- double : fr_value_box_float64, \
- size_t : fr_value_box_size \
+ double : fr_value_box_float64 \
)(_box, NULL, _var, _tainted)
/** Unbox an ethernet value (6 bytes, network byte order)
FR_VALUE_UNBOX(uint64_t, date_microseconds, FR_TYPE_DATE_MICROSECONDS)
FR_VALUE_UNBOX(uint64_t, date_nanoseconds, FR_TYPE_DATE_NANOSECONDS)
-FR_VALUE_UNBOX(size_t, size, FR_TYPE_SIZE)
-
/** Unbox simple types peforming type checks
*
* @param[out] _var to write to.
int32_t * : fr_value_unbox_int32, \
int64_t * : fr_value_unbox_int64, \
float * : fr_value_unbox_float32, \
- double * : fr_value_unbox_float64, \
- size_t * : fr_value_unbox_size \
+ double * : fr_value_unbox_float64 \
)(_var, _box)
/* @} **/
*
* @param[in] out boxed value containing the option.
* @param[in] proto_ctx to retrieve data from.
- * @param[in] group Option group to use.
+ * @param[in] opt_group Option group to use.
* @param[in] opt to retrieve.
* @return
* - 0 on success.
* - -1 on failure.
*/
-typedef int (*fr_proto_get_option_t)(fr_value_box_t *out, void const *proto_ctx, fr_proto_opt_group_t group, int opt);
+typedef int (*fr_proto_get_option_t)(fr_value_box_t *out, void const *proto_ctx,
+ fr_proto_opt_group_t opt_group, int opt);
/** Set a protocol option
*
* @param[in] proto_ctx to set option in.
- * @param[in] group Option group to use.
+ * @param[in] opt_group Option group to use.
* @param[in] opt to set.
* @param[in] in value to set.
* @return
typedef struct {
RAD_MODULE_COMMON; //!< Common fields to all loadable modules.
- size_t proto_ctx_size; //!< Size required for the packet ctx structure.
+ size_t proto_ctx_size; //!< Size required for the packet ctx structure.
fr_proto_opt_group_t opt_group; //!< Option groups implemented by proto lib.
case PROTO_OPT_GROUP_L2:
switch (opt) {
case PROTO_OPT_L2_PAYLOAD_LEN:
- return fr_value_box_shallow(out, ether_ctx->payload_len, true);
+ fr_value_box_init(out, FR_TYPE_SIZE, NULL, true);
+ out->vb_size = ether_ctx->payload_len;
+ return 0;
case PROTO_OPT_L2_SRC_ADDRESS:
return fr_value_box_ethernet_addr(out, NULL, ether_ctx->src_addr, true);
case PROTO_OPT_GROUP_L2:
switch (opt) {
case PROTO_OPT_L2_PAYLOAD_LEN:
- return fr_value_unbox_shallow(ðer_ctx->payload_len, in);
+ if (in->type != FR_TYPE_SIZE) {
+ fr_strerror_printf("Unboxing failed. Needed type %s, had type %s",
+ fr_int2str(dict_attr_types, FR_TYPE_SIZE, "?Unknown?"),
+ fr_int2str(dict_attr_types, in->type, "?Unknown?"));
+ return -1;
+ }
+ ether_ctx->payload_len = in->vb_size;
+ return 0;
case PROTO_OPT_L2_SRC_ADDRESS:
return fr_value_unbox_ethernet_addr(ether_ctx->src_addr, in);