Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[deliverable/linux.git] / include / net / netfilter / nf_log.h
CommitLineData
f01ffbd6
PM
1#ifndef _NF_LOG_H
2#define _NF_LOG_H
3
ca735b3a
EL
4#include <linux/netfilter.h>
5
f01ffbd6
PM
6/* those NF_LOG_* defines and struct nf_loginfo are legacy definitios that will
7 * disappear once iptables is replaced with pkttables. Please DO NOT use them
8 * for any new code! */
9#define NF_LOG_TCPSEQ 0x01 /* Log TCP sequence numbers */
10#define NF_LOG_TCPOPT 0x02 /* Log TCP options */
11#define NF_LOG_IPOPT 0x04 /* Log IP options */
12#define NF_LOG_UID 0x08 /* Log UID owning local socket */
13#define NF_LOG_MASK 0x0f
14
7643507f
VP
15/* This flag indicates that copy_len field in nf_loginfo is set */
16#define NF_LOG_F_COPY_LEN 0x1
17
5962815a
PNA
18enum nf_log_type {
19 NF_LOG_TYPE_LOG = 0,
20 NF_LOG_TYPE_ULOG,
21 NF_LOG_TYPE_MAX
22};
f01ffbd6
PM
23
24struct nf_loginfo {
25 u_int8_t type;
26 union {
27 struct {
7643507f
VP
28 /* copy_len will be used iff you set
29 * NF_LOG_F_COPY_LEN in flags
30 */
f01ffbd6
PM
31 u_int32_t copy_len;
32 u_int16_t group;
33 u_int16_t qthreshold;
7643507f 34 u_int16_t flags;
f01ffbd6
PM
35 } ulog;
36 struct {
37 u_int8_t level;
38 u_int8_t logflags;
39 } log;
40 } u;
41};
42
8cdb46da
HS
43typedef void nf_logfn(struct net *net,
44 u_int8_t pf,
f01ffbd6
PM
45 unsigned int hooknum,
46 const struct sk_buff *skb,
47 const struct net_device *in,
48 const struct net_device *out,
49 const struct nf_loginfo *li,
50 const char *prefix);
51
52struct nf_logger {
5962815a
PNA
53 char *name;
54 enum nf_log_type type;
55 nf_logfn *logfn;
56 struct module *me;
f01ffbd6
PM
57};
58
59/* Function to register/unregister log function. */
ca735b3a
EL
60int nf_log_register(u_int8_t pf, struct nf_logger *logger);
61void nf_log_unregister(struct nf_logger *logger);
62
30e0c6a6
G
63void nf_log_set(struct net *net, u_int8_t pf,
64 const struct nf_logger *logger);
65void nf_log_unset(struct net *net, const struct nf_logger *logger);
66
67int nf_log_bind_pf(struct net *net, u_int8_t pf,
68 const struct nf_logger *logger);
69void nf_log_unbind_pf(struct net *net, u_int8_t pf);
f01ffbd6 70
fab4085f
PNA
71int nf_logger_find_get(int pf, enum nf_log_type type);
72void nf_logger_put(int pf, enum nf_log_type type);
960649d1 73void nf_logger_request_module(int pf, enum nf_log_type type);
fab4085f
PNA
74
75#define MODULE_ALIAS_NF_LOGGER(family, type) \
76 MODULE_ALIAS("nf-logger-" __stringify(family) "-" __stringify(type))
77
f01ffbd6 78/* Calls the registered backend logging function */
30e0c6a6
G
79__printf(8, 9)
80void nf_log_packet(struct net *net,
81 u_int8_t pf,
f01ffbd6
PM
82 unsigned int hooknum,
83 const struct sk_buff *skb,
84 const struct net_device *in,
85 const struct net_device *out,
7b2f9631 86 const struct nf_loginfo *li,
b9075fa9 87 const char *fmt, ...);
f01ffbd6 88
4017a7ee
PNA
89__printf(8, 9)
90void nf_log_trace(struct net *net,
91 u_int8_t pf,
92 unsigned int hooknum,
93 const struct sk_buff *skb,
94 const struct net_device *in,
95 const struct net_device *out,
96 const struct nf_loginfo *li,
97 const char *fmt, ...);
98
27fd8d90
PNA
99struct nf_log_buf;
100
101struct nf_log_buf *nf_log_buf_open(void);
102__printf(2, 3) int nf_log_buf_add(struct nf_log_buf *m, const char *f, ...);
103void nf_log_buf_close(struct nf_log_buf *m);
104
83e96d44
PNA
105/* common logging functions */
106int nf_log_dump_udp_header(struct nf_log_buf *m, const struct sk_buff *skb,
107 u8 proto, int fragment, unsigned int offset);
108int nf_log_dump_tcp_header(struct nf_log_buf *m, const struct sk_buff *skb,
109 u8 proto, int fragment, unsigned int offset,
110 unsigned int logflags);
111void nf_log_dump_sk_uid_gid(struct nf_log_buf *m, struct sock *sk);
112void nf_log_dump_packet_common(struct nf_log_buf *m, u_int8_t pf,
113 unsigned int hooknum, const struct sk_buff *skb,
114 const struct net_device *in,
115 const struct net_device *out,
116 const struct nf_loginfo *loginfo,
117 const char *prefix);
118
f01ffbd6 119#endif /* _NF_LOG_H */
This page took 0.792221 seconds and 5 git commands to generate.