mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
libpfctl: implement status counter accessor functions
The new nvlist-based status call allows us to easily add new counters. However, the libpfctl interface defines a TAILQ, so it's not quite trivial to find the counter consumers are interested in. Provide convenience functions to access the counters. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D41649
This commit is contained in:
parent
0b01878fd0
commit
e3d3d61a7d
|
@ -252,6 +252,37 @@ pfctl_get_status(int dev)
|
|||
return (status);
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
_pfctl_status_counter(struct pfctl_status_counters *counters, uint64_t id)
|
||||
{
|
||||
struct pfctl_status_counter *c;
|
||||
|
||||
TAILQ_FOREACH(c, counters, entry) {
|
||||
if (c->id == id)
|
||||
return (c->counter);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
pfctl_status_counter(struct pfctl_status *status, int id)
|
||||
{
|
||||
return (_pfctl_status_counter(&status->counters, id));
|
||||
}
|
||||
|
||||
uint64_t
|
||||
pfctl_status_fcounter(struct pfctl_status *status, int id)
|
||||
{
|
||||
return (_pfctl_status_counter(&status->fcounters, id));
|
||||
}
|
||||
|
||||
uint64_t
|
||||
pfctl_status_scounter(struct pfctl_status *status, int id)
|
||||
{
|
||||
return (_pfctl_status_counter(&status->scounters, id));
|
||||
}
|
||||
|
||||
void
|
||||
pfctl_free_status(struct pfctl_status *status)
|
||||
{
|
||||
|
|
|
@ -385,6 +385,9 @@ struct pfctl_syncookies {
|
|||
};
|
||||
|
||||
struct pfctl_status* pfctl_get_status(int dev);
|
||||
uint64_t pfctl_status_counter(struct pfctl_status *status, int id);
|
||||
uint64_t pfctl_status_fcounter(struct pfctl_status *status, int id);
|
||||
uint64_t pfctl_status_scounter(struct pfctl_status *status, int id);
|
||||
void pfctl_free_status(struct pfctl_status *status);
|
||||
|
||||
int pfctl_get_eth_rulesets_info(int dev,
|
||||
|
|
Loading…
Reference in a new issue