ip6tables-standalone.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Author: Paul.Russell@rustcorp.com.au and mneuling@radlogic.com.au
  3. *
  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. *
  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. #include <stdio.h>
  34. #include <stdlib.h>
  35. #include <errno.h>
  36. #include <ip6tables.h>
  37. #include "ip6tables-multi.h"
  38. int
  39. ip6tables_main(int argc, char *argv[])
  40. {
  41. int ret;
  42. char *table = "filter";
  43. struct xtc_handle *handle = NULL;
  44. ip6tables_globals.program_name = "ip6tables";
  45. ret = xtables_init_all(&ip6tables_globals, NFPROTO_IPV6);
  46. if (ret < 0) {
  47. fprintf(stderr, "%s/%s Failed to initialize xtables\n",
  48. ip6tables_globals.program_name,
  49. ip6tables_globals.program_version);
  50. exit(1);
  51. }
  52. #if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
  53. init_extensions();
  54. init_extensions6();
  55. #endif
  56. ret = do_command6(argc, argv, &table, &handle);
  57. if (ret) {
  58. ret = ip6tc_commit(handle);
  59. ip6tc_free(handle);
  60. }
  61. if (!ret) {
  62. if (errno == EINVAL) {
  63. fprintf(stderr, "ip6tables: %s. "
  64. "Run `dmesg' for more information.\n",
  65. ip6tc_strerror(errno));
  66. } else {
  67. fprintf(stderr, "ip6tables: %s.\n",
  68. ip6tc_strerror(errno));
  69. }
  70. }
  71. exit(!ret);
  72. }