]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Remove boxing for size_t, conflicts with uint64
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 14 Jul 2017 19:13:21 +0000 (15:13 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 14 Jul 2017 19:13:21 +0000 (15:13 -0400)
src/include/value.h
src/lib/io/proto.h
src/protocols/ethernet/ethernet.c

index 5f5584f465c585c29ebe6d91640ebd8f45e370f1..f6944e5cc34b300188e24261ee02611d043e04f1 100644 (file)
@@ -298,8 +298,6 @@ FR_VALUE_BOX(uint64_t, date_milliseconds, FR_TYPE_DATE_MILLISECONDS)
 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
@@ -326,8 +324,7 @@ _Generic((_var), \
        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)
@@ -380,8 +377,6 @@ FR_VALUE_UNBOX(uint64_t, date_milliseconds, FR_TYPE_DATE_MILLISECONDS)
 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.
@@ -398,8 +393,7 @@ _Generic((_var), \
        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)
 
 /* @} **/
index 18dafde45add4bee0bafd333cac6774c32bc50ad..3890ef015ea004f973639da559a5c145c9a8d188 100644 (file)
@@ -131,18 +131,19 @@ typedef void (*fr_proto_invert_t)(void *proto_ctx);
  *
  * @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
@@ -158,7 +159,7 @@ typedef int (*fr_proto_set_option_t)(void *proto_ctx, fr_proto_opt_group_t opt_g
 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.
 
index a5978dd526c90a5c0bad68aa8cf95984419389bc..79c0517c7f8ef903af36346e603e3b8170479c0b 100644 (file)
@@ -297,7 +297,9 @@ static int fr_ethernet_get_option(fr_value_box_t *out, void const *proto_ctx, fr
        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);
@@ -370,7 +372,14 @@ static int fr_ethernet_set_option(void *proto_ctx, fr_proto_opt_group_t group, i
        case PROTO_OPT_GROUP_L2:
                switch (opt) {
                case PROTO_OPT_L2_PAYLOAD_LEN:
-                       return fr_value_unbox_shallow(&ether_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);