contrib/fwd: update main, not really useful yet

This commit is contained in:
Jo-Philipp Wich 2009-12-15 11:22:56 +00:00
parent 7001c02a38
commit b957d3f56d

View file

@ -21,13 +21,16 @@
#include "fwd_addr.h" #include "fwd_addr.h"
#include "fwd_rules.h" #include "fwd_rules.h"
#include "fwd_config.h" #include "fwd_config.h"
#include "fwd_xtables.h"
#define IPT "iptables"
int main(int argc, const char *argv[]) int main(int argc, const char *argv[])
{ {
struct fwd_handle *h; struct fwd_handle *h;
struct iptc_handle *ipt;
if( getuid() > 0 )
fwd_fatal("Need root permissions!");
if( !(h = fwd_alloc_ptr(struct fwd_handle)) ) if( !(h = fwd_alloc_ptr(struct fwd_handle)) )
fwd_fatal("Out of memory"); fwd_fatal("Out of memory");
@ -41,13 +44,11 @@ int main(int argc, const char *argv[])
if( !(h->addrs = fwd_get_addrs(h->rtnl_socket, AF_INET)) ) if( !(h->addrs = fwd_get_addrs(h->rtnl_socket, AF_INET)) )
fwd_fatal("Failed to issue RTM_GETADDR (%m)"); fwd_fatal("Failed to issue RTM_GETADDR (%m)");
fwd_ipt_build_ruleset(h); fwd_ipt_build_ruleset(h);
fwd_ipt_addif(h, "lan"); fwd_ipt_addif(h, "lan");
fwd_ipt_addif(h, "wan"); fwd_ipt_addif(h, "wan");
close(h->rtnl_socket); close(h->rtnl_socket);
fwd_free_config(h->conf); fwd_free_config(h->conf);
fwd_free_addrs(h->addrs); fwd_free_addrs(h->addrs);