The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Functions | Variables
rlm_icmp.c File Reference

Send ICMP echo requests. More...

#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/util/cap.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/unlang/xlat_func.h>
#include <fcntl.h>
#include <unistd.h>
+ Include dependency graph for rlm_icmp.c:

Go to the source code of this file.

Data Structures

struct  icmp_header_t
 
struct  rlm_icmp_echo_t
 
struct  rlm_icmp_t
 
struct  rlm_icmp_thread_t
 

Macros

#define FD_CLOEXEC   (0)
 
#define ICMP_ECHOREPLY   (0)
 
#define ICMP_ECHOREQUEST   (8)
 
#define ICMPV6_ECHOREPLY   (129)
 
#define ICMPV6_ECHOREQUEST   (128)
 

Functions

static void _xlat_icmp_timeout (xlat_ctx_t const *xctx, request_t *request, UNUSED fr_time_t fired)
 
static int8_t echo_cmp (void const *one, void const *two)
 
static uint16_t icmp_checksum (uint8_t *data, size_t data_len, uint16_t checksum)
 
static int mod_bootstrap (module_inst_ctx_t const *mctx)
 
static void mod_icmp_error (fr_event_list_t *el, UNUSED int sockfd, UNUSED int flags, UNUSED int fd_errno, void *uctx)
 
static void mod_icmp_read (UNUSED fr_event_list_t *el, UNUSED int sockfd, UNUSED int flags, void *uctx)
 
static int mod_instantiate (module_inst_ctx_t const *mctx)
 
static int mod_load (void)
 
static int mod_thread_detach (module_thread_inst_ctx_t const *mctx)
 Destroy thread data for the submodule. More...
 
static int mod_thread_instantiate (module_thread_inst_ctx_t const *mctx)
 Instantiate thread data for the submodule. More...
 
static xlat_action_t xlat_icmp (TALLOC_CTX *ctx, UNUSED fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in)
 Xlat to ping a specified ip address. More...
 
static void xlat_icmp_cancel (xlat_ctx_t const *xctx, request_t *request, UNUSED fr_signal_t action)
 
static xlat_action_t xlat_icmp_resume (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, UNUSED request_t *request, UNUSED fr_value_box_list_t *in)
 

Variables

static const conf_parser_t module_config []
 
module_rlm_t rlm_icmp
 
static xlat_arg_parser_t const xlat_icmp_args []
 

Detailed Description

Send ICMP echo requests.

Id
fc972abb18b9dcbdb4595c20d9d9870bae0b13fb

Definition in file rlm_icmp.c.


Data Structure Documentation

◆ icmp_header_t

struct icmp_header_t

Definition at line 65 of file rlm_icmp.c.

Data Fields
uint16_t checksum
uint8_t code
uint32_t counter so that requests for the same IP are unique
uint32_t data another 32-bits of randomness
uint16_t ident
uint16_t sequence
uint8_t type

◆ rlm_icmp_echo_t

struct rlm_icmp_echo_t

Definition at line 57 of file rlm_icmp.c.

+ Collaboration diagram for rlm_icmp_echo_t:
Data Fields
uint32_t counter for pinging the same IP multiple times
fr_value_box_t * ip the IP we're pinging
fr_rb_node_t node Entry in the outstanding list of echo requests.
bool replied do we have a reply?
request_t * request so it can be resumed when we get the echo reply

◆ rlm_icmp_t

struct rlm_icmp_t

Definition at line 38 of file rlm_icmp.c.

+ Collaboration diagram for rlm_icmp_t:
Data Fields
char const * interface
fr_ipaddr_t src_ipaddr
fr_time_delta_t timeout

◆ rlm_icmp_thread_t

struct rlm_icmp_thread_t

Definition at line 44 of file rlm_icmp.c.

+ Collaboration diagram for rlm_icmp_thread_t:
Data Fields
uint32_t counter
uint32_t data
int fd
uint16_t ident
fr_type_t ipaddr_type
uint8_t reply_type
uint8_t request_type
fr_rb_tree_t * tree

Macro Definition Documentation

◆ FD_CLOEXEC

#define FD_CLOEXEC   (0)

◆ ICMP_ECHOREPLY

#define ICMP_ECHOREPLY   (0)

Definition at line 75 of file rlm_icmp.c.

◆ ICMP_ECHOREQUEST

#define ICMP_ECHOREQUEST   (8)

Definition at line 76 of file rlm_icmp.c.

◆ ICMPV6_ECHOREPLY

#define ICMPV6_ECHOREPLY   (129)

Definition at line 79 of file rlm_icmp.c.

◆ ICMPV6_ECHOREQUEST

#define ICMPV6_ECHOREQUEST   (128)

Definition at line 78 of file rlm_icmp.c.

Function Documentation

◆ _xlat_icmp_timeout()

static void _xlat_icmp_timeout ( xlat_ctx_t const *  xctx,
request_t request,
UNUSED fr_time_t  fired 
)
static

Definition at line 142 of file rlm_icmp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ echo_cmp()

static int8_t echo_cmp ( void const *  one,
void const *  two 
)
static

