xshared.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #ifndef IPTABLES_XSHARED_H
  2. #define IPTABLES_XSHARED_H 1
  3. #include <limits.h>
  4. #include <stdint.h>
  5. #include <netinet/in.h>
  6. #include <net/if.h>
  7. #include <linux/netfilter_ipv4/ip_tables.h>
  8. #include <linux/netfilter_ipv6/ip6_tables.h>
  9. enum {
  10. OPT_NONE = 0,
  11. OPT_NUMERIC = 1 << 0,
  12. OPT_SOURCE = 1 << 1,
  13. OPT_DESTINATION = 1 << 2,
  14. OPT_PROTOCOL = 1 << 3,
  15. OPT_JUMP = 1 << 4,
  16. OPT_VERBOSE = 1 << 5,
  17. OPT_EXPANDED = 1 << 6,
  18. OPT_VIANAMEIN = 1 << 7,
  19. OPT_VIANAMEOUT = 1 << 8,
  20. OPT_LINENUMBERS = 1 << 9,
  21. OPT_COUNTERS = 1 << 10,
  22. };
  23. struct xtables_globals;
  24. struct xtables_rule_match;
  25. struct xtables_target;
  26. /**
  27. * xtables_afinfo - protocol family dependent information
  28. * @kmod: kernel module basename (e.g. "ip_tables")
  29. * @proc_exists: file which exists in procfs when module already loaded
  30. * @libprefix: prefix of .so library name (e.g. "libipt_")
  31. * @family: nfproto family
  32. * @ipproto: used by setsockopt (e.g. IPPROTO_IP)
  33. * @so_rev_match: optname to check revision support of match
  34. * @so_rev_target: optname to check revision support of target
  35. */
  36. struct xtables_afinfo {
  37. const char *kmod;
  38. const char *proc_exists;
  39. const char *libprefix;
  40. uint8_t family;
  41. uint8_t ipproto;
  42. int so_rev_match;
  43. int so_rev_target;
  44. };
  45. struct iptables_command_state {
  46. union {
  47. struct ipt_entry fw;
  48. struct ip6t_entry fw6;
  49. };
  50. int invert;
  51. int c;
  52. unsigned int options;
  53. struct xtables_rule_match *matches;
  54. struct xtables_target *target;
  55. char *protocol;
  56. int proto_used;
  57. const char *jumpto;
  58. char **argv;
  59. };
  60. typedef int (*mainfunc_t)(int, char **);
  61. struct subcommand {
  62. const char *name;
  63. mainfunc_t main;
  64. };
  65. enum {
  66. XT_OPTION_OFFSET_SCALE = 256,
  67. };
  68. extern void print_extension_helps(const struct xtables_target *,
  69. const struct xtables_rule_match *);
  70. extern const char *proto_to_name(uint8_t, int);
  71. extern int command_default(struct iptables_command_state *,
  72. struct xtables_globals *);
  73. extern struct xtables_match *load_proto(struct iptables_command_state *);
  74. extern int subcmd_main(int, char **, const struct subcommand *);
  75. extern void xs_init_target(struct xtables_target *);
  76. extern void xs_init_match(struct xtables_match *);
  77. extern const struct xtables_afinfo *afinfo;
  78. #endif /* IPTABLES_XSHARED_H */