Blame bootstrap_ver/iptables/iptables-standalone.c

Packit Service 1ec7f4
/*
Packit Service 1ec7f4
 * Author: Paul.Russell@rustcorp.com.au and mneuling@radlogic.com.au
Packit Service 1ec7f4
 *
Packit Service 1ec7f4
 * Based on the ipchains code by Paul Russell and Michael Neuling
Packit Service 1ec7f4
 *
Packit Service 1ec7f4
 * (C) 2000-2002 by the netfilter coreteam <coreteam@netfilter.org>:
Packit Service 1ec7f4
 * 		    Paul 'Rusty' Russell <rusty@rustcorp.com.au>
Packit Service 1ec7f4
 * 		    Marc Boucher <marc+nf@mbsi.ca>
Packit Service 1ec7f4
 * 		    James Morris <jmorris@intercode.com.au>
Packit Service 1ec7f4
 * 		    Harald Welte <laforge@gnumonks.org>
Packit Service 1ec7f4
 * 		    Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Packit Service 1ec7f4
 *
Packit Service 1ec7f4
 *	iptables -- IP firewall administration for kernels with
Packit Service 1ec7f4
 *	firewall table (aimed for the 2.3 kernels)
Packit Service 1ec7f4
 *
Packit Service 1ec7f4
 *	See the accompanying manual page iptables(8) for information
Packit Service 1ec7f4
 *	about proper usage of this program.
Packit Service 1ec7f4
 *
Packit Service 1ec7f4
 *	This program is free software; you can redistribute it and/or modify
Packit Service 1ec7f4
 *	it under the terms of the GNU General Public License as published by
Packit Service 1ec7f4
 *	the Free Software Foundation; either version 2 of the License, or
Packit Service 1ec7f4
 *	(at your option) any later version.
Packit Service 1ec7f4
 *
Packit Service 1ec7f4
 *	This program is distributed in the hope that it will be useful,
Packit Service 1ec7f4
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 1ec7f4
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 1ec7f4
 *	GNU General Public License for more details.
Packit Service 1ec7f4
 *
Packit Service 1ec7f4
 *	You should have received a copy of the GNU General Public License
Packit Service 1ec7f4
 *	along with this program; if not, write to the Free Software
Packit Service 1ec7f4
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Packit Service 1ec7f4
 */
Packit Service 1ec7f4
Packit Service 1ec7f4
#include <stdio.h>
Packit Service 1ec7f4
#include <stdlib.h>
Packit Service 1ec7f4
#include <errno.h>
Packit Service 1ec7f4
#include <string.h>
Packit Service 1ec7f4
#include <iptables.h>
Packit Service 1ec7f4
#include "iptables-multi.h"
Packit Service 1ec7f4
Packit Service 1ec7f4
int
Packit Service 1ec7f4
iptables_main(int argc, char *argv[])
Packit Service 1ec7f4
{
Packit Service 1ec7f4
	int ret;
Packit Service 1ec7f4
	char *table = "filter";
Packit Service 1ec7f4
	struct xtc_handle *handle = NULL;
Packit Service 1ec7f4
Packit Service 1ec7f4
	iptables_globals.program_name = "iptables";
Packit Service 1ec7f4
	ret = xtables_init_all(&iptables_globals, NFPROTO_IPV4);
Packit Service 1ec7f4
	if (ret < 0) {
Packit Service 1ec7f4
		fprintf(stderr, "%s/%s Failed to initialize xtables\n",
Packit Service 1ec7f4
				iptables_globals.program_name,
Packit Service 1ec7f4
				iptables_globals.program_version);
Packit Service 1ec7f4
				exit(1);
Packit Service 1ec7f4
	}
Packit Service 1ec7f4
#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
Packit Service 1ec7f4
	init_extensions();
Packit Service 1ec7f4
	init_extensions4();
Packit Service 1ec7f4
#endif
Packit Service 1ec7f4
Packit Service 1ec7f4
	ret = do_command4(argc, argv, &table, &handle, false);
Packit Service 1ec7f4
	if (ret) {
Packit Service 1ec7f4
		ret = iptc_commit(handle);
Packit Service 1ec7f4
		iptc_free(handle);
Packit Service 1ec7f4
	}
Packit Service 1ec7f4
Packit Service 1ec7f4
	if (!ret) {
Packit Service 1ec7f4
		if (errno == EINVAL) {
Packit Service 1ec7f4
			fprintf(stderr, "iptables: %s. "
Packit Service 1ec7f4
					"Run `dmesg' for more information.\n",
Packit Service 1ec7f4
				iptc_strerror(errno));
Packit Service 1ec7f4
		} else {
Packit Service 1ec7f4
			fprintf(stderr, "iptables: %s.\n",
Packit Service 1ec7f4
				iptc_strerror(errno));
Packit Service 1ec7f4
		}
Packit Service 1ec7f4
		if (errno == EAGAIN)
Packit Service 1ec7f4
			exit(RESOURCE_PROBLEM);
Packit Service 1ec7f4
	}
Packit Service 1ec7f4
Packit Service 1ec7f4
	exit(!ret);
Packit Service 1ec7f4
}