mirror of
https://github.com/strongswan/strongswan.git
synced 2025-10-07 00:01:49 -04:00
eap-radius: add an option to disable accounting for tunnels without virtual IP
This commit is contained in:
parent
69620a48e8
commit
aea7ce3c64
@ -56,6 +56,11 @@ struct private_eap_radius_accounting_t {
|
||||
* Format string we use for Called/Calling-Station-Id for a host
|
||||
*/
|
||||
char *station_id_fmt;
|
||||
|
||||
/**
|
||||
* Disable accounting unless IKE_SA has at least one virtual IP
|
||||
*/
|
||||
bool acct_req_vip;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -437,6 +442,22 @@ static void schedule_interim(private_eap_radius_accounting_t *this,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an IKE_SA has assigned a virtual IP (to peer)
|
||||
*/
|
||||
static bool has_vip(ike_sa_t *ike_sa)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
host_t *host;
|
||||
bool found;
|
||||
|
||||
enumerator = ike_sa->create_virtual_ip_enumerator(ike_sa, FALSE);
|
||||
found = enumerator->enumerate(enumerator, &host);
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an accounting start message
|
||||
*/
|
||||
@ -446,6 +467,11 @@ static void send_start(private_eap_radius_accounting_t *this, ike_sa_t *ike_sa)
|
||||
entry_t *entry;
|
||||
u_int32_t value;
|
||||
|
||||
if (this->acct_req_vip && !has_vip(ike_sa))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this->mutex->lock(this->mutex);
|
||||
|
||||
entry = get_or_create_entry(this, ike_sa);
|
||||
@ -700,6 +726,10 @@ eap_radius_accounting_t *eap_radius_accounting_create()
|
||||
singleton = this;
|
||||
charon->bus->add_listener(charon->bus, &this->public.listener);
|
||||
}
|
||||
this->acct_req_vip = lib->settings->get_bool(lib->settings,
|
||||
"%s.plugins.eap-radius.accounting_requires_vip",
|
||||
FALSE, charon->name);
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user