contrib/fwd: reorganize internal data model
[project/luci.git] / contrib / fwd / src / fwd.c
index 44b7f5a..903834b 100644 (file)
 #include "fwd_addr.h"
 #include "fwd_rules.h"
 #include "fwd_config.h"
-
-#define IPT "iptables"
+#include "fwd_xtables.h"
 
 
 int main(int argc, const char *argv[])
 {
        struct fwd_handle *h;
 
+       if( getuid() > 0 )
+               fwd_fatal("Need root permissions!");
+
        if( !(h = fwd_alloc_ptr(struct fwd_handle)) )
                fwd_fatal("Out of memory");
 
@@ -41,12 +43,17 @@ int main(int argc, const char *argv[])
        if( !(h->addrs = fwd_get_addrs(h->rtnl_socket, AF_INET)) )
                fwd_fatal("Failed to issue RTM_GETADDR (%m)");
 
-
        fwd_ipt_build_ruleset(h);
 
        fwd_ipt_addif(h, "lan");
        fwd_ipt_addif(h, "wan");
 
+       sleep(1);
+
+       fwd_ipt_delif(h, "wan");
+       fwd_ipt_delif(h, "lan");
+
+       fwd_ipt_clear_ruleset(h);
 
        close(h->rtnl_socket);
        fwd_free_config(h->conf);