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 methodes 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-2008 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 version 3 as
21 * published by the Free Software Foundation.
23 * Anytun is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with anytun. If not, see <http://www.gnu.org/licenses/>.
32 #ifndef _LOG_TARGETS_H_
33 #define _LOG_TARGETS_H_
46 #include "datatypes.h"
53 virtual ~LogTarget() {};
55 virtual void open() = 0;
56 virtual void close() = 0;
57 bool isOpen() { return opened; };
59 void enable() { enabled = true; };
60 void disable() { enabled = false; };
61 bool isEnabled() { return enabled; };
63 int getMaxPrio() { return max_prio; };
64 void setMaxPrio(int p) { max_prio = p; };
66 virtual void log(std::string msg, int prio) = 0;
77 typedef enum { TARGET_UNKNOWN, TARGET_SYSLOG, TARGET_FILE,
78 TARGET_STDOUT, TARGET_STDERR, TARGET_WINEVENTLOG } target_type_t;
80 static target_type_t targetTypeFromString(std::string type);
81 static std::string targetTypeToString(target_type_t type);
84 LogTarget* add(std::string conf);
85 LogTarget* add(target_type_t type, int prio, std::string conf);
88 void log(std::string msg, int prio);
91 typedef std::multimap<target_type_t, LogTarget*> TargetsMap;
97 class LogTargetSyslog : public LogTarget
100 static const int FAC_USER = LOG_USER;
101 static const int FAC_MAIL = LOG_MAIL;
102 static const int FAC_DAEMON = LOG_DAEMON;
103 static const int FAC_AUTH = LOG_AUTH;
104 static const int FAC_SYSLOG = LOG_SYSLOG;
105 static const int FAC_LPR = LOG_LPR;
106 static const int FAC_NEWS = LOG_NEWS;
107 static const int FAC_UUCP = LOG_UUCP;
108 static const int FAC_CRON = LOG_CRON;
109 static const int FAC_AUTHPRIV = LOG_AUTHPRIV;
110 static const int FAC_FTP = LOG_FTP;
111 static const int FAC_LOCAL0 = LOG_LOCAL0;
112 static const int FAC_LOCAL1 = LOG_LOCAL1;
113 static const int FAC_LOCAL2 = LOG_LOCAL2;
114 static const int FAC_LOCAL3 = LOG_LOCAL3;
115 static const int FAC_LOCAL4 = LOG_LOCAL4;
116 static const int FAC_LOCAL5 = LOG_LOCAL5;
117 static const int FAC_LOCAL6 = LOG_LOCAL6;
118 static const int FAC_LOCAL7 = LOG_LOCAL7;
120 static int facilityFromString(std::string fac);
121 static std::string facilityToString(int fac);
123 LogTargetSyslog(int prio, std::string conf);
128 void log(std::string msg, int prio);
129 static bool duplicateAllowed() { return false; };
131 LogTargetSyslog& setLogName(std::string l);
132 std::string getLogName() const { return logname; }
133 LogTargetSyslog& setFacility(int f);
134 int getFacility() const { return facility; }
143 class LogTargetFile : public LogTarget
146 LogTargetFile(int prio, std::string conf);
151 void log(std::string msg, int prio);
152 static bool duplicateAllowed() { return true; };
154 LogTargetFile& setLogFilename(std::string l);
155 std::string getLogFilename() const { return logfilename; }
158 std::string logfilename;
159 std::ofstream logfile;
164 class LogTargetStdout : public LogTarget
167 LogTargetStdout(int prio, std::ostream& s);
172 void log(std::string msg, int prio);
173 static bool duplicateAllowed() { return false; };
176 std::ostream& stream;
180 #ifdef LOG_WINEVENTLOG
181 class LogTargetWinEventlog : public LogTarget
184 static WORD prioToEventLogType(int prio);
186 LogTargetWinEventlog(int prio, std::string conf);
187 ~LogTargetWinEventlog();
191 void log(std::string msg, int prio);
192 static bool duplicateAllowed() { return false; };
194 LogTargetWinEventlog& setLogName(std::string l);
195 std::string getLogName() const { return logname; };
199 HANDLE h_event_source;