1
2 #ifndef _NFNETLINK_COMPAT_H
3 #define _NFNETLINK_COMPAT_H
4
5 #include <linux/types.h>
6
7 #ifndef __KERNEL__
8
9
10
11 #define NF_NETLINK_CONNTRACK_NEW 0x00000001
12 #define NF_NETLINK_CONNTRACK_UPDATE 0x00000002
13 #define NF_NETLINK_CONNTRACK_DESTROY 0x00000004
14 #define NF_NETLINK_CONNTRACK_EXP_NEW 0x00000008
15 #define NF_NETLINK_CONNTRACK_EXP_UPDATE 0x00000010
16 #define NF_NETLINK_CONNTRACK_EXP_DESTROY 0x00000020
17
18
19
20
21
22
23
24
25 struct nfattr {
26 __u16 nfa_len;
27 __u16 nfa_type;
28
29 };
30
31
32
33
34 #define NFNL_NFA_NEST 0x8000
35 #define NFA_TYPE(attr) ((attr)->nfa_type & 0x7fff)
36
37 #define NFA_ALIGNTO 4
38 #define NFA_ALIGN(len) (((len) + NFA_ALIGNTO - 1) & ~(NFA_ALIGNTO - 1))
39 #define NFA_OK(nfa,len) ((len) > 0 && (nfa)->nfa_len >= sizeof(struct nfattr) \
40 && (nfa)->nfa_len <= (len))
41 #define NFA_NEXT(nfa,attrlen) ((attrlen) -= NFA_ALIGN((nfa)->nfa_len), \
42 (struct nfattr *)(((char *)(nfa)) + NFA_ALIGN((nfa)->nfa_len)))
43 #define NFA_LENGTH(len) (NFA_ALIGN(sizeof(struct nfattr)) + (len))
44 #define NFA_SPACE(len) NFA_ALIGN(NFA_LENGTH(len))
45 #define NFA_DATA(nfa) ((void *)(((char *)(nfa)) + NFA_LENGTH(0)))
46 #define NFA_PAYLOAD(nfa) ((int)((nfa)->nfa_len) - NFA_LENGTH(0))
47 #define NFA_NEST(skb, type) \
48 ({ struct nfattr *__start = (struct nfattr *)skb_tail_pointer(skb); \
49 NFA_PUT(skb, (NFNL_NFA_NEST | type), 0, NULL); \
50 __start; })
51 #define NFA_NEST_END(skb, start) \
52 ({ (start)->nfa_len = skb_tail_pointer(skb) - (unsigned char *)(start); \
53 (skb)->len; })
54 #define NFA_NEST_CANCEL(skb, start) \
55 ({ if (start) \
56 skb_trim(skb, (unsigned char *) (start) - (skb)->data); \
57 -1; })
58
59 #define NFM_NFA(n) ((struct nfattr *)(((char *)(n)) \
60 + NLMSG_ALIGN(sizeof(struct nfgenmsg))))
61 #define NFM_PAYLOAD(n) NLMSG_PAYLOAD(n, sizeof(struct nfgenmsg))
62
63 #endif
64 #endif