pfctl: move astats query into libpfctl
Sponsored by: Rubicon Communications, LLC ("Netgate")
This commit is contained in:
@@ -3751,4 +3751,26 @@ pfctl_clear_addrs(struct pfctl_handle *h, const struct pfr_table *filter,
|
||||
|
||||
return (e.error);
|
||||
}
|
||||
int
|
||||
pfctl_get_astats(struct pfctl_handle *h, const struct pfr_table *tbl,
|
||||
struct pfr_astats *addr, int *size, int flags)
|
||||
{
|
||||
struct pfioc_table io;
|
||||
|
||||
if (tbl == NULL || size == NULL || *size < 0 ||
|
||||
(*size && addr == NULL)) {
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
bzero(&io, sizeof io);
|
||||
io.pfrio_flags = flags;
|
||||
io.pfrio_table = *tbl;
|
||||
io.pfrio_buffer = addr;
|
||||
io.pfrio_esize = sizeof(*addr);
|
||||
io.pfrio_size = *size;
|
||||
if (ioctl(h->fd, DIOCRGETASTATS, &io)) {
|
||||
return (-1);
|
||||
}
|
||||
*size = io.pfrio_size;
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -584,4 +584,7 @@ int pfctl_clear_tstats(struct pfctl_handle *h, const struct pfr_table *filter,
|
||||
int pfctl_clear_addrs(struct pfctl_handle *h, const struct pfr_table *filter,
|
||||
int *ndel, int flags);
|
||||
|
||||
int pfctl_get_astats(struct pfctl_handle *h, const struct pfr_table *tbl,
|
||||
struct pfr_astats *addr, int *size, int flags);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -194,25 +194,7 @@ int
|
||||
pfr_get_astats(struct pfr_table *tbl, struct pfr_astats *addr, int *size,
|
||||
int flags)
|
||||
{
|
||||
struct pfioc_table io;
|
||||
|
||||
if (tbl == NULL || size == NULL || *size < 0 ||
|
||||
(*size && addr == NULL)) {
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
bzero(&io, sizeof io);
|
||||
io.pfrio_flags = flags;
|
||||
io.pfrio_table = *tbl;
|
||||
io.pfrio_buffer = addr;
|
||||
io.pfrio_esize = sizeof(*addr);
|
||||
io.pfrio_size = *size;
|
||||
if (ioctl(dev, DIOCRGETASTATS, &io)) {
|
||||
pfr_report_error(tbl, &io, "get astats from");
|
||||
return (-1);
|
||||
}
|
||||
*size = io.pfrio_size;
|
||||
return (0);
|
||||
return (pfctl_get_astats(pfh, tbl, addr, size, flags));
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
Reference in New Issue
Block a user