nf_nat_protocol.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* Header for use in defining a given protocol. */
  2. #ifndef _NF_NAT_PROTOCOL_H
  3. #define _NF_NAT_PROTOCOL_H
  4. #include <net/netfilter/nf_nat.h>
  5. #include <linux/netfilter/nfnetlink_conntrack.h>
  6. struct nf_nat_range;
  7. struct nf_nat_protocol
  8. {
  9. /* Protocol name */
  10. const char *name;
  11. /* Protocol number. */
  12. unsigned int protonum;
  13. struct module *me;
  14. /* Translate a packet to the target according to manip type.
  15. Return true if succeeded. */
  16. int (*manip_pkt)(struct sk_buff **pskb,
  17. unsigned int iphdroff,
  18. const struct nf_conntrack_tuple *tuple,
  19. enum nf_nat_manip_type maniptype);
  20. /* Is the manipable part of the tuple between min and max incl? */
  21. int (*in_range)(const struct nf_conntrack_tuple *tuple,
  22. enum nf_nat_manip_type maniptype,
  23. const union nf_conntrack_man_proto *min,
  24. const union nf_conntrack_man_proto *max);
  25. /* Alter the per-proto part of the tuple (depending on
  26. maniptype), to give a unique tuple in the given range if
  27. possible; return false if not. Per-protocol part of tuple
  28. is initialized to the incoming packet. */
  29. int (*unique_tuple)(struct nf_conntrack_tuple *tuple,
  30. const struct nf_nat_range *range,
  31. enum nf_nat_manip_type maniptype,
  32. const struct nf_conn *ct);
  33. int (*range_to_nfattr)(struct sk_buff *skb,
  34. const struct nf_nat_range *range);
  35. int (*nfattr_to_range)(struct nfattr *tb[],
  36. struct nf_nat_range *range);
  37. };
  38. /* Protocol registration. */
  39. extern int nf_nat_protocol_register(struct nf_nat_protocol *proto);
  40. extern void nf_nat_protocol_unregister(struct nf_nat_protocol *proto);
  41. extern struct nf_nat_protocol *nf_nat_proto_find_get(u_int8_t protocol);
  42. extern void nf_nat_proto_put(struct nf_nat_protocol *proto);
  43. /* Built-in protocols. */
  44. extern struct nf_nat_protocol nf_nat_protocol_tcp;
  45. extern struct nf_nat_protocol nf_nat_protocol_udp;
  46. extern struct nf_nat_protocol nf_nat_protocol_icmp;
  47. extern struct nf_nat_protocol nf_nat_unknown_protocol;
  48. extern int init_protocols(void) __init;
  49. extern void cleanup_protocols(void);
  50. extern struct nf_nat_protocol *find_nat_proto(u_int16_t protonum);
  51. extern int nf_nat_port_range_to_nfattr(struct sk_buff *skb,
  52. const struct nf_nat_range *range);
  53. extern int nf_nat_port_nfattr_to_range(struct nfattr *tb[],
  54. struct nf_nat_range *range);
  55. #endif /*_NF_NAT_PROTO_H*/