netfilter.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef _UAPI__LINUX_NETFILTER_H
  2. #define _UAPI__LINUX_NETFILTER_H
  3. #include <linux/types.h>
  4. #include <linux/compiler.h>
  5. #include <linux/sysctl.h>
  6. /* Responses from hook functions. */
  7. #define NF_DROP 0
  8. #define NF_ACCEPT 1
  9. #define NF_STOLEN 2
  10. #define NF_QUEUE 3
  11. #define NF_REPEAT 4
  12. #define NF_STOP 5
  13. #define NF_MAX_VERDICT NF_STOP
  14. /* we overload the higher bits for encoding auxiliary data such as the queue
  15. * number or errno values. Not nice, but better than additional function
  16. * arguments. */
  17. #define NF_VERDICT_MASK 0x000000ff
  18. /* extra verdict flags have mask 0x0000ff00 */
  19. #define NF_VERDICT_FLAG_QUEUE_BYPASS 0x00008000
  20. /* queue number (NF_QUEUE) or errno (NF_DROP) */
  21. #define NF_VERDICT_QMASK 0xffff0000
  22. #define NF_VERDICT_QBITS 16
  23. #define NF_QUEUE_NR(x) ((((x) << 16) & NF_VERDICT_QMASK) | NF_QUEUE)
  24. #define NF_DROP_ERR(x) (((-x) << 16) | NF_DROP)
  25. /* only for userspace compatibility */
  26. #ifndef __KERNEL__
  27. /* Generic cache responses from hook functions.
  28. <= 0x2000 is used for protocol-flags. */
  29. #define NFC_UNKNOWN 0x4000
  30. #define NFC_ALTERED 0x8000
  31. /* NF_VERDICT_BITS should be 8 now, but userspace might break if this changes */
  32. #define NF_VERDICT_BITS 16
  33. #endif
  34. enum nf_inet_hooks {
  35. NF_INET_PRE_ROUTING,
  36. NF_INET_LOCAL_IN,
  37. NF_INET_FORWARD,
  38. NF_INET_LOCAL_OUT,
  39. NF_INET_POST_ROUTING,
  40. NF_INET_NUMHOOKS
  41. };
  42. enum {
  43. NFPROTO_UNSPEC = 0,
  44. NFPROTO_INET = 1,
  45. NFPROTO_IPV4 = 2,
  46. NFPROTO_ARP = 3,
  47. NFPROTO_BRIDGE = 7,
  48. NFPROTO_IPV6 = 10,
  49. NFPROTO_DECNET = 12,
  50. NFPROTO_NUMPROTO,
  51. };
  52. union nf_inet_addr {
  53. __u32 all[4];
  54. __be32 ip;
  55. __be32 ip6[4];
  56. struct in_addr in;
  57. struct in6_addr in6;
  58. };
  59. #endif /* _UAPI__LINUX_NETFILTER_H */