blob: 9190873218a4999bcd824126f879755f38bdb9ec [file] [log] [blame]
Marc Bouchere6869a82000-03-20 06:03:29 +00001/*
2 * Author: Paul.Russell@rustcorp.com.au and mneuling@radlogic.com.au
3 *
4 * Based on the ipchains code by Paul Russell and Michael Neuling
5 *
Harald Welte10a907f2002-08-07 09:07:41 +00006 * (C) 2000-2002 by the netfilter coreteam <coreteam@netfilter.org>:
7 * Paul 'Rusty' Russell <rusty@rustcorp.com.au>
8 * Marc Boucher <marc+nf@mbsi.ca>
9 * James Morris <jmorris@intercode.com.au>
10 * Harald Welte <laforge@gnumonks.org>
11 * Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
12 *
Marc Bouchere6869a82000-03-20 06:03:29 +000013 * iptables -- IP firewall administration for kernels with
14 * firewall table (aimed for the 2.3 kernels)
15 *
16 * See the accompanying manual page iptables(8) for information
17 * about proper usage of this program.
18 *
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 */
33
34#include <stdio.h>
Rusty Russelldb780472000-12-19 05:17:50 +000035#include <stdlib.h>
Marc Bouchere6869a82000-03-20 06:03:29 +000036#include <errno.h>
Harald Welted8e65632001-01-05 15:20:07 +000037#include <string.h>
Marc Bouchere6869a82000-03-20 06:03:29 +000038#include <iptables.h>
Jan Engelhardt33690a12008-02-11 00:54:00 +010039#include "iptables-multi.h"
Marc Bouchere6869a82000-03-20 06:03:29 +000040
Bastiaan Bakker4e3771f2004-06-25 11:18:57 +000041#ifdef IPTABLES_MULTI
42int
43iptables_main(int argc, char *argv[])
44#else
Marc Bouchere6869a82000-03-20 06:03:29 +000045int
46main(int argc, char *argv[])
Bastiaan Bakker4e3771f2004-06-25 11:18:57 +000047#endif
Marc Bouchere6869a82000-03-20 06:03:29 +000048{
49 int ret;
50 char *table = "filter";
Jan Engelhardtfd187312008-11-10 16:59:27 +010051 struct iptc_handle *handle = NULL;
Marc Bouchere6869a82000-03-20 06:03:29 +000052
53 program_name = "iptables";
Jan Engelhardtdacafa52009-01-27 20:56:23 +010054 program_version = IPTABLES_VERSION;
Marc Bouchere6869a82000-03-20 06:03:29 +000055
Jan Engelhardtdacafa52009-01-27 20:56:23 +010056 xtables_program_name = program_name;
Jan Engelhardt39bf9c82009-01-27 15:59:06 +010057 xtables_init();
Harald Welte3efb6ea2001-08-06 18:50:21 +000058#ifdef NO_SHARED_LIBS
59 init_extensions();
60#endif
61
Rusty Russellf7b062f2001-01-07 06:55:24 +000062 ret = do_command(argc, argv, &table, &handle);
Jan Engelhardt1c9015b2008-11-10 17:00:41 +010063 if (ret) {
64 ret = iptc_commit(handle);
65 iptc_free(handle);
66 }
Marc Bouchere6869a82000-03-20 06:03:29 +000067
Jesper Dangaard Brouer056564f2006-06-19 16:53:03 +000068 if (!ret) {
Pablo Neira Ayuso7937e942008-11-19 19:01:26 +010069 fprintf(stderr, "iptables: %s. "
70 "Run `dmesg' for more information.\n",
Marc Bouchere6869a82000-03-20 06:03:29 +000071 iptc_strerror(errno));
Jesper Dangaard Brouer056564f2006-06-19 16:53:03 +000072 if (errno == EAGAIN) {
73 exit(RESOURCE_PROBLEM);
74 }
75 }
Marc Bouchere6869a82000-03-20 06:03:29 +000076
77 exit(!ret);
78}