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 anytun.org <satp@wirdorange.org>
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License version 2
18 * as published by the Free Software Foundation.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program (see the file COPYING included with this
27 * distribution); if not, write to the Free Software Foundation, Inc.,
28 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
38 #include "threadUtils.hpp"
42 class LogStringBuilder
45 LogStringBuilder(LogStringBuilder
const& src
);
46 LogStringBuilder(Log
& l
, int p
);
50 std::ostream
& operator<<(T
const& value
) { return stream
<< value
; }
55 std::stringstream stream
;
58 class Log
: public std::ostringstream
61 static const int FAC_USER
= LOG_USER
;
62 static const int FAC_MAIL
= LOG_MAIL
;
63 static const int FAC_DAEMON
= LOG_DAEMON
;
64 static const int FAC_AUTH
= LOG_AUTH
;
65 static const int FAC_SYSLOG
= LOG_SYSLOG
;
66 static const int FAC_LPR
= LOG_LPR
;
67 static const int FAC_NEWS
= LOG_NEWS
;
68 static const int FAC_UUCP
= LOG_UUCP
;
69 static const int FAC_CRON
= LOG_CRON
;
70 static const int FAC_AUTHPRIV
= LOG_AUTHPRIV
;
71 static const int FAC_FTP
= LOG_FTP
;
72 static const int FAC_LOCAL0
= LOG_LOCAL0
;
73 static const int FAC_LOCAL1
= LOG_LOCAL1
;
74 static const int FAC_LOCAL2
= LOG_LOCAL2
;
75 static const int FAC_LOCAL3
= LOG_LOCAL3
;
76 static const int FAC_LOCAL4
= LOG_LOCAL4
;
77 static const int FAC_LOCAL5
= LOG_LOCAL5
;
78 static const int FAC_LOCAL6
= LOG_LOCAL6
;
79 static const int FAC_LOCAL7
= LOG_LOCAL7
;
81 static const int PRIO_EMERG
= LOG_EMERG
;
82 static const int PRIO_ALERT
= LOG_ALERT
;
83 static const int PRIO_CRIT
= LOG_CRIT
;
84 static const int PRIO_ERR
= LOG_ERR
;
85 static const int PRIO_WARNING
= LOG_WARNING
;
86 static const int PRIO_NOTICE
= LOG_NOTICE
;
87 static const int PRIO_INFO
= LOG_INFO
;
88 static const int PRIO_DEBUG
= LOG_DEBUG
;
90 static Log
& instance();
92 Log
& setLogName(std::string newLogName
);
93 std::string
getLogName() const { return logName
; }
94 Log
& setFacility(int newFacility
);
95 int getFacility() const { return facility
; }
97 LogStringBuilder
msg(int prio
=PRIO_INFO
) { return LogStringBuilder(*this, prio
); }
103 void operator=(const Log
&l
);
106 static Mutex instMutex
;
107 class instanceCleaner
{
108 public: ~instanceCleaner() {
113 friend class instanceCleaner
;
118 friend class LogStringBuilder
;