libipsec: Support usage statistics and query_sa() on IPsec SAs
This commit is contained in:
@@ -530,6 +530,28 @@ METHOD(ipsec_sa_mgr_t, update_sa, status_t,
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
METHOD(ipsec_sa_mgr_t, query_sa, status_t,
|
||||
private_ipsec_sa_mgr_t *this, host_t *src, host_t *dst,
|
||||
u_int32_t spi, u_int8_t protocol, mark_t mark,
|
||||
u_int64_t *bytes, u_int64_t *packets, time_t *time)
|
||||
{
|
||||
ipsec_sa_entry_t *entry = NULL;
|
||||
|
||||
this->mutex->lock(this->mutex);
|
||||
if (this->sas->find_first(this->sas, (void*)match_entry_by_spi_src_dst,
|
||||
(void**)&entry, &spi, src, dst) == SUCCESS &&
|
||||
wait_for_entry(this, entry))
|
||||
{
|
||||
entry->sa->get_usestats(entry->sa, bytes, packets, time);
|
||||
/* checkin the entry */
|
||||
entry->locked = FALSE;
|
||||
entry->condvar->signal(entry->condvar);
|
||||
}
|
||||
this->mutex->unlock(this->mutex);
|
||||
|
||||
return entry ? SUCCESS : NOT_FOUND;
|
||||
}
|
||||
|
||||
METHOD(ipsec_sa_mgr_t, del_sa, status_t,
|
||||
private_ipsec_sa_mgr_t *this, host_t *src, host_t *dst, u_int32_t spi,
|
||||
u_int8_t protocol, u_int16_t cpi, mark_t mark)
|
||||
@@ -653,6 +675,7 @@ ipsec_sa_mgr_t *ipsec_sa_mgr_create()
|
||||
.get_spi = _get_spi,
|
||||
.add_sa = _add_sa,
|
||||
.update_sa = _update_sa,
|
||||
.query_sa = _query_sa,
|
||||
.del_sa = _del_sa,
|
||||
.checkout_by_spi = _checkout_by_spi,
|
||||
.checkout_by_reqid = _checkout_by_reqid,
|
||||
|
||||
Reference in New Issue
Block a user