nf_log.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #ifndef _NF_LOG_H
  2. #define _NF_LOG_H
  3. #include <linux/netfilter.h>
  4. /* those NF_LOG_* defines and struct nf_loginfo are legacy definitios that will
  5. * disappear once iptables is replaced with pkttables. Please DO NOT use them
  6. * for any new code! */
  7. #define NF_LOG_TCPSEQ 0x01 /* Log TCP sequence numbers */
  8. #define NF_LOG_TCPOPT 0x02 /* Log TCP options */
  9. #define NF_LOG_IPOPT 0x04 /* Log IP options */
  10. #define NF_LOG_UID 0x08 /* Log UID owning local socket */
  11. #define NF_LOG_MASK 0x0f
  12. enum nf_log_type {
  13. NF_LOG_TYPE_LOG = 0,
  14. NF_LOG_TYPE_ULOG,
  15. NF_LOG_TYPE_MAX
  16. };
  17. struct nf_loginfo {
  18. u_int8_t type;
  19. union {
  20. struct {
  21. u_int32_t copy_len;
  22. u_int16_t group;
  23. u_int16_t qthreshold;
  24. } ulog;
  25. struct {
  26. u_int8_t level;
  27. u_int8_t logflags;
  28. } log;
  29. } u;
  30. };
  31. typedef void nf_logfn(struct net *net,
  32. u_int8_t pf,
  33. unsigned int hooknum,
  34. const struct sk_buff *skb,
  35. const struct net_device *in,
  36. const struct net_device *out,
  37. const struct nf_loginfo *li,
  38. const char *prefix);
  39. struct nf_logger {
  40. char *name;
  41. enum nf_log_type type;
  42. nf_logfn *logfn;
  43. struct module *me;
  44. };
  45. /* Function to register/unregister log function. */
  46. int nf_log_register(u_int8_t pf, struct nf_logger *logger);
  47. void nf_log_unregister(struct nf_logger *logger);
  48. void nf_log_set(struct net *net, u_int8_t pf,
  49. const struct nf_logger *logger);
  50. void nf_log_unset(struct net *net, const struct nf_logger *logger);
  51. int nf_log_bind_pf(struct net *net, u_int8_t pf,
  52. const struct nf_logger *logger);
  53. void nf_log_unbind_pf(struct net *net, u_int8_t pf);
  54. int nf_logger_find_get(int pf, enum nf_log_type type);
  55. void nf_logger_put(int pf, enum nf_log_type type);
  56. void nf_logger_request_module(int pf, enum nf_log_type type);
  57. #define MODULE_ALIAS_NF_LOGGER(family, type) \
  58. MODULE_ALIAS("nf-logger-" __stringify(family) "-" __stringify(type))
  59. /* Calls the registered backend logging function */
  60. __printf(8, 9)
  61. void nf_log_packet(struct net *net,
  62. u_int8_t pf,
  63. unsigned int hooknum,
  64. const struct sk_buff *skb,
  65. const struct net_device *in,
  66. const struct net_device *out,
  67. const struct nf_loginfo *li,
  68. const char *fmt, ...);
  69. __printf(8, 9)
  70. void nf_log_trace(struct net *net,
  71. u_int8_t pf,
  72. unsigned int hooknum,
  73. const struct sk_buff *skb,
  74. const struct net_device *in,
  75. const struct net_device *out,
  76. const struct nf_loginfo *li,
  77. const char *fmt, ...);
  78. struct nf_log_buf;
  79. struct nf_log_buf *nf_log_buf_open(void);
  80. __printf(2, 3) int nf_log_buf_add(struct nf_log_buf *m, const char *f, ...);
  81. void nf_log_buf_close(struct nf_log_buf *m);
  82. /* common logging functions */
  83. int nf_log_dump_udp_header(struct nf_log_buf *m, const struct sk_buff *skb,
  84. u8 proto, int fragment, unsigned int offset);
  85. int nf_log_dump_tcp_header(struct nf_log_buf *m, const struct sk_buff *skb,
  86. u8 proto, int fragment, unsigned int offset,
  87. unsigned int logflags);
  88. void nf_log_dump_sk_uid_gid(struct nf_log_buf *m, struct sock *sk);
  89. void nf_log_dump_packet_common(struct nf_log_buf *m, u_int8_t pf,
  90. unsigned int hooknum, const struct sk_buff *skb,
  91. const struct net_device *in,
  92. const struct net_device *out,
  93. const struct nf_loginfo *loginfo,
  94. const char *prefix);
  95. #endif /* _NF_LOG_H */