Rusty Russell | 5eed48a | 2000-06-02 20:12:24 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Author: Paul.Russell@rustcorp.com.au and mneuling@radlogic.com.au |
| 3 | * |
Harald Welte | 10a907f | 2002-08-07 09:07:41 +0000 | [diff] [blame] | 4 | * (C) 2000-2002 by the netfilter coreteam <coreteam@netfilter.org>: |
| 5 | * Paul 'Rusty' Russell <rusty@rustcorp.com.au> |
| 6 | * Marc Boucher <marc+nf@mbsi.ca> |
| 7 | * James Morris <jmorris@intercode.com.au> |
| 8 | * Harald Welte <laforge@gnumonks.org> |
| 9 | * Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> |
| 10 | * |
Rusty Russell | 5eed48a | 2000-06-02 20:12:24 +0000 | [diff] [blame] | 11 | * Based on the ipchains code by Paul Russell and Michael Neuling |
| 12 | * |
| 13 | * 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> |
Harald Welte | d8e6563 | 2001-01-05 15:20:07 +0000 | [diff] [blame] | 35 | #include <stdlib.h> |
Rusty Russell | 5eed48a | 2000-06-02 20:12:24 +0000 | [diff] [blame] | 36 | #include <errno.h> |
| 37 | #include <ip6tables.h> |
Jan Engelhardt | 33690a1 | 2008-02-11 00:54:00 +0100 | [diff] [blame] | 38 | #include "ip6tables-multi.h" |
Rusty Russell | 5eed48a | 2000-06-02 20:12:24 +0000 | [diff] [blame] | 39 | |
Hann-Huei Chiou | 4bc4833 | 2007-10-23 14:22:34 +0000 | [diff] [blame] | 40 | #ifdef IPTABLES_MULTI |
| 41 | int |
| 42 | ip6tables_main(int argc, char *argv[]) |
| 43 | #else |
Rusty Russell | 5eed48a | 2000-06-02 20:12:24 +0000 | [diff] [blame] | 44 | int |
| 45 | main(int argc, char *argv[]) |
Hann-Huei Chiou | 4bc4833 | 2007-10-23 14:22:34 +0000 | [diff] [blame] | 46 | #endif |
Rusty Russell | 5eed48a | 2000-06-02 20:12:24 +0000 | [diff] [blame] | 47 | { |
| 48 | int ret; |
| 49 | char *table = "filter"; |
Jan Engelhardt | fd18731 | 2008-11-10 16:59:27 +0100 | [diff] [blame] | 50 | struct ip6tc_handle *handle = NULL; |
Rusty Russell | 5eed48a | 2000-06-02 20:12:24 +0000 | [diff] [blame] | 51 | |
Jamal Hadi Salim | 617d3d1 | 2009-02-11 16:28:31 -0500 | [diff] [blame] | 52 | ip6tables_globals.program_name = "ip6tables"; |
Jamal Hadi Salim | 7e4db2f | 2009-02-13 09:14:17 -0500 | [diff] [blame] | 53 | ret = xtables_init_all(&ip6tables_globals, NFPROTO_IPV6); |
| 54 | if (ret < 0) { |
| 55 | fprintf(stderr, "%s/%s Failed to initialize xtables\n", |
| 56 | ip6tables_globals.program_name, |
| 57 | ip6tables_globals.program_version); |
| 58 | exit(1); |
| 59 | } |
| 60 | |
Jan Engelhardt | b79ec69 | 2009-07-23 17:41:21 +0200 | [diff] [blame] | 61 | #if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS) |
Harald Welte | 3efb6ea | 2001-08-06 18:50:21 +0000 | [diff] [blame] | 62 | init_extensions(); |
| 63 | #endif |
| 64 | |
Rusty Russell | 5eed48a | 2000-06-02 20:12:24 +0000 | [diff] [blame] | 65 | ret = do_command6(argc, argv, &table, &handle); |
Jan Engelhardt | 1c9015b | 2008-11-10 17:00:41 +0100 | [diff] [blame] | 66 | if (ret) { |
| 67 | ret = ip6tc_commit(handle); |
| 68 | ip6tc_free(handle); |
| 69 | } |
Rusty Russell | 5eed48a | 2000-06-02 20:12:24 +0000 | [diff] [blame] | 70 | |
Pablo Neira Ayuso | 6e70f46 | 2009-03-24 13:08:24 +0100 | [diff] [blame] | 71 | if (!ret) { |
| 72 | if (errno == EINVAL) { |
| 73 | fprintf(stderr, "ip6tables: %s. " |
| 74 | "Run `dmesg' for more information.\n", |
| 75 | ip6tc_strerror(errno)); |
| 76 | } else { |
| 77 | fprintf(stderr, "ip6tables: %s.\n", |
| 78 | ip6tc_strerror(errno)); |
| 79 | } |
| 80 | } |
Rusty Russell | 5eed48a | 2000-06-02 20:12:24 +0000 | [diff] [blame] | 81 | |
| 82 | exit(!ret); |
| 83 | } |