1 | /* |
---|
2 | * ksyslog: In-kernel syslog receiver |
---|
3 | * Copyright(C) 2013 Atzm WATANABE All rights reserved |
---|
4 | * Distributed under the GPL |
---|
5 | */ |
---|
6 | |
---|
7 | #ifndef KSYSLOG_H |
---|
8 | #define KSYSLOG_H |
---|
9 | |
---|
10 | #define UDP_ENCAP_KSYSLOG 16 |
---|
11 | |
---|
12 | enum ksyslog_facility { |
---|
13 | KSYSLOG_F_KERN, |
---|
14 | KSYSLOG_F_USER, |
---|
15 | KSYSLOG_F_MAIL, |
---|
16 | KSYSLOG_F_DAEMON, |
---|
17 | KSYSLOG_F_AUTH, |
---|
18 | KSYSLOG_F_SYSLOG, |
---|
19 | KSYSLOG_F_LPR, |
---|
20 | KSYSLOG_F_NEWS, |
---|
21 | KSYSLOG_F_UUCP, |
---|
22 | KSYSLOG_F_CRON, |
---|
23 | KSYSLOG_F_AUTHPRIV, |
---|
24 | KSYSLOG_F_FTP, |
---|
25 | KSYSLOG_F_NTP, |
---|
26 | KSYSLOG_F_AUDIT, |
---|
27 | KSYSLOG_F_ALERT, |
---|
28 | KSYSLOG_F_CRONPRIV, /* ? */ |
---|
29 | KSYSLOG_F_LOCAL0, |
---|
30 | KSYSLOG_F_LOCAL1, |
---|
31 | KSYSLOG_F_LOCAL2, |
---|
32 | KSYSLOG_F_LOCAL3, |
---|
33 | KSYSLOG_F_LOCAL4, |
---|
34 | KSYSLOG_F_LOCAL5, |
---|
35 | KSYSLOG_F_LOCAL6, |
---|
36 | KSYSLOG_F_LOCAL7, |
---|
37 | __KSYSLOG_F_MAX, |
---|
38 | }; |
---|
39 | |
---|
40 | enum ksyslog_severity { |
---|
41 | KSYSLOG_S_EMERG, |
---|
42 | KSYSLOG_S_ALERT, |
---|
43 | KSYSLOG_S_CRIT, |
---|
44 | KSYSLOG_S_ERR, |
---|
45 | KSYSLOG_S_WARN, |
---|
46 | KSYSLOG_S_NOTICE, |
---|
47 | KSYSLOG_S_INFO, |
---|
48 | KSYSLOG_S_DEBUG, |
---|
49 | __KSYSLOG_S_MAX, |
---|
50 | }; |
---|
51 | |
---|
52 | struct ksyslog_entry { |
---|
53 | struct list_head list; |
---|
54 | |
---|
55 | struct timeval tv; |
---|
56 | enum ksyslog_facility facility; |
---|
57 | enum ksyslog_severity severity; |
---|
58 | |
---|
59 | union { |
---|
60 | __u8 addr8[4]; |
---|
61 | __be32 addr32; |
---|
62 | } daddr, saddr; |
---|
63 | |
---|
64 | __be16 dport, sport; |
---|
65 | |
---|
66 | size_t length; |
---|
67 | char *data; |
---|
68 | |
---|
69 | struct rcu_head rcu; |
---|
70 | }; |
---|
71 | |
---|
72 | struct ksyslog_queue { |
---|
73 | struct list_head head; |
---|
74 | unsigned int length; |
---|
75 | }; |
---|
76 | |
---|
77 | static inline const char * |
---|
78 | ksyslog_facility_str(const enum ksyslog_facility facility) |
---|
79 | { |
---|
80 | switch (facility) { |
---|
81 | case KSYSLOG_F_KERN: return "kern"; |
---|
82 | case KSYSLOG_F_USER: return "user"; |
---|
83 | case KSYSLOG_F_MAIL: return "mail"; |
---|
84 | case KSYSLOG_F_DAEMON: return "daemon"; |
---|
85 | case KSYSLOG_F_AUTH: return "auth"; |
---|
86 | case KSYSLOG_F_SYSLOG: return "syslog"; |
---|
87 | case KSYSLOG_F_LPR: return "lpr"; |
---|
88 | case KSYSLOG_F_NEWS: return "news"; |
---|
89 | case KSYSLOG_F_UUCP: return "uucp"; |
---|
90 | case KSYSLOG_F_CRON: return "cron"; |
---|
91 | case KSYSLOG_F_AUTHPRIV: return "authpriv"; |
---|
92 | case KSYSLOG_F_FTP: return "ftp"; |
---|
93 | case KSYSLOG_F_NTP: return "ntp"; |
---|
94 | case KSYSLOG_F_AUDIT: return "audit"; |
---|
95 | case KSYSLOG_F_ALERT: return "alert"; |
---|
96 | case KSYSLOG_F_CRONPRIV: return "cronpriv"; |
---|
97 | case KSYSLOG_F_LOCAL0: return "local0"; |
---|
98 | case KSYSLOG_F_LOCAL1: return "local1"; |
---|
99 | case KSYSLOG_F_LOCAL2: return "local2"; |
---|
100 | case KSYSLOG_F_LOCAL3: return "local3"; |
---|
101 | case KSYSLOG_F_LOCAL4: return "local4"; |
---|
102 | case KSYSLOG_F_LOCAL5: return "local5"; |
---|
103 | case KSYSLOG_F_LOCAL6: return "local6"; |
---|
104 | case KSYSLOG_F_LOCAL7: return "local7"; |
---|
105 | default: return "unknown"; |
---|
106 | } |
---|
107 | } |
---|
108 | |
---|
109 | static inline const char * |
---|
110 | ksyslog_severity_str(const enum ksyslog_severity severity) |
---|
111 | { |
---|
112 | switch (severity) { |
---|
113 | case KSYSLOG_S_EMERG: return "emerg"; |
---|
114 | case KSYSLOG_S_ALERT: return "alert"; |
---|
115 | case KSYSLOG_S_CRIT: return "crit"; |
---|
116 | case KSYSLOG_S_ERR: return "err"; |
---|
117 | case KSYSLOG_S_WARN: return "warn"; |
---|
118 | case KSYSLOG_S_NOTICE: return "notice"; |
---|
119 | case KSYSLOG_S_INFO: return "info"; |
---|
120 | case KSYSLOG_S_DEBUG: return "debug"; |
---|
121 | default: return "unknown"; |
---|
122 | } |
---|
123 | } |
---|
124 | |
---|
125 | #endif |
---|