pf plugin: dont reinvent code, use code from pfctl
authorStefan Rinkes <stefan.rinkes@gmail.com>
Mon, 25 Apr 2011 16:13:09 +0000 (18:13 +0200)
committerStefan Rinkes <stefan.rinkes@gmail.com>
Mon, 25 Apr 2011 16:13:09 +0000 (18:13 +0200)
src/pf.c

index 1c5f316..3b8e809 100644 (file)
--- a/src/pf.c
+++ b/src/pf.c
 
 #include "pfcommon.h"
 
-static int     pf_init(void);
-static int     pf_read(void);
-static void    submit_counter(const char *, const char *, counter_t);
+static int      pf_init(void);
+static int      pf_read(void);
+static void     submit_counter(const char *, const char *, counter_t);
 
-int    pfdev = -1;
+char           *pf_device = "/dev/pf";
 
 int
 pf_init(void)
 {
        struct pf_status        status;
+       int                     pfdev = -1;
 
-       if ((pfdev = open(PF_SOCKET, O_RDONLY)) == -1) {
-               warn("unable to open %s", PF_SOCKET);
+       if ((pfdev = open(pf_device, O_RDONLY)) == -1) {
+               warn("unable to open %s", pf_device);
                return (-1);
        }
 
@@ -49,15 +50,16 @@ pf_init(void)
 int
 pf_read(void)
 {
-       int                     i;
        struct pf_status        status;
+       int                     pfdev = -1;
+       int                     i;
 
        char            *cnames[] = PFRES_NAMES;
        char            *lnames[] = LCNT_NAMES;
        char            *names[] = { "searches", "inserts", "removals" };
 
-       if ((pfdev = open(PF_SOCKET, O_RDONLY)) == -1) {
-               warn("unable tot open %s", PF_SOCKET);
+       if ((pfdev = open(pf_device, O_RDONLY)) == -1) {
+               warn("unable to open %s", pf_device);
                return (-1);
        }