| 1 |
#ifndef _NFNETLINK_H |
| 2 |
#define _NFNETLINK_H |
| 3 |
#include <linux/types.h> |
| 4 |
#include <linux/netfilter/nfnetlink_compat.h> |
| 5 |
|
| 6 |
enum nfnetlink_groups { |
| 7 |
NFNLGRP_NONE, |
| 8 |
#define NFNLGRP_NONE NFNLGRP_NONE |
| 9 |
NFNLGRP_CONNTRACK_NEW, |
| 10 |
#define NFNLGRP_CONNTRACK_NEW NFNLGRP_CONNTRACK_NEW |
| 11 |
NFNLGRP_CONNTRACK_UPDATE, |
| 12 |
#define NFNLGRP_CONNTRACK_UPDATE NFNLGRP_CONNTRACK_UPDATE |
| 13 |
NFNLGRP_CONNTRACK_DESTROY, |
| 14 |
#define NFNLGRP_CONNTRACK_DESTROY NFNLGRP_CONNTRACK_DESTROY |
| 15 |
NFNLGRP_CONNTRACK_EXP_NEW, |
| 16 |
#define NFNLGRP_CONNTRACK_EXP_NEW NFNLGRP_CONNTRACK_EXP_NEW |
| 17 |
NFNLGRP_CONNTRACK_EXP_UPDATE, |
| 18 |
#define NFNLGRP_CONNTRACK_EXP_UPDATE NFNLGRP_CONNTRACK_EXP_UPDATE |
| 19 |
NFNLGRP_CONNTRACK_EXP_DESTROY, |
| 20 |
#define NFNLGRP_CONNTRACK_EXP_DESTROY NFNLGRP_CONNTRACK_EXP_DESTROY |
| 21 |
NFNLGRP_NFTABLES, |
| 22 |
#define NFNLGRP_NFTABLES NFNLGRP_NFTABLES |
| 23 |
__NFNLGRP_MAX, |
| 24 |
}; |
| 25 |
#define NFNLGRP_MAX (__NFNLGRP_MAX - 1) |
| 26 |
|
| 27 |
/* General form of address family dependent message. |
| 28 |
*/ |
| 29 |
struct nfgenmsg { |
| 30 |
__u8 nfgen_family; /* AF_xxx */ |
| 31 |
__u8 version; /* nfnetlink version */ |
| 32 |
__be16 res_id; /* resource id */ |
| 33 |
}; |
| 34 |
|
| 35 |
#define NFNETLINK_V0 0 |
| 36 |
|
| 37 |
/* netfilter netlink message types are split in two pieces: |
| 38 |
* 8 bit subsystem, 8bit operation. |
| 39 |
*/ |
| 40 |
|
| 41 |
#define NFNL_SUBSYS_ID(x) ((x & 0xff00) >> 8) |
| 42 |
#define NFNL_MSG_TYPE(x) (x & 0x00ff) |
| 43 |
|
| 44 |
/* No enum here, otherwise __stringify() trick of MODULE_ALIAS_NFNL_SUBSYS() |
| 45 |
* won't work anymore */ |
| 46 |
#define NFNL_SUBSYS_NONE 0 |
| 47 |
#define NFNL_SUBSYS_CTNETLINK 1 |
| 48 |
#define NFNL_SUBSYS_CTNETLINK_EXP 2 |
| 49 |
#define NFNL_SUBSYS_QUEUE 3 |
| 50 |
#define NFNL_SUBSYS_ULOG 4 |
| 51 |
#define NFNL_SUBSYS_OSF 5 |
| 52 |
#define NFNL_SUBSYS_IPSET 6 |
| 53 |
#define NFNL_SUBSYS_ACCT 7 |
| 54 |
#define NFNL_SUBSYS_CTNETLINK_TIMEOUT 8 |
| 55 |
#define NFNL_SUBSYS_CTHELPER 9 |
| 56 |
#define NFNL_SUBSYS_NFTABLES 10 |
| 57 |
#define NFNL_SUBSYS_NFT_COMPAT 11 |
| 58 |
#define NFNL_SUBSYS_COUNT 12 |
| 59 |
|
| 60 |
#ifdef __KERNEL__ |
| 61 |
|
| 62 |
#include <linux/netlink.h> |
| 63 |
#include <linux/capability.h> |
| 64 |
#include <net/netlink.h> |
| 65 |
|
| 66 |
struct nfnl_callback { |
| 67 |
int (*call)(struct sock *nl, struct sk_buff *skb, |
| 68 |
const struct nlmsghdr *nlh, |
| 69 |
const struct nlattr * const cda[]); |
| 70 |
int (*call_rcu)(struct sock *nl, struct sk_buff *skb, |
| 71 |
const struct nlmsghdr *nlh, |
| 72 |
const struct nlattr * const cda[]); |
| 73 |
const struct nla_policy *policy; /* netlink attribute policy */ |
| 74 |
const u_int16_t attr_count; /* number of nlattr's */ |
| 75 |
}; |
| 76 |
|
| 77 |
struct nfnetlink_subsystem { |
| 78 |
const char *name; |
| 79 |
__u8 subsys_id; /* nfnetlink subsystem ID */ |
| 80 |
__u8 cb_count; /* number of callbacks */ |
| 81 |
const struct nfnl_callback *cb; /* callback for individual types */ |
| 82 |
}; |
| 83 |
|
| 84 |
extern int nfnetlink_subsys_register(const struct nfnetlink_subsystem *n); |
| 85 |
extern int nfnetlink_subsys_unregister(const struct nfnetlink_subsystem *n); |
| 86 |
|
| 87 |
extern int nfnetlink_has_listeners(struct net *net, unsigned int group); |
| 88 |
extern int nfnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, unsigned int group, |
| 89 |
int echo, gfp_t flags); |
| 90 |
extern int nfnetlink_set_err(struct net *net, u32 pid, u32 group, int error); |
| 91 |
extern int nfnetlink_unicast(struct sk_buff *skb, struct net *net, u_int32_t pid, int flags); |
| 92 |
|
| 93 |
extern void nfnl_lock(void); |
| 94 |
extern void nfnl_unlock(void); |
| 95 |
|
| 96 |
#define MODULE_ALIAS_NFNL_SUBSYS(subsys) \ |
| 97 |
MODULE_ALIAS("nfnetlink-subsys-" __stringify(subsys)) |
| 98 |
|
| 99 |
#endif /* __KERNEL__ */ |
| 100 |
|
| 101 |
/* Reserved control nfnetlink messages */ |
| 102 |
#define NFNL_MSG_BATCH_BEGIN NLMSG_MIN_TYPE |
| 103 |
#define NFNL_MSG_BATCH_END NLMSG_MIN_TYPE+1 |
| 104 |
|
| 105 |
#endif /* _NFNETLINK_H */ |