logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

nfnetlink_compat.h (2444B)


  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. #ifndef _NFNETLINK_COMPAT_H
  3. #define _NFNETLINK_COMPAT_H
  4. #include <linux/types.h>
  5. /* Old nfnetlink macros for userspace */
  6. /* nfnetlink groups: Up to 32 maximum */
  7. #define NF_NETLINK_CONNTRACK_NEW 0x00000001
  8. #define NF_NETLINK_CONNTRACK_UPDATE 0x00000002
  9. #define NF_NETLINK_CONNTRACK_DESTROY 0x00000004
  10. #define NF_NETLINK_CONNTRACK_EXP_NEW 0x00000008
  11. #define NF_NETLINK_CONNTRACK_EXP_UPDATE 0x00000010
  12. #define NF_NETLINK_CONNTRACK_EXP_DESTROY 0x00000020
  13. /* Generic structure for encapsulation optional netfilter information.
  14. * It is reminiscent of sockaddr, but with sa_family replaced
  15. * with attribute type.
  16. * ! This should someday be put somewhere generic as now rtnetlink and
  17. * ! nfnetlink use the same attributes methods. - J. Schulist.
  18. */
  19. struct nfattr {
  20. __u16 nfa_len;
  21. __u16 nfa_type; /* we use 15 bits for the type, and the highest
  22. * bit to indicate whether the payload is nested */
  23. };
  24. /* FIXME: Apart from NFNL_NFA_NESTED shamelessly copy and pasted from
  25. * rtnetlink.h, it's time to put this in a generic file */
  26. #define NFNL_NFA_NEST 0x8000
  27. #define NFA_TYPE(attr) ((attr)->nfa_type & 0x7fff)
  28. #define NFA_ALIGNTO 4
  29. #define NFA_ALIGN(len) (((len) + NFA_ALIGNTO - 1) & ~(NFA_ALIGNTO - 1))
  30. #define NFA_OK(nfa,len) ((len) > 0 && (nfa)->nfa_len >= sizeof(struct nfattr) \
  31. && (nfa)->nfa_len <= (len))
  32. #define NFA_NEXT(nfa,attrlen) ((attrlen) -= NFA_ALIGN((nfa)->nfa_len), \
  33. (struct nfattr *)(((char *)(nfa)) + NFA_ALIGN((nfa)->nfa_len)))
  34. #define NFA_LENGTH(len) (NFA_ALIGN(sizeof(struct nfattr)) + (len))
  35. #define NFA_SPACE(len) NFA_ALIGN(NFA_LENGTH(len))
  36. #define NFA_DATA(nfa) ((void *)(((char *)(nfa)) + NFA_LENGTH(0)))
  37. #define NFA_PAYLOAD(nfa) ((int)((nfa)->nfa_len) - NFA_LENGTH(0))
  38. #define NFA_NEST(skb, type) \
  39. ({ struct nfattr *__start = (struct nfattr *)skb_tail_pointer(skb); \
  40. NFA_PUT(skb, (NFNL_NFA_NEST | type), 0, NULL); \
  41. __start; })
  42. #define NFA_NEST_END(skb, start) \
  43. ({ (start)->nfa_len = skb_tail_pointer(skb) - (unsigned char *)(start); \
  44. (skb)->len; })
  45. #define NFA_NEST_CANCEL(skb, start) \
  46. ({ if (start) \
  47. skb_trim(skb, (unsigned char *) (start) - (skb)->data); \
  48. -1; })
  49. #define NFM_NFA(n) ((struct nfattr *)(((char *)(n)) \
  50. + NLMSG_ALIGN(sizeof(struct nfgenmsg))))
  51. #define NFM_PAYLOAD(n) NLMSG_PAYLOAD(n, sizeof(struct nfgenmsg))
  52. #endif /* _NFNETLINK_COMPAT_H */