#
# This module is useful only for `xlat`. Use it via the following expansion:
#
-# `%{icmp:192.0.2.1}`
+# `%(icmp:192.0.2.1)`
#
# The module will "ping" the given IP address. If that IP address responds
# with an ICMP Echo Reply, then the result of the expansion will be `yes`.
# The IP address does not have to be a fixed string. It can be another
# expansion, such as:
#
-# `%{icmp:%{NAS-IP-Address}}`
+# `%(icmp:%{NAS-IP-Address})`
#
#
# == Capabilities and Permissions
#
-# On Linus, you may need to do:
+# On Linux, you may need to do:
#
# $ setcap cap_net_raw+ep ${bindir}/radiusd
#
unlang_interpret_mark_runnable(request);
}
-/** Xlat to delay the request
+/** Xlat to ping a specified ip address
*
* Example (ping 192.0.2.1):
@verbatim
-"%{icmp:192.0.2.1}"
+"%(icmp:192.0.2.1)"
@endverbatim
*
* @ingroup xlat_functions
*/
if (!in_head) return XLAT_ACTION_FAIL;
- if (fr_value_box_list_concat(ctx, in_head, in, FR_TYPE_STRING, true) < 0) {
- RPEDEBUG("Failed concatenating input");
- return XLAT_ACTION_FAIL;
- }
-
if (fr_value_box_cast_in_place(ctx, in_head, thread->t->ipaddr_type, NULL) < 0) {
RPEDEBUG("Failed casting result to IP address");
return XLAT_ACTION_FAIL;
return unlang_xlat_yield(request, xlat_icmp_resume, xlat_icmp_cancel, echo);
}
+extern xlat_arg_parser_t xlat_icmp_arg;
+xlat_arg_parser_t xlat_icmp_arg = {
+ .required = false, .concat = true, .variadic = false, .type = FR_TYPE_STRING, .func = NULL, .uctx = NULL
+};
+
static int echo_cmp(void const *one, void const *two)
{
rlm_icmp_echo_t const *a = one;
static int mod_bootstrap(void *instance, CONF_SECTION *conf)
{
- rlm_icmp_t *inst = instance;
- xlat_t const *xlat;
+ rlm_icmp_t *inst = instance;
+ xlat_t *xlat;
inst->xlat_name = cf_section_name2(conf);
if (!inst->xlat_name) inst->xlat_name = cf_section_name1(conf);
inst->name = inst->xlat_name;
xlat = xlat_register(inst, inst->xlat_name, xlat_icmp, true);
+ xlat_func_mono(xlat, &xlat_icmp_arg);
xlat_async_instantiate_set(xlat, mod_xlat_instantiate, rlm_icmp_t *, NULL, inst);
xlat_async_thread_instantiate_set(xlat, mod_xlat_thread_instantiate, xlat_icmp_thread_inst_t, NULL, inst);