nf_nat.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef _NF_NAT_H
  2. #define _NF_NAT_H
  3. #include <linux/netfilter_ipv4.h>
  4. #include <net/netfilter/nf_conntrack_tuple.h>
  5. #define NF_NAT_MAPPING_TYPE_MAX_NAMELEN 16
  6. enum nf_nat_manip_type
  7. {
  8. IP_NAT_MANIP_SRC,
  9. IP_NAT_MANIP_DST
  10. };
  11. /* SRC manip occurs POST_ROUTING or LOCAL_IN */
  12. #define HOOK2MANIP(hooknum) ((hooknum) != NF_IP_POST_ROUTING && (hooknum) != NF_IP_LOCAL_IN)
  13. #define IP_NAT_RANGE_MAP_IPS 1
  14. #define IP_NAT_RANGE_PROTO_SPECIFIED 2
  15. #define IP_NAT_RANGE_PROTO_RANDOM 4
  16. /* NAT sequence number modifications */
  17. struct nf_nat_seq {
  18. /* position of the last TCP sequence number modification (if any) */
  19. u_int32_t correction_pos;
  20. /* sequence number offset before and after last modification */
  21. int16_t offset_before, offset_after;
  22. };
  23. /* Single range specification. */
  24. struct nf_nat_range
  25. {
  26. /* Set to OR of flags above. */
  27. unsigned int flags;
  28. /* Inclusive: network order. */
  29. __be32 min_ip, max_ip;
  30. /* Inclusive: network order */
  31. union nf_conntrack_man_proto min, max;
  32. };
  33. /* For backwards compat: don't use in modern code. */
  34. struct nf_nat_multi_range_compat
  35. {
  36. unsigned int rangesize; /* Must be 1. */
  37. /* hangs off end. */
  38. struct nf_nat_range range[1];
  39. };
  40. #ifdef __KERNEL__
  41. #include <linux/list.h>
  42. /* The structure embedded in the conntrack structure. */
  43. struct nf_nat_info
  44. {
  45. struct list_head bysource;
  46. struct nf_nat_seq seq[IP_CT_DIR_MAX];
  47. };
  48. struct nf_conn;
  49. /* Set up the info structure to map into this range. */
  50. extern unsigned int nf_nat_setup_info(struct nf_conn *ct,
  51. const struct nf_nat_range *range,
  52. unsigned int hooknum);
  53. /* Is this tuple already taken? (not by us)*/
  54. extern int nf_nat_used_tuple(const struct nf_conntrack_tuple *tuple,
  55. const struct nf_conn *ignored_conntrack);
  56. extern int nf_nat_module_is_loaded;
  57. #else /* !__KERNEL__: iptables wants this to compile. */
  58. #define nf_nat_multi_range nf_nat_multi_range_compat
  59. #endif /*__KERNEL__*/
  60. #endif