Definition at line 264 of file rlm_icmp.c.

+ Here is the caller graph for this function:

◆ icmp_checksum()

static uint16_t icmp_checksum ( uint8_t data,
size_t  data_len,
uint16_t  checksum 
)
static

Definition at line 84 of file rlm_icmp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mod_bootstrap()

static int mod_bootstrap ( module_inst_ctx_t const *  mctx)
static

Definition at line 518 of file rlm_icmp.c.

+ Here is the call graph for this function:

◆ mod_icmp_error()

static void mod_icmp_error ( fr_event_list_t el,
UNUSED int  sockfd,
UNUSED int  flags,
UNUSED int  fd_errno,
void *  uctx 
)
static

Definition at line 360 of file rlm_icmp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mod_icmp_read()

static void mod_icmp_read ( UNUSED fr_event_list_t el,
UNUSED int  sockfd,
UNUSED int  flags,
void *  uctx 
)
static

Definition at line 275 of file rlm_icmp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mod_instantiate()

static int mod_instantiate ( module_inst_ctx_t const *  mctx)
static

Definition at line 508 of file rlm_icmp.c.

+ Here is the call graph for this function:

◆ mod_load()

static int mod_load ( void  )
static

Definition at line 528 of file rlm_icmp.c.

◆ mod_thread_detach()

static int mod_thread_detach ( module_thread_inst_ctx_t const *  mctx)
static

Destroy thread data for the submodule.

Definition at line 376 of file rlm_icmp.c.

+ Here is the call graph for this function:

◆ mod_thread_instantiate()

static int mod_thread_instantiate ( module_thread_inst_ctx_t const *  mctx)
static

Instantiate thread data for the submodule.

Definition at line 392 of file rlm_icmp.c.

+ Here is the call graph for this function:

◆ xlat_icmp_cancel()

static void xlat_icmp_cancel ( xlat_ctx_t const *  xctx,
request_t request,
UNUSED fr_signal_t  action 
)
static

Definition at line 130 of file rlm_icmp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xlat_icmp_resume()

static xlat_action_t xlat_icmp_resume ( TALLOC_CTX *  ctx,
fr_dcursor_t out,
xlat_ctx_t const *  xctx,
UNUSED request_t request,
UNUSED fr_value_box_list_t *  in 
)
static

Definition at line 111 of file rlm_icmp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ module_config

const conf_parser_t module_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("interface", rlm_icmp_t, interface) },
{ FR_CONF_OFFSET_TYPE_FLAGS("src_ipaddr", FR_TYPE_COMBO_IP_ADDR, 0, rlm_icmp_t, src_ipaddr) },
{ FR_CONF_OFFSET("timeout", rlm_icmp_t, timeout), .dflt = "1s" },
}
#define CONF_PARSER_TERMINATOR
Definition: cf_parse.h:627
#define FR_CONF_OFFSET(_name, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition: cf_parse.h:268
#define FR_CONF_OFFSET_TYPE_FLAGS(_name, _type, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition: cf_parse.h:241
static fr_time_delta_t timeout
Definition: dhcpclient.c:54
@ FR_TYPE_COMBO_IP_ADDR
IPv4 or IPv6 address depending on length.
Definition: merged_model.c:91

Definition at line 104 of file rlm_icmp.c.

◆ rlm_icmp

module_rlm_t rlm_icmp
Initial value:
= {
.common = {
.name = "icmp",
.inst_size = sizeof(rlm_icmp_t),
.onload = mod_load,
.bootstrap = mod_bootstrap,
.thread_inst_size = sizeof(rlm_icmp_thread_t),
.thread_inst_type = "rlm_icmp_thread_t",
.thread_instantiate = mod_thread_instantiate,
.thread_detach = mod_thread_detach
}
}
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition: dl_module.h:63
static const conf_parser_t config[]
Definition: base.c:183
static int mod_load(void)
Definition: rlm_icmp.c:528
static int mod_bootstrap(module_inst_ctx_t const *mctx)
Definition: rlm_icmp.c:518
static int mod_thread_instantiate(module_thread_inst_ctx_t const *mctx)
Instantiate thread data for the submodule.
Definition: rlm_icmp.c:392
static const conf_parser_t module_config[]
Definition: rlm_icmp.c:104
static int mod_thread_detach(module_thread_inst_ctx_t const *mctx)
Destroy thread data for the submodule.
Definition: rlm_icmp.c:376
static int mod_instantiate(module_inst_ctx_t const *mctx)
Definition: rlm_icmp.c:508
static int instantiate(module_inst_ctx_t const *mctx)
Definition: rlm_rest.c:1302

Definition at line 558 of file rlm_icmp.c.

◆ xlat_icmp_args

xlat_arg_parser_t const xlat_icmp_args[]
static
Initial value:
= {
{ .required = true, .single = true, .type = FR_TYPE_STRING },
}
@ FR_TYPE_STRING
String of printable characters.
Definition: merged_model.c:83
#define XLAT_ARG_PARSER_TERMINATOR
Definition: xlat.h:166

Definition at line 153 of file rlm_icmp.c.