Dr Andrew Scott G7VAV

My photo
 
June 2025
Mo Tu We Th Fr Sa Su
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 1 2 3 4 5 6


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


for client (none)
© Andrew Scott 2006 - 2025,
All Rights Reserved
http://www.andrew-scott.uk/
Andrew Scott
http://www.andrew-scott.co.uk/