File Index
Files and directories
Sign in
FILE

nf_log.h

File preview with syntax highlighting.

linux-6.19.14/include/net/netfilter/nf_log.h C
  1/* SPDX-License-Identifier: GPL-2.0 */
  2#ifndef _NF_LOG_H
  3#define _NF_LOG_H
  4
  5#include <linux/netfilter.h>
  6#include <linux/netfilter/nf_log.h>
  7
  8/* Log tcp sequence, tcp options, ip options and uid owning local socket */
  9#define NF_LOG_DEFAULT_MASK	0x0f
 10
 11/* This flag indicates that copy_len field in nf_loginfo is set */
 12#define NF_LOG_F_COPY_LEN	0x1
 13
 14enum nf_log_type {
 15	NF_LOG_TYPE_LOG		= 0,
 16	NF_LOG_TYPE_ULOG,
 17	NF_LOG_TYPE_MAX
 18};
 19
 20struct nf_loginfo {
 21	u_int8_t type;
 22	union {
 23		struct {
 24			/* copy_len will be used iff you set
 25			 * NF_LOG_F_COPY_LEN in flags
 26			 */
 27			u_int32_t copy_len;
 28			u_int16_t group;
 29			u_int16_t qthreshold;
 30			u_int16_t flags;
 31		} ulog;
 32		struct {
 33			u_int8_t level;
 34			u_int8_t logflags;
 35		} log;
 36	} u;
 37};
 38
 39typedef void nf_logfn(struct net *net,
 40		      u_int8_t pf,
 41		      unsigned int hooknum,
 42		      const struct sk_buff *skb,
 43		      const struct net_device *in,
 44		      const struct net_device *out,
 45		      const struct nf_loginfo *li,
 46		      const char *prefix);
 47
 48struct nf_logger {
 49	char			*name;
 50	enum nf_log_type	type;
 51	nf_logfn 		*logfn;
 52	struct module		*me;
 53};
 54
 55/* sysctl_nf_log_all_netns - allow LOG target in all network namespaces */
 56extern int sysctl_nf_log_all_netns;
 57
 58/* Function to register/unregister log function. */
 59int nf_log_register(u_int8_t pf, struct nf_logger *logger);
 60void nf_log_unregister(struct nf_logger *logger);
 61
 62/* Check if any logger is registered for a given protocol family. */
 63bool nf_log_is_registered(u_int8_t pf);
 64
 65int nf_log_set(struct net *net, u_int8_t pf, const struct nf_logger *logger);
 66void nf_log_unset(struct net *net, const struct nf_logger *logger);
 67
 68int nf_log_bind_pf(struct net *net, u_int8_t pf,
 69		   const struct nf_logger *logger);
 70void nf_log_unbind_pf(struct net *net, u_int8_t pf);
 71
 72int nf_logger_find_get(int pf, enum nf_log_type type);
 73void nf_logger_put(int pf, enum nf_log_type type);
 74
 75#define MODULE_ALIAS_NF_LOGGER(family, type) \
 76	MODULE_ALIAS("nf-logger-" __stringify(family) "-" __stringify(type))
 77
 78/* Calls the registered backend logging function */
 79__printf(8, 9)
 80void nf_log_packet(struct net *net,
 81		   u_int8_t pf,
 82		   unsigned int hooknum,
 83		   const struct sk_buff *skb,
 84		   const struct net_device *in,
 85		   const struct net_device *out,
 86		   const struct nf_loginfo *li,
 87		   const char *fmt, ...);
 88
 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
 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#endif /* _NF_LOG_H */
~/ Read-only file preview.