Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v2.6.14-rc2 169 lines 5.6 kB view raw
1#ifndef _NFNETLINK_H 2#define _NFNETLINK_H 3#include <linux/types.h> 4 5#ifndef __KERNEL__ 6/* nfnetlink groups: Up to 32 maximum - backwards compatibility for userspace */ 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#endif 14 15enum nfnetlink_groups { 16 NFNLGRP_NONE, 17#define NFNLGRP_NONE NFNLGRP_NONE 18 NFNLGRP_CONNTRACK_NEW, 19#define NFNLGRP_CONNTRACK_NEW NFNLGRP_CONNTRACK_NEW 20 NFNLGRP_CONNTRACK_UPDATE, 21#define NFNLGRP_CONNTRACK_UPDATE NFNLGRP_CONNTRACK_UPDATE 22 NFNLGRP_CONNTRACK_DESTROY, 23#define NFNLGRP_CONNTRACK_DESTROY NFNLGRP_CONNTRACK_DESTROY 24 NFNLGRP_CONNTRACK_EXP_NEW, 25#define NFNLGRP_CONNTRACK_EXP_NEW NFNLGRP_CONNTRACK_EXP_NEW 26 NFNLGRP_CONNTRACK_EXP_UPDATE, 27#define NFNLGRP_CONNTRACK_EXP_UPDATE NFNLGRP_CONNTRACK_EXP_UPDATE 28 NFNLGRP_CONNTRACK_EXP_DESTROY, 29#define NFNLGRP_CONNTRACK_EXP_DESTROY NFNLGRP_CONNTRACK_EXP_DESTROY 30 __NFNLGRP_MAX, 31}; 32#define NFNLGRP_MAX (__NFNLGRP_MAX - 1) 33 34/* Generic structure for encapsulation optional netfilter information. 35 * It is reminiscent of sockaddr, but with sa_family replaced 36 * with attribute type. 37 * ! This should someday be put somewhere generic as now rtnetlink and 38 * ! nfnetlink use the same attributes methods. - J. Schulist. 39 */ 40 41struct nfattr 42{ 43 u_int16_t nfa_len; 44 u_int16_t nfa_type; 45} __attribute__ ((packed)); 46 47/* FIXME: Shamelessly copy and pasted from rtnetlink.h, it's time 48 * to put this in a generic file */ 49 50#define NFA_ALIGNTO 4 51#define NFA_ALIGN(len) (((len) + NFA_ALIGNTO - 1) & ~(NFA_ALIGNTO - 1)) 52#define NFA_OK(nfa,len) ((len) > 0 && (nfa)->nfa_len >= sizeof(struct nfattr) \ 53 && (nfa)->nfa_len <= (len)) 54#define NFA_NEXT(nfa,attrlen) ((attrlen) -= NFA_ALIGN((nfa)->nfa_len), \ 55 (struct nfattr *)(((char *)(nfa)) + NFA_ALIGN((nfa)->nfa_len))) 56#define NFA_LENGTH(len) (NFA_ALIGN(sizeof(struct nfattr)) + (len)) 57#define NFA_SPACE(len) NFA_ALIGN(NFA_LENGTH(len)) 58#define NFA_DATA(nfa) ((void *)(((char *)(nfa)) + NFA_LENGTH(0))) 59#define NFA_PAYLOAD(nfa) ((int)((nfa)->nfa_len) - NFA_LENGTH(0)) 60#define NFA_NEST(skb, type) \ 61({ struct nfattr *__start = (struct nfattr *) (skb)->tail; \ 62 NFA_PUT(skb, type, 0, NULL); \ 63 __start; }) 64#define NFA_NEST_END(skb, start) \ 65({ (start)->nfa_len = ((skb)->tail - (unsigned char *) (start)); \ 66 (skb)->len; }) 67#define NFA_NEST_CANCEL(skb, start) \ 68({ if (start) \ 69 skb_trim(skb, (unsigned char *) (start) - (skb)->data); \ 70 -1; }) 71 72/* General form of address family dependent message. 73 */ 74struct nfgenmsg { 75 u_int8_t nfgen_family; /* AF_xxx */ 76 u_int8_t version; /* nfnetlink version */ 77 u_int16_t res_id; /* resource id */ 78} __attribute__ ((packed)); 79 80#define NFNETLINK_V0 0 81 82#define NFM_NFA(n) ((struct nfattr *)(((char *)(n)) \ 83 + NLMSG_ALIGN(sizeof(struct nfgenmsg)))) 84#define NFM_PAYLOAD(n) NLMSG_PAYLOAD(n, sizeof(struct nfgenmsg)) 85 86/* netfilter netlink message types are split in two pieces: 87 * 8 bit subsystem, 8bit operation. 88 */ 89 90#define NFNL_SUBSYS_ID(x) ((x & 0xff00) >> 8) 91#define NFNL_MSG_TYPE(x) (x & 0x00ff) 92 93/* No enum here, otherwise __stringify() trick of MODULE_ALIAS_NFNL_SUBSYS() 94 * won't work anymore */ 95#define NFNL_SUBSYS_NONE 0 96#define NFNL_SUBSYS_CTNETLINK 1 97#define NFNL_SUBSYS_CTNETLINK_EXP 2 98#define NFNL_SUBSYS_QUEUE 3 99#define NFNL_SUBSYS_ULOG 4 100#define NFNL_SUBSYS_COUNT 5 101 102#ifdef __KERNEL__ 103 104#include <linux/netlink.h> 105#include <linux/capability.h> 106 107struct nfnl_callback 108{ 109 int (*call)(struct sock *nl, struct sk_buff *skb, 110 struct nlmsghdr *nlh, struct nfattr *cda[], int *errp); 111 kernel_cap_t cap_required; /* capabilities required for this msg */ 112 u_int16_t attr_count; /* number of nfattr's */ 113}; 114 115struct nfnetlink_subsystem 116{ 117 const char *name; 118 __u8 subsys_id; /* nfnetlink subsystem ID */ 119 __u8 cb_count; /* number of callbacks */ 120 struct nfnl_callback *cb; /* callback for individual types */ 121}; 122 123extern void __nfa_fill(struct sk_buff *skb, int attrtype, 124 int attrlen, const void *data); 125#define NFA_PUT(skb, attrtype, attrlen, data) \ 126({ if (skb_tailroom(skb) < (int)NFA_SPACE(attrlen)) goto nfattr_failure; \ 127 __nfa_fill(skb, attrtype, attrlen, data); }) 128 129extern struct semaphore nfnl_sem; 130 131#define nfnl_shlock() down(&nfnl_sem) 132#define nfnl_shlock_nowait() down_trylock(&nfnl_sem) 133 134#define nfnl_shunlock() do { up(&nfnl_sem); \ 135 if(nfnl && nfnl->sk_receive_queue.qlen) \ 136 nfnl->sk_data_ready(nfnl, 0); \ 137 } while(0) 138 139extern void nfnl_lock(void); 140extern void nfnl_unlock(void); 141 142extern int nfnetlink_subsys_register(struct nfnetlink_subsystem *n); 143extern int nfnetlink_subsys_unregister(struct nfnetlink_subsystem *n); 144 145extern int nfattr_parse(struct nfattr *tb[], int maxattr, 146 struct nfattr *nfa, int len); 147 148#define nfattr_parse_nested(tb, max, nfa) \ 149 nfattr_parse((tb), (max), NFA_DATA((nfa)), NFA_PAYLOAD((nfa))) 150 151#define nfattr_bad_size(tb, max, cta_min) \ 152({ int __i, __res = 0; \ 153 for (__i=0; __i<max; __i++) \ 154 if (tb[__i] && NFA_PAYLOAD(tb[__i]) < cta_min[__i]){ \ 155 __res = 1; \ 156 break; \ 157 } \ 158 __res; \ 159}) 160 161extern int nfnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, 162 int echo); 163extern int nfnetlink_unicast(struct sk_buff *skb, u_int32_t pid, int flags); 164 165#define MODULE_ALIAS_NFNL_SUBSYS(subsys) \ 166 MODULE_ALIAS("nfnetlink-subsys-" __stringify(subsys)) 167 168#endif /* __KERNEL__ */ 169#endif /* _NFNETLINK_H */