aboutsummaryrefslogtreecommitdiffstats
path: root/ip6tables-standalone.c
diff options
context:
space:
mode:
Diffstat (limited to 'ip6tables-standalone.c')
-rw-r--r--ip6tables-standalone.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/ip6tables-standalone.c b/ip6tables-standalone.c
index 36dde33..8661bd9 100644
--- a/ip6tables-standalone.c
+++ b/ip6tables-standalone.c
@@ -35,32 +35,49 @@
#include <stdlib.h>
#include <errno.h>
#include <ip6tables.h>
+#include "ip6tables-multi.h"
+#ifdef IPTABLES_MULTI
+int
+ip6tables_main(int argc, char *argv[])
+#else
int
main(int argc, char *argv[])
+#endif
{
int ret;
char *table = "filter";
- ip6tc_handle_t handle = NULL;
-
- program_name = "ip6tables";
- program_version = IPTABLES_VERSION;
+ struct ip6tc_handle *handle = NULL;
- lib_dir = getenv("IP6TABLES_LIB_DIR");
- if (!lib_dir)
- lib_dir = IP6T_LIB_DIR;
+ ip6tables_globals.program_name = "ip6tables";
+ ret = xtables_init_all(&ip6tables_globals, NFPROTO_IPV6);
+ if (ret < 0) {
+ fprintf(stderr, "%s/%s Failed to initialize xtables\n",
+ ip6tables_globals.program_name,
+ ip6tables_globals.program_version);
+ exit(1);
+ }
-#ifdef NO_SHARED_LIBS
+#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
init_extensions();
#endif
ret = do_command6(argc, argv, &table, &handle);
- if (ret)
- ret = ip6tc_commit(&handle);
+ if (ret) {
+ ret = ip6tc_commit(handle);
+ ip6tc_free(handle);
+ }
- if (!ret)
- fprintf(stderr, "ip6tables: %s\n",
- ip6tc_strerror(errno));
+ if (!ret) {
+ if (errno == EINVAL) {
+ fprintf(stderr, "ip6tables: %s. "
+ "Run `dmesg' for more information.\n",
+ ip6tc_strerror(errno));
+ } else {
+ fprintf(stderr, "ip6tables: %s.\n",
+ ip6tc_strerror(errno));
+ }
+ }
exit(!ret);
}