4 * The secure anycast tunneling protocol (satp) defines a protocol used
5 * for communication between any combination of unicast and anycast
6 * tunnel endpoints. It has less protocol overhead than IPSec in Tunnel
7 * mode and allows tunneling of every ETHER TYPE protocol (e.g.
8 * ethernet, ip, arp ...). satp directly includes cryptography and
9 * message authentication based on the methods used by SRTP. It is
10 * intended to deliver a generic, scaleable and secure solution for
11 * tunneling and relaying of packets of any protocol.
14 * Copyright (C) 2007-2014 Markus Grüneis, Othmar Gsenger, Erwin Nindl,
15 * Christian Pointner <satp@wirdorange.org>
17 * This file is part of Anytun.
19 * Anytun is free software: you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation, either version 3 of the License, or
24 * Anytun is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with Anytun. If not, see <http://www.gnu.org/licenses/>.
32 * In addition, as a special exception, the copyright holders give
33 * permission to link the code of portions of this program with the
34 * OpenSSL library under certain conditions as described in each
35 * individual source file, and distribute linked combinations
37 * You must obey the GNU General Public License in all respects
38 * for all of the code used other than OpenSSL. If you modify
39 * file(s) with this exception, you may extend this exception to your
40 * version of the file(s), but you are not obligated to do so. If you
41 * do not wish to do so, delete this exception statement from your
42 * version. If you delete this exception statement from all source
43 * files in the program, then also delete it here.
46 #ifndef ANYTUN_logTargets_h_INCLUDED
47 #define ANYTUN_logTargets_h_INCLUDED
60 #include "datatypes.h"
67 virtual ~LogTarget() {};
69 virtual void open() = 0;
70 virtual void close() = 0;
71 bool isOpen() { return opened; };
73 void enable() { enabled = true; };
74 void disable() { enabled = false; };
75 bool isEnabled() { return enabled; };
77 int getMaxPrio() { return max_prio; };
78 void setMaxPrio(int p) { max_prio = p; };
80 virtual void log(std::string msg, int prio) = 0;
91 typedef enum { TARGET_UNKNOWN, TARGET_SYSLOG, TARGET_FILE,
92 TARGET_STDOUT, TARGET_STDERR, TARGET_WINEVENTLOG
95 static target_type_t targetTypeFromString(std::string type);
96 static std::string targetTypeToString(target_type_t type);
99 LogTarget* add(std::string conf);
100 LogTarget* add(target_type_t type, int prio, std::string conf);
103 void log(std::string msg, int prio);
106 typedef std::multimap<target_type_t, LogTarget*> TargetsMap;
112 class LogTargetSyslog : public LogTarget
115 static const int FAC_USER = LOG_USER;
116 static const int FAC_MAIL = LOG_MAIL;
117 static const int FAC_DAEMON = LOG_DAEMON;
118 static const int FAC_AUTH = LOG_AUTH;
119 static const int FAC_SYSLOG = LOG_SYSLOG;
120 static const int FAC_LPR = LOG_LPR;
121 static const int FAC_NEWS = LOG_NEWS;
122 static const int FAC_UUCP = LOG_UUCP;
123 static const int FAC_CRON = LOG_CRON;
124 static const int FAC_AUTHPRIV = LOG_AUTHPRIV;
125 static const int FAC_FTP = LOG_FTP;
126 static const int FAC_LOCAL0 = LOG_LOCAL0;
127 static const int FAC_LOCAL1 = LOG_LOCAL1;
128 static const int FAC_LOCAL2 = LOG_LOCAL2;
129 static const int FAC_LOCAL3 = LOG_LOCAL3;
130 static const int FAC_LOCAL4 = LOG_LOCAL4;
131 static const int FAC_LOCAL5 = LOG_LOCAL5;
132 static const int FAC_LOCAL6 = LOG_LOCAL6;
133 static const int FAC_LOCAL7 = LOG_LOCAL7;
135 static int facilityFromString(std::string fac);
136 static std::string facilityToString(int fac);
138 LogTargetSyslog(int prio, std::string conf);
143 void log(std::string msg, int prio);
144 static bool duplicateAllowed() { return false; };
146 LogTargetSyslog& setLogName(std::string l);
147 std::string getLogName() const { return logname; }
148 LogTargetSyslog& setFacility(int f);
149 int getFacility() const { return facility; }
158 class LogTargetFile : public LogTarget
161 LogTargetFile(int prio, std::string conf);
166 void log(std::string msg, int prio);
167 static bool duplicateAllowed() { return true; };
169 LogTargetFile& setLogFilename(std::string l);
170 std::string getLogFilename() const { return logfilename; }
173 std::string logfilename;
174 std::ofstream logfile;
179 class LogTargetStdout : public LogTarget
182 LogTargetStdout(int prio, std::ostream& s);
187 void log(std::string msg, int prio);
188 static bool duplicateAllowed() { return false; };
191 std::ostream& stream;
195 #ifdef LOG_WINEVENTLOG
196 class LogTargetWinEventlog : public LogTarget
199 static WORD prioToEventLogType(int prio);
201 LogTargetWinEventlog(int prio, std::string conf);
202 ~LogTargetWinEventlog();
206 void log(std::string msg, int prio);
207 static bool duplicateAllowed() { return false; };
209 LogTargetWinEventlog& setLogName(std::string l);
210 std::string getLogName() const { return logname; };
214 HANDLE h_event_source;