25#define LOG_PREFIX "process_dhcpv4"
27#include <freeradius-devel/io/application.h>
28#include <freeradius-devel/server/protocol.h>
29#include <freeradius-devel/server/module_method.h>
30#include <freeradius-devel/util/dict.h>
31#include <freeradius-devel/util/debug.h>
32#include <freeradius-devel/dhcpv4/dhcpv4.h>
61#ifdef WITH_IFINDEX_NAME_RESOLUTION
62 char if_name[IFNAMSIZ];
69#ifdef WITH_IFINDEX_NAME_RESOLUTION
73 received ?
"Received" :
"Sending",
76 packet->
socket.inet.src_ipaddr.
af == AF_INET6 ?
"[" :
"",
78 packet->
socket.inet.src_ipaddr.
af == AF_INET6 ?
"]" :
"",
79 packet->
socket.inet.src_port,
80 packet->
socket.inet.dst_ipaddr.
af == AF_INET6 ?
"[" :
"",
82 packet->
socket.inet.dst_ipaddr.
af == AF_INET6 ?
"]" :
"",
83 packet->
socket.inet.dst_port
84#ifdef WITH_IFINDEX_NAME_RESOLUTION
85 , packet->
socket.inet.ifindex ?
"via " :
"",
86 packet->
socket.inet.ifindex ? fr_ifname_from_ifindex(if_name, packet->
socket.inet.ifindex) :
"",
87 packet->
socket.inet.ifindex ?
" " :
""
91 if (received || request->parent) {
125#define FR_DHCP_PROCESS_CODE_VALID(_x) (FR_DHCP_PACKET_CODE_VALID(_x) || (_x == FR_DHCP_DO_NOT_RESPOND))
127#define PROCESS_PACKET_TYPE fr_dhcpv4_packet_code_t
128#define PROCESS_CODE_MAX FR_DHCP_CODE_MAX
129#define PROCESS_CODE_DO_NOT_RESPOND FR_DHCP_DO_NOT_RESPOND
130#define PROCESS_PACKET_CODE_VALID FR_DHCP_PROCESS_CODE_VALID
131#define PROCESS_INST process_dhcpv4_t
132#define PROCESS_CODE_DYNAMIC_CLIENT FR_DHCP_ACK
133#include <freeradius-devel/server/process.h>
141 REDEBUG(
"%s packet does not have YIADDR. The client will not receive an IP address.",
159 return CALL_RESUME(send_generic);
178 .recv = recv_generic,
179 .resume = resume_recv_generic,
198 .send = send_generic,
199 .resume = resume_check_offer_ack_options,
218 .recv = recv_generic,
219 .resume = resume_recv_generic,
238 .recv = recv_generic,
239 .resume = resume_recv_generic,
259 .send = send_generic,
260 .resume = resume_check_offer_ack_options,
279 .send = send_generic,
280 .resume = resume_send_generic,
299 .recv = recv_generic,
300 .resume = resume_recv_generic,
319 .recv = recv_generic,
320 .resume = resume_recv_generic,
339 .recv = recv_generic,
340 .resume = resume_recv_generic,
360 .send = send_generic,
361 .resume = resume_send_generic,
381 .send = send_generic,
382 .resume = resume_send_generic,
402 .send = send_generic,
403 .resume = resume_send_generic,
423 .send = send_generic,
424 .resume = resume_send_generic,
431 fr_process_state_t
const *state;
438 request->component =
"dhcpv4";
439 request->module = NULL;
442 UPDATE_STATE(packet);
445 REDEBUG(
"Invalid packet type (%u)", request->packet->code);
452 return new_client(p_result, mctx, request);
455 return state->recv(p_result, mctx, request);
549 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.
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
void log_request_proto_pair_list(fr_log_lvl_t lvl, request_t *request, fr_pair_t const *parent, fr_pair_list_t const *vps, char const *prefix)
Print a list of protocol fr_pair_ts.
void log_request(fr_log_type_t type, fr_log_lvl_t lvl, request_t *request, char const *file, int line, char const *fmt,...)
Marshal variadic log arguments into a va_list and pass to normal logging functions.
void log_request_pair_list(fr_log_lvl_t lvl, request_t *request, fr_pair_t const *parent, fr_pair_list_t const *vps, char const *prefix)
Print a fr_pair_list_t.
@ L_DBG_LVL_1
Highest priority debug messages (-x).
@ L_DBG
Only displayed when debugging is enabled.
@ 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
static void dhcpv4_packet_debug(request_t *request, fr_packet_t *packet, fr_pair_list_t *list, bool received)
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
unsigned int code
Packet code (type).
fr_socket_t socket
This packet was received on.
int id
Packet ID (used to link requests/responses).
int af
AF_INET, AF_INET6, or AF_UNIX.
#define fr_box_ipaddr(_val)
section_name_t const * section
Identifier for the section.
#define COMPILE_TERMINATOR
Processing sections which are allowed in this virtual server.