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-2009 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/>.
33 #ifndef ANYTUN_logTargets_h_INCLUDED
34 #define ANYTUN_logTargets_h_INCLUDED
47 #include "datatypes.h"
54 virtual ~LogTarget() {};
56 virtual void open() = 0;
57 virtual void close() = 0;
58 bool isOpen() { return opened; };
60 void enable() { enabled = true; };
61 void disable() { enabled = false; };
62 bool isEnabled() { return enabled; };
64 int getMaxPrio() { return max_prio; };
65 void setMaxPrio(int p) { max_prio = p; };
67 virtual void log(std::string msg, int prio) = 0;
78 typedef enum { TARGET_UNKNOWN, TARGET_SYSLOG, TARGET_FILE,
79 TARGET_STDOUT, TARGET_STDERR, TARGET_WINEVENTLOG } target_type_t;
81 static target_type_t targetTypeFromString(std::string type);
82 static std::string targetTypeToString(target_type_t type);
85 LogTarget* add(std::string conf);
86 LogTarget* add(target_type_t type, int prio, std::string conf);
89 void log(std::string msg, int prio);
92 typedef std::multimap<target_type_t, LogTarget*> TargetsMap;
98 class LogTargetSyslog : public LogTarget
101 static const int FAC_USER = LOG_USER;
102 static const int FAC_MAIL = LOG_MAIL;
103 static const int FAC_DAEMON = LOG_DAEMON;
104 static const int FAC_AUTH = LOG_AUTH;
105 static const int FAC_SYSLOG = LOG_SYSLOG;
106 static const int FAC_LPR = LOG_LPR;
107 static const int FAC_NEWS = LOG_NEWS;
108 static const int FAC_UUCP = LOG_UUCP;
109 static const int FAC_CRON = LOG_CRON;
110 static const int FAC_AUTHPRIV = LOG_AUTHPRIV;
111 static const int FAC_FTP = LOG_FTP;
112 static const int FAC_LOCAL0 = LOG_LOCAL0;
113 static const int FAC_LOCAL1 = LOG_LOCAL1;
114 static const int FAC_LOCAL2 = LOG_LOCAL2;
115 static const int FAC_LOCAL3 = LOG_LOCAL3;
116 static const int FAC_LOCAL4 = LOG_LOCAL4;
117 static const int FAC_LOCAL5 = LOG_LOCAL5;
118 static const int FAC_LOCAL6 = LOG_LOCAL6;
119 static const int FAC_LOCAL7 = LOG_LOCAL7;
121 static int facilityFromString(std::string fac);
122 static std::string facilityToString(int fac);
124 LogTargetSyslog(int prio, std::string conf);
129 void log(std::string msg, int prio);
130 static bool duplicateAllowed() { return false; };
132 LogTargetSyslog& setLogName(std::string l);
133 std::string getLogName() const { return logname; }
134 LogTargetSyslog& setFacility(int f);
135 int getFacility() const { return facility; }
144 class LogTargetFile : public LogTarget
147 LogTargetFile(int prio, std::string conf);
152 void log(std::string msg, int prio);
153 static bool duplicateAllowed() { return true; };
155 LogTargetFile& setLogFilename(std::string l);
156 std::string getLogFilename() const { return logfilename; }
159 std::string logfilename;
160 std::ofstream logfile;
165 class LogTargetStdout : public LogTarget
168 LogTargetStdout(int prio, std::ostream& s);
173 void log(std::string msg, int prio);
174 static bool duplicateAllowed() { return false; };
177 std::ostream& stream;
181 #ifdef LOG_WINEVENTLOG
182 class LogTargetWinEventlog : public LogTarget
185 static WORD prioToEventLogType(int prio);
187 LogTargetWinEventlog(int prio, std::string conf);
188 ~LogTargetWinEventlog();
192 void log(std::string msg, int prio);
193 static bool duplicateAllowed() { return false; };
195 LogTargetWinEventlog& setLogName(std::string l);
196 std::string getLogName() const { return logname; };
200 HANDLE h_event_source;