blob: cadb7402d7a713fdcedbe4b3cb77c6095854f3ff [file] [log] [blame]
Harald Weltef9e815b2005-08-09 19:30:24 -07001#ifndef _NFNETLINK_H
2#define _NFNETLINK_H
Patrick McHardyac6d4392005-08-14 19:29:52 -07003
Harald Weltef9e815b2005-08-09 19:30:24 -07004
Harald Welte080774a2005-08-09 19:32:58 -07005#include <linux/netlink.h>
Harald Weltef9e815b2005-08-09 19:30:24 -07006#include <linux/capability.h>
Patrick McHardydf6fb862007-09-28 14:37:03 -07007#include <net/netlink.h>
David Howells94d0ec52012-10-09 09:48:54 +01008#include <uapi/linux/netfilter/nfnetlink.h>
Harald Weltef9e815b2005-08-09 19:30:24 -07009
Eric Dumazetd94d9fe2009-11-04 09:50:58 -080010struct nfnl_callback {
Harald Weltef9e815b2005-08-09 19:30:24 -070011 int (*call)(struct sock *nl, struct sk_buff *skb,
Patrick McHardy39938322009-08-25 16:07:58 +020012 const struct nlmsghdr *nlh,
13 const struct nlattr * const cda[]);
Eric Dumazet6b75e3e2011-07-18 16:08:07 +020014 int (*call_rcu)(struct sock *nl, struct sk_buff *skb,
15 const struct nlmsghdr *nlh,
16 const struct nlattr * const cda[]);
Patrick McHardye3730572007-09-28 14:38:52 -070017 const struct nla_policy *policy; /* netlink attribute policy */
18 const u_int16_t attr_count; /* number of nlattr's */
Harald Weltef9e815b2005-08-09 19:30:24 -070019};
20
Eric Dumazetd94d9fe2009-11-04 09:50:58 -080021struct nfnetlink_subsystem {
Harald Weltef9e815b2005-08-09 19:30:24 -070022 const char *name;
Patrick McHardy7c8d4cb2007-09-28 14:15:45 -070023 __u8 subsys_id; /* nfnetlink subsystem ID */
24 __u8 cb_count; /* number of callbacks */
25 const struct nfnl_callback *cb; /* callback for individual types */
Harald Weltef9e815b2005-08-09 19:30:24 -070026};
27
Patrick McHardy7c8d4cb2007-09-28 14:15:45 -070028extern int nfnetlink_subsys_register(const struct nfnetlink_subsystem *n);
29extern int nfnetlink_subsys_unregister(const struct nfnetlink_subsystem *n);
Harald Weltef9e815b2005-08-09 19:30:24 -070030
Alexey Dobriyancd8c20b2010-01-13 16:02:14 +010031extern int nfnetlink_has_listeners(struct net *net, unsigned int group);
Patrick McHardy3ab1f682013-04-17 06:47:09 +000032extern struct sk_buff *nfnetlink_alloc_skb(struct net *net, unsigned int size,
33 u32 dst_portid, gfp_t gfp_mask);
Patrick McHardyec464e52013-04-17 06:47:08 +000034extern int nfnetlink_send(struct sk_buff *skb, struct net *net, u32 portid,
35 unsigned int group, int echo, gfp_t flags);
36extern int nfnetlink_set_err(struct net *net, u32 portid, u32 group, int error);
37extern int nfnetlink_unicast(struct sk_buff *skb, struct net *net,
38 u32 portid, int flags);
Harald Weltef9e815b2005-08-09 19:30:24 -070039
Pablo Neira Ayusoc14b78e2013-02-05 01:50:26 +010040extern void nfnl_lock(__u8 subsys_id);
41extern void nfnl_unlock(__u8 subsys_id);
Pablo Neira Ayusoe6a7d3c2008-10-14 11:58:31 -070042
Harald Welte0ab43f82005-08-09 19:43:44 -070043#define MODULE_ALIAS_NFNL_SUBSYS(subsys) \
44 MODULE_ALIAS("nfnetlink-subsys-" __stringify(subsys))
45
Harald Weltef9e815b2005-08-09 19:30:24 -070046#endif /* _NFNETLINK_H */