extern struct option *xtables_merge_options(struct option *oldopts,
const struct option *newopts, unsigned int *option_offset);
+extern int xtables_init_all(struct xtables_globals *xtp, uint8_t nfproto);
extern struct xtables_match *xtables_find_match(const char *name,
enum xtables_tryload, struct xtables_rule_match **match);
extern struct xtables_target *xtables_find_target(const char *name,
line = 0;
xtables_program_name = program_name;
- xtables_init();
- xtables_set_nfproto(NFPROTO_IPV6);
ip6tables_globals.program_name = "ip6tables-restore";
+ c = xtables_init_all(&ip6tables_globals, NFPROTO_IPV6);
+ if (c < 0) {
+ fprintf(stderr, "%s/%s Failed to initialize xtables\n",
+ ip6tables_globals.program_name,
+ ip6tables_globals.program_version);
+ exit(1);
+ }
#ifdef NO_SHARED_LIBS
init_extensions();
#endif
program_version = IPTABLES_VERSION;
xtables_program_name = program_name;
- xtables_init();
- xtables_set_nfproto(NFPROTO_IPV6);
ip6tables_globals.program_name = "ip6tables-save";
+ c = xtables_init_all(&ip6tables_globals, NFPROTO_IPV6);
+ if (c < 0) {
+ fprintf(stderr, "%s/%s Failed to initialize xtables\n",
+ ip6tables_globals.program_name,
+ ip6tables_globals.program_version);
+ exit(1);
+ }
#ifdef NO_SHARED_LIBS
init_extensions();
#endif
program_version = IPTABLES_VERSION;
xtables_program_name = program_name;
- xtables_init();
- xtables_set_nfproto(NFPROTO_IPV6);
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
init_extensions();
#endif
demand-load a protocol. */
opterr = 0;
- xtables_set_params(&ip6tables_globals);
while ((c = getopt_long(argc, argv,
"-A:D:R:I:L::S::M:F::Z::N:X::E:P:Vh::o:p:s:d:j:i:bvnt:m:xc:g:",
opts, NULL)) != -1) {
line = 0;
xtables_program_name = program_name;
- xtables_init();
- xtables_set_nfproto(NFPROTO_IPV4);
iptables_globals.program_name = "iptables-restore";
+ c = xtables_init_all(&iptables_globals, NFPROTO_IPV4);
+ if (c < 0) {
+ fprintf(stderr, "%s/%s Failed to initialize xtables\n",
+ iptables_globals.program_name,
+ iptables_globals.program_version);
+ exit(1);
+ }
#ifdef NO_SHARED_LIBS
init_extensions();
#endif
program_version = IPTABLES_VERSION;
xtables_program_name = program_name;
- xtables_init();
- xtables_set_nfproto(NFPROTO_IPV4);
iptables_globals.program_name = "iptables-save";
+ c = xtables_init_all(&iptables_globals, NFPROTO_IPV4);
+ if (c < 0) {
+ fprintf(stderr, "%s/%s Failed to initialize xtables\n",
+ iptables_globals.program_name,
+ iptables_globals.program_version);
+ exit(1);
+ }
#ifdef NO_SHARED_LIBS
init_extensions();
#endif
program_version = IPTABLES_VERSION;
xtables_program_name = program_name;
- xtables_init();
- xtables_set_nfproto(NFPROTO_IPV4);
iptables_globals.program_name = "iptables";
+ ret = xtables_init_all(&iptables_globals, NFPROTO_IPV4);
+ if (ret < 0) {
+ fprintf(stderr, "%s/%s Failed to initialize xtables\n",
+ iptables_globals.program_name,
+ iptables_globals.program_version);
+ exit(1);
+ }
#ifdef NO_SHARED_LIBS
init_extensions();
#endif
demand-load a protocol. */
opterr = 0;
- xtables_set_params(&iptables_globals);
while ((c = getopt_long(argc, argv,
"-A:D:R:I:L::S::M:F::Z::N:X::E:P:Vh::o:p:s:d:j:i:fbvnt:m:xc:g:",
opts, NULL)) != -1) {
}
-/**
- * xtables_set_params - set the global parameters used by xtables
- * @xtp: input xtables_globals structure
- *
- * The app is expected to pass a valid xtables_globals data-filled
- * with proper values
- * @xtp cannot be NULL
- *
- * Returns -1 on failure to set and 0 on success
- */
-int xtables_set_params(struct xtables_globals *xtp)
-{
- if (!xtp) {
- fprintf(stderr, "%s: Illegal global params\n",__func__);
- return -1;
- }
-
- xt_params = xtp;
-
- if (!xt_params->exit_err)
- xt_params->exit_err = basic_exit_err;
-
- return 0;
-}
-
void xtables_free_opts(int reset_offset)
{
if (xt_params->opts != xt_params->orig_opts) {
}
}
+/**
+ * xtables_set_params - set the global parameters used by xtables
+ * @xtp: input xtables_globals structure
+ *
+ * The app is expected to pass a valid xtables_globals data-filled
+ * with proper values
+ * @xtp cannot be NULL
+ *
+ * Returns -1 on failure to set and 0 on success
+ */
+int xtables_set_params(struct xtables_globals *xtp)
+{
+ if (!xtp) {
+ fprintf(stderr, "%s: Illegal global params\n",__func__);
+ return -1;
+ }
+
+ xt_params = xtp;
+
+ if (!xt_params->exit_err)
+ xt_params->exit_err = basic_exit_err;
+
+ return 0;
+}
+
+int xtables_init_all(struct xtables_globals *xtp, uint8_t nfproto)
+{
+ xtables_init();
+ xtables_set_nfproto(nfproto);
+ return xtables_set_params(xtp);
+}
+
/**
* xtables_*alloc - wrappers that exit on failure
*/