]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
clean up and rename RADIUS flags
authorAlan T. DeKok <aland@freeradius.org>
Thu, 17 Sep 2020 15:21:01 +0000 (11:21 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 21 Sep 2020 16:17:22 +0000 (11:17 -0500)
src/modules/proto_radius/proto_radius.c
src/modules/proto_tacacs/proto_tacacs.c
src/protocols/radius/base.c
src/protocols/radius/decode.c
src/protocols/radius/encode.c
src/protocols/radius/radius.h

index 3aedaeb2f4a320930c0353d838a8cdb7d5189f73..df1b2bf359008c589eb2036f8a3f4c06e8be1fc4 100644 (file)
@@ -349,7 +349,7 @@ static int mod_decode(void const *instance, REQUEST *request, uint8_t *const dat
                for (vp = fr_cursor_init(&cursor, &request->packet->vps);
                     vp != NULL;
                     vp = fr_cursor_next(&cursor)) {
-                       if (vp->da->flags.subtype != FLAG_ENCRYPT_NONE) {
+                       if (!flag_encrypted(&vp->da->flags)) {
                                switch (vp->da->type) {
                                default:
                                        break;
index f85a896d8a229bc4a696e894835d910ca2b896ff..ad16e56769fbd39ba42de241c019dc53c37951f5 100644 (file)
@@ -319,7 +319,7 @@ static int mod_decode(void const *instance, REQUEST *request, uint8_t *const dat
                for (vp = fr_cursor_init(&cursor, &request->packet->vps);
                     vp != NULL;
                     vp = fr_cursor_next(&cursor)) {
-                       if (vp->da->flags.subtype != FLAG_ENCRYPT_NONE) {
+                       if (!vp->da->flags.subtype) {
                                switch (vp->da->type) {
                                default:
                                        break;
index 77447565890813ced94e2e47534fa49a4cb84c2c..036c83eeabea43f6b46516dfee43558feb2c1dad 100644 (file)
@@ -1135,7 +1135,7 @@ static fr_table_num_ordered_t const subtype_table[] = {
        { L("encrypt=1"),               FLAG_ENCRYPT_USER_PASSWORD },
        { L("encrypt=2"),               FLAG_ENCRYPT_TUNNEL_PASSWORD },
        { L("encrypt=3"),               FLAG_ENCRYPT_ASCEND_SECRET },
-       { L("long"),                    FLAG_EXTENDED_ATTR },
+       { L("long"),                    FLAG_LONG_EXTENDED_ATTR },
 
        /*
         *      And some humanly-readable names
@@ -1148,11 +1148,6 @@ static fr_table_num_ordered_t const subtype_table[] = {
 static bool attr_valid(UNUSED fr_dict_t *dict, fr_dict_attr_t const *parent,
                       UNUSED char const *name, UNUSED int attr, fr_type_t type, fr_dict_attr_flags_t *flags)
 {
-       if ((parent->type == FR_TYPE_STRUCT) && (type == FR_TYPE_EXTENDED)) {
-               fr_strerror_printf("Attributes of type 'extended' cannot be used inside of a 'struct'");
-               return false;
-       }
-
        /*
         *      "extra" signifies that subtype is being used by the
         *      dictionaries itself.
@@ -1174,18 +1169,13 @@ static bool attr_valid(UNUSED fr_dict_t *dict, fr_dict_attr_t const *parent,
        }
 
        if (parent->type == FR_TYPE_STRUCT) {
-               if (flags->subtype == FLAG_EXTENDED_ATTR) {
+               if (type == FR_TYPE_EXTENDED) {
                        fr_strerror_printf("Attributes of type 'extended' cannot be used inside of a 'struct'");
                        return false;
                }
 
-               if (flag_encrypted(flags)) {
-                       fr_strerror_printf("Attributes inside of a 'struct' MUST NOT be encrypted.");
-                       return false;
-               }
-
-               if (flag_has_tag(flags)) {
-                       fr_strerror_printf("Tagged attributes cannot be used inside of a 'struct'");
+               if (flags->subtype) {
+                       fr_strerror_printf("Attributes inside of a 'struct' MUST NOT have flags set");
                        return false;
                }
 
@@ -1202,7 +1192,7 @@ static bool attr_valid(UNUSED fr_dict_t *dict, fr_dict_attr_t const *parent,
                return false;
        }
 
-       if ((flags->subtype == FLAG_EXTENDED_ATTR) && (type != FR_TYPE_EXTENDED)) {
+       if (flag_long_extended(flags) && (type != FR_TYPE_EXTENDED)) {
                fr_strerror_printf("The 'long' flag can only be used for attributes of type 'extended'");
                return false;
        }
@@ -1236,7 +1226,7 @@ static bool attr_valid(UNUSED fr_dict_t *dict, fr_dict_attr_t const *parent,
 
        switch (type) {
        case FR_TYPE_EXTENDED:
-               if (flags->subtype == FLAG_EXTENDED_ATTR) break;
+               if (flag_long_extended(flags)) break;
                FALL_THROUGH;
 
        default:
index 34047799987ffd6456e694172c8b981796a212c0..4ffabeef267535a2c9305af41c05525bd23fe616 100644 (file)
@@ -1029,7 +1029,7 @@ ssize_t fr_radius_decode_pair_value(TALLOC_CTX *ctx, fr_cursor_t *cursor, fr_dic
        FR_PROTO_TRACE("Parent %s len %zu ... %zu", parent->name, attr_len, packet_len);
 
        data_len = attr_len;
-       extra = flag_extended(&parent->flags);
+       extra = flag_long_extended(&parent->flags);
 
        /*
         *      Silently ignore zero-length attributes.
index 4633b56ca3b7fc8e46c6da70557fbb18ec930a1c..84d1a31f945ca453e4b23d45950750f5e997f306 100644 (file)
@@ -823,7 +823,7 @@ static ssize_t encode_extended_hdr(fr_dbuff_t *dbuff,
        VP_VERIFY(vp);
        FR_PROTO_STACK_PRINT(da_stack, depth);
 
-       extra = flag_extended(&da_stack->da[0]->flags);
+       extra = flag_long_extended(&da_stack->da[0]->flags);
 
        /*
         *      @fixme: check depth of stack
index a85b1d10767a02d9f9420028a97d1d3b8d53102a..6d63a328b65c5726aea6468d18ede6dca827af8e 100644 (file)
@@ -84,8 +84,8 @@ typedef enum {
  *  Order of the flags is important for the flag_foo() checks.
  */
 enum {
-       FLAG_ENCRYPT_NONE = 0,                          //!< Don't encrypt the attribute.
-       FLAG_EXTENDED_ATTR,                             //!< the attribute is a long extended attribute
+       FLAG_NONE = 0,                                  //!< No extra flags
+       FLAG_LONG_EXTENDED_ATTR,                        //!< the attribute is a long extended attribute
        FLAG_CONCAT,                                    //!< the attribute is concatenated
 
        FLAG_ENCRYPT_USER_PASSWORD,                     //!< Encrypt attribute RFC 2865 style.
@@ -97,7 +97,7 @@ enum {
 #define flag_has_tag(_flags)        ((_flags)->has_tag)
 #define flag_concat(_flags)         (!(_flags)->extra && (_flags)->subtype == FLAG_CONCAT)
 #define flag_encrypted(_flags)      (!(_flags)->extra && (_flags)->subtype >= FLAG_ENCRYPT_USER_PASSWORD)
-#define flag_extended(_flags)       (!(_flags)->extra && (_flags)->subtype == FLAG_EXTENDED_ATTR)
+#define flag_long_extended(_flags)   (!(_flags)->extra && (_flags)->subtype == FLAG_LONG_EXTENDED_ATTR)
 #define flag_tunnel_password(_flags) (!(_flags)->extra && (_flags)->subtype == FLAG_ENCRYPT_TUNNEL_PASSWORD)
 
 /*