]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
just use attr_name instead of attr_dhcp_name
authorAlan T. DeKok <aland@freeradius.org>
Tue, 29 May 2018 15:33:05 +0000 (11:33 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 29 May 2018 15:33:05 +0000 (11:33 -0400)
we already know that this is DHCPv4

src/modules/proto_dhcpv4/proto_dhcpv4.c
src/modules/proto_dhcpv4/proto_dhcpv4_base.c
src/modules/proto_dhcpv4/proto_dhcpv4_udp.c

index aadf0d0dcb6330d027b3859bbce7ce852fb57abc..bac0c15c0eca048cd3e1a9515b1c3aaa51fa312e 100644 (file)
@@ -99,11 +99,11 @@ fr_dict_autoload_t proto_dhcpv4_dict[] = {
        { NULL }
 };
 
-static fr_dict_attr_t const *attr_dhcp_message_type;
+static fr_dict_attr_t const *attr_message_type;
 
 extern fr_dict_attr_autoload_t proto_dhcpv4_dict_attr[];
 fr_dict_attr_autoload_t proto_dhcpv4_dict_attr[] = {
-       { .out = &attr_dhcp_message_type, .name = "DHCP-Message-Type", .type = FR_TYPE_UINT8, .dict = &dict_dhcpv4},
+       { .out = &attr_message_type, .name = "DHCP-Message-Type", .type = FR_TYPE_UINT8, .dict = &dict_dhcpv4},
        { NULL }
 };
 
@@ -158,7 +158,7 @@ static int type_parse(TALLOC_CTX *ctx, void *out, CONF_ITEM *ci, UNUSED CONF_PAR
         *      Allow the process module to be specified by
         *      packet type.
         */
-       type_enum = fr_dict_enum_by_alias(attr_dhcp_message_type, type_str, -1);
+       type_enum = fr_dict_enum_by_alias(attr_message_type, type_str, -1);
        if (!type_enum) {
                cf_log_err(ci, "Invalid type \"%s\"", type_str);
                return -1;
@@ -614,7 +614,7 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
                 *      Check that the packet type is known.
                 */
                packet_type = cf_section_name2(subcs);
-               dv = fr_dict_enum_by_alias(attr_dhcp_message_type, packet_type, -1);
+               dv = fr_dict_enum_by_alias(attr_message_type, packet_type, -1);
                if (!dv || ((dv->value->vb_uint32 > FR_DHCP_MAX) &&
                            (dv->value->vb_uint32 == FR_DHCP_MESSAGE_TYPE_VALUE_DHCP_DO_NOT_RESPOND))) {
                        cf_log_err(subcs, "Invalid DHCPV4 packet type in '%s %s {...}'",
@@ -746,7 +746,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
        inst->io.server_cs = cf_item_to_section(cf_parent(conf));
 
        rad_assert(dict_dhcpv4 != NULL);
-       rad_assert(attr_dhcp_message_type != NULL);
+       rad_assert(attr_message_type != NULL);
 
        /*
         *      Bootstrap the process modules
index e3d079807239f9b8129d6d68d8ebd8efbb7d64d2..c8512798e3f2704652e3e2182c56eba2b01ba3ef 100644 (file)
@@ -39,13 +39,13 @@ fr_dict_autoload_t proto_dhcpv4_dict[] = {
        { NULL }
 };
 
-static fr_dict_attr_t const *attr_dhcp_message_type;
-static fr_dict_attr_t const *attr_dhcp_yiaddr;
+static fr_dict_attr_t const *attr_message_type;
+static fr_dict_attr_t const *attr_yiaddr;
 
 extern fr_dict_attr_autoload_t proto_dhcpv4_base_dict_attr[];
 fr_dict_attr_autoload_t proto_dhcpv4_base_dict_attr[] = {
-       { .out = &attr_dhcp_message_type, .name = "DHCP-Message-Type", .type = FR_TYPE_UINT8, .dict = &dict_dhcpv4},
-       { .out = &attr_dhcp_yiaddr, .name = "DHCP-Your-IP-Address", .type = FR_TYPE_IPV4_ADDR, .dict = &dict_dhcpv4},
+       { .out = &attr_message_type, .name = "DHCP-Message-Type", .type = FR_TYPE_UINT8, .dict = &dict_dhcpv4},
+       { .out = &attr_yiaddr, .name = "DHCP-Your-IP-Address", .type = FR_TYPE_IPV4_ADDR, .dict = &dict_dhcpv4},
        { NULL }
 };
 
@@ -92,7 +92,7 @@ static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request,
 
                request->component = "dhcpv4";
 
-               dv = fr_dict_enum_by_value(attr_dhcp_message_type, fr_box_uint8(request->packet->code));
+               dv = fr_dict_enum_by_value(attr_message_type, fr_box_uint8(request->packet->code));
                if (!dv) {
                        REDEBUG("Failed to find value for &request:DHCP-Message-Type");
                        return FR_IO_FAIL;
@@ -124,7 +124,7 @@ static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request,
                 *      Allow the admin to explicitly set the reply
                 *      type.
                 */
-               vp = fr_pair_find_by_da(request->reply->vps, attr_dhcp_message_type, TAG_ANY);
+               vp = fr_pair_find_by_da(request->reply->vps, attr_message_type, TAG_ANY);
                if (vp) {
                        request->reply->code = vp->vp_uint8;
                } else switch (rcode) {
@@ -156,7 +156,7 @@ static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request,
                 *      Offer and ACK MUST have YIADDR.
                 */
                if ((request->reply->code == FR_DHCP_OFFER) || (request->reply->code == FR_DHCP_ACK)) {
-                       vp = fr_pair_find_by_da(request->reply->vps, attr_dhcp_yiaddr, TAG_ANY);
+                       vp = fr_pair_find_by_da(request->reply->vps, attr_yiaddr, TAG_ANY);
                        if (!vp) {
                                REDEBUG("%s packet does not have YIADDR.  The client will not receive an IP address.",
                                        dhcp_message_types[request->reply->code]);
@@ -199,7 +199,7 @@ static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request,
                         *      the NAK section.
                         */
                        if (request->reply->code != FR_DHCP_MESSAGE_TYPE_VALUE_DHCP_DO_NOT_RESPOND) {
-                               dv = fr_dict_enum_by_value(attr_dhcp_message_type, fr_box_uint8(request->reply->code));
+                               dv = fr_dict_enum_by_value(attr_message_type, fr_box_uint8(request->reply->code));
                                RWDEBUG("Failed running 'send %s', trying 'send Do-Not-Respond'", dv->alias);
 
                                request->reply->code = FR_DHCP_MESSAGE_TYPE_VALUE_DHCP_DO_NOT_RESPOND;
index 93f3fd5cad0c5938988029b48493b4a1f7792405..79b085474282ac20af43168b2dddc2d6281adbb5 100644 (file)
@@ -115,11 +115,11 @@ fr_dict_autoload_t proto_dhcpv4_udp_dict[] = {
        { NULL }
 };
 
-static fr_dict_attr_t const *attr_dhcp_message_type;
+static fr_dict_attr_t const *attr_message_type;
 
 extern fr_dict_attr_autoload_t proto_dhcpv4_udp_dict_attr[];
 fr_dict_attr_autoload_t proto_dhcpv4_udp_dict_attr[] = {
-       { .out = &attr_dhcp_message_type, .name = "DHCP-Message-Type", .type = FR_TYPE_UINT8, .dict = &dict_dhcpv4},
+       { .out = &attr_message_type, .name = "DHCP-Message-Type", .type = FR_TYPE_UINT8, .dict = &dict_dhcpv4},
        { NULL }
 };
 
@@ -254,7 +254,7 @@ static ssize_t mod_write(void *instance, void *packet_ctx,
                /*
                 *      This isn't available in the packet header.
                 */
-               code = fr_dhcpv4_packet_get_option(packet, buffer_len, attr_dhcp_message_type);
+               code = fr_dhcpv4_packet_get_option(packet, buffer_len, attr_message_type);
                if (!code || (code[1] < 1) || (code[2] == 0) || (code[2] >= FR_DHCP_INFORM)) {
                        DEBUG("WARNING - silently discarding reply due to invalid or missing message type");
                        return 0;