Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / include / linux / netfilter / nfnetlink_compat.h
blob5693cbe985c6e9b55ba9efe34fbae4835d393efa
1 #ifndef _NFNETLINK_COMPAT_H
2 #define _NFNETLINK_COMPAT_H
3 <<<<<<< HEAD:include/linux/netfilter/nfnetlink_compat.h
4 #ifndef __KERNEL
5 =======
6 #ifndef __KERNEL__
7 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:include/linux/netfilter/nfnetlink_compat.h
8 /* Old nfnetlink macros for userspace */
10 /* nfnetlink groups: Up to 32 maximum */
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
18 /* Generic structure for encapsulation optional netfilter information.
19 * It is reminiscent of sockaddr, but with sa_family replaced
20 * with attribute type.
21 * ! This should someday be put somewhere generic as now rtnetlink and
22 * ! nfnetlink use the same attributes methods. - J. Schulist.
25 struct nfattr
27 u_int16_t nfa_len;
28 u_int16_t nfa_type; /* we use 15 bits for the type, and the highest
29 * bit to indicate whether the payload is nested */
32 /* FIXME: Apart from NFNL_NFA_NESTED shamelessly copy and pasted from
33 * rtnetlink.h, it's time to put this in a generic file */
35 #define NFNL_NFA_NEST 0x8000
36 #define NFA_TYPE(attr) ((attr)->nfa_type & 0x7fff)
38 #define NFA_ALIGNTO 4
39 #define NFA_ALIGN(len) (((len) + NFA_ALIGNTO - 1) & ~(NFA_ALIGNTO - 1))
40 #define NFA_OK(nfa,len) ((len) > 0 && (nfa)->nfa_len >= sizeof(struct nfattr) \
41 && (nfa)->nfa_len <= (len))
42 #define NFA_NEXT(nfa,attrlen) ((attrlen) -= NFA_ALIGN((nfa)->nfa_len), \
43 (struct nfattr *)(((char *)(nfa)) + NFA_ALIGN((nfa)->nfa_len)))
44 #define NFA_LENGTH(len) (NFA_ALIGN(sizeof(struct nfattr)) + (len))
45 #define NFA_SPACE(len) NFA_ALIGN(NFA_LENGTH(len))
46 #define NFA_DATA(nfa) ((void *)(((char *)(nfa)) + NFA_LENGTH(0)))
47 #define NFA_PAYLOAD(nfa) ((int)((nfa)->nfa_len) - NFA_LENGTH(0))
48 #define NFA_NEST(skb, type) \
49 ({ struct nfattr *__start = (struct nfattr *)skb_tail_pointer(skb); \
50 NFA_PUT(skb, (NFNL_NFA_NEST | type), 0, NULL); \
51 __start; })
52 #define NFA_NEST_END(skb, start) \
53 ({ (start)->nfa_len = skb_tail_pointer(skb) - (unsigned char *)(start); \
54 (skb)->len; })
55 #define NFA_NEST_CANCEL(skb, start) \
56 ({ if (start) \
57 skb_trim(skb, (unsigned char *) (start) - (skb)->data); \
58 -1; })
60 #define NFM_NFA(n) ((struct nfattr *)(((char *)(n)) \
61 + NLMSG_ALIGN(sizeof(struct nfgenmsg))))
62 #define NFM_PAYLOAD(n) NLMSG_PAYLOAD(n, sizeof(struct nfgenmsg))
64 #endif /* ! __KERNEL__ */
65 #endif /* _NFNETLINK_COMPAT_H */