Merge tag 'master-2014-07-31' of git://git.kernel.org/pub/scm/linux/kernel/git/linvil...
[cascardo/linux.git] / include / net / netfilter / nf_log.h
index 99eac12..534e1f2 100644 (file)
 #define NF_LOG_UID             0x08    /* Log UID owning local socket */
 #define NF_LOG_MASK            0x0f
 
-#define NF_LOG_TYPE_LOG                0x01
-#define NF_LOG_TYPE_ULOG       0x02
+enum nf_log_type {
+       NF_LOG_TYPE_LOG         = 0,
+       NF_LOG_TYPE_ULOG,
+       NF_LOG_TYPE_MAX
+};
 
 struct nf_loginfo {
        u_int8_t type;
@@ -40,10 +43,10 @@ typedef void nf_logfn(struct net *net,
                      const char *prefix);
 
 struct nf_logger {
-       struct module   *me;
-       nf_logfn        *logfn;
-       char            *name;
-       struct list_head        list[NFPROTO_NUMPROTO];
+       char                    *name;
+       enum nf_log_type        type;
+       nf_logfn                *logfn;
+       struct module           *me;
 };
 
 /* Function to register/unregister log function. */
@@ -58,6 +61,13 @@ 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);
 
+int nf_logger_find_get(int pf, enum nf_log_type type);
+void nf_logger_put(int pf, enum nf_log_type type);
+void nf_logger_request_module(int pf, enum nf_log_type type);
+
+#define MODULE_ALIAS_NF_LOGGER(family, type) \
+       MODULE_ALIAS("nf-logger-" __stringify(family) "-" __stringify(type))
+
 /* Calls the registered backend logging function */
 __printf(8, 9)
 void nf_log_packet(struct net *net,
@@ -69,4 +79,24 @@ void nf_log_packet(struct net *net,
                   const struct nf_loginfo *li,
                   const char *fmt, ...);
 
+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);
+
+/* 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);
+
 #endif /* _NF_LOG_H */