Няма описание https://github.com/Netsukuku/netsukuku
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. #ifndef _IPTABLES_USER_H
  2. #define _IPTABLES_USER_H
  3. #include "iptables_common.h"
  4. #include "libiptc/libiptc.h"
  5. #ifndef IPT_LIB_DIR
  6. #define IPT_LIB_DIR "/usr/local/lib/iptables"
  7. #endif
  8. #ifndef IPPROTO_SCTP
  9. #define IPPROTO_SCTP 132
  10. #endif
  11. #ifndef IPT_SO_GET_REVISION_MATCH /* Old kernel source. */
  12. #define IPT_SO_GET_REVISION_MATCH (IPT_BASE_CTL + 2)
  13. #define IPT_SO_GET_REVISION_TARGET (IPT_BASE_CTL + 3)
  14. struct ipt_get_revision {
  15. char name[IPT_FUNCTION_MAXNAMELEN - 1];
  16. u_int8_t revision;
  17. };
  18. #endif /* IPT_SO_GET_REVISION_MATCH Old kernel source */
  19. struct iptables_rule_match {
  20. struct iptables_rule_match *next;
  21. struct iptables_match *match;
  22. };
  23. /* Include file for additions: new matches and targets. */
  24. struct iptables_match {
  25. struct iptables_match *next;
  26. ipt_chainlabel name;
  27. /* Revision of match (0 by default). */
  28. u_int8_t revision;
  29. const char *version;
  30. /* Size of match data. */
  31. size_t size;
  32. /* Size of match data relevent for userspace comparison purposes */
  33. size_t userspacesize;
  34. /* Function which prints out usage message. */
  35. void (*help) (void);
  36. /* Initialize the match. */
  37. void (*init) (struct ipt_entry_match * m, unsigned int *nfcache);
  38. /* Function which parses command options; returns true if it
  39. ate an option */
  40. int (*parse) (int c, char **argv, int invert, unsigned int *flags,
  41. const struct ipt_entry * entry,
  42. unsigned int *nfcache, struct ipt_entry_match ** match);
  43. /* Final check; exit if not ok. */
  44. void (*final_check) (unsigned int flags);
  45. /* Prints out the match iff non-NULL: put space at end */
  46. void (*print) (const struct ipt_ip * ip,
  47. const struct ipt_entry_match * match, int numeric);
  48. /* Saves the match info in parsable form to stdout. */
  49. void (*save) (const struct ipt_ip * ip,
  50. const struct ipt_entry_match * match);
  51. /* Pointer to list of extra command-line options */
  52. const struct option *extra_opts;
  53. /* Ignore these men behind the curtain: */
  54. unsigned int option_offset;
  55. struct ipt_entry_match *m;
  56. unsigned int mflags;
  57. #ifdef NO_SHARED_LIBS
  58. unsigned int loaded; /* simulate loading so options are merged properly */
  59. #endif
  60. };
  61. struct iptables_target {
  62. struct iptables_target *next;
  63. ipt_chainlabel name;
  64. /* Revision of target (0 by default). */
  65. u_int8_t revision;
  66. const char *version;
  67. /* Size of target data. */
  68. size_t size;
  69. /* Size of target data relevent for userspace comparison purposes */
  70. size_t userspacesize;
  71. /* Function which prints out usage message. */
  72. void (*help) (void);
  73. /* Initialize the target. */
  74. void (*init) (struct ipt_entry_target * t, unsigned int *nfcache);
  75. /* Function which parses command options; returns true if it
  76. ate an option */
  77. int (*parse) (int c, char **argv, int invert, unsigned int *flags,
  78. const struct ipt_entry * entry,
  79. struct ipt_entry_target ** target);
  80. /* Final check; exit if not ok. */
  81. void (*final_check) (unsigned int flags);
  82. /* Prints out the target iff non-NULL: put space at end */
  83. void (*print) (const struct ipt_ip * ip,
  84. const struct ipt_entry_target * target, int numeric);
  85. /* Saves the targinfo in parsable form to stdout. */
  86. void (*save) (const struct ipt_ip * ip,
  87. const struct ipt_entry_target * target);
  88. /* Pointer to list of extra command-line options */
  89. struct option *extra_opts;
  90. /* Ignore these men behind the curtain: */
  91. unsigned int option_offset;
  92. struct ipt_entry_target *t;
  93. unsigned int tflags;
  94. unsigned int used;
  95. #ifdef NO_SHARED_LIBS
  96. unsigned int loaded; /* simulate loading so options are merged properly */
  97. #endif
  98. };
  99. extern int line;
  100. /* Your shared library should call one of these. */
  101. extern void register_match(struct iptables_match *me);
  102. extern void register_target(struct iptables_target *me);
  103. extern struct in_addr *dotted_to_addr(const char *dotted);
  104. extern char *addr_to_dotted(const struct in_addr *addrp);
  105. extern char *addr_to_anyname(const struct in_addr *addr);
  106. extern char *mask_to_dotted(const struct in_addr *mask);
  107. extern void parse_hostnetworkmask(const char *name,
  108. struct in_addr **addrpp,
  109. struct in_addr *maskp,
  110. unsigned int *naddrs);
  111. extern u_int16_t parse_protocol(const char *s);
  112. extern void parse_interface(const char *arg, char *vianame,
  113. unsigned char *mask);
  114. extern int do_command(int argc, char *argv[], char **table,
  115. iptc_handle_t * handle);
  116. /* Keeping track of external matches and targets: linked lists. */
  117. extern struct iptables_match *iptables_matches;
  118. extern struct iptables_target *iptables_targets;
  119. enum ipt_tryload {
  120. DONT_LOAD,
  121. TRY_LOAD,
  122. LOAD_MUST_SUCCEED
  123. };
  124. extern struct iptables_target *find_target(const char *name,
  125. enum ipt_tryload);
  126. extern struct iptables_match *find_match(const char *name,
  127. enum ipt_tryload,
  128. struct iptables_rule_match
  129. **match);
  130. extern int delete_chain(const ipt_chainlabel chain, int verbose,
  131. iptc_handle_t * handle);
  132. extern int flush_entries(const ipt_chainlabel chain, int verbose,
  133. iptc_handle_t * handle);
  134. extern int
  135. for_each_chain(int (*fn) (const ipt_chainlabel, int, iptc_handle_t *),
  136. int verbose, int builtinstoo, iptc_handle_t * handle);
  137. /* kernel revision handling */
  138. extern int kernel_version;
  139. extern void get_kernel_version(void);
  140. #define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z)
  141. #define LINUX_VERSION_MAJOR(x) (((x)>>16) & 0xFF)
  142. #define LINUX_VERSION_MINOR(x) (((x)>> 8) & 0xFF)
  143. #define LINUX_VERSION_PATCH(x) ( (x) & 0xFF)
  144. #endif /*_IPTABLES_USER_H*/