summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3e394c1)
raw | patch | inline | side by side (parent: 3e394c1)
author | Stefan Rinkes <stefan.rinkes@gmail.com> | |
Mon, 25 Apr 2011 14:46:04 +0000 (16:46 +0200) | ||
committer | Stefan Rinkes <stefan.rinkes@gmail.com> | |
Mon, 25 Apr 2011 14:52:31 +0000 (16:52 +0200) |
src/pf.c | patch | blob | history |
diff --git a/src/pf.c b/src/pf.c
index 33e2d4b964c0ef8dc5d45058c383a5a7889dfd55..1c5f31619c4cfb8984646d2615444de0e9c6b77c 100644 (file)
--- a/src/pf.c
+++ b/src/pf.c
static int pf_read(void);
static void submit_counter(const char *, const char *, counter_t);
+int pfdev = -1;
+
int
pf_init(void)
{
struct pf_status status;
- if ((dev = open(PF_SOCKET, O_RDONLY)) == -1) {
+ if ((pfdev = open(PF_SOCKET, O_RDONLY)) == -1) {
+ warn("unable to open %s", PF_SOCKET);
return (-1);
}
- if (ioctl(dev, DIOCGETSTATUS, &status) == -1) {
+
+ if (ioctl(pfdev, DIOCGETSTATUS, &status) == -1) {
+ warn("DIOCGETSTATUS: %i", pfdev);
+ close(pfdev);
return (-1);
}
- close(dev);
+ close(pfdev);
if (!status.running)
return (-1);
char *lnames[] = LCNT_NAMES;
char *names[] = { "searches", "inserts", "removals" };
- if ((dev = open(PF_SOCKET, O_RDONLY)) == -1) {
+ if ((pfdev = open(PF_SOCKET, O_RDONLY)) == -1) {
+ warn("unable tot open %s", PF_SOCKET);
return (-1);
}
- if (ioctl(dev, DIOCGETSTATUS, &status) == -1) {
+
+ if (ioctl(pfdev, DIOCGETSTATUS, &status) == -1) {
+ warn("DIOCGETSTATUS: %i", pfdev);
+ close(pfdev);
return (-1);
}
- close(dev);
+ close(pfdev);
+
for (i = 0; i < PFRES_MAX; i++)
submit_counter("pf_counters", cnames[i], status.counters[i]);
for (i = 0; i < LCNT_MAX; i++)
submit_counter("pf_state", names[i], status.fcounters[i]);
for (i = 0; i < SCNT_MAX; i++)
submit_counter("pf_source", names[i], status.scounters[i]);
+
return (0);
}