diff --git a/apps/clicktocall/HttpBase.cxx b/apps/clicktocall/HttpBase.cxx index c238c18167..1921d9ece8 100644 --- a/apps/clicktocall/HttpBase.cxx +++ b/apps/clicktocall/HttpBase.cxx @@ -15,6 +15,7 @@ #include "HttpConnection.hxx" #include "WebAdmin.hxx" #include +#include "rutil/Errdes.hxx" using namespace clicktocall; using namespace resip; @@ -62,7 +63,7 @@ HttpBase::HttpBase( int port, IpVersion ipVer, const Data& realm ): if ( mFd == INVALID_SOCKET ) { int e = getErrno(); - ErrLog (<< "Failed to create socket: " << strerror(e)); + ErrLog (<< "Failed to create socket: " << strerror(e) <<" error message from Errdes.hxx file: " << errortostringOS(e) ); sane = false; return; } @@ -78,7 +79,7 @@ HttpBase::HttpBase( int port, IpVersion ipVer, const Data& realm ): #endif { int e = getErrno(); - ErrLog (<< "Couldn't set sockoptions SO_REUSEPORT | SO_REUSEADDR: " << strerror(e)); + ErrLog (<< "Couldn't set sockoptions SO_REUSEPORT | SO_REUSEADDR: " << strerror(e) <<" error message from Errdes.hxx file: " << errortostringOS(e) ); sane = false; return; } @@ -116,7 +117,7 @@ HttpBase::HttpBase( int port, IpVersion ipVer, const Data& realm ): if (e != 0 ) { int e = getErrno(); - InfoLog (<< "Failed listen " << strerror(e)); + InfoLog (<< "Failed listen " << strerror(e) <<" error message from Errdes.hxx file: " << errortostringOS(e) ); sane = false; return; } @@ -155,7 +156,7 @@ HttpBase::process(FdSet& fdset) case EWOULDBLOCK: return; default: - ErrLog(<< "Some error reading from socket: " << e); + ErrLog(<< "Some error reading from socket: "<< e <<", error message: " << errortostringOS(e) ); } return; } diff --git a/apps/clicktocall/HttpConnection.cxx b/apps/clicktocall/HttpConnection.cxx index bc6cc9a9a0..c5a1dfdc13 100644 --- a/apps/clicktocall/HttpConnection.cxx +++ b/apps/clicktocall/HttpConnection.cxx @@ -8,6 +8,7 @@ #include #include #include +#include "rutil/Errdes.hxx" #include "Version.hxx" #include "AppSubsystem.hxx" @@ -30,7 +31,7 @@ HttpConnection::HttpConnection( HttpBase& base, resip::Socket pSock ): mSock(pSock), mParsedRequest(false) { - resip_assert( mSock > 0 ); + resip_assert( mSock > 0 ); } @@ -235,10 +236,10 @@ HttpConnection::processSomeReads() InfoLog (<< "buf is outside your accessible address space."); break; default: - InfoLog (<< "Some other error"); + InfoLog (<< "Some other error: " << e << " error message: " << errortostringOS(e) ); break; } - InfoLog (<< "Failed read on " << (int)mSock << " " << strerror(e)); + InfoLog (<< "Failed read on " << (int)mSock << " " << strerror(e) << " error message from Errdes.hxx file: " << errortostringOS(e) ); return false; } else if (bytesRead == 0) @@ -347,7 +348,7 @@ HttpConnection::processSomeWrites() if (bytesWritten == INVALID_SOCKET) { int e = getErrno(); - InfoLog (<< "HttpConnection failed write on " << mSock << " " << strerror(e)); + InfoLog (<< "HttpConnection failed write on " << mSock << " " << strerror(e) << " error message from Errdes.hxx file " << errortostringOS(e) ); return false; } diff --git a/apps/clicktocall/XmlRpcConnection.cxx b/apps/clicktocall/XmlRpcConnection.cxx index 87464e683e..3f302da1ce 100644 --- a/apps/clicktocall/XmlRpcConnection.cxx +++ b/apps/clicktocall/XmlRpcConnection.cxx @@ -8,6 +8,7 @@ #include #include #include +#include "rutil/Errdes.hxx" #include "Version.hxx" #include "AppSubsystem.hxx" @@ -30,7 +31,7 @@ XmlRpcConnection::XmlRpcConnection(XmlRpcServerBase& server, resip::Socket sock) mNextRequestId(1), mSock(sock) { - resip_assert(mSock > 0); + resip_assert(mSock > 0); } @@ -107,7 +108,7 @@ XmlRpcConnection::processSomeReads() { int e = getErrno(); XmlRpcServerBase::logSocketError(e); - InfoLog (<< "XmlRpcConnection::processSomeReads: Failed read on " << (int)mSock); + InfoLog (<< "XmlRpcConnection::processSomeReads: Failed read on " << (int)mSock << " " << strerror(e) << " error message from Errdes.hxx file : " << errortostringOS(e)); return false; } else if(bytesRead == 0) @@ -191,7 +192,7 @@ XmlRpcConnection::processSomeWrites() { int e = getErrno(); XmlRpcServerBase::logSocketError(e); - InfoLog (<< "XmlRpcConnection::processSomeWrites - failed write on " << mSock << " " << strerror(e)); + InfoLog (<< "XmlRpcConnection::processSomeWrites - failed write on " << mSock << " " << strerror(e) << " error message from Errdes.hxx file : " << errortostringOS(e)); return false; } diff --git a/apps/clicktocall/XmlRpcServerBase.cxx b/apps/clicktocall/XmlRpcServerBase.cxx index 3906def0be..d3aef41f87 100644 --- a/apps/clicktocall/XmlRpcServerBase.cxx +++ b/apps/clicktocall/XmlRpcServerBase.cxx @@ -14,6 +14,7 @@ #include "XmlRpcServerBase.hxx" #include "XmlRpcConnection.hxx" #include +#include "rutil/Errdes.hxx" using namespace clicktocall; using namespace resip; @@ -36,7 +37,7 @@ XmlRpcServerBase::XmlRpcServerBase(int port, IpVersion ipVer) : { int e = getErrno(); logSocketError(e); - ErrLog(<< "XmlRpcServerBase::XmlRpcServerBase: Failed to create socket: " << strerror(e)); + ErrLog(<< "XmlRpcServerBase::XmlRpcServerBase: Failed to create socket: " << strerror(e) << " error message from Errdes.hxx file: " << errortostringOS(e) ); mSane = false; return; } @@ -53,7 +54,7 @@ XmlRpcServerBase::XmlRpcServerBase(int port, IpVersion ipVer) : { int e = getErrno(); logSocketError(e); - ErrLog(<< "XmlRpcServerBase::XmlRpcServerBase: Couldn't set sockoptions SO_REUSEPORT | SO_REUSEADDR: " << strerror(e)); + ErrLog(<< "XmlRpcServerBase::XmlRpcServerBase: Couldn't set sockoptions SO_REUSEPORT | SO_REUSEADDR: " << strerror(e) << " error message from Errdes.hxx file: " << errortostringOS(e) ); mSane = false; return; } @@ -81,7 +82,7 @@ XmlRpcServerBase::XmlRpcServerBase(int port, IpVersion ipVer) : { int e = getErrno(); logSocketError(e); - ErrLog(<< "XmlRpcServerBase::XmlRpcServerBase: Could not make HTTP socket non-blocking " << port); + ErrLog(<< "XmlRpcServerBase::XmlRpcServerBase: Could not make HTTP socket non-blocking " << port << strerror(e) << " error message from Errdes.hxx file: " << errortostringOS(e) ); mSane = false; return; } @@ -94,7 +95,7 @@ XmlRpcServerBase::XmlRpcServerBase(int port, IpVersion ipVer) : if (e != 0) { int e = getErrno(); - InfoLog(<< "XmlRpcServerBase::XmlRpcServerBase: Failed listen " << strerror(e)); + InfoLog(<< "XmlRpcServerBase::XmlRpcServerBase: Failed listen " << strerror(e) << " error message from Errdes.hxx file: " << errortostringOS(e) ); mSane = false; return; } @@ -164,7 +165,7 @@ XmlRpcServerBase::process(FdSet& fdset) return; default: logSocketError(e); - ErrLog(<< "XmlRpcServerBase::process: Some error reading from socket: " << e); + ErrLog(<< "XmlRpcServerBase::process: Some error reading from socket: " << e << " error message from Errdes.hxx file: " << errortostringOS(e) ); } return; } @@ -240,22 +241,22 @@ XmlRpcServerBase::logSocketError(int e) switch (e) { case EAGAIN: - InfoLog (<< "No data ready to read" << strerror(e)); + InfoLog (<< "No data ready to read : " << errortostringOS(e) ); break; case EINTR: - InfoLog (<< "The call was interrupted by a signal before any data was read : " << strerror(e)); + InfoLog (<< "The call was interrupted by a signal before any data was read : " << errortostringOS(e) ); break; case EIO: - InfoLog (<< "I/O error : " << strerror(e)); + InfoLog (<< "I/O error : " << errortostringOS(e) ); break; case EBADF: - InfoLog (<< "fd is not a valid file descriptor or is not open for reading : " << strerror(e)); + InfoLog (<< "fd is not a valid file descriptor or is not open for reading : " << errortostringOS(e) ); break; case EINVAL: - InfoLog (<< "fd is attached to an object which is unsuitable for reading : " << strerror(e)); + InfoLog (<< "fd is attached to an object which is unsuitable for reading : " << errortostringOS(e) ); break; case EFAULT: - InfoLog (<< "buf is outside your accessible address space : " << strerror(e)); + InfoLog (<< "buf is outside your accessible address space : " << errortostringOS(e) ); break; #if defined(WIN32) @@ -309,7 +310,7 @@ XmlRpcServerBase::logSocketError(int e) InfoLog (<<"Connection reset "); break; - case WSAEWOULDBLOCK: + case WSAEWOULDBLOCK: DebugLog (<<"Would Block "); break; @@ -353,7 +354,7 @@ XmlRpcServerBase::logSocketError(int e) #endif default: - InfoLog (<< "Some other error (" << e << "): " << strerror(e)); + InfoLog (<< "Some other error (" << e << "): " << errortostringOS(e) ); break; } } diff --git a/apps/ichat-gw/MediaRelay.cxx b/apps/ichat-gw/MediaRelay.cxx index 751e8a17f6..37348fba34 100644 --- a/apps/ichat-gw/MediaRelay.cxx +++ b/apps/ichat-gw/MediaRelay.cxx @@ -15,6 +15,7 @@ #include "AppSubsystem.hxx" #include "MediaRelay.hxx" #include +#include "rutil/Errdes.hxx" using namespace gateway; using namespace resip; @@ -31,7 +32,7 @@ using namespace std; typedef struct { unsigned short versionExtPayloadTypeAndMarker; - unsigned short sequenceNumber; + unsigned short sequenceNumber; unsigned int timestamp; unsigned int ssrc; } RtpHeader; @@ -171,7 +172,7 @@ MediaRelay::createRelaySocket(resip::Tuple& tuple) if ( fd == INVALID_SOCKET ) { int e = getErrno(); - ErrLog (<< "MediaRelay::createRelaySocket - Failed to create socket: " << strerror(e)); + ErrLog (<< "MediaRelay::createRelaySocket - Failed to create socket: " << strerror(e) << " error message from Errdes.hxx file: " << errortostringOS(e) ); return INVALID_SOCKET; } @@ -188,7 +189,7 @@ MediaRelay::createRelaySocket(resip::Tuple& tuple) } else { - ErrLog (<< "MediaRelay::createRelaySocket - Could not bind to " << tuple << ", error=" << e); + ErrLog (<< "MediaRelay::createRelaySocket - Could not bind to " << tuple << ", error = " << e << " error message from Errdes.hxx file: " << errortostringOS(e) ); } return INVALID_SOCKET; } @@ -200,7 +201,7 @@ MediaRelay::createRelaySocket(resip::Tuple& tuple) if(::getsockname(fd, &tuple.getMutableSockaddr(), &len) == SOCKET_ERROR) { int e = getErrno(); - ErrLog (<<"MediaRelay::createRelaySocket - getsockname failed, error=" << e); + ErrLog (<<"MediaRelay::createRelaySocket - getsockname failed, error=" << e << " error message from Errdes.hxx file: " << errortostringOS(e) ); return INVALID_SOCKET; } } @@ -518,7 +519,7 @@ MediaRelay::processReads(FdSet& fdset, MediaRelayPort* relayPort) int err = getErrno(); if ( err != EWOULDBLOCK ) { - ErrLog (<< "MediaRelay::processReads: port=" << relayPort->mLocalV4Tuple.getPort() << ", Error calling recvfrom: " << err); + ErrLog (<< "MediaRelay::processReads: port=" << relayPort->mLocalV4Tuple.getPort() << ", Error calling recvfrom: " << err << " error message: " << errortostringOS(err) ); } buffer.reset(); } diff --git a/configure.ac b/configure.ac index 49b00f8320..c6472e9857 100644 --- a/configure.ac +++ b/configure.ac @@ -14,7 +14,8 @@ AC_SUBST(LIBTOOL_VERSION_RELEASE) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) -AM_INIT_AUTOMAKE([foreign subdir-objects]) +AM_INIT_AUTOMAKE + m4_pattern_forbid([^PKG_]) AC_CANONICAL_HOST diff --git a/repro/HttpBase.cxx b/repro/HttpBase.cxx index bd75cc80ca..7bd0540d63 100644 --- a/repro/HttpBase.cxx +++ b/repro/HttpBase.cxx @@ -18,7 +18,7 @@ #include "repro/HttpConnection.hxx" #include "repro/WebAdmin.hxx" #include "rutil/WinLeakCheck.hxx" - +#include "rutil/Errdes.hxx" using namespace resip; using namespace repro; @@ -69,7 +69,7 @@ HttpBase::HttpBase( int port, IpVersion ipVer, const Data& realm, const resip::D if ( mFd == INVALID_SOCKET ) { int e = getErrno(); - ErrLog (<< "Failed to create socket: " << strerror(e)); + ErrLog (<< "Failed to create socket: errno " << e << " error message : "<< errortostringOS(e)); sane = false; return; } @@ -85,7 +85,7 @@ HttpBase::HttpBase( int port, IpVersion ipVer, const Data& realm, const resip::D #endif { int e = getErrno(); - ErrLog (<< "Couldn't set sockoptions SO_REUSEPORT | SO_REUSEADDR: " << strerror(e)); + ErrLog (<< "Couldn't set sockoptions SO_REUSEPORT | SO_REUSEADDR: errno " << e << " error message : "<< errortostringOS(e)); sane = false; return; } @@ -97,7 +97,7 @@ HttpBase::HttpBase( int port, IpVersion ipVer, const Data& realm, const resip::D if ( ::setsockopt(mFd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) ) { int e = getErrno(); - ErrLog(<< "HttpBase::HttpBase: Couldn't set sockoptions IPV6_V6ONLY: " << strerror(e)); + ErrLog(<< "HttpBase::HttpBase: Couldn't set sockoptions IPV6_V6ONLY: errno " << e << " error message : "<< errortostringOS(e)); sane = false; return; } @@ -138,7 +138,7 @@ HttpBase::HttpBase( int port, IpVersion ipVer, const Data& realm, const resip::D if (e != 0 ) { int e = getErrno(); - InfoLog (<< "Failed listen " << strerror(e)); + InfoLog (<< "Failed listen : errno " << e << " error message : "<< errortostringOS(e)); sane = false; return; } @@ -181,7 +181,7 @@ HttpBase::process(FdSet& fdset) // !jf! this can not be ready in some cases return; default: - ErrLog(<< "Some error reading from socket: " << e); + ErrLog(<< "Some error reading from socket: errno " << e << " error message : "<< errortostringOS(e)); // .bwc. This is almost certainly a bad assert that a nefarious // endpoint could hit. // assert(0); // Transport::error(e); diff --git a/repro/HttpConnection.cxx b/repro/HttpConnection.cxx index cd7d851f1d..d29c13bb3a 100644 --- a/repro/HttpConnection.cxx +++ b/repro/HttpConnection.cxx @@ -8,6 +8,7 @@ #include "resip/stack/Tuple.hxx" #include "rutil/DnsUtil.hxx" #include "rutil/ParseBuffer.hxx" +#include "rutil/Errdes.hxx" #include "repro/ReproVersion.hxx" #include "repro/HttpBase.hxx" @@ -31,7 +32,7 @@ HttpConnection::HttpConnection( HttpBase& base, Socket pSock ): mSock(pSock), mParsedRequest(false) { - resip_assert( mSock > 0 ); + resip_assert( mSock > 0 ); } @@ -248,7 +249,7 @@ HttpConnection::processSomeReads() InfoLog (<< "Some other error"); break; } - InfoLog (<< "Failed read on " << (int)mSock << " " << strerror(e)); + InfoLog (<< "Failed read on " << (int)mSock << " " << errortostringOS(e)); return false; } else if (bytesRead == 0) @@ -366,7 +367,7 @@ HttpConnection::processSomeWrites() if (bytesWritten == INVALID_SOCKET) { int e = getErrno(); - InfoLog (<< "HttpConnection failed write on " << mSock << " " << strerror(e)); + InfoLog (<< "HttpConnection failed write on " << mSock << " " << strerror(e) << " error message from Errdes.hxx file : " << errortostringOS(e) ); return false; } diff --git a/repro/RegSyncClient.cxx b/repro/RegSyncClient.cxx index ee951509a7..fc28e04a10 100644 --- a/repro/RegSyncClient.cxx +++ b/repro/RegSyncClient.cxx @@ -14,6 +14,7 @@ #include "repro/RegSyncClient.hxx" #include "repro/RegSyncServer.hxx" +#include "rutil/Errdes.hxx" using namespace repro; using namespace resip; @@ -93,7 +94,7 @@ RegSyncClient::thread() if(mSocketDesc < 0) { int e = getErrno(); - ErrLog(<< "RegSyncClient: cannot open socket, err=" << e); + ErrLog(<< "RegSyncClient: cannot open socket, errno = " << e << " error message : " << errortostringOS(e) ); mSocketDesc = 0; return; } @@ -103,7 +104,7 @@ RegSyncClient::thread() if(rc < 0) { int e = getErrno(); - ErrLog(<<"RegSyncClient: error binding locally, err=" << e); + ErrLog(<<"RegSyncClient: error binding locally, errno = " << e << " error message : " << errortostringOS(e) ); closeSocket(mSocketDesc); mSocketDesc = 0; return; @@ -114,7 +115,7 @@ RegSyncClient::thread() if(rc < 0) { int e = getErrno(); - if(!mShutdown) ErrLog(<< "RegSyncClient: error connecting to " << mAddress << ":" << mPort << ", err=" << e); + if(!mShutdown) ErrLog(<< "RegSyncClient: error connecting to " << mAddress << ":" << mPort << ", errno = " << e << " error message : " << errortostringOS(e) ); closeSocket(mSocketDesc); mSocketDesc = 0; delaySeconds(30); @@ -131,7 +132,7 @@ RegSyncClient::thread() if(rc < 0) { int e = getErrno(); - if(!mShutdown) ErrLog(<< "RegSyncClient: error sending, err=" << e); + if(!mShutdown) ErrLog(<< "RegSyncClient: error sending, errno = " << e << " error message : " << errortostringOS(e) ); closeSocket(mSocketDesc); mSocketDesc = 0; continue; @@ -142,7 +143,7 @@ RegSyncClient::thread() if (!ok) { int e = getErrno(); - ErrLog(<< "RegSyncClient: Could not make HTTP socket non-blocking, err=" << e); + ErrLog(<< "RegSyncClient: Could not make HTTP socket non-blocking, errno = " << e << " error message : " << errortostringOS(e) ); closeSocket(mSocketDesc); mSocketDesc = 0; continue; @@ -163,7 +164,7 @@ RegSyncClient::thread() if(rc < 0) { int e = getErrno(); - if(!mShutdown) ErrLog(<< "RegSyncClient: error receiving, err=" << e); + if(!mShutdown) ErrLog(<< "RegSyncClient: error receiving, errno = " << e << " error message : " << errortostringOS(e) ); closeSocket(mSocketDesc); mSocketDesc = 0; break; @@ -184,7 +185,7 @@ RegSyncClient::thread() // If send is blocking then we must have pending send data - so just ignore error - no need to keepalive if ( e != EAGAIN && e != EWOULDBLOCK ) // Treat EGAIN and EWOULDBLOCK as the same: http://stackoverflow.com/questions/7003234/which-systems-define-eagain-and-ewouldblock-as-different-values { - if(!mShutdown) ErrLog(<< "RegSyncClient: error sending keepalive, err=" << e); + if(!mShutdown) ErrLog(<< "RegSyncClient: error sending keepalive, errno = " << e << " error message : " << errortostringOS(e) ); closeSocket(mSocketDesc); mSocketDesc = 0; continue; @@ -198,7 +199,7 @@ RegSyncClient::thread() else { int e = getErrno(); - if(!mShutdown) ErrLog(<< "RegSyncClient: error calling select, err=" << e); + if(!mShutdown) ErrLog(<< "RegSyncClient: error calling select, errno = " << e << " error message : " << errortostringOS(e) ); closeSocket(mSocketDesc); mSocketDesc = 0; break; diff --git a/repro/XmlRpcConnection.cxx b/repro/XmlRpcConnection.cxx index 056356e86a..4bd6141153 100644 --- a/repro/XmlRpcConnection.cxx +++ b/repro/XmlRpcConnection.cxx @@ -9,6 +9,7 @@ #include #include +#include "rutil/Errdes.hxx" #include "repro/XmlRpcServerBase.hxx" #include "repro/XmlRpcConnection.hxx" @@ -27,7 +28,7 @@ XmlRpcConnection::XmlRpcConnection(XmlRpcServerBase& server, resip::Socket sock) mNextRequestId(1), mSock(sock) { - resip_assert(mSock > 0); + resip_assert(mSock > 0); } @@ -187,7 +188,7 @@ XmlRpcConnection::processSomeWrites() { int e = getErrno(); XmlRpcServerBase::logSocketError(e); - InfoLog (<< "XmlRpcConnection::processSomeWrites - failed write on " << mSock << " " << strerror(e)); + InfoLog (<< "XmlRpcConnection::processSomeWrites - failed write on " << mSock << " " << strerror(e) << " error message from Errdes.hxx file : " << errortostringOS(e)); return false; } diff --git a/repro/XmlRpcServerBase.cxx b/repro/XmlRpcServerBase.cxx index 828d8a9b8f..de5b65a4e4 100644 --- a/repro/XmlRpcServerBase.cxx +++ b/repro/XmlRpcServerBase.cxx @@ -17,6 +17,7 @@ #include "repro/XmlRpcServerBase.hxx" #include "repro/XmlRpcConnection.hxx" #include +#include "rutil/Errdes.hxx" using namespace repro; using namespace resip; @@ -39,7 +40,7 @@ XmlRpcServerBase::XmlRpcServerBase(int port, IpVersion ipVer, Data ipAddr) : { int e = getErrno(); logSocketError(e); - ErrLog(<< "XmlRpcServerBase::XmlRpcServerBase: Failed to create socket: " << strerror(e)); + ErrLog(<< "XmlRpcServerBase::XmlRpcServerBase: Failed to create socket: " << errortostringOS(e)); mSane = false; return; } @@ -56,7 +57,7 @@ XmlRpcServerBase::XmlRpcServerBase(int port, IpVersion ipVer, Data ipAddr) : { int e = getErrno(); logSocketError(e); - ErrLog(<< "XmlRpcServerBase::XmlRpcServerBase: Couldn't set sockoptions SO_REUSEPORT | SO_REUSEADDR: " << strerror(e)); + ErrLog(<< "XmlRpcServerBase::XmlRpcServerBase: Couldn't set sockoptions SO_REUSEPORT | SO_REUSEADDR: " << errortostringOS(e)); mSane = false; return; } @@ -69,7 +70,7 @@ XmlRpcServerBase::XmlRpcServerBase(int port, IpVersion ipVer, Data ipAddr) : { int e = getErrno(); logSocketError(e); - ErrLog(<< "XmlRpcServerBase::XmlRpcServerBase: Couldn't set sockoptions IPV6_V6ONLY: " << strerror(e)); + ErrLog(<< "XmlRpcServerBase::XmlRpcServerBase: Couldn't set sockoptions IPV6_V6ONLY: " << errortostringOS(e)); mSane = false; return; } @@ -113,7 +114,7 @@ XmlRpcServerBase::XmlRpcServerBase(int port, IpVersion ipVer, Data ipAddr) : if (e != 0) { int e = getErrno(); - InfoLog(<< "XmlRpcServerBase::XmlRpcServerBase: Failed listen " << strerror(e)); + InfoLog(<< "XmlRpcServerBase::XmlRpcServerBase: Failed listen " << errortostringOS(e)); mSane = false; return; } @@ -210,7 +211,7 @@ XmlRpcServerBase::process(FdSet& fdset) return; default: logSocketError(e); - ErrLog(<< "XmlRpcServerBase::process: Some error reading from socket: " << e); + ErrLog(<< "XmlRpcServerBase::process: Some error reading from socket: " << e << "error message : " << errortostringOS(e)); } return; } @@ -293,22 +294,22 @@ XmlRpcServerBase::logSocketError(int e) switch (e) { case EAGAIN: - InfoLog (<< "No data ready to read" << strerror(e)); + InfoLog (<< "No data ready to read" << errortostringOS(e)); break; case EINTR: - InfoLog (<< "The call was interrupted by a signal before any data was read : " << strerror(e)); + InfoLog (<< "The call was interrupted by a signal before any data was read : " << errortostringOS(e)); break; case EIO: - InfoLog (<< "I/O error : " << strerror(e)); + InfoLog (<< "I/O error : " << errortostringOS(e)); break; case EBADF: - InfoLog (<< "fd is not a valid file descriptor or is not open for reading : " << strerror(e)); + InfoLog (<< "fd is not a valid file descriptor or is not open for reading : " << errortostringOS(e)); break; case EINVAL: - InfoLog (<< "fd is attached to an object which is unsuitable for reading : " << strerror(e)); + InfoLog (<< "fd is attached to an object which is unsuitable for reading : " << errortostringOS(e)); break; case EFAULT: - InfoLog (<< "buf is outside your accessible address space : " << strerror(e)); + InfoLog (<< "buf is outside your accessible address space : " << errortostringOS(e)); break; #if defined(WIN32) @@ -362,7 +363,7 @@ XmlRpcServerBase::logSocketError(int e) InfoLog (<<"Connection reset "); break; - case WSAEWOULDBLOCK: + case WSAEWOULDBLOCK: DebugLog (<<"Would Block "); break; @@ -406,7 +407,7 @@ XmlRpcServerBase::logSocketError(int e) #endif default: - InfoLog (<< "Some other error (" << e << "): " << strerror(e)); + InfoLog (<< "Some other error (" << e << "): " << errortostringOS(e)); break; } } diff --git a/resip/recon/MOHParkServer/HttpBase.cxx b/resip/recon/MOHParkServer/HttpBase.cxx index 8cca4fe04a..d3268d65e4 100644 --- a/resip/recon/MOHParkServer/HttpBase.cxx +++ b/resip/recon/MOHParkServer/HttpBase.cxx @@ -19,7 +19,7 @@ #include "HttpConnection.hxx" #include "WebAdmin.hxx" #include "rutil/WinLeakCheck.hxx" - +#include "rutil/Errdes.hxx" using namespace resip; using namespace mohparkserver; @@ -67,7 +67,7 @@ HttpBase::HttpBase( int port, IpVersion ipVer, const Data& realm ): if ( mFd == INVALID_SOCKET ) { int e = getErrno(); - ErrLog (<< "Failed to create socket: " << strerror(e)); + ErrLog (<< "Failed to create socket: " << errortostringOS(e)); sane = false; return; } @@ -83,7 +83,7 @@ HttpBase::HttpBase( int port, IpVersion ipVer, const Data& realm ): #endif { int e = getErrno(); - ErrLog (<< "Couldn't set sockoptions SO_REUSEPORT | SO_REUSEADDR: " << strerror(e)); + ErrLog (<< "Couldn't set sockoptions SO_REUSEPORT | SO_REUSEADDR: " << errortostringOS(e)); sane = false; return; } @@ -121,7 +121,7 @@ HttpBase::HttpBase( int port, IpVersion ipVer, const Data& realm ): if (e != 0 ) { int e = getErrno(); - InfoLog (<< "Failed listen " << strerror(e)); + InfoLog (<< "Failed listen " << errortostringOS(e)); sane = false; return; } @@ -161,7 +161,7 @@ HttpBase::process(FdSet& fdset) // !jf! this can not be ready in some cases return; default: - ErrLog(<< "Some error reading from socket: " << e); + ErrLog(<< "Some error reading from socket: " << e << " error message " << errortostringOS(e) ); // .bwc. This is almost certainly a bad assert that a nefarious // endpoint could hit. // assert(0); // Transport::error(e); diff --git a/resip/stack/ConnectionManager.cxx b/resip/stack/ConnectionManager.cxx index d8332d45e2..75eb51f6b1 100644 --- a/resip/stack/ConnectionManager.cxx +++ b/resip/stack/ConnectionManager.cxx @@ -11,6 +11,7 @@ #include "resip/stack/InteropHelper.hxx" #include "rutil/Logger.hxx" #include "rutil/Inserter.hxx" +#include "rutil/Errdes.hxx" #include @@ -301,7 +302,7 @@ ConnectionManager::gc(UInt64 relThreshold, unsigned int maxToRemove) struct rlimit rlim; if(getrlimit(RLIMIT_NOFILE, &rlim) != 0) { - ErrLog(<<"Call to getrlimit() for RLIMIT_NOFILE failed: " << strerror(errno)); + ErrLog(<<"Call to getrlimit() for RLIMIT_NOFILE failed: " << errortostringOS(errno)); } else { @@ -393,7 +394,7 @@ ConnectionManager::moveToFlowTimerLru(Connection *connection) void ConnectionManager::process(FdSet& fdset) { - resip_assert( mPollGrp==NULL ); // owner shouldn't call this if polling + resip_assert( mPollGrp==NULL ); // owner shouldn't call this if polling // process the write list for (ConnectionWriteList::iterator writeIter = mWriteHead->begin(); diff --git a/resip/stack/DateCategory.cxx b/resip/stack/DateCategory.cxx index 11e14b87af..3f4480b1e1 100644 --- a/resip/stack/DateCategory.cxx +++ b/resip/stack/DateCategory.cxx @@ -16,6 +16,8 @@ #include "rutil/Socket.hxx" //#include "rutil/WinLeakCheck.hxx" // not compatible with placement new used below +#include "rutil/Errdes.hxx" + using namespace resip; using namespace std; @@ -91,7 +93,7 @@ DateCategory::DateCategory() if (now == ((time_t)-1)) { int e = getErrno(); - DebugLog (<< "Failed to get time: " << strerror(e)); + DebugLog (<< "Failed to get time: " << errortostringOS(e)); Transport::error(e); return; } @@ -163,7 +165,7 @@ DateCategory::setDatetime(time_t datetime) if (gmtp == 0) { int e = getErrno(); - DebugLog (<< "Failed to convert to gmt: " << strerror(e)); + DebugLog (<< "Failed to convert to gmt: " << errortostringOS(e)); Transport::error(e); return false; } @@ -172,7 +174,7 @@ DateCategory::setDatetime(time_t datetime) if (gmtime_r(&datetime, &gmt) == 0) { int e = getErrno(); - DebugLog (<< "Failed to convert to gmt: " << strerror(e)); + DebugLog (<< "Failed to convert to gmt: " << errortostringOS(e)); Transport::error(e); return false; } @@ -460,4 +462,4 @@ DateCategory::encodeParsed(EncodeStream& str) const * Inc. For more information on Vovida Networks, Inc., please see * . * - */ + */ \ No newline at end of file diff --git a/resip/stack/GenericPidfContents.cxx b/resip/stack/GenericPidfContents.cxx index 8257e46c26..bf50aaa2a7 100644 --- a/resip/stack/GenericPidfContents.cxx +++ b/resip/stack/GenericPidfContents.cxx @@ -12,6 +12,7 @@ #include "rutil/Logger.hxx" #include "rutil/Inserter.hxx" #include "rutil/WinLeakCheck.hxx" +#include "rutil/Errdes.hxx" using namespace resip; using namespace std; @@ -812,7 +813,7 @@ GenericPidfContents::generateTimestampData(time_t datetime) if (gmtp == 0) { int e = getErrno(); - DebugLog(<< "Failed to convert to gmt: " << strerror(e)); + DebugLog(<< "Failed to convert to gmt: " << errortostringOS(e)); return Data::Empty; } memcpy(&gmt, gmtp, sizeof(gmt)); @@ -820,7 +821,7 @@ GenericPidfContents::generateTimestampData(time_t datetime) if (gmtime_r(&datetime, &gmt) == 0) { int e = getErrno(); - DebugLog(<< "Failed to convert to gmt: " << strerror(e)); + DebugLog(<< "Failed to convert to gmt: " << errortostringOS(e)); return Data::Empty; } #endif diff --git a/resip/stack/InternalTransport.cxx b/resip/stack/InternalTransport.cxx index 87cdce0b2a..5e7559b060 100644 --- a/resip/stack/InternalTransport.cxx +++ b/resip/stack/InternalTransport.cxx @@ -14,6 +14,7 @@ #include "rutil/DnsUtil.hxx" #include "rutil/Logger.hxx" #include "rutil/WinLeakCheck.hxx" +#include "rutil/Errdes.hxx" using namespace resip; using namespace std; @@ -98,7 +99,7 @@ InternalTransport::socket(TransportType type, IpVersion ipVer) if ( fd == INVALID_SOCKET ) { int e = getErrno(); - ErrLog (<< "Failed to create socket: " << strerror(e)); + ErrLog (<< "Failed to create socket: " << errortostringOS(e)); throw Transport::Exception("Can't create TcpBaseTransport", __FILE__,__LINE__); } @@ -110,7 +111,7 @@ InternalTransport::socket(TransportType type, IpVersion ipVer) if ( ::setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) ) { int e = getErrno(); - InfoLog (<< "Couldn't set sockoptions IPV6_V6ONLY: " << strerror(e)); + InfoLog (<< "Couldn't set sockoptions IPV6_V6ONLY: " << errortostringOS(e)); error(e); throw Exception("Failed setsockopt", __FILE__,__LINE__); } @@ -157,7 +158,7 @@ InternalTransport::bind() if (::getsockname(mFd, &mTuple.getMutableSockaddr(), &len) == SOCKET_ERROR) { int e = getErrno(); - ErrLog (<<"getsockname failed, error=" << e); + ErrLog (<<"getsockname failed, error number = " << e << "error message : " << errortostringOS(e) ); throw Transport::Exception("Could not query port", __FILE__,__LINE__); } } diff --git a/resip/stack/TcpBaseTransport.cxx b/resip/stack/TcpBaseTransport.cxx index 327cfbbfc7..c8a3ca70ab 100644 --- a/resip/stack/TcpBaseTransport.cxx +++ b/resip/stack/TcpBaseTransport.cxx @@ -10,6 +10,7 @@ #include "rutil/Logger.hxx" #include "rutil/NetNs.hxx" #include "resip/stack/TcpBaseTransport.hxx" +#include "rutil/Errdes.hxx" #define RESIPROCATE_SUBSYSTEM Subsystem::TRANSPORT @@ -82,7 +83,7 @@ TcpBaseTransport::init() #endif { int e = getErrno(); - InfoLog (<< "Couldn't set sockoptions SO_REUSEPORT | SO_REUSEADDR: " << strerror(e)); + InfoLog (<< "Couldn't set sockoptions SO_REUSEPORT | SO_REUSEADDR: " << errortostringOS(e)); error(e); throw Exception("Failed setsockopt", __FILE__,__LINE__); } @@ -98,7 +99,7 @@ TcpBaseTransport::init() if (e != 0 ) { int e = getErrno(); - InfoLog (<< "Failed listen " << strerror(e)); + InfoLog (<< "Failed listen " << errortostringOS(e)); error(e); // !cj! deal with errors throw Transport::Exception("Address already in use", __FILE__,__LINE__); @@ -221,7 +222,7 @@ TcpBaseTransport::makeOutgoingConnection(const Tuple &dest, if ( sock == INVALID_SOCKET ) // no socket found - try to free one up and try again { int err = getErrno(); - InfoLog (<< "Failed to create a socket " << strerror(err)); + InfoLog (<< "Failed to create a socket " << errortostringOS(err)); error(err); if(mConnectionManager.gc(ConnectionManager::MinimumGcAge, 1) == 0) { @@ -235,7 +236,7 @@ TcpBaseTransport::makeOutgoingConnection(const Tuple &dest, if ( sock == INVALID_SOCKET ) { err = getErrno(); - WarningLog( << "Error in finding free filedescriptor to use. " << strerror(err)); + WarningLog( << "Error in finding free filedescriptor to use. " << errortostringOS(err)); error(err); failReason = TransportFailure::TransportNoSocket; failSubCode = err; @@ -255,7 +256,7 @@ TcpBaseTransport::makeOutgoingConnection(const Tuple &dest, #endif if(::bind(sock, sa, mTuple.length()) != 0) { - WarningLog( << "Error in binding to source interface address. " << strerror(errno)); + WarningLog( << "Error in binding to source interface address. " << errortostringOS(errno)); failReason = TransportFailure::Failure; failSubCode = errno; return NULL; @@ -288,7 +289,7 @@ TcpBaseTransport::makeOutgoingConnection(const Tuple &dest, default: { // !jf! this has failed - InfoLog( << "Error on TCP connect to " << dest << ", err=" << err << ": " << strerror(err)); + InfoLog( << "Error on TCP connect to " << dest << ", err=" << err << ": " << errortostringOS(err)); error(err); //fdset.clear(sock); closeSocket(sock); @@ -428,7 +429,7 @@ TcpBaseTransport::processPollEvent(FdPollEventMask mask) { void TcpBaseTransport::setRcvBufLen(int buflen) { - resip_assert(0); // not implemented yet + resip_assert(0); // not implemented yet // need to store away the length and use when setting up new connections } diff --git a/resip/stack/TcpConnection.cxx b/resip/stack/TcpConnection.cxx index 11ac608307..640857ac2e 100644 --- a/resip/stack/TcpConnection.cxx +++ b/resip/stack/TcpConnection.cxx @@ -6,6 +6,7 @@ #include "rutil/Socket.hxx" #include "resip/stack/TcpConnection.hxx" #include "resip/stack/Tuple.hxx" +#include "rutil/Errdes.hxx" using namespace resip; @@ -58,11 +59,11 @@ TcpConnection::read( char* buf, int count ) ErrLog (<< "buf is outside your accessible address space."); break; default: - ErrLog (<< "Some other error, code = " << e); + ErrLog (<< "Some other error, code = " << e << " error message : " << errortostringOS(e) ); break; } - InfoLog (<< "Failed read on " << getSocket() << " " << strerror(e)); + InfoLog (<< "Failed read on " << getSocket() << " " << errortostringOS(e)); Transport::error(e); setFailureReason(TransportFailure::ConnectionException, e+2000); return -1; @@ -100,7 +101,7 @@ TcpConnection::write( const char* buf, const int count ) // TCP buffers are backed up - we couldn't write anything - but we shouldn't treat this an error - return we wrote 0 bytes return 0; } - InfoLog (<< "Failed write on " << getSocket() << " " << strerror(e)); + InfoLog (<< "Failed write on " << getSocket() << " " << errortostringOS(e)); Transport::error(e); return -1; } diff --git a/resip/stack/TransportSelector.cxx b/resip/stack/TransportSelector.cxx index 6bae0490bf..0631b6758c 100644 --- a/resip/stack/TransportSelector.cxx +++ b/resip/stack/TransportSelector.cxx @@ -61,6 +61,7 @@ #endif #include +#include "rutil/Errdes.hxx" using namespace resip; @@ -607,7 +608,7 @@ TransportSelector::getFirstInterface(bool is_v4, TransportType type) { int e = getErrno(); Transport::error( e ); - InfoLog(<< "Can't query local hostname : [" << e << "] " << strerror(e) ); + InfoLog(<< "Can't query local hostname : [" << e << "] " << errortostringOS(e) ); throw Transport::Exception("Can't query local hostname", __FILE__, __LINE__); } InfoLog(<< "Local hostname is [" << hostname << "]"); @@ -779,7 +780,7 @@ TransportSelector::determineSourceInterface(SipMessage* msg, const Tuple& target { int e = getErrno(); Transport::error( e ); - InfoLog(<< "Unable to route to " << target << " : [" << e << "] " << strerror(e) ); + InfoLog(<< "Unable to route to " << target << " : [" << e << "] " << errortostringOS(e) ); throw Transport::Exception("Can't find source address for Via", __FILE__,__LINE__); } @@ -789,7 +790,7 @@ TransportSelector::determineSourceInterface(SipMessage* msg, const Tuple& target { int e = getErrno(); Transport::error(e); - InfoLog(<< "Can't determine name of socket " << target << " : " << strerror(e) ); + InfoLog(<< "Can't determine name of socket " << target << " : " << errortostringOS(e) ); throw Transport::Exception("Can't find source address for Via", __FILE__,__LINE__); } @@ -843,7 +844,7 @@ TransportSelector::determineSourceInterface(SipMessage* msg, const Tuple& target //.dcm. OS X 10.5 workaround, we could #ifdef for specific OS X version. if (!(e ==EAFNOSUPPORT || e == EADDRNOTAVAIL)) { - ErrLog(<< "Can't disconnect socket : " << strerror(e) ); + ErrLog(<< "Can't disconnect socket : " << errortostringOS(e) ); Transport::error(e); throw Transport::Exception("Can't disconnect socket", __FILE__,__LINE__); } diff --git a/resip/stack/ssl/DtlsTransport.cxx b/resip/stack/ssl/DtlsTransport.cxx index 62cb9d0460..6558083f24 100644 --- a/resip/stack/ssl/DtlsTransport.cxx +++ b/resip/stack/ssl/DtlsTransport.cxx @@ -49,6 +49,7 @@ #endif #include "rutil/WinLeakCheck.hxx" +#include "rutil/Errdes.hxx" #include #include @@ -245,7 +246,10 @@ DtlsTransport::_read( FdSet& fdset ) switch( err ) { case SSL_ERROR_NONE: - break ; + { + DebugLog( << errortostringSSL(err) ); + break ; + } case SSL_ERROR_SSL: { ERR_error_string_n(ERR_get_error(), errorString, sizeof(errorString)); @@ -256,9 +260,15 @@ DtlsTransport::_read( FdSet& fdset ) } break ; case SSL_ERROR_WANT_READ: - break ; + { + DebugLog( << errortostringSSL(err) ); + break ; + } case SSL_ERROR_WANT_WRITE: - break ; + { + DebugLog( << errortostringSSL(err) ); + break ; + } case SSL_ERROR_SYSCALL: { ERR_error_string_n(ERR_get_error(), errorString, sizeof(errorString)); @@ -281,9 +291,15 @@ DtlsTransport::_read( FdSet& fdset ) } break ; case SSL_ERROR_WANT_CONNECT: - break ; + { + DebugLog( << errortostringSSL(err) ); + break ; + } case SSL_ERROR_WANT_ACCEPT: - break ; + { + DebugLog( << errortostringSSL(err) ); + break ; + } default: break ; } @@ -535,7 +551,10 @@ void DtlsTransport::_write( FdSet& fdset ) switch( err ) { case SSL_ERROR_NONE: - break; + { + DebugLog( << errortostringSSL(err) ); + break ; + } case SSL_ERROR_SSL: { ERR_error_string_n(ERR_get_error(), errorString, sizeof(errorString)); @@ -545,12 +564,18 @@ void DtlsTransport::_write( FdSet& fdset ) } break; case SSL_ERROR_WANT_READ: - retry = 1 ; - break; + { + retry = 1 ; + DebugLog( << errortostringSSL(err) ); + break ; + } case SSL_ERROR_WANT_WRITE: - retry = 1 ; - fdset.setWrite(mFd); - break; + { + retry = 1 ; + fdset.setWrite(mFd); + DebugLog( << errortostringSSL(err) ); + break; + } case SSL_ERROR_SYSCALL: { int e = getErrno(); @@ -576,9 +601,15 @@ void DtlsTransport::_write( FdSet& fdset ) } break ; case SSL_ERROR_WANT_CONNECT: - break; + { + DebugLog( << errortostringSSL(err) ); + break ; + } case SSL_ERROR_WANT_ACCEPT: - break; + { + DebugLog( << errortostringSSL(err) ); + break ; + } default: break ; } @@ -620,7 +651,10 @@ DtlsTransport::_doHandshake( void ) switch (err) { case SSL_ERROR_NONE: - break; + { + DebugLog( << errortostringSSL(err) ); + break ; + } case SSL_ERROR_SSL: { ERR_error_string_n(ERR_get_error(), errorString, sizeof(errorString)); @@ -629,9 +663,15 @@ DtlsTransport::_doHandshake( void ) } break; case SSL_ERROR_WANT_READ: - break; + { + DebugLog( << errortostringSSL(err) ); + break ; + } case SSL_ERROR_WANT_WRITE: - break; + { + DebugLog( << errortostringSSL(err) ); + break ; + } case SSL_ERROR_SYSCALL: { ERR_error_string_n(ERR_get_error(), errorString, sizeof(errorString)); @@ -647,9 +687,15 @@ DtlsTransport::_doHandshake( void ) } break; case SSL_ERROR_WANT_CONNECT: - break; + { + DebugLog( << errortostringSSL(err) ); + break ; + } case SSL_ERROR_WANT_ACCEPT: - break; + { + DebugLog( << errortostringSSL(err) ); + break ; + } default: break ; } diff --git a/resip/stack/ssl/Security.cxx b/resip/stack/ssl/Security.cxx index c2efb56b6d..73fc5a4b57 100644 --- a/resip/stack/ssl/Security.cxx +++ b/resip/stack/ssl/Security.cxx @@ -29,6 +29,7 @@ #include "rutil/WinLeakCheck.hxx" #include "rutil/ssl/SHA1Stream.hxx" +#include "rutil/Errdes.hxx" #if !defined(WIN32) #include @@ -115,7 +116,7 @@ verifyCallback(int iInCode, X509_STORE_CTX *pInStore) snprintf(cBuf2, 500, ", depth=%d %s\n", iDepth, cBuf1); if(!iInCode) { - ErrLog(<< "Error when verifying peer's chain of certificates: " << X509_verify_cert_error_string(pInStore->error) << cBuf2 ); + ErrLog(<< "Error when verifying peer's chain of certificates: " << errortostringX509(pInStore->error) << cBuf2 ); DebugLog(<<"additional validation checks may have failed but only one is ever logged - please check peer certificate carefully"); } @@ -242,7 +243,7 @@ Security::preload() if(stat(fileName.c_str(), &s) < 0) { ErrLog(<<"Error calling stat() for " << fileName.c_str() - << ": " << strerror(errno)); + << ": " << errortostringOS(errno)); } else { @@ -2617,7 +2618,7 @@ BaseSecurity::getCertNames(X509 *cert, std::list &peerNames, X509_NAME_ENTRY* entry = X509_NAME_get_entry(subject,i); resip_assert( entry ); - ASN1_STRING* s = X509_NAME_ENTRY_get_data(entry); + ASN1_STRING* s = X509_NAME_ENTRY_get_data(entry); resip_assert( s ); int t = M_ASN1_STRING_type(s); @@ -3076,8 +3077,8 @@ BaseSecurity::setDHParams(SSL_CTX* ctx) { if (SSL_CTX_set_tmp_ecdh(ctx, ecdh)) { - DebugLog(<<"ECDH initialized"); - } + DebugLog(<<"ECDH initialized"); + } else { WarningLog(<<"unable to initialize ECDH: SSL_CTX_set_tmp_ecdh failed"); diff --git a/resip/stack/ssl/TlsConnection.cxx b/resip/stack/ssl/TlsConnection.cxx index f1f6986fdb..f893d7ad16 100644 --- a/resip/stack/ssl/TlsConnection.cxx +++ b/resip/stack/ssl/TlsConnection.cxx @@ -10,6 +10,7 @@ #include "rutil/Logger.hxx" #include "resip/stack/Uri.hxx" #include "rutil/Socket.hxx" +#include "rutil/Errdes.hxx" #include #include @@ -154,11 +155,11 @@ TlsConnection::~TlsConnection() { // WANT_READ or WANT_WRITE can arise for bi-directional shutdown on // non-blocking sockets, safe to ignore - StackLog( << "Got TLS shutdown error condition of " << err ); + StackLog( << "Got TLS shutdown error condition of " << err << " " << errortostringSSL(err) ); } break; default: - ErrLog(<<"Unexpected error in SSL_shutdown"); + ErrLog(<< "Unexpected error in SSL_shutdown "<< errortostringSSL(err) ); handleOpenSSLErrorQueue(ret, err, "SSL_shutdown"); } } @@ -224,31 +225,31 @@ TlsConnection::checkState() switch (err) { case SSL_ERROR_WANT_READ: - StackLog( << "TLS handshake want read" ); + StackLog( << "TLS handshake want read" << errortostringSSL(err) ); mHandShakeWantsRead = true; return mTlsState; case SSL_ERROR_WANT_WRITE: - StackLog( << "TLS handshake want write" ); + StackLog( << "TLS handshake want write" << errortostringSSL(err) ); ensureWritable(); return mTlsState; case SSL_ERROR_ZERO_RETURN: - StackLog( << "TLS connection closed cleanly"); + StackLog( << "TLS connection closed cleanly" << errortostringSSL(err) ); return mTlsState; case SSL_ERROR_WANT_CONNECT: - StackLog( << "BIO not connected, try later"); + StackLog( << "BIO not connected, try later" << errortostringSSL(err) ); return mTlsState; #if ( OPENSSL_VERSION_NUMBER >= 0x0090702fL ) case SSL_ERROR_WANT_ACCEPT: - StackLog( << "TLS connection want accept" ); + StackLog( << "TLS connection want accept" << errortostringSSL(err) ); return mTlsState; #endif case SSL_ERROR_WANT_X509_LOOKUP: - DebugLog( << "Try later / SSL_ERROR_WANT_X509_LOOKUP"); + DebugLog( << "Try later / SSL_ERROR_WANT_X509_LOOKUP" << errortostringSSL(err) ); return mTlsState; default: @@ -265,7 +266,7 @@ TlsConnection::checkState() StackLog( << "try later"); return mTlsState; } - ErrLog( << "socket error " << e); + ErrLog( << "socket error " << errortostringOS(e) ); Transport::error(e); if(e == 0) { @@ -291,7 +292,7 @@ TlsConnection::checkState() DebugLog(<<"peer supplied a ceritifcate, but it has not been checked or it was checked successfully"); break; default: - ErrLog(<<"peer certificate validation failure: " << X509_verify_cert_error_string(verifyErrorCode)); + ErrLog(<<"peer certificate validation failure: " << errortostringX509(verifyErrorCode)); //X509_verify_cert_error_string(verifyErrorCode)); DebugLog(<<"additional validation checks may have failed but only one is ever logged - please check peer certificate carefully"); break; } @@ -316,7 +317,7 @@ TlsConnection::checkState() } else { - DebugLog(<<"unrecognised/unhandled SSL_get_error result: " << err); + DebugLog(<<"unrecognised/unhandled SSL_get_error result: " << errortostringSSL(err) ); } ErrLog( << "TLS handshake failed "); handleOpenSSLErrorQueue(ok, err, "SSL_do_handshake"); @@ -447,13 +448,13 @@ TlsConnection::read(char* buf, int count ) case SSL_ERROR_WANT_WRITE: case SSL_ERROR_NONE: { - StackLog( << "Got TLS read got condition of " << err ); + StackLog( << "Got TLS read got condition of " << errortostringSSL(err) ); return 0; } break; case SSL_ERROR_ZERO_RETURN: { - DebugLog( << "Got SSL_ERROR_ZERO_RETURN (TLS shutdown by peer)"); + DebugLog( << "Got SSL_ERROR_ZERO_RETURN (TLS shutdown by peer)" << errortostringSSL(err)); return -1; } break; @@ -540,13 +541,13 @@ TlsConnection::write( const char* buf, int count ) case SSL_ERROR_WANT_WRITE: case SSL_ERROR_NONE: { - StackLog( << "Got TLS write got condition of " << err ); + StackLog( << "Got TLS write got condition of " << errortostringSSL(err) ); return 0; } break; case SSL_ERROR_ZERO_RETURN: { - DebugLog( << "Got SSL_ERROR_ZERO_RETURN (TLS shutdown by peer)"); + DebugLog( << "Got SSL_ERROR_ZERO_RETURN (TLS shutdown by peer)" << errortostringSSL(err) ); return -1; } break; diff --git a/resip/stack/test/Resolver.cxx b/resip/stack/test/Resolver.cxx index 505b662be4..d131d91214 100644 --- a/resip/stack/test/Resolver.cxx +++ b/resip/stack/test/Resolver.cxx @@ -21,6 +21,7 @@ #include "rutil/ParseBuffer.hxx" #include "Resolver.hxx" +#include "rutil/Errdes.hxx" #define RESIPROCATE_SUBSYSTEM resip::Subsystem::SIP @@ -88,7 +89,7 @@ Resolver::Resolver(const Uri& uri) : Tuple tuple; if (inet_pton(AF_INET, mHost.c_str(), &tuple.ipv4.s_addr) <= 0) { - DebugLog( << "inet_pton failed to parse address: " << mHost << " " << strerror(errno)); + DebugLog( << "inet_pton failed to parse address: " << mHost << " " << errortostringOS(errno)); assert(0); } tuple.port = mPort; @@ -129,7 +130,7 @@ Resolver::Resolver(const Data& host, int port, TransportType transport) Tuple tuple; if (inet_pton(AF_INET, mHost.c_str(), &tuple.ipv4.s_addr) <= 0) { - DebugLog( << "inet_pton failed to parse address: " << mHost << " " << strerror(errno)); + DebugLog( << "inet_pton failed to parse address: " << mHost << " " << errortostringOS(errno)); assert(0); } tuple.port = mPort; @@ -155,8 +156,8 @@ Resolver::lookupARecords() #else #if defined( WIN32 ) || defined( __APPLE__ ) || defined (__SUNPRO_CC) || defined(__FreeBSD__) - assert(0); // !cj! - int ret = -1; + assert(0); // !cj! + int ret = -1; #else int ret = gethostbyname_r (mHost.c_str(), &hostbuf, buffer, sizeof(buffer), &result, &herrno); #endif @@ -231,7 +232,7 @@ Resolver::getHostName() char buffer[255]; if (gethostname(buffer, sizeof(buffer)) < 0) { - InfoLog (<< "Failed gethostname() " << strerror(errno)); + InfoLog (<< "Failed gethostname() " << errortostringOS(errno)); return "localhost"; } else diff --git a/resip/stack/test/Transceiver.cxx b/resip/stack/test/Transceiver.cxx index b94056fbb6..c7bd5d30e6 100644 --- a/resip/stack/test/Transceiver.cxx +++ b/resip/stack/test/Transceiver.cxx @@ -12,7 +12,7 @@ #include "rutil/DataStream.hxx" #include "rutil/DnsUtil.hxx" #include "rutil/Timer.hxx" - +#include "rutil/Errdes.hxx" #define RESIPROCATE_SUBSYSTEM Subsystem::SIP @@ -116,7 +116,7 @@ Transceiver::receive(int waitMs) int e = errno; if ( err == -1 ) { - InfoLog(<< "Error " << e << " " << strerror(e) << " in select"); + InfoLog(<< "Error " << e << " " << errortostringOS(e) << " in select"); } DebugLog(<<"Calling process in Transceiver::receive"); diff --git a/resip/stack/test/dumpTls.cxx b/resip/stack/test/dumpTls.cxx index 81381620aa..a676be05b4 100644 --- a/resip/stack/test/dumpTls.cxx +++ b/resip/stack/test/dumpTls.cxx @@ -31,6 +31,7 @@ #include "resip/stack/ShutdownMessage.hxx" #include "resip/stack/ssl/Security.hxx" +#include "rutil/Errdes.hxx" using namespace resip; using namespace std; @@ -89,11 +90,11 @@ main(int argc, char* argv[]) // promise to not modify the strings. Thus shouldn't use static string // initializers above! int ret = execvp("ssldump",const_cast(args)); - ErrLog(<< "Can't execvp: return is " << ret <<" errno is " << errno); + ErrLog(<< "Can't execvp: return is " << ret << " errno is " << errno << " err message is " << errortostringOS(errno) ); exit(-1); } - DebugLog(<< "ssldump's pid is " << dumpPid); + DebugLog(<< "ssldump's pid is " << dumpPid << " err message is " << errortostringOS(dumpPid) ); IpVersion version = V4; Data bindInterface; @@ -197,7 +198,13 @@ main(int argc, char* argv[]) { DebugLog( << "Trying to kill process id " << dumpPid); int ret = kill(dumpPid, SIGINT); // ssldump catches INT and does an fflush + + if(ret == 0) //http://linux.die.net/man/3/kill DebugLog( << "Kill returned: " << ret); + else + { + DebugLog( << "Kill failed " << ret << " error number is " << errno <<" error message is " << errortostringOS(errno) ) + } } diff --git a/resip/stack/test/testSipStackInvite.cxx b/resip/stack/test/testSipStackInvite.cxx index 9bd059dcd6..6e189a6b1d 100644 --- a/resip/stack/test/testSipStackInvite.cxx +++ b/resip/stack/test/testSipStackInvite.cxx @@ -4,12 +4,12 @@ #include "rutil/Logger.hxx" #include "rutil/DataStream.hxx" +#include "rutil/Errdes.hxx" #include #include #include - using namespace resip; using namespace std; @@ -65,7 +65,7 @@ main(int argc, char *argv[]) // send the test message to the stack int err = sendto(fd, message, strlen(message), 0, (struct sockaddr*) & sa, sizeof(sa)); - DebugLog(<<"errno="< 0) { tp += NS_INADDRSZ; saw_xdigit = 0; - break; /* '\0' was seen by inet_pton4(). */ + break; /* '\0' was seen by inet_pton4(). */ } return (0); } diff --git a/rutil/Errdes.hxx b/rutil/Errdes.hxx new file mode 100644 index 0000000000..97b82344c8 --- /dev/null +++ b/rutil/Errdes.hxx @@ -0,0 +1,331 @@ +/* +This header file contains functions that will return error message associated with error number/code from following functions : + +-> SSL_ERROR_SYSCALL [http://www.cl.cam.ac.uk/cgi-bin/manpage?3+errno] +-> SSL_get_error [https://www.openssl.org/docs/manmaster/ssl/SSL_get_error.html] +-> X509_verify_cert_error_string(verifyErrorCode) [https://www.openssl.org/docs/manmaster/crypto/X509_STORE_CTX_get_error.html] + +*/ + +/* Q. Why strerror(int errno) function is not used ? (http://www.cplusplus.com/reference/cstring/strerror/) + A. If error code is 22, strerror(int errno) will print "Invalid argument". But this is not so convenient, instead of using this function, + I have created function 'errortostringXX(int errno)' which will print error description in the format "EINVAL (Invalid argument)" + which is more easy to read and understand. + */ + +/*----------------END-------------------END-------------------END-------------------END---------------------END-------------------END----------*/ + +#pragma GCC diagnostic ignored "-Wwrite-strings" + +#ifndef ERRDES_HXX +#define ERRDES_HXX + +#include "Errdes.hxx" +#include +#include + +#define MAX_ERROR_LEN 256 +static char buf[MAX_ERROR_LEN]; + +/* Below are the error description from SSL_ERROR_SYSCALL or strerror(int errno) [http://www.cl.cam.ac.uk/cgi-bin/manpage?3+errno] */ + +static char* messagesOS[] = { +/*0 0 */ "No error 0", +/*EPERM 1 */ "EPERM (Operation not permitted) 1", +/*ENOENT 2 */ "ENOENT (No such file or directory) 2", +/*ESRCH 3 */ "ESRCH (No such process) 3", +/*EINTR 4 */ "EINTR (Interrupted system call) 4", +/*EIO 5 */ "EIO (Input/output error) 5", +/*ENXIO 6 */ "ENXIO (No such device or address) 6", +/*E2BIG 7 */ "E2BIG (Argument list too long) 7", +/*ENOEXEC 8 */ "ENOEXEC (Exec format error) 8", +/*EBADF 9 */ "EBADF (Bad file descriptor) 9", +/*ECHILD 10 */ "ECHILD (No child processes) 10", +/*EAGAIN 11 */ "EAGAIN (Resource temporarily unavailable) 11", +/*ENOMEM 12 */ "ENOMEM (Cannot allocate memory) 12", +/*EACCES 13 */ "EACCES (Permission denied) 13", +/*EFAULT 14 */ "EFAULT (Bad address) 14", +/*ENOTBLK 15 */ "ENOTBLK (Block device required) 15", +/*EBUSY 16 */ "EBUSY (Device or resource busy) 16", +/*EEXIST 17 */ "EEXIST (File exists) 17", +/*EXDEV 18 */ "EXDEV (Invalid cross-device link) 18", +/*ENODEV 19 */ "ENODEV (No such device) 19", +/*ENOTDIR 20 */ "ENOTDIR (Not a directory) 20", +/*EISDIR 21 */ "EISDIR (Is a directory) 21", +/*EINVAL 22 */ "EINVAL (Invalid argument) 22", +/*ENFILE 23 */ "ENFILE (Too many open files in system) 23", +/*EMFILE 24 */ "EMFILE (Too many open files) 24", +/*ENOTTY 25 */ "ENOTTY (Inappropriate ioctl for device) 25", +/*ETXTBSY 26 */ "ETXTBSY (Text file busy) 26", +/*EFBIG 27 */ "EFBIG (File too large) 27", +/*ENOSPC 28 */ "ENOSPC (No space left on device) 28", +/*ESPIPE 29 */ "ESPIPE (Illegal seek) 29", +/*EROFS 30 */ "EROFS (Read-only file system) 30", +/*EMLINK 31 */ "EMLINK (Too many links) 31", +/*EPIPE 32 */ "EPIPE (Broken pipe) 32", +/*EDOM 33 */ "EDOM (Numerical argument out of domain) 33", +/*ERANGE 34 */ "ERANGE (Numerical result out of range) 34", +/*EDEADLK 35 */ "EDEADLK (Resource deadlock avoided) 35", +/*ENAMETOOLONG 36 */ "ENAMETOOLONG (File name too long) 36", +/*ENOLCK 37 */ "ENOLCK (No locks available) 37", +/*ENOSYS 38 */ "ENOSYS (Function not implemented) 38", +/*ENOTEMPTY 39 */ "ENOTEMPTY (Directory not empty) 39", +/*ELOOP 40 */ "ELOOP (Too many levels of symbolic links) 40", +/*EWOULDBLOCK 41 */ "EWOULDBLOCK (Resource temporarily unavailable) 41", +/*ENOMSG 42 */ "ENOMSG (No message of desired type) 42", +/*EIDRM 43 */ "EIDRM (Identifier removed) 43", +/*ECHRNG 44 */ "ECHRNG (Channel number out of range) 44", +/*EL2NSYNC 45 */ "EL2NSYNC (Level 2 not synchronized) 45", +/*EL3HLT 46 */ "EL3HLT (Level 3 halted) 46", +/*EL3RST 47 */ "EL3RST (Level 3 reset) 47", +/*ELNRNG 48 */ "ELNRNG (Link number out of range) 48", +/*EUNATCH 49 */ "EUNATCH (Protocol driver not attached) 49", +/*ENOCSI 50 */ "ENOCSI (No CSI structure available) 50", +/*EL2HLT 51 */ "EL2HLT (Level 2 halted) 51", +/*EBADE 52 */ "EBADE (Invalid exchange) 52", +/*EBADR 53 */ "EBADR (Invalid request descriptor) 53", +/*EXFULL 54 */ "EXFULL (Exchange full) 54", +/*ENOANO 55 */ "ENOANO (No anode) 55", +/*EBADRQC 56 */ "EBADRQC (Invalid request code) 56", +/*EBADSLT 57 */ "EBADSLT (Invalid slot) 57", +/*EDEADLOCK 58 */ "EDEADLOCK (Resource deadlock avoided) 58", +/*EBFONT 59 */ "EBFONT (Bad font file format) 59", +/*ENOSTR 60 */ "ENOSTR (Device not a stream) 60", +/*ENODATA 61 */ "ENODATA (No data available) 61", +/*ETIME 62 */ "ETIME (Timer expired) 62", +/*ENOSR 63 */ "ENOSR (Out of streams resources) 63", +/*ENONET 64 */ "ENONET (Machine is not on the network) 64", +/*ENOPKG 65 */ "ENOPKG (Package not installed) 65", +/*EREMOTE 66 */ "EREMOTE (Object is remote) 66", +/*ENOLINK 67 */ "ENOLINK (Link has been severed) 67", +/*EADV 68 */ "EADV (Advertise error) 68", +/*ESRMNT 69 */ "ESRMNT (Srmount error) 69", +/*ECOMM 70 */ "ECOMM (Communication error on send) 70", +/*EPROTO 71 */ "EPROTO (Protocol error) 71", +/*EMULTIHOP 72 */ "EMULTIHOP (Multihop attempted) 72", +/*EDOTDOT 73 */ "EDOTDOT (RFS specific error) 73", +/*EBADMSG 74 */ "EBADMSG (Bad message) 74", +/*EOVERFLOW 75 */ "EOVERFLOW (Value too large for defined data type) 75", +/*ENOTUNIQ 76 */ "ENOTUNIQ (Name not unique on network) 76", +/*EBADFD 77 */ "EBADFD (File descriptor in bad state) 77", +/*EREMCHG 78 */ "EREMCHG (Remote address changed) 78", +/*ELIBACC 79 */ "ELIBACC (Can not access a needed shared library) 79", +/*ELIBBAD 80 */ "ELIBBAD (Accessing a corrupted shared library) 80", +/*ELIBSCN 81 */ "ELIBSCN (.lib section in a.out corrupted) 81", +/*ELIBMAX 82 */ "ELIBMAX (Attempting to link in too many shared libraries) 82", +/*ELIBEXEC 83 */ "ELIBEXEC (Cannot exec a shared library directly) 83", +/*EILSEQ 84 */ "EILSEQ (Invalid or incomplete multibyte or wide character) 84", +/*ERESTART 85 */ "ERESTART (Interrupted system call should be restarted) 85", +/*ESTRPIPE 86 */ "ESTRPIPE (Streams pipe error) 86", +/*EUSERS 87 */ "EUSERS (Too many users) 87", +/*ENOTSOCK 88 */ "ENOTSOCK (Socket operation on non-socket) 88", +/*EDESTADDRREQ 89 */ "EDESTADDRREQ (Destination address required) 89", +/*EMSGSIZE 90 */ "EMSGSIZE (Message too long) 90", +/*EPROTOTYPE 91 */ "EPROTOTYPE (Protocol wrong type for socket) 91", +/*ENOPROTOOPT 92 */ "ENOPROTOOPT (Protocol not available) 92", +/*EPROTONOSUPPORT 93 */ "EPROTONOSUPPORT (Protocol not supported) 93", +/*ESOCKTNOSUPPORT 94 */ "ESOCKTNOSUPPORT (Socket type not supported) 94", +/*EOPNOTSUPP 95 */ "EOPNOTSUPP (Operation not supported) 95", +/*EPFNOSUPPORT 96 */ "EPFNOSUPPORT (Protocol family not supported) 96", +/*EAFNOSUPPORT 97 */ "EAFNOSUPPORT (Address family not supported by protocol) 97", +/*EADDRINUSE 98 */ "EADDRINUSE (Address already in use) 98", +/*EADDRNOTAVAIL 99 */ "EADDRNOTAVAIL (Cannot assign requested address) 99", +/*ENETDOWN 100 */ "ENETDOWN (Network is down) 100", +/*ENETUNREACH 101 */ "ENETUNREACH (Network is unreachable) 101", +/*ENETRESET 102 */ "ENETRESET (Network dropped connection on reset) 102", +/*ECONNABORTED 103 */ "ECONNABORTED (Software caused connection abort) 103", +/*ECONNRESET 104 */ "ECONNRESET (Connection reset by peer) 104", +/*ENOBUFS 105 */ "ENOBUFS (No buffer space available) 105", +/*EISCONN 106 */ "EISCONN (Transport endpoint is already connected) 106", +/*ENOTCONN 107 */ "ENOTCONN (Transport endpoint is not connected) 107", +/*ESHUTDOWN 108 */ "ESHUTDOWN (Cannot send after transport endpoint shutdown) 108", +/*ETOOMANYREFS 109 */ "ETOOMANYREFS (Too many references: cannot splice) 109", +/*ETIMEDOUT 110 */ "ETIMEDOUT (Connection timed out) 110", +/*ECONNREFUSED 111 */ "ECONNREFUSED (Connection refused) 111", +/*EHOSTDOWN 112 */ "EHOSTDOWN (Host is down) 112", +/*EHOSTUNREACH 113 */ "EHOSTUNREACH (No route to host) 113", +/*EALREADY 114 */ "EALREADY (Operation already in progress) 114", +/*EINPROGRESS 115 */ "EINPROGRESS (Operation now in progress) 115", +/*ESTALE 116 */ "ESTALE (Stale file handle) 116", +/*EUCLEAN 117 */ "EUCLEAN (Structure needs cleaning) 117", +/*ENOTNAM 118 */ "ENOTNAM (Not a XENIX named type file) 118", +/*ENAVAIL 119 */ "ENAVAIL (No XENIX semaphores available) 119", +/*EISNAM 120 */ "EISNAM (Is a named type file) 120", +/*EREMOTEIO 121 */ "EREMOTEIO (Remote I/O error) 121", +/*EDQUOT 122 */ "EDQUOT (Disk quota exceeded) 122", +/*ENOMEDIUM 123 */ "ENOMEDIUM (No medium found) 123", +/*EMEDIUMTYPE 124 */ "EMEDIUMTYPE (Wrong medium type) 124", +/*ECANCELED 125 */ "ECANCELED (Operation canceled) 125", +/*ENOKEY 126 */ "ENOKEY (Required key not available) 126", +/*EKEYEXPIRED 127 */ "EKEYEXPIRED (Key has expired) 127", +/*EKEYREVOKED 128 */ "EKEYREVOKED (Key has been revoked) 128", +/*EKEYREJECTED 129 */ "EKEYREJECTED (Key was rejected by service) 129", +/*EOWNERDEAD 130 */ "EOWNERDEAD (Owner died) 130", +/*ENOTRECOVERABLE 131 */ "ENOTRECOVERABLE (State not recoverable) 131", +/*ERFKILL 132 */ "ERFKILL (Operation not possible due to RF-kill) 132", +/*EHWPOISON 133 */ "EHWPOISON (Memory page has hardware error) 133", +}; +static const int NUM_MESSAGES_OS = sizeof(messagesOS)/sizeof(messagesOS[0]); + +static inline char* errortostringOS(int errnumOS) +{ + if( (errnumOS >= 0 ) && (errnumOS < NUM_MESSAGES_OS)) + { + strncpy(buf,messagesOS[errnumOS],MAX_ERROR_LEN-1); + buf[MAX_ERROR_LEN - 1] = '\0'; /* Ensure null termination */ + } + else + { + snprintf(buf, MAX_ERROR_LEN, "Unknown error %d", errnumOS); + } + return buf; +} + +/*----------------END-------------------END-------------------END-------------------END---------------------END-------------------END----------*/ + +/* Below are the error description from SSL_get_error [https://www.openssl.org/docs/manmaster/ssl/SSL_get_error.html] */ + +static char* messagesSSL[] = { +/* 0 */ "SSL_ERROR_NONE 0", +/* 1 */ "SSL_ERROR_SSL 1", +/* 2 */ "SSL_ERROR_WANT_READ 2", +/* 3 */ "SSL_ERROR_WANT_WRITE 3", +/* 4 */ "SSL_ERROR_WANT_X509_LOOKUP 4", +/* 5 */ "SSL_ERROR_SYSCALL 5", +/* 6 */ "SSL_ERROR_ZERO_RETURN 6", +/* 7 */ "SSL_ERROR_WANT_CONNECT 7", +/* 8 */ "SSL_ERROR_WANT_ACCEPT 8", +}; +static const int NUM_MESSAGES_SSL = sizeof(messagesSSL)/sizeof(messagesSSL[0]); + +static inline char* errortostringSSL(int errnumSSL) +{ + if( (errnumSSL>= 0 ) && (errnumSSL < NUM_MESSAGES_SSL)) + { + strncpy(buf,messagesSSL[errnumSSL],MAX_ERROR_LEN-1); + buf[MAX_ERROR_LEN - 1] = '\0'; /* Ensure null termination */ + } + else + { + snprintf(buf, MAX_ERROR_LEN, "Unknown error %d", errnumSSL); + } + return buf; +} + +/*----------------END-------------------END-------------------END-------------------END---------------------END-------------------END----------*/ + +/* Below are the error description from X509_verify_cert_error_string(verifyErrorCode) [https://www.openssl.org/docs/manmaster/crypto/X509_STORE_CTX_get_error.html] */ + +static char* messagesX509[] = { +/* 0 */ "X509_V_OK 0", +/* 1 */ "illegal error (for uninitialized values, to avoid X509_V_OK) 1", +/* 2 */ "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT 2", +/* 3 */ "X509_V_ERR_UNABLE_TO_GET_CRL 3", +/* 4 */ "X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE 4", +/* 5 */ "X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE 5", +/* 6 */ "X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY 6", +/* 7 */ "X509_V_ERR_CERT_SIGNATURE_FAILURE 7", +/* 8 */ "X509_V_ERR_CRL_SIGNATURE_FAILURE 8", +/* 9 */ "X509_V_ERR_CERT_NOT_YET_VALID 9", +/* 10 */ "X509_V_ERR_CERT_HAS_EXPIRED 10", +/* 11 */ "X509_V_ERR_CRL_NOT_YET_VALID 11", +/* 12 */ "X509_V_ERR_CRL_HAS_EXPIRED 12", +/* 13 */ "X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD 13", +/* 14 */ "X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD 14", +/* 15 */ "X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD 15", +/* 16 */ "X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD 16", +/* 17 */ "X509_V_ERR_OUT_OF_MEM 17", +/* 18 */ "X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT 18", +/* 19 */ "X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN 19", +/* 20 */ "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY 20", +/* 21 */ "X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE 21", +/* 22 */ "X509_V_ERR_CERT_CHAIN_TOO_LONG 22", +/* 23 */ "X509_V_ERR_CERT_REVOKED 23", +/* 24 */ "X509_V_ERR_INVALID_CA 24", +/* 25 */ "X509_V_ERR_PATH_LENGTH_EXCEEDED 25", +/* 26 */ "X509_V_ERR_INVALID_PURPOSE 26", +/* 27 */ "X509_V_ERR_CERT_UNTRUSTED 27", +/* 28 */ "X509_V_ERR_CERT_REJECTED 28", +/* 29 */ "X509_V_ERR_SUBJECT_ISSUER_MISMATCH 29", +/* 30 */ "X509_V_ERR_AKID_SKID_MISMATCH 30", +/* 31 */ "X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH 31", +/* 32 */ "X509_V_ERR_KEYUSAGE_NO_CERTSIGN 32", +/* 33 */ "X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER 33", +/* 34 */ "X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION 34", +/* 35 */ "X509_V_ERR_KEYUSAGE_NO_CRL_SIGN 35", +/* 36 */ "X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION 36", +/* 37 */ "X509_V_ERR_INVALID_NON_CA 37", +/* 38 */ "X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED 38", +/* 39 */ "X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE 39", +/* 40 */ "X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED 40", +/* 41 */ "X509_V_ERR_INVALID_EXTENSION 41", +/* 42 */ "X509_V_ERR_INVALID_POLICY_EXTENSION 42", +/* 43 */ "X509_V_ERR_NO_EXPLICIT_POLICY 43", +/* 44 */ "X509_V_ERR_DIFFERENT_CRL_SCOPE 44", +/* 45 */ "X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE 45", +/* 46 */ "X509_V_ERR_UNNESTED_RESOURCE 46", +/* 47 */ "X509_V_ERR_PERMITTED_VIOLATION 47", +/* 48 */ "X509_V_ERR_EXCLUDED_VIOLATION 48", +/* 49 */ "X509_V_ERR_SUBTREE_MINMAX 49", +/* 50 */ "X509_V_ERR_APPLICATION_VERIFICATION 50", +/* 51 */ "X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE 51", +/* 52 */ "X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX 52", +/* 53 */ "X509_V_ERR_UNSUPPORTED_NAME_SYNTAX 53", +/* 54 */ "X509_V_ERR_CRL_PATH_VALIDATION_ERROR 54", +}; +static const int NUM_MESSAGES_X509 = sizeof(messagesX509)/sizeof(messagesX509[0]); + +static inline char* errortostringX509(int errnumX509) +{ + if( (errnumX509>= 0 ) && (errnumX509 < NUM_MESSAGES_X509)) + { + strncpy(buf,messagesX509[errnumX509],MAX_ERROR_LEN-1); + buf[MAX_ERROR_LEN - 1] = '\0'; /* Ensure null termination */ + } + else + { + snprintf(buf, MAX_ERROR_LEN, "Unknown error %d", errnumX509); + } + return buf; +} + +/*----------------END-------------------END-------------------END-------------------END---------------------END-------------------END----------*/ + +#endif + +/* ==================================================================== + * + * Copyright 2013 Daniel Pocock http://danielpocock.com All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. Neither the name of the author(s) nor the names of any contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * ==================================================================== + * + * + */ diff --git a/rutil/FdPoll.cxx b/rutil/FdPoll.cxx index a9d84e16d7..7acd12fe5e 100644 --- a/rutil/FdPoll.cxx +++ b/rutil/FdPoll.cxx @@ -5,6 +5,7 @@ #include "rutil/FdSetIOObserver.hxx" #include "rutil/Logger.hxx" #include "rutil/BaseException.hxx" +#include "rutil/Errdes.hxx" #include @@ -12,6 +13,7 @@ # include #endif + using namespace resip; #define RESIPROCATE_SUBSYSTEM Subsystem::SIP @@ -341,7 +343,7 @@ FdPollImplFdSet::waitAndProcess(int ms) int err = getErrno(); if ( err!=EINTR ) { - CritLog(<<"select() failed: "< #include "rutil/ResipAssert.h" +#include "rutil/Errdes.hxx" + using namespace resip; #define RESIPROCATE_SUBSYSTEM Subsystem::SIP @@ -125,7 +127,7 @@ FileSystem::Directory::iterator::is_directory() const StackLog(<<"calling stat() for " << mDirent->d_name); if(stat(mFullFilename.c_str(), &s) < 0) { - ErrLog(<<"Error calling stat() for " << mFullFilename.c_str() << ": " << strerror(errno)); + ErrLog(<<"Error calling stat() for " << mFullFilename.c_str() << ": " << strerror(errno) << " message from Errdes.hxx file : " << errortostringOS(errno) ); throw Exception("stat() failed", __FILE__, __LINE__); } return S_ISDIR(s.st_mode); diff --git a/rutil/ServerProcess.cxx b/rutil/ServerProcess.cxx index 31184063da..6ae52aea18 100644 --- a/rutil/ServerProcess.cxx +++ b/rutil/ServerProcess.cxx @@ -18,6 +18,7 @@ #include "rutil/ServerProcess.hxx" #include "rutil/Log.hxx" #include "rutil/Logger.hxx" +#include "rutil/Errdes.hxx" #define RESIPROCATE_SUBSYSTEM resip::Subsystem::SIP @@ -198,7 +199,7 @@ ServerProcess::daemonize() if ((pid = fork()) < 0) { // fork() failed - ErrLog(<<"fork() failed: "< -#include // for getrlimit() +#include // for getrlimit() #endif using namespace resip; @@ -21,21 +22,21 @@ bool resip::makeSocketNonBlocking(Socket fd) { #if defined(WIN32) - unsigned long noBlock = 1; - int errNoBlock = ioctlsocket( fd, FIONBIO , &noBlock ); - if ( errNoBlock != 0 ) - { - return false; - } + unsigned long noBlock = 1; + int errNoBlock = ioctlsocket( fd, FIONBIO , &noBlock ); + if ( errNoBlock != 0 ) + { + return false; + } #else - int flags = fcntl( fd, F_GETFL, 0); - int errNoBlock = fcntl(fd, F_SETFL, flags | O_NONBLOCK ); - if ( errNoBlock != 0 ) // !cj! I may have messed up this line - { - return false; - } + int flags = fcntl( fd, F_GETFL, 0); + int errNoBlock = fcntl(fd, F_SETFL, flags | O_NONBLOCK ); + if ( errNoBlock != 0 ) // !cj! I may have messed up this line + { + return false; + } #endif - return true; + return true; } @@ -43,21 +44,21 @@ bool resip::makeSocketBlocking(Socket fd) { #if defined(WIN32) - unsigned long noBlock = 0; - int errNoBlock = ioctlsocket( fd, FIONBIO , &noBlock ); - if ( errNoBlock != 0 ) - { - return false; - } + unsigned long noBlock = 0; + int errNoBlock = ioctlsocket( fd, FIONBIO , &noBlock ); + if ( errNoBlock != 0 ) + { + return false; + } #else - int flags = fcntl( fd, F_GETFL, 0); - int errNoBlock = fcntl(fd, F_SETFL, flags & ~O_NONBLOCK ); - if ( errNoBlock != 0 ) // !cj! I may have messed up this line - { - return false; - } + int flags = fcntl( fd, F_GETFL, 0); + int errNoBlock = fcntl(fd, F_SETFL, flags & ~O_NONBLOCK ); + if ( errNoBlock != 0 ) // !cj! I may have messed up this line + { + return false; + } #endif - return true; + return true; } @@ -70,7 +71,7 @@ resip::configureConnectedSocket(Socket fd) if ( ::setsockopt ( fd, SOL_SOCKET, SO_NOSIGPIPE, (const char*)&on, sizeof(on)) ) { int e = getErrno(); - ErrLog (<< "Couldn't set sockoption SO_NOSIGPIPE: " << strerror(e)); + ErrLog (<< "Couldn't set sockoption SO_NOSIGPIPE: " << errortostringOS(e)); return false; } #endif @@ -83,10 +84,10 @@ void resip::initNetwork() { #if defined(WIN32) - bool doneInit=false; - if( !doneInit ) - { - doneInit=true; + bool doneInit=false; + if( !doneInit ) + { + doneInit=true; WORD wVersionRequested = MAKEWORD( 2, 2 ); WSADATA wsaData; @@ -118,7 +119,7 @@ resip::initNetwork() resip_assert(0); // if this is failing, try a different version that 2.2, 1.0 or later will likely work exit(1); } - } + } #endif } @@ -137,7 +138,7 @@ resip::closeSocket( Socket fd ) int ret = ::close(fd); if (ret < 0) { - InfoLog (<< "Failed to shutdown socket " << fd << " : " << strerror(errno)); + InfoLog (<< "Failed to shutdown socket " << fd << " : " << errortostringOS(errno)); } return ret; } @@ -167,36 +168,36 @@ resip::increaseLimitFds(unsigned int targetFds) struct rlimit lim; if (getrlimit(RLIMIT_NOFILE, &lim) < 0) - { - CritLog(<<"getrlimit(NOFILE) failed: " << strerror(errno)); - return -1; + { + CritLog(<<"getrlimit(NOFILE) failed: " << errortostringOS(errno)); + return -1; } if (lim.rlim_cur==RLIM_INFINITY || targetFds < lim.rlim_cur) - { + { return targetFds; - } + } int euid = geteuid(); if (lim.rlim_max==RLIM_INFINITY || targetFds < lim.rlim_max) - { - lim.rlim_cur=targetFds; + { + lim.rlim_cur=targetFds; } - else - { - if (euid!=0) - { - CritLog(<<"Attempting to increase number of fds when not root. This probably wont work"); - } + else + { + if (euid!=0) + { + CritLog(<<"Attempting to increase number of fds when not root. This probably wont work"); + } lim.rlim_cur=targetFds; lim.rlim_max=targetFds; } if (setrlimit(RLIMIT_NOFILE, &lim) < 0) - { - CritLog(<<"setrlimit(NOFILE)=(c="<