24#include <freeradius-devel/server/protocol.h>
25#include <freeradius-devel/util/debug.h>
26#include <freeradius-devel/bfd/bfd.h>
52 CONF_SECTION *recv_ ## _x; \
53 CONF_SECTION *send_ ## _x
68#define PROCESS_PACKET_TYPE fr_bfd_packet_code_t
69#define PROCESS_CODE_MAX FR_BFD_CODE_MAX
70#define PROCESS_PACKET_CODE_VALID FR_BFD_PACKET_CODE_VALID
71#define PROCESS_INST process_bfd_t
73#define PROCESS_SEND_RECV (1)
75#include <freeradius-devel/server/process.h>
82#ifdef WITH_IFINDEX_NAME_RESOLUTION
83 char if_name[IFNAMSIZ];
90#ifdef WITH_IFINDEX_NAME_RESOLUTION
94 received ?
"Received" :
"Sending",
97 packet->
socket.inet.src_ipaddr.
af == AF_INET6 ?
"[" :
"",
99 packet->
socket.inet.src_ipaddr.
af == AF_INET6 ?
"]" :
"",
100 packet->
socket.inet.src_port,
101 packet->
socket.inet.dst_ipaddr.
af == AF_INET6 ?
"[" :
"",
103 packet->
socket.inet.dst_ipaddr.
af == AF_INET6 ?
"]" :
"",
104 packet->
socket.inet.dst_port
105#ifdef WITH_IFINDEX_NAME_RESOLUTION
106 , packet->
socket.inet.ifindex ?
"via " :
"",
107 packet->
socket.inet.ifindex ? fr_ifname_from_ifindex(if_name, packet->
socket.inet.ifindex) :
"",
108 packet->
socket.inet.ifindex ?
" " :
""
112 if (received || request->parent) {
137 state =
vp->vp_uint32;
141 if (
vp) state =
vp->vp_uint8;
147 request->reply->code = state;
149 request->reply->timestamp =
fr_time();
162 .recv = recv_generic,
163 .resume = resume_recv_bfd,
170 .recv = recv_generic,
171 .resume = resume_recv_bfd,
178 .recv = recv_generic,
179 .resume = resume_recv_bfd,
186 .recv = recv_generic,
187 .resume = resume_recv_bfd,
198 .send = send_generic,
199 .resume = resume_send_generic,
205 .send = send_generic,
206 .resume = resume_send_generic,
212 .send = send_generic,
213 .resume = resume_send_generic,
219 .send = send_generic,
220 .resume = resume_send_generic,
227 fr_process_state_t
const *state;
235 request->component =
"bfd";
236 request->module = NULL;
251 return state->send(p_result, mctx, request);
256 UPDATE_STATE(packet);
259 REDEBUG(
"Invalid packet type (%u)", request->packet->code);
265 return state->recv(p_result, mctx, request);
271#define SEND_RECV(_x, _y) \
273 .section = SECTION_NAME("recv", _x), \
274 .actions = &mod_actions_postauth, \
275 .offset = PROCESS_CONF_OFFSET(recv_ ## _y), \
278 .section = SECTION_NAME("send", _x), \
279 .actions = &mod_actions_postauth, \
280 .offset = PROCESS_CONF_OFFSET(send_ ## _y), \
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
@ UNLANG_ACTION_CALCULATE_RESULT
Calculate a new section rlm_rcode_t value.
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.
@ BFD_WRAPPER_SEND_PACKET
@ BFD_WRAPPER_RECV_PACKET
@ FR_TYPE_UINT8
8 Bit unsigned integer.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_STRUCT
like TLV, but without T or L, and fixed-width children
module_instance_t const * mi
Instance of the module being instantiated.
Temporary structure to hold arguments for module calls.
fr_pair_t * fr_pair_find_by_da_nested(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find a pair with a matching fr_dict_attr_t, by walking the nested fr_dict_attr_t tree.
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[]
#define PROCESS_PACKET_CODE_VALID
fr_dict_autoload_t process_bfd_dict[]
static fr_dict_attr_t const * attr_bfd_packet
process_bfd_sections_t sections
fr_process_module_t process_bfd
static void bfd_packet_debug(request_t *request, fr_packet_t *packet, fr_pair_list_t *list, bool received)
static fr_dict_attr_t const * attr_bfd_state
static fr_process_state_t const process_state_reply[]
fr_dict_attr_autoload_t process_bfd_dict_attr[]
RESUME_FLAG(recv_bfd, UNUSED,)
static fr_dict_t const * dict_bfd
#define SEND_RECV(_x, _y)
static fr_process_state_t const process_state_packet[]
#define PROCESS_TRACE
Trace each state function as it's entered.
module_t common
Common fields for all loadable modules.
Common public symbol definition for all process modules.
char const * fr_bfd_packet_names[FR_BFD_CODE_MAX]
#define RETURN_UNLANG_FAIL
rlm_rcode_t
Return codes indicating the result of the module call.
@ RLM_MODULE_FAIL
Module failed, don't reply.
@ RLM_MODULE_NOOP
Module succeeded without doing anything.
@ RLM_MODULE_NUMCODES
How many valid return codes there are.
void * data
Module's instance data.
#define MODULE_RCTX(_ctype)
#define MODULE_INST(_ctype)
#define fr_time()
Allow us to arbitrarily manipulate time.
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)
#define COMPILE_TERMINATOR
Processing sections which are allowed in this virtual server.