2007-12-18 06:38:49 +00:00
|
|
|
#ifndef _NF_LOG_H
|
|
|
|
#define _NF_LOG_H
|
|
|
|
|
2009-03-16 13:54:21 +00:00
|
|
|
#include <linux/netfilter.h>
|
|
|
|
|
2007-12-18 06:38:49 +00:00
|
|
|
/* those NF_LOG_* defines and struct nf_loginfo are legacy definitios that will
|
|
|
|
* disappear once iptables is replaced with pkttables. Please DO NOT use them
|
|
|
|
* for any new code! */
|
|
|
|
#define NF_LOG_TCPSEQ 0x01 /* Log TCP sequence numbers */
|
|
|
|
#define NF_LOG_TCPOPT 0x02 /* Log TCP options */
|
|
|
|
#define NF_LOG_IPOPT 0x04 /* Log IP options */
|
|
|
|
#define NF_LOG_UID 0x08 /* Log UID owning local socket */
|
|
|
|
#define NF_LOG_MASK 0x0f
|
|
|
|
|
2014-06-18 17:24:30 +00:00
|
|
|
enum nf_log_type {
|
|
|
|
NF_LOG_TYPE_LOG = 0,
|
|
|
|
NF_LOG_TYPE_ULOG,
|
|
|
|
NF_LOG_TYPE_MAX
|
|
|
|
};
|
2007-12-18 06:38:49 +00:00
|
|
|
|
|
|
|
struct nf_loginfo {
|
|
|
|
u_int8_t type;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
u_int32_t copy_len;
|
|
|
|
u_int16_t group;
|
|
|
|
u_int16_t qthreshold;
|
|
|
|
} ulog;
|
|
|
|
struct {
|
|
|
|
u_int8_t level;
|
|
|
|
u_int8_t logflags;
|
|
|
|
} log;
|
|
|
|
} u;
|
|
|
|
};
|
|
|
|
|
2013-05-15 01:23:45 +00:00
|
|
|
typedef void nf_logfn(struct net *net,
|
|
|
|
u_int8_t pf,
|
2007-12-18 06:38:49 +00:00
|
|
|
unsigned int hooknum,
|
|
|
|
const struct sk_buff *skb,
|
|
|
|
const struct net_device *in,
|
|
|
|
const struct net_device *out,
|
|
|
|
const struct nf_loginfo *li,
|
|
|
|
const char *prefix);
|
|
|
|
|
|
|
|
struct nf_logger {
|
2014-06-18 17:24:30 +00:00
|
|
|
char *name;
|
|
|
|
enum nf_log_type type;
|
|
|
|
nf_logfn *logfn;
|
|
|
|
struct module *me;
|
2007-12-18 06:38:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Function to register/unregister log function. */
|
2009-03-16 13:54:21 +00:00
|
|
|
int nf_log_register(u_int8_t pf, struct nf_logger *logger);
|
|
|
|
void nf_log_unregister(struct nf_logger *logger);
|
|
|
|
|
2013-03-24 23:50:40 +00:00
|
|
|
void nf_log_set(struct net *net, u_int8_t pf,
|
|
|
|
const struct nf_logger *logger);
|
|
|
|
void nf_log_unset(struct net *net, const struct nf_logger *logger);
|
|
|
|
|
|
|
|
int nf_log_bind_pf(struct net *net, u_int8_t pf,
|
|
|
|
const struct nf_logger *logger);
|
|
|
|
void nf_log_unbind_pf(struct net *net, u_int8_t pf);
|
2007-12-18 06:38:49 +00:00
|
|
|
|
2014-06-18 17:38:25 +00:00
|
|
|
int nf_logger_find_get(int pf, enum nf_log_type type);
|
|
|
|
void nf_logger_put(int pf, enum nf_log_type type);
|
2014-06-22 22:28:18 +00:00
|
|
|
void nf_logger_request_module(int pf, enum nf_log_type type);
|
2014-06-18 17:38:25 +00:00
|
|
|
|
|
|
|
#define MODULE_ALIAS_NF_LOGGER(family, type) \
|
|
|
|
MODULE_ALIAS("nf-logger-" __stringify(family) "-" __stringify(type))
|
|
|
|
|
2007-12-18 06:38:49 +00:00
|
|
|
/* Calls the registered backend logging function */
|
2013-03-24 23:50:40 +00:00
|
|
|
__printf(8, 9)
|
|
|
|
void nf_log_packet(struct net *net,
|
|
|
|
u_int8_t pf,
|
2007-12-18 06:38:49 +00:00
|
|
|
unsigned int hooknum,
|
|
|
|
const struct sk_buff *skb,
|
|
|
|
const struct net_device *in,
|
|
|
|
const struct net_device *out,
|
2007-12-18 06:39:08 +00:00
|
|
|
const struct nf_loginfo *li,
|
2011-11-01 00:11:33 +00:00
|
|
|
const char *fmt, ...);
|
2007-12-18 06:38:49 +00:00
|
|
|
|
2014-06-19 10:37:58 +00:00
|
|
|
struct nf_log_buf;
|
|
|
|
|
|
|
|
struct nf_log_buf *nf_log_buf_open(void);
|
|
|
|
__printf(2, 3) int nf_log_buf_add(struct nf_log_buf *m, const char *f, ...);
|
|
|
|
void nf_log_buf_close(struct nf_log_buf *m);
|
|
|
|
|
2014-06-19 18:47:14 +00:00
|
|
|
/* common logging functions */
|
|
|
|
int nf_log_dump_udp_header(struct nf_log_buf *m, const struct sk_buff *skb,
|
|
|
|
u8 proto, int fragment, unsigned int offset);
|
|
|
|
int nf_log_dump_tcp_header(struct nf_log_buf *m, const struct sk_buff *skb,
|
|
|
|
u8 proto, int fragment, unsigned int offset,
|
|
|
|
unsigned int logflags);
|
|
|
|
void nf_log_dump_sk_uid_gid(struct nf_log_buf *m, struct sock *sk);
|
|
|
|
void nf_log_dump_packet_common(struct nf_log_buf *m, u_int8_t pf,
|
|
|
|
unsigned int hooknum, const struct sk_buff *skb,
|
|
|
|
const struct net_device *in,
|
|
|
|
const struct net_device *out,
|
|
|
|
const struct nf_loginfo *loginfo,
|
|
|
|
const char *prefix);
|
|
|
|
|
2007-12-18 06:38:49 +00:00
|
|
|
#endif /* _NF_LOG_H */
|