25#define LOG_PREFIX "process_dhcpv4"
27#include <freeradius-devel/io/application.h>
28#include <freeradius-devel/server/module_method.h>
29#include <freeradius-devel/util/dict.h>
30#include <freeradius-devel/util/debug.h>
31#include <freeradius-devel/dhcpv4/dhcpv4.h>
82#define FR_DHCP_PROCESS_CODE_VALID(_x) (FR_DHCP_PACKET_CODE_VALID(_x) || (_x == FR_DHCP_DO_NOT_RESPOND))
84#define PROCESS_PACKET_TYPE fr_dhcpv4_packet_code_t
85#define PROCESS_CODE_MAX FR_DHCP_CODE_MAX
86#define PROCESS_CODE_DO_NOT_RESPOND FR_DHCP_DO_NOT_RESPOND
87#define PROCESS_PACKET_CODE_VALID FR_DHCP_PROCESS_CODE_VALID
88#define PROCESS_INST process_dhcpv4_t
89#define PROCESS_CODE_DYNAMIC_CLIENT FR_DHCP_ACK
90#include <freeradius-devel/server/process.h>
98 REDEBUG(
"%s packet does not have YIADDR. The client will not receive an IP address.",
118 return CALL_RESUME(send_generic);
137 .recv = recv_generic,
138 .resume = resume_recv_generic,
157 .send = send_generic,
158 .resume = resume_check_offer_ack_options,
177 .recv = recv_generic,
178 .resume = resume_recv_generic,
197 .recv = recv_generic,
198 .resume = resume_recv_generic,
218 .send = send_generic,
219 .resume = resume_check_offer_ack_options,
238 .send = send_generic,
239 .resume = resume_send_generic,
258 .recv = recv_generic,
259 .resume = resume_recv_generic,
278 .recv = recv_generic,
279 .resume = resume_recv_generic,
298 .recv = recv_generic,
299 .resume = resume_recv_generic,
319 .send = send_generic,
320 .resume = resume_send_generic,
340 .send = send_generic,
341 .resume = resume_send_generic,
361 .send = send_generic,
362 .resume = resume_send_generic,
382 .send = send_generic,
383 .resume = resume_send_generic,
390 fr_process_state_t
const *
state;
397 request->component =
"dhcpv4";
398 request->module = NULL;
401 UPDATE_STATE(packet);
404 REDEBUG(
"Invalid packet type (%u)", request->packet->code);
409 return new_client(p_result, mctx, request);
412 return state->recv(p_result, mctx, request);
506 DYNAMIC_CLIENT_SECTIONS,
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
A section grouping multiple CONF_PAIR.
@ FR_DHCP_LEASE_UNASSIGNED
fr_dict_attr_t const ** out
Where to write a pointer to the resolved fr_dict_attr_t.
fr_dict_t const ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
#define DICT_AUTOLOAD_TERMINATOR
Specifies an attribute which must be present for the module to function.
Specifies a dictionary which must be loaded/loadable for the module to function.
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
fr_dict_attr_t const * attr_packet_type
@ FR_TYPE_IPV4_ADDR
32 Bit IPv4 Address.
@ FR_TYPE_TLV
Contains nested attributes.
@ FR_TYPE_UINT8
8 Bit unsigned integer.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
unlang_mod_actions_t const mod_actions_postauth
unlang_mod_action_t actions[RLM_MODULE_NUMCODES]
module_instance_t const * mi
Instance of the module being instantiated.
Temporary structure to hold arguments for module calls.
section_name_t module_method_ippool_mark
section_name_t module_method_ippool_extend
section_name_t module_method_ippool_release
section_name_t module_method_ippool_allocate
int fr_pair_list_copy(TALLOC_CTX *ctx, fr_pair_list_t *to, fr_pair_list_t const *from)
Duplicate a list of pairs.
fr_pair_t * fr_pair_find_by_da(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find the first pair with a matching da.
static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request)
static const virtual_server_compile_t compile_list[]
static fr_process_state_t const process_state[]
#define PROCESS_PACKET_CODE_VALID
CONF_SECTION * lease_query
CONF_SECTION * lease_unassigned
CONF_SECTION * do_not_respond
fr_process_module_t process_dhcpv4
static fr_dict_attr_t const * attr_yiaddr
CONF_SECTION * force_renew
CONF_SECTION * new_client
fr_dict_attr_autoload_t process_dhcpv4_dict_attr[]
static fr_dict_t const * dict_dhcpv4
static fr_dict_attr_t const * attr_dhcp_option_82
fr_dict_autoload_t process_dhcpv4_dict[]
CONF_SECTION * add_client
CONF_SECTION * lease_active
process_dhcpv4_sections_t sections
CONF_SECTION * deny_client
CONF_SECTION * lease_unknown
static fr_dict_attr_t const * attr_message_type
#define PROCESS_TRACE
Trace each state function as it's entered.
#define PROCESS_CONF_OFFSET(_x)
module_t common
Common fields for all loadable modules.
Common public symbol definition for all process modules.
char const * dhcp_message_types[]
#define RETURN_UNLANG_FAIL
@ RLM_MODULE_INVALID
The module considers the request invalid.
@ RLM_MODULE_OK
The module is OK, continue.
@ RLM_MODULE_FAIL
Module failed, don't reply.
@ RLM_MODULE_DISALLOW
Reject the request (user is locked out).
@ RLM_MODULE_REJECT
Immediately reject the request.
@ RLM_MODULE_TIMEOUT
Module (or section) timed out.
@ RLM_MODULE_NOTFOUND
User not found.
@ RLM_MODULE_UPDATED
OK (pairs modified).
@ RLM_MODULE_NOOP
Module succeeded without doing anything.
#define request_is_dynamic_client(_x)
#define SECTION_NAME(_name1, _name2)
Define a section name consisting of a verb and a noun.
void * data
Module's instance data.
#define MODULE_RCTX(_ctype)
#define MODULE_INST(_ctype)
#define pair_update_reply(_attr, _da)
Return or allocate a fr_pair_t in the reply list.
Stores an attribute, a value and various bits of other data.
#define talloc_get_type_abort_const
size_t fr_pair_list_num_elements(fr_pair_list_t const *list)
Get the length of a list of fr_pair_t.
section_name_t const * section
Identifier for the section.
#define COMPILE_TERMINATOR
Processing sections which are allowed in this virtual server.