This optional parameter allows you to define a Perl function
that will be called when the reachability of a next hop Host changes. See
section
Section 3.42.1. Failure algorithm for more
about reachability detection. The following arguments are passed in the
following order:
- Reference to the request that was sent to the Host but received no
reply and triggered the change state. Request type is
Status-Server
when this request type is used for
reachability detection.
- Reference to this
Radius::AuthRADSEC
structure
- Reference to the
Radius::Host
structure for the
remote host
- New host state. One of integer constant values:
$Radius::AuthRADIUS::HOST_STATE::REACHABLE
$Radius::AuthRADIUS::HOST_STATE::UNREACHABLE
- IP address of the Host that is now reachable or unreachable
- Port on the Host that is now reachable or unreachable
The hook code is compiled by Perl when Radiator starts up.
Compilation errors in your hook code will be reported to the log file at
start-up time. Runtime errors in your hook will also be reported to the
log file when your hook executes. Multiline hooks (i.e. with trailing
backslashes (\)) are parsed by Radiator into one long line. Therefore you
should not use trailing comments in your
hook.
HostStateChangeHook
can be an arbitrarily
complicated Perl function, that might run external processes, consult
databases, change the contents of the current request or many other
things. The following example shows how to use the state constants, store
the state over hook invocations and log information from the
hook.
HostStateChangeHook sub { \
my ($p, $self, $host, $new_state, $ip, $port) = @_; \
my $old_state = $host->{state_change_hook_current_state}; \
$old_state = $Radius::AuthRADIUS::HOST_STATE::REACHABLE
unless defined $old_state; \
return if $old_state == $new_state; \
$host->{state_change_hook_current_state} = $new_state; \
my $st = ($new_state == $Radius::AuthRADIUS::HOST_STATE::UNREACHABLE) ?
'Unreachable' : 'Reachable'; \
my $msg = "HostStateChangeHook: IP '$ip', Port '$port', New State: '$st'"; \
$self->log($main::LOG_INFO, "$self->{log_class_identifier} $msg", $p); \
return; }