netfilter.h 1.8 KB

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