From: Alan T. DeKok Date: Tue, 29 May 2018 15:33:05 +0000 (-0400) Subject: just use attr_name instead of attr_dhcp_name X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=475e022cd1853c69323fefdba66cf665e8b13d04;p=thirdparty%2Ffreeradius-server.git just use attr_name instead of attr_dhcp_name we already know that this is DHCPv4 --- diff --git a/src/modules/proto_dhcpv4/proto_dhcpv4.c b/src/modules/proto_dhcpv4/proto_dhcpv4.c index aadf0d0dcb6..bac0c15c0ec 100644 --- a/src/modules/proto_dhcpv4/proto_dhcpv4.c +++ b/src/modules/proto_dhcpv4/proto_dhcpv4.c @@ -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 diff --git a/src/modules/proto_dhcpv4/proto_dhcpv4_base.c b/src/modules/proto_dhcpv4/proto_dhcpv4_base.c index e3d07980723..c8512798e3f 100644 --- a/src/modules/proto_dhcpv4/proto_dhcpv4_base.c +++ b/src/modules/proto_dhcpv4/proto_dhcpv4_base.c @@ -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; diff --git a/src/modules/proto_dhcpv4/proto_dhcpv4_udp.c b/src/modules/proto_dhcpv4/proto_dhcpv4_udp.c index 93f3fd5cad0..79b08547428 100644 --- a/src/modules/proto_dhcpv4/proto_dhcpv4_udp.c +++ b/src/modules/proto_dhcpv4/proto_dhcpv4_udp.c @@ -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;