]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
no longer need these
authorAlan T. DeKok <aland@freeradius.org>
Sun, 17 Apr 2022 05:27:36 +0000 (01:27 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 20 Apr 2022 13:13:25 +0000 (09:13 -0400)
src/protocols/dhcpv4/base.c
src/protocols/dhcpv4/dhcpv4.h
src/protocols/dhcpv6/base.c
src/protocols/dhcpv6/dhcpv6.h

index 56a962767eb20385cf22bf0db8b2dd408d67c6cf..362fef559f068b31e7137f67b65f90af9eaff875 100644 (file)
@@ -97,31 +97,6 @@ fr_dict_attr_autoload_t dhcpv4_dict_attr[] = {
        { NULL }
 };
 
-size_t const fr_dhcpv4_attr_sizes[FR_TYPE_MAX + 1][2] = {
-       [FR_TYPE_NULL]          = {~0, 0},
-
-       [FR_TYPE_STRING]                = {0, ~0},
-       [FR_TYPE_OCTETS]                = {0, ~0},
-
-       [FR_TYPE_IPV4_ADDR]             = {4, 4},
-       [FR_TYPE_IPV4_PREFIX]           = {1, 5},       //!< Zero length prefix still requires one byte for prefix len.
-       [FR_TYPE_IPV6_ADDR]             = {16, 16},
-       [FR_TYPE_IPV6_PREFIX]           = {1, 17},      //!< Zero length prefix still requires one byte for prefix len.
-       [FR_TYPE_IFID]                  = {8, 8},
-       [FR_TYPE_ETHERNET]              = {6, 6},
-
-       [FR_TYPE_BOOL]                  = {1, 1},
-       [FR_TYPE_UINT8]                 = {1, 1},
-       [FR_TYPE_UINT16]                = {2, 2},
-       [FR_TYPE_UINT32]                = {4, 4},
-       [FR_TYPE_UINT64]                = {8, 8},
-
-       [FR_TYPE_TLV]                   = {2, ~0},
-       [FR_TYPE_STRUCT]                = {1, ~0},
-
-       [FR_TYPE_MAX]                   = {~0, 0}       //!< Ensure array covers all types.
-};
-
 /*
  *     INADDR_ANY : 68 -> INADDR_BROADCAST : 67        DISCOVER
  *     INADDR_BROADCAST : 68 <- SERVER_IP : 67         OFFER
@@ -226,51 +201,6 @@ int8_t fr_dhcpv4_attr_cmp(void const *a, void const *b)
        return fr_pair_cmp_by_parent_num(my_a, my_b);
 }
 
-/** Return the on-the-wire length of an attribute value
- *
- * @param[in] vp to return the length of.
- * @return the length of the attribute.
- */
-size_t fr_dhcpv4_option_len(fr_pair_t const *vp)
-{
-       switch (vp->vp_type) {
-       case FR_TYPE_VARIABLE_SIZE:
-#ifndef NDEBUG
-               if (da_is_dns_label(vp->da)) {
-                       fr_assert_fail("DNS labels MUST be encoded/decoded with their own function, and not with generic 'string' functions");
-                       return 0;
-               }
-#endif
-
-               if (vp->da->flags.length) return vp->da->flags.length;  /* Variable type with fixed length */
-
-               /*
-                *      Arrays get maxed at 2^8 - 1
-                */
-               if (vp->da->flags.array && ((vp->vp_type == FR_TYPE_STRING) || (vp->vp_type == FR_TYPE_OCTETS))) {
-                       if (vp->vp_length > 255) return 255;
-               }
-
-               return vp->vp_length;
-
-       case FR_TYPE_DATE:
-       case FR_TYPE_TIME_DELTA:
-               if (vp->data.enumv->flags.length) return vp->data.enumv->flags.length;
-               return sizeof(uint32_t);
-
-       case FR_TYPE_STRUCTURAL:
-               fr_assert_fail(NULL);
-               return 0;
-
-       case FR_TYPE_IPV4_PREFIX:
-               if (da_is_split_prefix(vp->da)) return 8;
-               FALL_THROUGH;
-
-       default:
-               return fr_dhcpv4_attr_sizes[vp->vp_type][0];
-       }
-}
-
 /** Check received DHCP request is valid and build fr_radius_packet_t structure if it is
  *
  * @param data pointer to received packet.
index 807953398db119691f1fae41daa0e5cf92366096..ed394db206f3f7175cc624f02b7b56cd2e02302a 100644 (file)
@@ -34,8 +34,6 @@ extern "C" {
 #include <freeradius-devel/util/packet.h>
 #include <freeradius-devel/protocol/dhcpv4/rfc2131.h>
 
-extern size_t const fr_dhcpv4_attr_sizes[FR_TYPE_MAX + 1][2];
-
 #define DHCP_CHADDR_LEN        (16)
 #define DHCP_SNAME_LEN (64)
 #define DHCP_FILE_LEN  (128)
@@ -161,7 +159,6 @@ typedef struct {
  */
 int8_t         fr_dhcpv4_attr_cmp(void const *a, void const *b);
 
-size_t         fr_dhcpv4_option_len(fr_pair_t const *vp);
 bool           fr_dhcpv4_ok(uint8_t const *data, ssize_t data_len, uint8_t *message_type, uint32_t *xid);
 fr_radius_packet_t     *fr_dhcpv4_packet_alloc(uint8_t const *data, ssize_t data_len);
 bool           fr_dhcpv4_is_encodable(void const *item, void const *uctx);
index 1d9f7fcb739d1a9d4e1527571e5768ec4b5f0308..0379c2cd77c590bc57dc66777390838c223c983c 100644 (file)
@@ -65,31 +65,6 @@ fr_dict_attr_autoload_t libfreeradius_dhcpv6_dict_attr[] = {
        { NULL }
 };
 
-size_t const fr_dhcpv6_attr_sizes[FR_TYPE_MAX + 1][2] = {
-       [FR_TYPE_NULL]          = {~0, 0},      //!< Ensure array starts at 0 (umm?)
-
-       [FR_TYPE_STRING]                = {0, ~0},
-       [FR_TYPE_OCTETS]                = {0, ~0},
-
-       [FR_TYPE_IPV4_ADDR]             = {4, 4},
-       [FR_TYPE_IPV4_PREFIX]           = {1, 5},       //!< Zero length prefix still requires one byte for prefix len.
-       [FR_TYPE_IPV6_ADDR]             = {16, 16},
-       [FR_TYPE_IPV6_PREFIX]           = {1, 17},      //!< Zero length prefix still requires one byte for prefix len.
-       [FR_TYPE_IFID]                  = {8, 8},
-       [FR_TYPE_ETHERNET]              = {6, 6},
-
-       [FR_TYPE_BOOL]                  = {1, 1},
-       [FR_TYPE_UINT8]                 = {1, 1},
-       [FR_TYPE_UINT16]                = {2, 2},
-       [FR_TYPE_UINT32]                = {4, 4},
-       [FR_TYPE_UINT64]                = {8, 8},
-
-       [FR_TYPE_TLV]                   = {2, ~0},
-       [FR_TYPE_STRUCT]                = {1, ~0},
-
-       [FR_TYPE_MAX]                   = {~0, 0}       //!< Ensure array covers all types.
-};
-
 /*
  * grep VALUE share/dictionary/dhcpv6/dictionary.freeradius.internal  | awk '{print "[" $4 "] = \"" $3 "\"," }'
  */
@@ -137,47 +112,6 @@ static fr_table_num_ordered_t const subtype_table[] = {
        { L("partial_dns_label"),               FLAG_ENCODE_PARTIAL_DNS_LABEL }
 };
 
-/** Return the on-the-wire length of an attribute value
- *
- * @param[in] vp to return the length of.
- * @return the length of the attribute.
- */
-size_t fr_dhcpv6_option_len(fr_pair_t const *vp)
-{
-       switch (vp->vp_type) {
-       case FR_TYPE_VARIABLE_SIZE:
-#ifndef NDEBUG
-               if (da_is_dns_label(vp->da)) {
-                       fr_assert_fail("DNS labels MUST be encoded/decoded with their own function, and not with generic 'string' functions");
-                       return 0;
-               }
-#endif
-
-               if (vp->da->flags.length) return vp->da->flags.length;  /* Variable type with fixed length */
-
-               /*
-                *      Arrays get maxed at 2^16-1
-                */
-               if (vp->da->flags.array && ((vp->vp_type == FR_TYPE_STRING) || (vp->vp_type == FR_TYPE_OCTETS))) {
-                       if (vp->vp_length > 65535) return 65535;
-               }
-
-               return vp->vp_length;
-
-       case FR_TYPE_DATE:
-       case FR_TYPE_TIME_DELTA:
-               if (vp->data.enumv->flags.length) return vp->data.enumv->flags.length;
-               return sizeof(uint32_t);
-
-       case FR_TYPE_STRUCTURAL:
-               fr_assert_fail(NULL);
-               return 0;
-
-       default:
-               return fr_dhcpv6_attr_sizes[vp->vp_type][0];
-       }
-}
-
 static ssize_t fr_dhcpv6_ok_internal(uint8_t const *packet, uint8_t const *end, size_t max_attributes, int depth);
 
 static ssize_t fr_dhcpv6_options_ok(uint8_t const *packet, uint8_t const *end, size_t max_attributes,
index a85fbb19d2de314a6c4d73d8ac111ef6e41f6f5f..d74c222807bdbcffa991b1d8eb680914722a6dd9 100644 (file)
@@ -32,8 +32,6 @@ RCSIDH(dhcpv6_h, "$Id$")
 
 #include <freeradius-devel/protocol/dhcpv6/dictionary.h>
 
-extern size_t const fr_dhcpv6_attr_sizes[FR_TYPE_MAX + 1][2];
-
 #define DHCPV6_MSG_TYPE_LEN            1U
 
 #define DHCPV6_TRANSACTION_ID_LEN      3U
@@ -147,8 +145,6 @@ typedef struct {
 /*
  *     base.c
  */
-size_t         fr_dhcpv6_option_len(fr_pair_t const *vp);
-
 uint8_t const  *fr_dhcpv6_option_find(uint8_t const *start, uint8_t const *end, unsigned int option);
 
 bool           fr_dhcpv6_ok(uint8_t const *packet, size_t packet_len,