summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/server/Daemon.cpp3
-rw-r--r--lib/server/Protocol.cpp23
-rw-r--r--lib/server/ProtocolUncertainStream.cpp3
-rw-r--r--lib/server/SSLLib.cpp3
-rw-r--r--lib/server/ServerException.h46
-rw-r--r--lib/server/Socket.cpp7
-rw-r--r--lib/server/SocketListen.h3
-rw-r--r--lib/server/SocketStream.cpp11
-rw-r--r--lib/server/SocketStreamTLS.cpp27
-rw-r--r--lib/server/TLSContext.cpp3
-rw-r--r--lib/server/WinNamedPipeListener.h8
-rw-r--r--lib/server/WinNamedPipeStream.cpp5
-rwxr-xr-xlib/server/makeprotocol.pl.in14
13 files changed, 60 insertions, 96 deletions
diff --git a/lib/server/Daemon.cpp b/lib/server/Daemon.cpp
index 7f2e902c..65ff5792 100644
--- a/lib/server/Daemon.cpp
+++ b/lib/server/Daemon.cpp
@@ -36,12 +36,13 @@
# include "BoxVersion.h"
#endif
+#include "autogen_ConnectionException.h"
+#include "autogen_ServerException.h"
#include "Configuration.h"
#include "Daemon.h"
#include "FileModificationTime.h"
#include "Guards.h"
#include "Logging.h"
-#include "ServerException.h"
#include "UnixUser.h"
#include "Utils.h"
diff --git a/lib/server/Protocol.cpp b/lib/server/Protocol.cpp
index ebc70f3b..15fb4139 100644
--- a/lib/server/Protocol.cpp
+++ b/lib/server/Protocol.cpp
@@ -17,10 +17,11 @@
#include <new>
+#include "autogen_ConnectionException.h"
+#include "autogen_ServerException.h"
#include "Protocol.h"
#include "ProtocolWire.h"
#include "SocketStream.h"
-#include "ServerException.h"
#include "PartialReadStream.h"
#include "ProtocolUncertainStream.h"
#include "Logging.h"
@@ -117,7 +118,7 @@ void Protocol::Handshake()
int bytesRead = mapConn->Read(readInto, bytesToRead, mTimeout);
if(bytesRead == 0)
{
- THROW_EXCEPTION(ConnectionException, Conn_Protocol_Timeout)
+ THROW_EXCEPTION(ConnectionException, Protocol_Timeout)
}
readInto += bytesRead;
bytesToRead -= bytesRead;
@@ -127,7 +128,7 @@ void Protocol::Handshake()
// Are they the same?
if(::memcmp(&hsSend, &hsReceive, sizeof(hsSend)) != 0)
{
- THROW_EXCEPTION(ConnectionException, Conn_Protocol_HandshakeFailed)
+ THROW_EXCEPTION(ConnectionException, Protocol_HandshakeFailed)
}
// Mark as done
@@ -161,7 +162,7 @@ void Protocol::CheckAndReadHdr(void *hdr)
if(!mapConn->ReadFullBuffer(hdr, sizeof(PW_ObjectHeader),
0 /* not interested in bytes read if this fails */, mTimeout))
{
- THROW_EXCEPTION(ConnectionException, Conn_Protocol_Timeout)
+ THROW_EXCEPTION(ConnectionException, Protocol_Timeout)
}
}
@@ -184,14 +185,14 @@ std::auto_ptr<Message> Protocol::ReceiveInternal()
// Hope it's not a stream
if(ntohl(objHeader.mObjType) == SPECIAL_STREAM_OBJECT_TYPE)
{
- THROW_EXCEPTION(ConnectionException, Conn_Protocol_StreamWhenObjExpected)
+ THROW_EXCEPTION(ConnectionException, Protocol_StreamWhenObjExpected)
}
// Check the object size
u_int32_t objSize = ntohl(objHeader.mObjSize);
if(objSize < sizeof(objHeader) || objSize > mMaxObjectSize)
{
- THROW_EXCEPTION(ConnectionException, Conn_Protocol_ObjTooBig)
+ THROW_EXCEPTION(ConnectionException, Protocol_ObjTooBig)
}
// Create a blank object
@@ -204,7 +205,7 @@ std::auto_ptr<Message> Protocol::ReceiveInternal()
if(!mapConn->ReadFullBuffer(mpBuffer, objSize - sizeof(objHeader),
0 /* not interested in bytes read if this fails */, mTimeout))
{
- THROW_EXCEPTION(ConnectionException, Conn_Protocol_Timeout)
+ THROW_EXCEPTION(ConnectionException, Protocol_Timeout)
}
// Setup ready to read out data from the buffer
@@ -234,7 +235,7 @@ std::auto_ptr<Message> Protocol::ReceiveInternal()
// Exception if not all the data was consumed
if(dataLeftOver)
{
- THROW_EXCEPTION(ConnectionException, Conn_Protocol_BadCommandRecieved)
+ THROW_EXCEPTION(ConnectionException, Protocol_BadCommandRecieved)
}
return obj;
@@ -349,7 +350,7 @@ void Protocol::EnsureBufferAllocated(int Size)
#define READ_CHECK_BYTES_AVAILABLE(bytesRequired) \
if((mReadOffset + (int)(bytesRequired)) > mValidDataSize) \
{ \
- THROW_EXCEPTION(ConnectionException, Conn_Protocol_BadCommandRecieved) \
+ THROW_EXCEPTION(ConnectionException, Protocol_BadCommandRecieved) \
}
// --------------------------------------------------------------------------
@@ -636,7 +637,7 @@ std::auto_ptr<IOStream> Protocol::ReceiveStream()
// Hope it's not an object
if(ntohl(objHeader.mObjType) != SPECIAL_STREAM_OBJECT_TYPE)
{
- THROW_EXCEPTION(ConnectionException, Conn_Protocol_ObjWhenStreamExpected)
+ THROW_EXCEPTION(ConnectionException, Protocol_ObjWhenStreamExpected)
}
// Get the stream size
@@ -764,7 +765,7 @@ void Protocol::SendStream(IOStream &rStream)
// Fixed size stream, send it all in one go
if(!rStream.CopyStreamTo(*mapConn, mTimeout, 4096 /* slightly larger buffer */))
{
- THROW_EXCEPTION(ConnectionException, Conn_Protocol_TimeOutWhenSendingStream)
+ THROW_EXCEPTION(ConnectionException, Protocol_TimeOutWhenSendingStream)
}
}
// Make sure everything is written
diff --git a/lib/server/ProtocolUncertainStream.cpp b/lib/server/ProtocolUncertainStream.cpp
index 84a213a8..336fd36d 100644
--- a/lib/server/ProtocolUncertainStream.cpp
+++ b/lib/server/ProtocolUncertainStream.cpp
@@ -8,8 +8,9 @@
// --------------------------------------------------------------------------
#include "Box.h"
+#include "autogen_ConnectionException.h"
+#include "autogen_ServerException.h"
#include "ProtocolUncertainStream.h"
-#include "ServerException.h"
#include "Protocol.h"
#include "MemLeakFindOn.h"
diff --git a/lib/server/SSLLib.cpp b/lib/server/SSLLib.cpp
index 004d2d98..d29b120a 100644
--- a/lib/server/SSLLib.cpp
+++ b/lib/server/SSLLib.cpp
@@ -18,9 +18,10 @@
#include <wincrypt.h>
#endif
+#include "autogen_ConnectionException.h"
+#include "autogen_ServerException.h"
#include "CryptoUtils.h"
#include "SSLLib.h"
-#include "ServerException.h"
#include "MemLeakFindOn.h"
diff --git a/lib/server/ServerException.h b/lib/server/ServerException.h
deleted file mode 100644
index 8851b90a..00000000
--- a/lib/server/ServerException.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// --------------------------------------------------------------------------
-//
-// File
-// Name: ServerException.h
-// Purpose: Exception
-// Created: 2003/07/08
-//
-// --------------------------------------------------------------------------
-
-#ifndef SERVEREXCEPTION__H
-#define SERVEREXCEPTION__H
-
-// Compatibility header
-#include "autogen_ServerException.h"
-#include "autogen_ConnectionException.h"
-
-// Rename old connection exception names to new names without Conn_ prefix
-// This is all because ConnectionException used to be derived from ServerException
-// with some funky magic with subtypes. Perhaps a little unreliable, and the
-// usefulness of it never really was used.
-#define Conn_SocketWriteError SocketWriteError
-#define Conn_SocketReadError SocketReadError
-#define Conn_SocketNameLookupError SocketNameLookupError
-#define Conn_SocketShutdownError SocketShutdownError
-#define Conn_SocketConnectError SocketConnectError
-#define Conn_TLSHandshakeFailed TLSHandshakeFailed
-#define Conn_TLSShutdownFailed TLSShutdownFailed
-#define Conn_TLSWriteFailed TLSWriteFailed
-#define Conn_TLSReadFailed TLSReadFailed
-#define Conn_TLSNoPeerCertificate TLSNoPeerCertificate
-#define Conn_TLSPeerCertificateInvalid TLSPeerCertificateInvalid
-#define Conn_TLSClosedWhenWriting TLSClosedWhenWriting
-#define Conn_TLSHandshakeTimedOut TLSHandshakeTimedOut
-#define Conn_Protocol_Timeout Protocol_Timeout
-#define Conn_Protocol_ObjTooBig Protocol_ObjTooBig
-#define Conn_Protocol_BadCommandRecieved Protocol_BadCommandRecieved
-#define Conn_Protocol_UnknownCommandRecieved Protocol_UnknownCommandRecieved
-#define Conn_Protocol_TriedToExecuteReplyCommand Protocol_TriedToExecuteReplyCommand
-#define Conn_Protocol_UnexpectedReply Protocol_UnexpectedReply
-#define Conn_Protocol_HandshakeFailed Protocol_HandshakeFailed
-#define Conn_Protocol_StreamWhenObjExpected Protocol_StreamWhenObjExpected
-#define Conn_Protocol_ObjWhenStreamExpected Protocol_ObjWhenStreamExpected
-#define Conn_Protocol_TimeOutWhenSendingStream Protocol_TimeOutWhenSendingStream
-
-#endif // SERVEREXCEPTION__H
-
diff --git a/lib/server/Socket.cpp b/lib/server/Socket.cpp
index f2a4996b..c9c1773d 100644
--- a/lib/server/Socket.cpp
+++ b/lib/server/Socket.cpp
@@ -24,8 +24,9 @@
#include <string.h>
#include <stdio.h>
+#include "autogen_ConnectionException.h"
+#include "autogen_ServerException.h"
#include "Socket.h"
-#include "ServerException.h"
#include "MemLeakFindOn.h"
@@ -69,12 +70,12 @@ void Socket::NameLookupToSockAddr(SocketAllAddr &addr, int &sockDomain,
}
else
{
- THROW_EXCEPTION(ConnectionException, Conn_SocketNameLookupError);
+ THROW_EXCEPTION(ConnectionException, SocketNameLookupError);
}
}
else
{
- THROW_EXCEPTION(ConnectionException, Conn_SocketNameLookupError);
+ THROW_EXCEPTION(ConnectionException, SocketNameLookupError);
}
}
break;
diff --git a/lib/server/SocketListen.h b/lib/server/SocketListen.h
index 39c60ba6..e35e9c30 100644
--- a/lib/server/SocketListen.h
+++ b/lib/server/SocketListen.h
@@ -29,8 +29,9 @@
#include <memory>
#include <string>
+#include "autogen_ConnectionException.h"
+#include "autogen_ServerException.h"
#include "Socket.h"
-#include "ServerException.h"
#include "MemLeakFindOn.h"
diff --git a/lib/server/SocketStream.cpp b/lib/server/SocketStream.cpp
index f0bfcf94..7b46b024 100644
--- a/lib/server/SocketStream.cpp
+++ b/lib/server/SocketStream.cpp
@@ -29,8 +29,9 @@
#include <bsd/unistd.h>
#endif
+#include "autogen_ConnectionException.h"
+#include "autogen_ServerException.h"
#include "SocketStream.h"
-#include "ServerException.h"
#include "CommonException.h"
#include "Socket.h"
@@ -184,7 +185,7 @@ void SocketStream::Open(Socket::Type Type, const std::string& rName, int Port)
#endif // WIN32
mSocketHandle = INVALID_SOCKET_VALUE;
- THROW_EXCEPTION(ConnectionException, Conn_SocketConnectError)
+ THROW_EXCEPTION(ConnectionException, SocketConnectError)
}
ResetCounters();
@@ -260,7 +261,7 @@ int SocketStream::Read(void *pBuffer, int NBytes, int Timeout)
// Other error
BOX_LOG_SYS_ERROR("Failed to read from socket");
THROW_EXCEPTION(ConnectionException,
- Conn_SocketReadError);
+ SocketReadError);
}
}
@@ -310,7 +311,7 @@ void SocketStream::Write(const void *pBuffer, int NBytes)
mWriteClosed = true; // assume can't write again
BOX_LOG_SYS_ERROR("Failed to write to socket");
THROW_EXCEPTION(ConnectionException,
- Conn_SocketWriteError);
+ SocketWriteError);
}
// Knock off bytes sent
@@ -401,7 +402,7 @@ void SocketStream::Shutdown(bool Read, bool Write)
if(::shutdown(mSocketHandle, how) == -1)
{
BOX_LOG_SYS_ERROR("Failed to shutdown socket");
- THROW_EXCEPTION(ConnectionException, Conn_SocketShutdownError)
+ THROW_EXCEPTION(ConnectionException, SocketShutdownError)
}
}
diff --git a/lib/server/SocketStreamTLS.cpp b/lib/server/SocketStreamTLS.cpp
index 576b53a2..127d697a 100644
--- a/lib/server/SocketStreamTLS.cpp
+++ b/lib/server/SocketStreamTLS.cpp
@@ -19,9 +19,10 @@
#include <poll.h>
#endif
+#include "autogen_ConnectionException.h"
+#include "autogen_ServerException.h"
#include "BoxTime.h"
#include "CryptoUtils.h"
-#include "ServerException.h"
#include "SocketStreamTLS.h"
#include "SSLLib.h"
#include "TLSContext.h"
@@ -196,7 +197,7 @@ void SocketStreamTLS::Handshake(const TLSContext &rContext, bool IsServer)
if(WaitWhenRetryRequired(se, TLS_HANDSHAKE_TIMEOUT) == false)
{
// timed out
- THROW_EXCEPTION(ConnectionException, Conn_TLSHandshakeTimedOut)
+ THROW_EXCEPTION(ConnectionException, TLSHandshakeTimedOut)
}
break;
@@ -205,12 +206,12 @@ void SocketStreamTLS::Handshake(const TLSContext &rContext, bool IsServer)
if(IsServer)
{
CryptoUtils::LogError("accepting connection");
- THROW_EXCEPTION(ConnectionException, Conn_TLSHandshakeFailed)
+ THROW_EXCEPTION(ConnectionException, TLSHandshakeFailed)
}
else
{
CryptoUtils::LogError("connecting");
- THROW_EXCEPTION(ConnectionException, Conn_TLSHandshakeFailed)
+ THROW_EXCEPTION(ConnectionException, TLSHandshakeFailed)
}
}
}
@@ -337,7 +338,7 @@ int SocketStreamTLS::Read(void *pBuffer, int NBytes, int Timeout)
default:
CryptoUtils::LogError("reading");
- THROW_EXCEPTION(ConnectionException, Conn_TLSReadFailed)
+ THROW_EXCEPTION(ConnectionException, TLSReadFailed)
break;
}
}
@@ -385,7 +386,7 @@ void SocketStreamTLS::Write(const void *pBuffer, int NBytes)
case SSL_ERROR_ZERO_RETURN:
// Connection closed
MarkAsWriteClosed();
- THROW_EXCEPTION(ConnectionException, Conn_TLSClosedWhenWriting)
+ THROW_EXCEPTION(ConnectionException, TLSClosedWhenWriting)
break;
case SSL_ERROR_WANT_READ:
@@ -402,7 +403,7 @@ void SocketStreamTLS::Write(const void *pBuffer, int NBytes)
default:
CryptoUtils::LogError("writing");
- THROW_EXCEPTION(ConnectionException, Conn_TLSWriteFailed)
+ THROW_EXCEPTION(ConnectionException, TLSWriteFailed)
break;
}
}
@@ -444,7 +445,7 @@ void SocketStreamTLS::Shutdown(bool Read, bool Write)
if(::SSL_shutdown(mpSSL) < 0)
{
CryptoUtils::LogError("shutting down");
- THROW_EXCEPTION(ConnectionException, Conn_TLSShutdownFailed)
+ THROW_EXCEPTION(ConnectionException, TLSShutdownFailed)
}
// Don't ask the base class to shutdown -- BIO does this, apparently.
@@ -467,15 +468,15 @@ std::string SocketStreamTLS::GetPeerCommonName()
if(cert == 0)
{
::X509_free(cert);
- THROW_EXCEPTION(ConnectionException, Conn_TLSNoPeerCertificate)
+ THROW_EXCEPTION(ConnectionException, TLSNoPeerCertificate)
}
- // Subject details
- X509_NAME *subject = ::X509_get_subject_name(cert);
+ // Subject details
+ X509_NAME *subject = ::X509_get_subject_name(cert);
if(subject == 0)
{
::X509_free(cert);
- THROW_EXCEPTION(ConnectionException, Conn_TLSPeerCertificateInvalid)
+ THROW_EXCEPTION(ConnectionException, TLSPeerCertificateInvalid)
}
// Common name
@@ -483,7 +484,7 @@ std::string SocketStreamTLS::GetPeerCommonName()
if(::X509_NAME_get_text_by_NID(subject, NID_commonName, commonName, sizeof(commonName)) <= 0)
{
::X509_free(cert);
- THROW_EXCEPTION(ConnectionException, Conn_TLSPeerCertificateInvalid)
+ THROW_EXCEPTION(ConnectionException, TLSPeerCertificateInvalid)
}
// Terminate just in case
commonName[sizeof(commonName)-1] = '\0';
diff --git a/lib/server/TLSContext.cpp b/lib/server/TLSContext.cpp
index 341043e9..35e254fd 100644
--- a/lib/server/TLSContext.cpp
+++ b/lib/server/TLSContext.cpp
@@ -12,8 +12,9 @@
#define TLS_CLASS_IMPLEMENTATION_CPP
#include <openssl/ssl.h>
+#include "autogen_ConnectionException.h"
+#include "autogen_ServerException.h"
#include "CryptoUtils.h"
-#include "ServerException.h"
#include "SSLLib.h"
#include "TLSContext.h"
diff --git a/lib/server/WinNamedPipeListener.h b/lib/server/WinNamedPipeListener.h
index 26e76e3d..d18f0054 100644
--- a/lib/server/WinNamedPipeListener.h
+++ b/lib/server/WinNamedPipeListener.h
@@ -11,10 +11,10 @@
#ifndef WINNAMEDPIPELISTENER__H
#define WINNAMEDPIPELISTENER__H
-#include <OverlappedIO.h>
-#include <WinNamedPipeStream.h>
-
-#include "ServerException.h"
+#include "autogen_ConnectionException.h"
+#include "autogen_ServerException.h"
+#include "OverlappedIO.h"
+#include "WinNamedPipeStream.h"
#include "MemLeakFindOn.h"
diff --git a/lib/server/WinNamedPipeStream.cpp b/lib/server/WinNamedPipeStream.cpp
index 1179516e..52ad9743 100644
--- a/lib/server/WinNamedPipeStream.cpp
+++ b/lib/server/WinNamedPipeStream.cpp
@@ -19,10 +19,11 @@
#include <errno.h>
#include <windows.h>
-#include "WinNamedPipeStream.h"
-#include "ServerException.h"
+#include "autogen_ConnectionException.h"
+#include "autogen_ServerException.h"
#include "CommonException.h"
#include "Socket.h"
+#include "WinNamedPipeStream.h"
#include "MemLeakFindOn.h"
diff --git a/lib/server/makeprotocol.pl.in b/lib/server/makeprotocol.pl.in
index df0e23ab..7dfab7b3 100755
--- a/lib/server/makeprotocol.pl.in
+++ b/lib/server/makeprotocol.pl.in
@@ -179,7 +179,7 @@ print H <<__E;
#include "Protocol.h"
#include "Message.h"
-#include "ServerException.h"
+#include "autogen_ConnectionException.h"
class IOStream;
class SocketStream;
@@ -261,13 +261,13 @@ print CPP <<__E;
std::auto_ptr<$message_base_class> $message_base_class\::DoCommand($replyable_base_class &rProtocol,
$context_class &rContext) const
{
- THROW_EXCEPTION(ConnectionException, Conn_Protocol_TriedToExecuteReplyCommand)
+ THROW_EXCEPTION(ConnectionException, Protocol_TriedToExecuteReplyCommand)
}
std::auto_ptr<$message_base_class> $message_base_class\::DoCommand($replyable_base_class &rProtocol,
$context_class &rContext, IOStream& rDataStream) const
{
- THROW_EXCEPTION(ConnectionException, Conn_Protocol_TriedToExecuteReplyCommand)
+ THROW_EXCEPTION(ConnectionException, Protocol_TriedToExecuteReplyCommand)
}
__E
@@ -640,7 +640,7 @@ __E
print CPP <<__E;
default:
- THROW_EXCEPTION(ConnectionException, Conn_Protocol_UnknownCommandRecieved)
+ THROW_EXCEPTION(ConnectionException, Protocol_UnknownCommandRecieved)
}
}
@@ -685,7 +685,7 @@ void $callable_base_class\::CheckReply(const std::string& requestCommandName,
{
SetLastError(type, subType);
THROW_EXCEPTION_MESSAGE(ConnectionException,
- Conn_Protocol_UnexpectedReply,
+ Protocol_UnexpectedReply,
requestCommandName << " command failed: "
"received error " <<
(($error_class&)rReply).GetMessage());
@@ -694,7 +694,7 @@ void $callable_base_class\::CheckReply(const std::string& requestCommandName,
{
SetLastError(Protocol::UnknownError, Protocol::UnknownError);
THROW_EXCEPTION_MESSAGE(ConnectionException,
- Conn_Protocol_UnexpectedReply,
+ Protocol_UnexpectedReply,
requestCommandName << " command failed: "
"received unexpected response type " <<
rReply.GetType());
@@ -1197,7 +1197,7 @@ sub obj_get_type_params
{
return $1 if $_ =~ m/\A$ty\((.+?)\)\Z/;
}
- die "Can't find attribute $ty\n"
+ die "Can't find attribute $ty on command $c\n"
}
# returns (is basic type, typename)