mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-03 07:32:54 +01:00
Merge pull request #1393 from pocoproject/revert-1103-net-wshadow-fixes
Revert "GH #1050 Net: fix gcc -Wshadow warnings"
This commit is contained in:
commit
4120620ced
@ -109,12 +109,12 @@ public:
|
||||
/// not found.
|
||||
{
|
||||
typename Container::const_iterator it = _list.begin();
|
||||
typename Container::const_iterator itEnd = _list.end();
|
||||
for(; it != itEnd; ++it)
|
||||
typename Container::const_iterator end = _list.end();
|
||||
for(; it != end; ++it)
|
||||
{
|
||||
if (isEqual(it->first, key)) return it;
|
||||
}
|
||||
return itEnd;
|
||||
return end;
|
||||
}
|
||||
|
||||
Iterator find(const KeyType& key)
|
||||
@ -124,12 +124,12 @@ public:
|
||||
/// not found.
|
||||
{
|
||||
typename Container::iterator it = _list.begin();
|
||||
typename Container::iterator itEnd = _list.end();
|
||||
for(; it != itEnd; ++it)
|
||||
typename Container::iterator end = _list.end();
|
||||
for(; it != end; ++it)
|
||||
{
|
||||
if (isEqual(it->first, key)) return it;
|
||||
}
|
||||
return itEnd;
|
||||
return end;
|
||||
}
|
||||
|
||||
Iterator insert(const ValueType& val)
|
||||
@ -203,8 +203,8 @@ public:
|
||||
else
|
||||
{
|
||||
ValueType value(key, Mapped());
|
||||
Iterator itInsert = insert(value);
|
||||
return itInsert->second;
|
||||
Iterator it = insert(value);
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -489,12 +489,12 @@ inline void IPAddress::newIPv6(const void* hostAddr)
|
||||
}
|
||||
|
||||
|
||||
inline void IPAddress::newIPv6(const void* hostAddr, Poco::UInt32 scopeIdentifier)
|
||||
inline void IPAddress::newIPv6(const void* hostAddr, Poco::UInt32 scope)
|
||||
{
|
||||
#ifdef POCO_HAVE_ALIGNMENT
|
||||
new (storage()) Poco::Net::Impl::IPv6AddressImpl(hostAddr, scopeIdentifier);
|
||||
new (storage()) Poco::Net::Impl::IPv6AddressImpl(hostAddr, scope);
|
||||
#else
|
||||
_pImpl = new Poco::Net::Impl::IPv6AddressImpl(hostAddr, scopeIdentifier);
|
||||
_pImpl = new Poco::Net::Impl::IPv6AddressImpl(hostAddr, scope);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -74,9 +74,9 @@ inline const NTPPacket &NTPEventArgs::packet()
|
||||
}
|
||||
|
||||
|
||||
inline void NTPEventArgs::setPacket(NTPPacket &rPacket)
|
||||
inline void NTPEventArgs::setPacket(NTPPacket &packet)
|
||||
{
|
||||
_packet = rPacket;
|
||||
_packet = packet;
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,10 +43,10 @@ AbstractHTTPRequestHandler::~AbstractHTTPRequestHandler()
|
||||
}
|
||||
|
||||
|
||||
void AbstractHTTPRequestHandler::handleRequest(HTTPServerRequest& rRequest, HTTPServerResponse& rResponse)
|
||||
void AbstractHTTPRequestHandler::handleRequest(HTTPServerRequest& request, HTTPServerResponse& response)
|
||||
{
|
||||
_pRequest = &rRequest;
|
||||
_pResponse = &rResponse;
|
||||
_pRequest = &request;
|
||||
_pResponse = &response;
|
||||
if (authenticate())
|
||||
{
|
||||
try
|
||||
@ -55,14 +55,14 @@ void AbstractHTTPRequestHandler::handleRequest(HTTPServerRequest& rRequest, HTTP
|
||||
}
|
||||
catch (Poco::Exception& exc)
|
||||
{
|
||||
if (!rResponse.sent())
|
||||
if (!response.sent())
|
||||
{
|
||||
sendErrorResponse(HTTPResponse::HTTP_INTERNAL_SERVER_ERROR, exc.displayText());
|
||||
}
|
||||
}
|
||||
catch (std::exception& exc)
|
||||
{
|
||||
if (!rResponse.sent())
|
||||
if (!response.sent())
|
||||
{
|
||||
sendErrorResponse(HTTPResponse::HTTP_INTERNAL_SERVER_ERROR, exc.what());
|
||||
}
|
||||
|
@ -36,9 +36,9 @@ DatagramSocket::DatagramSocket(SocketAddress::Family family): Socket(new Datagra
|
||||
}
|
||||
|
||||
|
||||
DatagramSocket::DatagramSocket(const SocketAddress& rAddress, bool reuseAddress): Socket(new DatagramSocketImpl(rAddress.family()))
|
||||
DatagramSocket::DatagramSocket(const SocketAddress& address, bool reuseAddress): Socket(new DatagramSocketImpl(address.family()))
|
||||
{
|
||||
bind(rAddress, reuseAddress);
|
||||
bind(address, reuseAddress);
|
||||
}
|
||||
|
||||
|
||||
@ -71,15 +71,15 @@ DatagramSocket& DatagramSocket::operator = (const Socket& socket)
|
||||
}
|
||||
|
||||
|
||||
void DatagramSocket::connect(const SocketAddress& rAddress)
|
||||
void DatagramSocket::connect(const SocketAddress& address)
|
||||
{
|
||||
impl()->connect(rAddress);
|
||||
impl()->connect(address);
|
||||
}
|
||||
|
||||
|
||||
void DatagramSocket::bind(const SocketAddress& rAddress, bool reuseAddress)
|
||||
void DatagramSocket::bind(const SocketAddress& address, bool reuseAddress)
|
||||
{
|
||||
impl()->bind(rAddress, reuseAddress);
|
||||
impl()->bind(address, reuseAddress);
|
||||
}
|
||||
|
||||
|
||||
@ -95,15 +95,15 @@ int DatagramSocket::receiveBytes(void* buffer, int length, int flags)
|
||||
}
|
||||
|
||||
|
||||
int DatagramSocket::sendTo(const void* buffer, int length, const SocketAddress& rAddress, int flags)
|
||||
int DatagramSocket::sendTo(const void* buffer, int length, const SocketAddress& address, int flags)
|
||||
{
|
||||
return impl()->sendTo(buffer, length, rAddress, flags);
|
||||
return impl()->sendTo(buffer, length, address, flags);
|
||||
}
|
||||
|
||||
|
||||
int DatagramSocket::receiveFrom(void* buffer, int length, SocketAddress& rAddress, int flags)
|
||||
int DatagramSocket::receiveFrom(void* buffer, int length, SocketAddress& address, int flags)
|
||||
{
|
||||
return impl()->receiveFrom(buffer, length, rAddress, flags);
|
||||
return impl()->receiveFrom(buffer, length, address, flags);
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,7 +46,7 @@ DatagramSocketImpl::DatagramSocketImpl(SocketAddress::Family family)
|
||||
}
|
||||
|
||||
|
||||
DatagramSocketImpl::DatagramSocketImpl(poco_socket_t socketfd): SocketImpl(socketfd)
|
||||
DatagramSocketImpl::DatagramSocketImpl(poco_socket_t sockfd): SocketImpl(sockfd)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,8 @@ DialogSocket::DialogSocket():
|
||||
}
|
||||
|
||||
|
||||
DialogSocket::DialogSocket(const SocketAddress& rAddress):
|
||||
StreamSocket(rAddress),
|
||||
DialogSocket::DialogSocket(const SocketAddress& address):
|
||||
StreamSocket(address),
|
||||
_pBuffer(0),
|
||||
_pNext(0),
|
||||
_pEnd(0)
|
||||
|
@ -38,8 +38,8 @@ FilePartSource::FilePartSource(const std::string& path):
|
||||
}
|
||||
|
||||
|
||||
FilePartSource::FilePartSource(const std::string& path, const std::string& rMediaType):
|
||||
PartSource(rMediaType),
|
||||
FilePartSource::FilePartSource(const std::string& path, const std::string& mediaType):
|
||||
PartSource(mediaType),
|
||||
_path(path),
|
||||
_istr(path)
|
||||
{
|
||||
@ -50,10 +50,10 @@ FilePartSource::FilePartSource(const std::string& path, const std::string& rMedi
|
||||
}
|
||||
|
||||
|
||||
FilePartSource::FilePartSource(const std::string& path, const std::string& rFilename, const std::string& rMediaType):
|
||||
PartSource(rMediaType),
|
||||
FilePartSource::FilePartSource(const std::string& path, const std::string& filename, const std::string& mediaType):
|
||||
PartSource(mediaType),
|
||||
_path(path),
|
||||
_filename(rFilename),
|
||||
_filename(filename),
|
||||
_istr(path)
|
||||
{
|
||||
Path p(path);
|
||||
|
@ -261,7 +261,7 @@ std::streamsize HTMLForm::calculateContentLength()
|
||||
}
|
||||
|
||||
|
||||
void HTMLForm::write(std::ostream& ostr, const std::string& rBoundary)
|
||||
void HTMLForm::write(std::ostream& ostr, const std::string& boundary)
|
||||
{
|
||||
if (_encoding == ENCODING_URL)
|
||||
{
|
||||
@ -269,7 +269,7 @@ void HTMLForm::write(std::ostream& ostr, const std::string& rBoundary)
|
||||
}
|
||||
else
|
||||
{
|
||||
_boundary = rBoundary;
|
||||
_boundary = boundary;
|
||||
writeMultipart(ostr);
|
||||
}
|
||||
}
|
||||
@ -359,12 +359,12 @@ void HTMLForm::readMultipart(std::istream& istr, PartHandler& handler)
|
||||
{
|
||||
std::string name = params["name"];
|
||||
std::string value;
|
||||
std::istream& rIstr = reader.stream();
|
||||
int ch = rIstr.get();
|
||||
std::istream& istr = reader.stream();
|
||||
int ch = istr.get();
|
||||
while (ch != eof)
|
||||
{
|
||||
value += (char) ch;
|
||||
ch = rIstr.get();
|
||||
ch = istr.get();
|
||||
}
|
||||
add(name, value);
|
||||
}
|
||||
|
@ -137,15 +137,15 @@ void HTTPAuthenticationParams::fromResponse(const HTTPResponse& response, const
|
||||
bool found = false;
|
||||
while (!found && it != response.end() && icompare(it->first, header) == 0)
|
||||
{
|
||||
const std::string& rHeader = it->second;
|
||||
if (icompare(rHeader, 0, 6, "Basic ") == 0)
|
||||
const std::string& header = it->second;
|
||||
if (icompare(header, 0, 6, "Basic ") == 0)
|
||||
{
|
||||
parse(rHeader.begin() + 6, rHeader.end());
|
||||
parse(header.begin() + 6, header.end());
|
||||
found = true;
|
||||
}
|
||||
else if (icompare(rHeader, 0, 7, "Digest ") == 0)
|
||||
else if (icompare(header, 0, 7, "Digest ") == 0)
|
||||
{
|
||||
parse(rHeader.begin() + 7, rHeader.end());
|
||||
parse(header.begin() + 7, header.end());
|
||||
found = true;
|
||||
}
|
||||
++it;
|
||||
|
@ -52,8 +52,8 @@ HTTPClientSession::HTTPClientSession():
|
||||
}
|
||||
|
||||
|
||||
HTTPClientSession::HTTPClientSession(const StreamSocket& rSocket):
|
||||
HTTPSession(rSocket),
|
||||
HTTPClientSession::HTTPClientSession(const StreamSocket& socket):
|
||||
HTTPSession(socket),
|
||||
_port(HTTPSession::HTTP_PORT),
|
||||
_proxyConfig(_globalProxyConfig),
|
||||
_keepAliveTimeout(DEFAULT_KEEP_ALIVE_TIMEOUT, 0),
|
||||
|
@ -241,11 +241,11 @@ void HTTPRequest::getCredentials(const std::string& header, std::string& scheme,
|
||||
{
|
||||
const std::string& auth = get(header);
|
||||
std::string::const_iterator it = auth.begin();
|
||||
std::string::const_iterator itEnd = auth.end();
|
||||
while (it != itEnd && Poco::Ascii::isSpace(*it)) ++it;
|
||||
while (it != itEnd && !Poco::Ascii::isSpace(*it)) scheme += *it++;
|
||||
while (it != itEnd && Poco::Ascii::isSpace(*it)) ++it;
|
||||
while (it != itEnd) authInfo += *it++;
|
||||
std::string::const_iterator end = auth.end();
|
||||
while (it != end && Poco::Ascii::isSpace(*it)) ++it;
|
||||
while (it != end && !Poco::Ascii::isSpace(*it)) scheme += *it++;
|
||||
while (it != end && Poco::Ascii::isSpace(*it)) ++it;
|
||||
while (it != end) authInfo += *it++;
|
||||
}
|
||||
else throw NotAuthenticatedException();
|
||||
}
|
||||
|
@ -29,15 +29,15 @@ HTTPServer::HTTPServer(HTTPRequestHandlerFactory::Ptr pFactory, Poco::UInt16 por
|
||||
}
|
||||
|
||||
|
||||
HTTPServer::HTTPServer(HTTPRequestHandlerFactory::Ptr pFactory, const ServerSocket& rSocket, HTTPServerParams::Ptr pParams):
|
||||
TCPServer(new HTTPServerConnectionFactory(pParams, pFactory), rSocket, pParams),
|
||||
HTTPServer::HTTPServer(HTTPRequestHandlerFactory::Ptr pFactory, const ServerSocket& socket, HTTPServerParams::Ptr pParams):
|
||||
TCPServer(new HTTPServerConnectionFactory(pParams, pFactory), socket, pParams),
|
||||
_pFactory(pFactory)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
HTTPServer::HTTPServer(HTTPRequestHandlerFactory::Ptr pFactory, Poco::ThreadPool& threadPool, const ServerSocket& rSocket, HTTPServerParams::Ptr pParams):
|
||||
TCPServer(new HTTPServerConnectionFactory(pParams, pFactory), threadPool, rSocket, pParams),
|
||||
HTTPServer::HTTPServer(HTTPRequestHandlerFactory::Ptr pFactory, Poco::ThreadPool& threadPool, const ServerSocket& socket, HTTPServerParams::Ptr pParams):
|
||||
TCPServer(new HTTPServerConnectionFactory(pParams, pFactory), threadPool, socket, pParams),
|
||||
_pFactory(pFactory)
|
||||
{
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ namespace Poco {
|
||||
namespace Net {
|
||||
|
||||
|
||||
HTTPServerConnection::HTTPServerConnection(const StreamSocket& rSocket, HTTPServerParams::Ptr pParams, HTTPRequestHandlerFactory::Ptr pFactory):
|
||||
TCPServerConnection(rSocket),
|
||||
HTTPServerConnection::HTTPServerConnection(const StreamSocket& socket, HTTPServerParams::Ptr pParams, HTTPRequestHandlerFactory::Ptr pFactory):
|
||||
TCPServerConnection(socket),
|
||||
_pParams(pParams),
|
||||
_pFactory(pFactory),
|
||||
_stopped(false)
|
||||
|
@ -33,13 +33,13 @@ namespace Poco {
|
||||
namespace Net {
|
||||
|
||||
|
||||
HTTPServerRequestImpl::HTTPServerRequestImpl(HTTPServerResponseImpl& rResponse, HTTPServerSession& session, HTTPServerParams* pParams):
|
||||
_response(rResponse),
|
||||
HTTPServerRequestImpl::HTTPServerRequestImpl(HTTPServerResponseImpl& response, HTTPServerSession& session, HTTPServerParams* pParams):
|
||||
_response(response),
|
||||
_session(session),
|
||||
_pStream(0),
|
||||
_pParams(pParams, true)
|
||||
{
|
||||
rResponse.attachRequest(this);
|
||||
response.attachRequest(this);
|
||||
|
||||
HTTPHeaderInputStream hs(session);
|
||||
read(hs);
|
||||
|
@ -21,14 +21,14 @@ namespace Poco {
|
||||
namespace Net {
|
||||
|
||||
|
||||
HTTPServerSession::HTTPServerSession(const StreamSocket& rSocket, HTTPServerParams::Ptr pParams):
|
||||
HTTPSession(rSocket, pParams->getKeepAlive()),
|
||||
HTTPServerSession::HTTPServerSession(const StreamSocket& socket, HTTPServerParams::Ptr pParams):
|
||||
HTTPSession(socket, pParams->getKeepAlive()),
|
||||
_firstRequest(true),
|
||||
_keepAliveTimeout(pParams->getKeepAliveTimeout()),
|
||||
_maxKeepAliveRequests(pParams->getMaxKeepAliveRequests())
|
||||
{
|
||||
setTimeout(pParams->getTimeout());
|
||||
socket().setReceiveTimeout(pParams->getTimeout());
|
||||
this->socket().setReceiveTimeout(pParams->getTimeout());
|
||||
}
|
||||
|
||||
|
||||
|
@ -38,8 +38,8 @@ HTTPSession::HTTPSession():
|
||||
}
|
||||
|
||||
|
||||
HTTPSession::HTTPSession(const StreamSocket& rSocket):
|
||||
_socket(rSocket),
|
||||
HTTPSession::HTTPSession(const StreamSocket& socket):
|
||||
_socket(socket),
|
||||
_pBuffer(0),
|
||||
_pCurrent(0),
|
||||
_pEnd(0),
|
||||
@ -50,8 +50,8 @@ HTTPSession::HTTPSession(const StreamSocket& rSocket):
|
||||
}
|
||||
|
||||
|
||||
HTTPSession::HTTPSession(const StreamSocket& rSocket, bool keepAlive):
|
||||
_socket(rSocket),
|
||||
HTTPSession::HTTPSession(const StreamSocket& socket, bool keepAlive):
|
||||
_socket(socket),
|
||||
_pBuffer(0),
|
||||
_pCurrent(0),
|
||||
_pEnd(0),
|
||||
@ -226,9 +226,9 @@ StreamSocket HTTPSession::detachSocket()
|
||||
}
|
||||
|
||||
|
||||
void HTTPSession::attachSocket(const StreamSocket& rSocket)
|
||||
void HTTPSession::attachSocket(const StreamSocket& socket)
|
||||
{
|
||||
_socket = rSocket;
|
||||
_socket = socket;
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,9 +35,9 @@ HTTPSessionFactory::HTTPSessionFactory():
|
||||
}
|
||||
|
||||
|
||||
HTTPSessionFactory::HTTPSessionFactory(const std::string& rProxyHost, Poco::UInt16 port):
|
||||
_proxyHost(rProxyHost),
|
||||
_proxyPort(port)
|
||||
HTTPSessionFactory::HTTPSessionFactory(const std::string& proxyHost, Poco::UInt16 proxyPort):
|
||||
_proxyHost(proxyHost),
|
||||
_proxyPort(proxyPort)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -32,13 +32,13 @@ namespace Poco {
|
||||
namespace Net {
|
||||
|
||||
|
||||
ICMPEventArgs::ICMPEventArgs(const SocketAddress& address, int operationRepetitions, int dataSizeInBytes, int operationTtl):
|
||||
ICMPEventArgs::ICMPEventArgs(const SocketAddress& address, int repetitions, int dataSize, int ttl):
|
||||
_address(address),
|
||||
_sent(0),
|
||||
_dataSize(dataSizeInBytes),
|
||||
_ttl(operationTtl),
|
||||
_rtt(operationRepetitions, 0),
|
||||
_errors(operationRepetitions)
|
||||
_dataSize(dataSize),
|
||||
_ttl(ttl),
|
||||
_rtt(repetitions, 0),
|
||||
_errors(repetitions)
|
||||
{
|
||||
}
|
||||
|
||||
@ -76,11 +76,11 @@ std::string ICMPEventArgs::hostAddress() const
|
||||
}
|
||||
|
||||
|
||||
void ICMPEventArgs::setRepetitions(int operationRepetitions)
|
||||
void ICMPEventArgs::setRepetitions(int repetitions)
|
||||
{
|
||||
_rtt.clear();
|
||||
_rtt.resize(operationRepetitions, 0);
|
||||
_errors.assign(operationRepetitions, "");
|
||||
_rtt.resize(repetitions, 0);
|
||||
_errors.assign(repetitions, "");
|
||||
}
|
||||
|
||||
|
||||
@ -101,13 +101,13 @@ ICMPEventArgs ICMPEventArgs::operator ++ (int)
|
||||
|
||||
int ICMPEventArgs::received() const
|
||||
{
|
||||
int ret = 0;
|
||||
int received = 0;
|
||||
|
||||
for (int i = 0; i < _rtt.size(); ++i)
|
||||
{
|
||||
if (_rtt[i]) ++ret;
|
||||
if (_rtt[i]) ++received;
|
||||
}
|
||||
return ret;
|
||||
return received;
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,11 +26,11 @@ namespace Poco {
|
||||
namespace Net {
|
||||
|
||||
|
||||
ICMPSocket::ICMPSocket(IPAddress::Family family, int dataSizeInBytes, int ttlValue, int socketTimeout):
|
||||
Socket(new ICMPSocketImpl(family, dataSizeInBytes, ttlValue, socketTimeout)),
|
||||
_dataSize(dataSizeInBytes),
|
||||
_ttl(ttlValue),
|
||||
_timeout(socketTimeout)
|
||||
ICMPSocket::ICMPSocket(IPAddress::Family family, int dataSize, int ttl, int timeout):
|
||||
Socket(new ICMPSocketImpl(family, dataSize, ttl, timeout)),
|
||||
_dataSize(dataSize),
|
||||
_ttl(ttl),
|
||||
_timeout(timeout)
|
||||
{
|
||||
}
|
||||
|
||||
@ -66,15 +66,15 @@ ICMPSocket& ICMPSocket::operator = (const Socket& socket)
|
||||
}
|
||||
|
||||
|
||||
int ICMPSocket::sendTo(const SocketAddress& rAddress, int flags)
|
||||
int ICMPSocket::sendTo(const SocketAddress& address, int flags)
|
||||
{
|
||||
return impl()->sendTo(0, 0, rAddress, flags);
|
||||
return impl()->sendTo(0, 0, address, flags);
|
||||
}
|
||||
|
||||
|
||||
int ICMPSocket::receiveFrom(SocketAddress& rAddress, int flags)
|
||||
int ICMPSocket::receiveFrom(SocketAddress& address, int flags)
|
||||
{
|
||||
return impl()->receiveFrom(0, 0, rAddress, flags);
|
||||
return impl()->receiveFrom(0, 0, address, flags);
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,14 +45,14 @@ ICMPSocketImpl::~ICMPSocketImpl()
|
||||
}
|
||||
|
||||
|
||||
int ICMPSocketImpl::sendTo(const void*, int, const SocketAddress& rAddress, int flags)
|
||||
int ICMPSocketImpl::sendTo(const void*, int, const SocketAddress& address, int flags)
|
||||
{
|
||||
int n = SocketImpl::sendTo(_icmpPacket.packet(), _icmpPacket.packetSize(), rAddress, flags);
|
||||
int n = SocketImpl::sendTo(_icmpPacket.packet(), _icmpPacket.packetSize(), address, flags);
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
int ICMPSocketImpl::receiveFrom(void*, int, SocketAddress& rAddress, int flags)
|
||||
int ICMPSocketImpl::receiveFrom(void*, int, SocketAddress& address, int flags)
|
||||
{
|
||||
int maxPacketSize = _icmpPacket.maxPacketSize();
|
||||
unsigned char* buffer = new unsigned char[maxPacketSize];
|
||||
@ -68,7 +68,7 @@ int ICMPSocketImpl::receiveFrom(void*, int, SocketAddress& rAddress, int flags)
|
||||
// fake ping responses will cause an endless loop.
|
||||
throw TimeoutException();
|
||||
}
|
||||
SocketImpl::receiveFrom(buffer, maxPacketSize, rAddress, flags);
|
||||
SocketImpl::receiveFrom(buffer, maxPacketSize, address, flags);
|
||||
}
|
||||
while (!_icmpPacket.validReplyID(buffer, maxPacketSize));
|
||||
}
|
||||
|
@ -60,39 +60,39 @@ IPAddress::IPAddress()
|
||||
}
|
||||
|
||||
|
||||
IPAddress::IPAddress(const IPAddress& rAddr)
|
||||
IPAddress::IPAddress(const IPAddress& addr)
|
||||
{
|
||||
if (rAddr.family() == IPv4)
|
||||
newIPv4(rAddr.addr());
|
||||
if (addr.family() == IPv4)
|
||||
newIPv4(addr.addr());
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
else
|
||||
newIPv6(rAddr.addr(), rAddr.scope());
|
||||
newIPv6(addr.addr(), addr.scope());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
IPAddress::IPAddress(Family addressFamily)
|
||||
IPAddress::IPAddress(Family family)
|
||||
{
|
||||
if (addressFamily == IPv4)
|
||||
if (family == IPv4)
|
||||
newIPv4();
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
else if (addressFamily == IPv6)
|
||||
else if (family == IPv6)
|
||||
newIPv6();
|
||||
#endif
|
||||
else throw Poco::InvalidArgumentException("Invalid or unsupported address family passed to IPAddress()");
|
||||
}
|
||||
|
||||
|
||||
IPAddress::IPAddress(const std::string& rAddr)
|
||||
IPAddress::IPAddress(const std::string& addr)
|
||||
{
|
||||
IPv4AddressImpl empty4 = IPv4AddressImpl();
|
||||
if (rAddr.empty() || trim(rAddr) == "0.0.0.0")
|
||||
if (addr.empty() || trim(addr) == "0.0.0.0")
|
||||
{
|
||||
newIPv4(empty4.addr());
|
||||
return;
|
||||
}
|
||||
|
||||
IPv4AddressImpl addr4(IPv4AddressImpl::parse(rAddr));
|
||||
IPv4AddressImpl addr4(IPv4AddressImpl::parse(addr));
|
||||
if (addr4 != empty4)
|
||||
{
|
||||
newIPv4(addr4.addr());
|
||||
@ -101,13 +101,13 @@ IPAddress::IPAddress(const std::string& rAddr)
|
||||
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
IPv6AddressImpl empty6 = IPv6AddressImpl();
|
||||
if (rAddr.empty() || trim(rAddr) == "::")
|
||||
if (addr.empty() || trim(addr) == "::")
|
||||
{
|
||||
newIPv6(empty6.addr());
|
||||
return;
|
||||
}
|
||||
|
||||
IPv6AddressImpl addr6(IPv6AddressImpl::parse(rAddr));
|
||||
IPv6AddressImpl addr6(IPv6AddressImpl::parse(addr));
|
||||
if (addr6 != IPv6AddressImpl())
|
||||
{
|
||||
newIPv6(addr6.addr(), addr6.scope());
|
||||
@ -115,22 +115,22 @@ IPAddress::IPAddress(const std::string& rAddr)
|
||||
}
|
||||
#endif
|
||||
|
||||
throw InvalidAddressException(rAddr);
|
||||
throw InvalidAddressException(addr);
|
||||
}
|
||||
|
||||
|
||||
IPAddress::IPAddress(const std::string& rAddr, Family addressFamily)
|
||||
IPAddress::IPAddress(const std::string& addr, Family family)
|
||||
{
|
||||
if (addressFamily == IPv4)
|
||||
if (family == IPv4)
|
||||
{
|
||||
IPv4AddressImpl addr4(IPv4AddressImpl::parse(rAddr));
|
||||
IPv4AddressImpl addr4(IPv4AddressImpl::parse(addr));
|
||||
newIPv4(addr4.addr());
|
||||
return;
|
||||
}
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
else if (addressFamily == IPv6)
|
||||
else if (family == IPv6)
|
||||
{
|
||||
IPv6AddressImpl addr6(IPv6AddressImpl::parse(rAddr));
|
||||
IPv6AddressImpl addr6(IPv6AddressImpl::parse(addr));
|
||||
newIPv6(addr6.addr(), addr6.scope());
|
||||
return;
|
||||
}
|
||||
@ -139,36 +139,36 @@ IPAddress::IPAddress(const std::string& rAddr, Family addressFamily)
|
||||
}
|
||||
|
||||
|
||||
IPAddress::IPAddress(const void* pAddr, poco_socklen_t addressLength)
|
||||
IPAddress::IPAddress(const void* addr, poco_socklen_t length)
|
||||
#ifndef POCO_HAVE_ALIGNMENT
|
||||
: _pImpl(0)
|
||||
#endif
|
||||
{
|
||||
if (addressLength == sizeof(struct in_addr))
|
||||
newIPv4(pAddr);
|
||||
if (length == sizeof(struct in_addr))
|
||||
newIPv4(addr);
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
else if (addressLength == sizeof(struct in6_addr))
|
||||
newIPv6(pAddr);
|
||||
else if (length == sizeof(struct in6_addr))
|
||||
newIPv6(addr);
|
||||
#endif
|
||||
else throw Poco::InvalidArgumentException("Invalid address length passed to IPAddress()");
|
||||
}
|
||||
|
||||
|
||||
IPAddress::IPAddress(const void* pAddr, poco_socklen_t addressLength, Poco::UInt32 scopeIdentifier)
|
||||
IPAddress::IPAddress(const void* addr, poco_socklen_t length, Poco::UInt32 scope)
|
||||
{
|
||||
if (addressLength == sizeof(struct in_addr))
|
||||
newIPv4(pAddr);
|
||||
if (length == sizeof(struct in_addr))
|
||||
newIPv4(addr);
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
else if (addressLength == sizeof(struct in6_addr))
|
||||
newIPv6(pAddr, scopeIdentifier);
|
||||
else if (length == sizeof(struct in6_addr))
|
||||
newIPv6(addr, scope);
|
||||
#endif
|
||||
else throw Poco::InvalidArgumentException("Invalid address length passed to IPAddress()");
|
||||
}
|
||||
|
||||
|
||||
IPAddress::IPAddress(unsigned prefix, Family addressFamily)
|
||||
IPAddress::IPAddress(unsigned prefix, Family family)
|
||||
{
|
||||
if (addressFamily == IPv4)
|
||||
if (family == IPv4)
|
||||
{
|
||||
if (prefix <= 32)
|
||||
newIPv4(prefix);
|
||||
@ -176,7 +176,7 @@ IPAddress::IPAddress(unsigned prefix, Family addressFamily)
|
||||
throw Poco::InvalidArgumentException("Invalid prefix length passed to IPAddress()");
|
||||
}
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
else if (addressFamily == IPv6)
|
||||
else if (family == IPv6)
|
||||
{
|
||||
if (prefix <= 128)
|
||||
newIPv6(prefix);
|
||||
@ -209,11 +209,11 @@ IPAddress::IPAddress(const SOCKET_ADDRESS& socket_address)
|
||||
|
||||
IPAddress::IPAddress(const struct sockaddr& sockaddr)
|
||||
{
|
||||
unsigned short addressFamily = sockaddr.sa_family;
|
||||
if (addressFamily == AF_INET)
|
||||
unsigned short family = sockaddr.sa_family;
|
||||
if (family == AF_INET)
|
||||
newIPv4(&reinterpret_cast<const struct sockaddr_in*>(&sockaddr)->sin_addr);
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
else if (addressFamily == AF_INET6)
|
||||
else if (family == AF_INET6)
|
||||
newIPv6(&reinterpret_cast<const struct sockaddr_in6*>(&sockaddr)->sin6_addr,
|
||||
reinterpret_cast<const struct sockaddr_in6*>(&sockaddr)->sin6_scope_id);
|
||||
#endif
|
||||
@ -227,16 +227,16 @@ IPAddress::~IPAddress()
|
||||
}
|
||||
|
||||
|
||||
IPAddress& IPAddress::operator = (const IPAddress& rAddr)
|
||||
IPAddress& IPAddress::operator = (const IPAddress& addr)
|
||||
{
|
||||
if (&rAddr != this)
|
||||
if (&addr != this)
|
||||
{
|
||||
destruct();
|
||||
if (rAddr.family() == IPAddress::IPv4)
|
||||
newIPv4(rAddr.addr());
|
||||
if (addr.family() == IPAddress::IPv4)
|
||||
newIPv4(addr.addr());
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
else if (rAddr.family() == IPAddress::IPv6)
|
||||
newIPv6(rAddr.addr(), rAddr.scope());
|
||||
else if (addr.family() == IPAddress::IPv6)
|
||||
newIPv6(addr.addr(), addr.scope());
|
||||
#endif
|
||||
else
|
||||
throw Poco::InvalidArgumentException("Invalid or unsupported address family");
|
||||
@ -553,16 +553,16 @@ bool IPAddress::tryParse(const std::string& addr, IPAddress& result)
|
||||
}
|
||||
|
||||
|
||||
void IPAddress::mask(const IPAddress& rMask)
|
||||
void IPAddress::mask(const IPAddress& mask)
|
||||
{
|
||||
IPAddress null;
|
||||
pImpl()->mask(rMask.pImpl(), null.pImpl());
|
||||
pImpl()->mask(mask.pImpl(), null.pImpl());
|
||||
}
|
||||
|
||||
|
||||
void IPAddress::mask(const IPAddress& rMask, const IPAddress& set)
|
||||
void IPAddress::mask(const IPAddress& mask, const IPAddress& set)
|
||||
{
|
||||
pImpl()->mask(rMask.pImpl(), set.pImpl());
|
||||
pImpl()->mask(mask.pImpl(), set.pImpl());
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,31 +86,31 @@ IPv4AddressImpl::IPv4AddressImpl()
|
||||
}
|
||||
|
||||
|
||||
IPv4AddressImpl::IPv4AddressImpl(const void* pAddr)
|
||||
IPv4AddressImpl::IPv4AddressImpl(const void* addr)
|
||||
{
|
||||
std::memcpy(&_addr, pAddr, sizeof(_addr));
|
||||
std::memcpy(&_addr, addr, sizeof(_addr));
|
||||
}
|
||||
|
||||
|
||||
IPv4AddressImpl::IPv4AddressImpl(unsigned prefix)
|
||||
{
|
||||
UInt32 address = (prefix == 32) ? 0xffffffff : ~(0xffffffff >> prefix);
|
||||
_addr.s_addr = ByteOrder::toNetwork(address);
|
||||
UInt32 addr = (prefix == 32) ? 0xffffffff : ~(0xffffffff >> prefix);
|
||||
_addr.s_addr = ByteOrder::toNetwork(addr);
|
||||
}
|
||||
|
||||
|
||||
IPv4AddressImpl::IPv4AddressImpl(const IPv4AddressImpl& rAddr)
|
||||
IPv4AddressImpl::IPv4AddressImpl(const IPv4AddressImpl& addr)
|
||||
{
|
||||
std::memcpy(&_addr, &rAddr._addr, sizeof(_addr));
|
||||
std::memcpy(&_addr, &addr._addr, sizeof(_addr));
|
||||
}
|
||||
|
||||
|
||||
IPv4AddressImpl& IPv4AddressImpl::operator = (const IPv4AddressImpl& rAddr)
|
||||
IPv4AddressImpl& IPv4AddressImpl::operator = (const IPv4AddressImpl& addr)
|
||||
{
|
||||
if (this == &rAddr)
|
||||
if (this == &addr)
|
||||
return *this;
|
||||
|
||||
std::memcpy(&_addr, &rAddr._addr, sizeof(_addr));
|
||||
std::memcpy(&_addr, &addr._addr, sizeof(_addr));
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -199,10 +199,10 @@ bool IPv4AddressImpl::isLinkLocal() const
|
||||
|
||||
bool IPv4AddressImpl::isSiteLocal() const
|
||||
{
|
||||
UInt32 address = ntohl(_addr.s_addr);
|
||||
return (address & 0xFF000000) == 0x0A000000 || // 10.0.0.0/24
|
||||
(address & 0xFFFF0000) == 0xC0A80000 || // 192.68.0.0/16
|
||||
(address >= 0xAC100000 && address <= 0xAC1FFFFF); // 172.16.0.0 to 172.31.255.255
|
||||
UInt32 addr = ntohl(_addr.s_addr);
|
||||
return (addr & 0xFF000000) == 0x0A000000 || // 10.0.0.0/24
|
||||
(addr & 0xFFFF0000) == 0xC0A80000 || // 192.68.0.0/16
|
||||
(addr >= 0xAC100000 && addr <= 0xAC1FFFFF); // 172.16.0.0 to 172.31.255.255
|
||||
}
|
||||
|
||||
|
||||
@ -250,8 +250,8 @@ bool IPv4AddressImpl::isOrgLocalMC() const
|
||||
|
||||
bool IPv4AddressImpl::isGlobalMC() const
|
||||
{
|
||||
UInt32 address = ntohl(_addr.s_addr);
|
||||
return address >= 0xE0000100 && address <= 0xEE000000; // 224.0.1.0 to 238.255.255.255
|
||||
UInt32 addr = ntohl(_addr.s_addr);
|
||||
return addr >= 0xE0000100 && addr <= 0xEE000000; // 224.0.1.0 to 238.255.255.255
|
||||
}
|
||||
|
||||
|
||||
@ -299,26 +299,26 @@ IPAddressImpl* IPv4AddressImpl::clone() const
|
||||
}
|
||||
|
||||
|
||||
IPv4AddressImpl IPv4AddressImpl::operator & (const IPv4AddressImpl& rAddr) const
|
||||
IPv4AddressImpl IPv4AddressImpl::operator & (const IPv4AddressImpl& addr) const
|
||||
{
|
||||
IPv4AddressImpl result(&_addr);
|
||||
result._addr.s_addr &= rAddr._addr.s_addr;
|
||||
result._addr.s_addr &= addr._addr.s_addr;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
IPv4AddressImpl IPv4AddressImpl::operator | (const IPv4AddressImpl& rAddr) const
|
||||
IPv4AddressImpl IPv4AddressImpl::operator | (const IPv4AddressImpl& addr) const
|
||||
{
|
||||
IPv4AddressImpl result(&_addr);
|
||||
result._addr.s_addr |= rAddr._addr.s_addr;
|
||||
result._addr.s_addr |= addr._addr.s_addr;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
IPv4AddressImpl IPv4AddressImpl::operator ^ (const IPv4AddressImpl& rAddr) const
|
||||
IPv4AddressImpl IPv4AddressImpl::operator ^ (const IPv4AddressImpl& addr) const
|
||||
{
|
||||
IPv4AddressImpl result(&_addr);
|
||||
result._addr.s_addr ^= rAddr._addr.s_addr;
|
||||
result._addr.s_addr ^= addr._addr.s_addr;
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -331,15 +331,15 @@ IPv4AddressImpl result(&_addr);
|
||||
}
|
||||
|
||||
|
||||
bool IPv4AddressImpl::operator == (const IPv4AddressImpl& rAddr) const
|
||||
bool IPv4AddressImpl::operator == (const IPv4AddressImpl& addr) const
|
||||
{
|
||||
return 0 == std::memcmp(&rAddr._addr, &_addr, sizeof(_addr));
|
||||
return 0 == std::memcmp(&addr._addr, &_addr, sizeof(_addr));
|
||||
}
|
||||
|
||||
|
||||
bool IPv4AddressImpl::operator != (const IPv4AddressImpl& rAddr) const
|
||||
bool IPv4AddressImpl::operator != (const IPv4AddressImpl& addr) const
|
||||
{
|
||||
return !(*this == rAddr);
|
||||
return !(*this == addr);
|
||||
}
|
||||
|
||||
|
||||
@ -357,31 +357,31 @@ IPv6AddressImpl::IPv6AddressImpl(): _scope(0)
|
||||
}
|
||||
|
||||
|
||||
IPv6AddressImpl::IPv6AddressImpl(const void* pAddr): _scope(0)
|
||||
IPv6AddressImpl::IPv6AddressImpl(const void* addr): _scope(0)
|
||||
{
|
||||
std::memcpy(&_addr, pAddr, sizeof(_addr));
|
||||
std::memcpy(&_addr, addr, sizeof(_addr));
|
||||
}
|
||||
|
||||
|
||||
IPv6AddressImpl::IPv6AddressImpl(const void* pAddr, Poco::UInt32 scopeIdentifier): _scope(scopeIdentifier)
|
||||
IPv6AddressImpl::IPv6AddressImpl(const void* addr, Poco::UInt32 scope): _scope(scope)
|
||||
{
|
||||
std::memcpy(&_addr, pAddr, sizeof(_addr));
|
||||
std::memcpy(&_addr, addr, sizeof(_addr));
|
||||
}
|
||||
|
||||
|
||||
IPv6AddressImpl::IPv6AddressImpl(const IPv6AddressImpl& rAddr): _scope(rAddr._scope)
|
||||
IPv6AddressImpl::IPv6AddressImpl(const IPv6AddressImpl& addr): _scope(addr._scope)
|
||||
{
|
||||
std::memcpy((void*) &_addr, (void*) &rAddr._addr, sizeof(_addr));
|
||||
std::memcpy((void*) &_addr, (void*) &addr._addr, sizeof(_addr));
|
||||
}
|
||||
|
||||
|
||||
IPv6AddressImpl& IPv6AddressImpl::operator = (const IPv6AddressImpl& rAddr)
|
||||
IPv6AddressImpl& IPv6AddressImpl::operator = (const IPv6AddressImpl& addr)
|
||||
{
|
||||
if (this == &rAddr)
|
||||
if (this == &addr)
|
||||
return *this;
|
||||
|
||||
_scope = rAddr._scope;
|
||||
std::memcpy(&_addr, &rAddr._addr, sizeof(_addr));
|
||||
_scope = addr._scope;
|
||||
std::memcpy(&_addr, &addr._addr, sizeof(_addr));
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -516,16 +516,16 @@ unsigned IPv6AddressImpl::prefixLength() const
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
for (int i = 3; i >= 0; --i)
|
||||
{
|
||||
unsigned address = ntohl(_addr.s6_addr32[i]);
|
||||
if ((bits = maskBits(address, 32))) return (bitPos - (32 - bits));
|
||||
unsigned addr = ntohl(_addr.s6_addr32[i]);
|
||||
if ((bits = maskBits(addr, 32))) return (bitPos - (32 - bits));
|
||||
bitPos -= 32;
|
||||
}
|
||||
return 0;
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
for (int i = 7; i >= 0; --i)
|
||||
{
|
||||
unsigned short address = ByteOrder::fromNetwork(_addr.s6_addr16[i]);
|
||||
if ((bits = maskBits(address, 16))) return (bitPos - (16 - bits));
|
||||
unsigned short addr = ByteOrder::fromNetwork(_addr.s6_addr16[i]);
|
||||
if ((bits = maskBits(addr, 16))) return (bitPos - (16 - bits));
|
||||
bitPos -= 16;
|
||||
}
|
||||
return 0;
|
||||
@ -696,77 +696,77 @@ IPAddressImpl* IPv6AddressImpl::clone() const
|
||||
}
|
||||
|
||||
|
||||
IPv6AddressImpl IPv6AddressImpl::operator & (const IPv6AddressImpl& rAddr) const
|
||||
IPv6AddressImpl IPv6AddressImpl::operator & (const IPv6AddressImpl& addr) const
|
||||
{
|
||||
if (_scope != rAddr._scope)
|
||||
if (_scope != addr._scope)
|
||||
throw Poco::InvalidArgumentException("Scope ID of passed IPv6 address does not match with the source one.");
|
||||
|
||||
IPv6AddressImpl result(*this);
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
result._addr.s6_addr16[0] &= rAddr._addr.s6_addr16[0];
|
||||
result._addr.s6_addr16[1] &= rAddr._addr.s6_addr16[1];
|
||||
result._addr.s6_addr16[2] &= rAddr._addr.s6_addr16[2];
|
||||
result._addr.s6_addr16[3] &= rAddr._addr.s6_addr16[3];
|
||||
result._addr.s6_addr16[4] &= rAddr._addr.s6_addr16[4];
|
||||
result._addr.s6_addr16[5] &= rAddr._addr.s6_addr16[5];
|
||||
result._addr.s6_addr16[6] &= rAddr._addr.s6_addr16[6];
|
||||
result._addr.s6_addr16[7] &= rAddr._addr.s6_addr16[7];
|
||||
result._addr.s6_addr16[0] &= addr._addr.s6_addr16[0];
|
||||
result._addr.s6_addr16[1] &= addr._addr.s6_addr16[1];
|
||||
result._addr.s6_addr16[2] &= addr._addr.s6_addr16[2];
|
||||
result._addr.s6_addr16[3] &= addr._addr.s6_addr16[3];
|
||||
result._addr.s6_addr16[4] &= addr._addr.s6_addr16[4];
|
||||
result._addr.s6_addr16[5] &= addr._addr.s6_addr16[5];
|
||||
result._addr.s6_addr16[6] &= addr._addr.s6_addr16[6];
|
||||
result._addr.s6_addr16[7] &= addr._addr.s6_addr16[7];
|
||||
#else
|
||||
result._addr.s6_addr32[0] &= rAddr._addr.s6_addr32[0];
|
||||
result._addr.s6_addr32[1] &= rAddr._addr.s6_addr32[1];
|
||||
result._addr.s6_addr32[2] &= rAddr._addr.s6_addr32[2];
|
||||
result._addr.s6_addr32[3] &= rAddr._addr.s6_addr32[3];
|
||||
result._addr.s6_addr32[0] &= addr._addr.s6_addr32[0];
|
||||
result._addr.s6_addr32[1] &= addr._addr.s6_addr32[1];
|
||||
result._addr.s6_addr32[2] &= addr._addr.s6_addr32[2];
|
||||
result._addr.s6_addr32[3] &= addr._addr.s6_addr32[3];
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
IPv6AddressImpl IPv6AddressImpl::operator | (const IPv6AddressImpl& rAddr) const
|
||||
IPv6AddressImpl IPv6AddressImpl::operator | (const IPv6AddressImpl& addr) const
|
||||
{
|
||||
if (_scope != rAddr._scope)
|
||||
if (_scope != addr._scope)
|
||||
throw Poco::InvalidArgumentException("Scope ID of passed IPv6 address does not match with the source one.");
|
||||
|
||||
IPv6AddressImpl result(*this);
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
result._addr.s6_addr16[0] |= rAddr._addr.s6_addr16[0];
|
||||
result._addr.s6_addr16[1] |= rAddr._addr.s6_addr16[1];
|
||||
result._addr.s6_addr16[2] |= rAddr._addr.s6_addr16[2];
|
||||
result._addr.s6_addr16[3] |= rAddr._addr.s6_addr16[3];
|
||||
result._addr.s6_addr16[4] |= rAddr._addr.s6_addr16[4];
|
||||
result._addr.s6_addr16[5] |= rAddr._addr.s6_addr16[5];
|
||||
result._addr.s6_addr16[6] |= rAddr._addr.s6_addr16[6];
|
||||
result._addr.s6_addr16[7] |= rAddr._addr.s6_addr16[7];
|
||||
result._addr.s6_addr16[0] |= addr._addr.s6_addr16[0];
|
||||
result._addr.s6_addr16[1] |= addr._addr.s6_addr16[1];
|
||||
result._addr.s6_addr16[2] |= addr._addr.s6_addr16[2];
|
||||
result._addr.s6_addr16[3] |= addr._addr.s6_addr16[3];
|
||||
result._addr.s6_addr16[4] |= addr._addr.s6_addr16[4];
|
||||
result._addr.s6_addr16[5] |= addr._addr.s6_addr16[5];
|
||||
result._addr.s6_addr16[6] |= addr._addr.s6_addr16[6];
|
||||
result._addr.s6_addr16[7] |= addr._addr.s6_addr16[7];
|
||||
#else
|
||||
result._addr.s6_addr32[0] |= rAddr._addr.s6_addr32[0];
|
||||
result._addr.s6_addr32[1] |= rAddr._addr.s6_addr32[1];
|
||||
result._addr.s6_addr32[2] |= rAddr._addr.s6_addr32[2];
|
||||
result._addr.s6_addr32[3] |= rAddr._addr.s6_addr32[3];
|
||||
result._addr.s6_addr32[0] |= addr._addr.s6_addr32[0];
|
||||
result._addr.s6_addr32[1] |= addr._addr.s6_addr32[1];
|
||||
result._addr.s6_addr32[2] |= addr._addr.s6_addr32[2];
|
||||
result._addr.s6_addr32[3] |= addr._addr.s6_addr32[3];
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
IPv6AddressImpl IPv6AddressImpl::operator ^ (const IPv6AddressImpl& rAddr) const
|
||||
IPv6AddressImpl IPv6AddressImpl::operator ^ (const IPv6AddressImpl& addr) const
|
||||
{
|
||||
if (_scope != rAddr._scope)
|
||||
if (_scope != addr._scope)
|
||||
throw Poco::InvalidArgumentException("Scope ID of passed IPv6 address does not match with the source one.");
|
||||
|
||||
IPv6AddressImpl result(*this);
|
||||
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
result._addr.s6_addr16[0] ^= rAddr._addr.s6_addr16[0];
|
||||
result._addr.s6_addr16[1] ^= rAddr._addr.s6_addr16[1];
|
||||
result._addr.s6_addr16[2] ^= rAddr._addr.s6_addr16[2];
|
||||
result._addr.s6_addr16[3] ^= rAddr._addr.s6_addr16[3];
|
||||
result._addr.s6_addr16[4] ^= rAddr._addr.s6_addr16[4];
|
||||
result._addr.s6_addr16[5] ^= rAddr._addr.s6_addr16[5];
|
||||
result._addr.s6_addr16[6] ^= rAddr._addr.s6_addr16[6];
|
||||
result._addr.s6_addr16[7] ^= rAddr._addr.s6_addr16[7];
|
||||
result._addr.s6_addr16[0] ^= addr._addr.s6_addr16[0];
|
||||
result._addr.s6_addr16[1] ^= addr._addr.s6_addr16[1];
|
||||
result._addr.s6_addr16[2] ^= addr._addr.s6_addr16[2];
|
||||
result._addr.s6_addr16[3] ^= addr._addr.s6_addr16[3];
|
||||
result._addr.s6_addr16[4] ^= addr._addr.s6_addr16[4];
|
||||
result._addr.s6_addr16[5] ^= addr._addr.s6_addr16[5];
|
||||
result._addr.s6_addr16[6] ^= addr._addr.s6_addr16[6];
|
||||
result._addr.s6_addr16[7] ^= addr._addr.s6_addr16[7];
|
||||
#else
|
||||
result._addr.s6_addr32[0] ^= rAddr._addr.s6_addr32[0];
|
||||
result._addr.s6_addr32[1] ^= rAddr._addr.s6_addr32[1];
|
||||
result._addr.s6_addr32[2] ^= rAddr._addr.s6_addr32[2];
|
||||
result._addr.s6_addr32[3] ^= rAddr._addr.s6_addr32[3];
|
||||
result._addr.s6_addr32[0] ^= addr._addr.s6_addr32[0];
|
||||
result._addr.s6_addr32[1] ^= addr._addr.s6_addr32[1];
|
||||
result._addr.s6_addr32[2] ^= addr._addr.s6_addr32[2];
|
||||
result._addr.s6_addr32[3] ^= addr._addr.s6_addr32[3];
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
@ -794,15 +794,15 @@ IPv6AddressImpl IPv6AddressImpl::operator ~ () const
|
||||
}
|
||||
|
||||
|
||||
bool IPv6AddressImpl::operator == (const IPv6AddressImpl& rAddr) const
|
||||
bool IPv6AddressImpl::operator == (const IPv6AddressImpl& addr) const
|
||||
{
|
||||
return _scope == rAddr._scope && 0 == std::memcmp(&rAddr._addr, &_addr, sizeof(_addr));
|
||||
return _scope == addr._scope && 0 == std::memcmp(&addr._addr, &_addr, sizeof(_addr));
|
||||
}
|
||||
|
||||
|
||||
bool IPv6AddressImpl::operator != (const IPv6AddressImpl& rAddr) const
|
||||
bool IPv6AddressImpl::operator != (const IPv6AddressImpl& addr) const
|
||||
{
|
||||
return !(*this == rAddr);
|
||||
return !(*this == addr);
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,7 +62,7 @@ MulticastSocket::MulticastSocket(SocketAddress::Family family): DatagramSocket(f
|
||||
}
|
||||
|
||||
|
||||
MulticastSocket::MulticastSocket(const SocketAddress& rAddress, bool reuseAddress): DatagramSocket(rAddress, reuseAddress)
|
||||
MulticastSocket::MulticastSocket(const SocketAddress& address, bool reuseAddress): DatagramSocket(address, reuseAddress)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -182,9 +182,9 @@ MultipartReader::MultipartReader(std::istream& istr):
|
||||
}
|
||||
|
||||
|
||||
MultipartReader::MultipartReader(std::istream& istr, const std::string& rBoundary):
|
||||
MultipartReader::MultipartReader(std::istream& istr, const std::string& boundary):
|
||||
_istr(istr),
|
||||
_boundary(rBoundary),
|
||||
_boundary(boundary),
|
||||
_pMPI(0)
|
||||
{
|
||||
}
|
||||
|
@ -36,9 +36,9 @@ MultipartWriter::MultipartWriter(std::ostream& ostr):
|
||||
}
|
||||
|
||||
|
||||
MultipartWriter::MultipartWriter(std::ostream& ostr, const std::string& rBoundary):
|
||||
MultipartWriter::MultipartWriter(std::ostream& ostr, const std::string& boundary):
|
||||
_ostr(ostr),
|
||||
_boundary(rBoundary),
|
||||
_boundary(boundary),
|
||||
_firstPart(true)
|
||||
{
|
||||
if (_boundary.empty())
|
||||
|
@ -73,9 +73,9 @@ NTPPacket::NTPPacket() :
|
||||
}
|
||||
|
||||
|
||||
NTPPacket::NTPPacket(Poco::UInt8 *pPacket)
|
||||
NTPPacket::NTPPacket(Poco::UInt8 *packet)
|
||||
{
|
||||
setPacket(pPacket);
|
||||
setPacket(packet);
|
||||
}
|
||||
|
||||
|
||||
@ -84,9 +84,9 @@ NTPPacket::~NTPPacket()
|
||||
}
|
||||
|
||||
|
||||
void NTPPacket::packet(Poco::UInt8 *pPacket) const
|
||||
void NTPPacket::packet(Poco::UInt8 *packet) const
|
||||
{
|
||||
NTPPacketData *p = (NTPPacketData*)pPacket;
|
||||
NTPPacketData *p = (NTPPacketData*)packet;
|
||||
|
||||
p->li = _leapIndicator;
|
||||
p->vn = _version;
|
||||
@ -104,9 +104,9 @@ void NTPPacket::packet(Poco::UInt8 *pPacket) const
|
||||
}
|
||||
|
||||
|
||||
void NTPPacket::setPacket(Poco::UInt8 *pPacket)
|
||||
void NTPPacket::setPacket(Poco::UInt8 *packet)
|
||||
{
|
||||
NTPPacketData *p = (NTPPacketData*)pPacket;
|
||||
NTPPacketData *p = (NTPPacketData*)packet;
|
||||
|
||||
_leapIndicator = p->li;
|
||||
_version = p->vn;
|
||||
|
@ -75,14 +75,14 @@ public:
|
||||
typedef NetworkInterface::Type Type;
|
||||
|
||||
NetworkInterfaceImpl(unsigned index);
|
||||
NetworkInterfaceImpl(const std::string& rName, const std::string& rDisplayName, const std::string& rAdapterName, const IPAddress& rAddress, unsigned index, NetworkInterface::MACAddress* pMACAddress = 0);
|
||||
NetworkInterfaceImpl(const std::string& rName, const std::string& rDisplayName, const std::string& rAdapterName, unsigned index = 0, NetworkInterface::MACAddress* pMACAddress = 0);
|
||||
NetworkInterfaceImpl(const std::string& rName,
|
||||
const std::string& rDisplayName,
|
||||
const std::string& rAdapterName,
|
||||
const IPAddress& rAddress,
|
||||
NetworkInterfaceImpl(const std::string& name, const std::string& displayName, const std::string& adapterName, const IPAddress& address, unsigned index, NetworkInterface::MACAddress* pMACAddress = 0);
|
||||
NetworkInterfaceImpl(const std::string& name, const std::string& displayName, const std::string& adapterName, unsigned index = 0, NetworkInterface::MACAddress* pMACAddress = 0);
|
||||
NetworkInterfaceImpl(const std::string& name,
|
||||
const std::string& displayName,
|
||||
const std::string& adapterName,
|
||||
const IPAddress& address,
|
||||
const IPAddress& subnetMask,
|
||||
const IPAddress& rBroadcastAddress,
|
||||
const IPAddress& broadcastAddress,
|
||||
unsigned index,
|
||||
NetworkInterface::MACAddress* pMACAddress = 0);
|
||||
|
||||
@ -91,10 +91,10 @@ public:
|
||||
const std::string& displayName() const;
|
||||
const std::string& adapterName() const;
|
||||
const IPAddress& firstAddress(IPAddress::Family family) const;
|
||||
void addAddress(const AddressTuple& rAddress);
|
||||
void addAddress(const AddressTuple& address);
|
||||
const IPAddress& address(unsigned index) const;
|
||||
const NetworkInterface::AddressList& addressList() const;
|
||||
bool hasAddress(const IPAddress& rAddress) const;
|
||||
bool hasAddress(const IPAddress& address) const;
|
||||
const IPAddress& subnetMask(unsigned index) const;
|
||||
const IPAddress& broadcastAddress(unsigned index) const;
|
||||
const IPAddress& destAddress(unsigned index) const;
|
||||
@ -102,9 +102,9 @@ public:
|
||||
bool supportsIPv4() const;
|
||||
bool supportsIPv6() const;
|
||||
|
||||
void setName(const std::string& rName);
|
||||
void setDisplayName(const std::string& rName);
|
||||
void setAdapterName(const std::string& rName);
|
||||
void setName(const std::string& name);
|
||||
void setDisplayName(const std::string& name);
|
||||
void setAdapterName(const std::string& name);
|
||||
void addAddress(const IPAddress& addr);
|
||||
void setMACAddress(const NetworkInterface::MACAddress& addr);
|
||||
void setMACAddress(const void *addr, std::size_t len);
|
||||
@ -157,8 +157,8 @@ private:
|
||||
};
|
||||
|
||||
|
||||
NetworkInterfaceImpl::NetworkInterfaceImpl(unsigned interfaceIndex):
|
||||
_index(interfaceIndex),
|
||||
NetworkInterfaceImpl::NetworkInterfaceImpl(unsigned index):
|
||||
_index(index),
|
||||
_broadcast(false),
|
||||
_loopback(false),
|
||||
_multicast(false),
|
||||
@ -171,11 +171,11 @@ NetworkInterfaceImpl::NetworkInterfaceImpl(unsigned interfaceIndex):
|
||||
}
|
||||
|
||||
|
||||
NetworkInterfaceImpl::NetworkInterfaceImpl(const std::string& rName, const std::string& rDisplayName, const std::string& rAdapterName, const IPAddress& rAddress, unsigned interfaceIndex, NetworkInterface::MACAddress* pMACAddress):
|
||||
_name(rName),
|
||||
_displayName(rDisplayName),
|
||||
_adapterName(rAdapterName),
|
||||
_index(interfaceIndex),
|
||||
NetworkInterfaceImpl::NetworkInterfaceImpl(const std::string& name, const std::string& displayName, const std::string& adapterName, const IPAddress& address, unsigned index, NetworkInterface::MACAddress* pMACAddress):
|
||||
_name(name),
|
||||
_displayName(displayName),
|
||||
_adapterName(adapterName),
|
||||
_index(index),
|
||||
_broadcast(false),
|
||||
_loopback(false),
|
||||
_multicast(false),
|
||||
@ -185,17 +185,17 @@ NetworkInterfaceImpl::NetworkInterfaceImpl(const std::string& rName, const std::
|
||||
_mtu(0),
|
||||
_type(NetworkInterface::NI_TYPE_OTHER)
|
||||
{
|
||||
_addressList.push_back(AddressTuple(rAddress, IPAddress(), IPAddress()));
|
||||
_addressList.push_back(AddressTuple(address, IPAddress(), IPAddress()));
|
||||
setPhyParams();
|
||||
if (pMACAddress) setMACAddress(*pMACAddress);
|
||||
}
|
||||
|
||||
|
||||
NetworkInterfaceImpl::NetworkInterfaceImpl(const std::string& rName, const std::string& rDisplayName, const std::string& rAdapterName, unsigned interfaceIndex, NetworkInterface::MACAddress* pMACAddress):
|
||||
_name(rName),
|
||||
_displayName(rDisplayName),
|
||||
_adapterName(rAdapterName),
|
||||
_index(interfaceIndex),
|
||||
NetworkInterfaceImpl::NetworkInterfaceImpl(const std::string& name, const std::string& displayName, const std::string& adapterName, unsigned index, NetworkInterface::MACAddress* pMACAddress):
|
||||
_name(name),
|
||||
_displayName(displayName),
|
||||
_adapterName(adapterName),
|
||||
_index(index),
|
||||
_broadcast(false),
|
||||
_loopback(false),
|
||||
_multicast(false),
|
||||
@ -210,18 +210,18 @@ NetworkInterfaceImpl::NetworkInterfaceImpl(const std::string& rName, const std::
|
||||
}
|
||||
|
||||
|
||||
NetworkInterfaceImpl::NetworkInterfaceImpl(const std::string& rName,
|
||||
const std::string& rDisplayName,
|
||||
const std::string& rAdapterName,
|
||||
const IPAddress& rAddress,
|
||||
const IPAddress& rSubnetMask,
|
||||
const IPAddress& rBroadcastAddress,
|
||||
unsigned interfaceIndex,
|
||||
NetworkInterfaceImpl::NetworkInterfaceImpl(const std::string& name,
|
||||
const std::string& displayName,
|
||||
const std::string& adapterName,
|
||||
const IPAddress& address,
|
||||
const IPAddress& subnetMask,
|
||||
const IPAddress& broadcastAddress,
|
||||
unsigned index,
|
||||
NetworkInterface::MACAddress* pMACAddress):
|
||||
_name(rName),
|
||||
_displayName(rDisplayName),
|
||||
_adapterName(rAdapterName),
|
||||
_index(interfaceIndex),
|
||||
_name(name),
|
||||
_displayName(displayName),
|
||||
_adapterName(adapterName),
|
||||
_index(index),
|
||||
_broadcast(false),
|
||||
_loopback(false),
|
||||
_multicast(false),
|
||||
@ -230,7 +230,7 @@ NetworkInterfaceImpl::NetworkInterfaceImpl(const std::string& rName,
|
||||
_running(false),
|
||||
_mtu(0)
|
||||
{
|
||||
_addressList.push_back(AddressTuple(rAddress, rSubnetMask, rBroadcastAddress));
|
||||
_addressList.push_back(AddressTuple(address, subnetMask, broadcastAddress));
|
||||
setPhyParams();
|
||||
if (pMACAddress) setMACAddress(*pMACAddress);
|
||||
}
|
||||
@ -324,29 +324,29 @@ const IPAddress& NetworkInterfaceImpl::firstAddress(IPAddress::Family family) co
|
||||
}
|
||||
|
||||
|
||||
inline void NetworkInterfaceImpl::addAddress(const AddressTuple& rAddress)
|
||||
inline void NetworkInterfaceImpl::addAddress(const AddressTuple& address)
|
||||
{
|
||||
_addressList.push_back(rAddress);
|
||||
_addressList.push_back(address);
|
||||
}
|
||||
|
||||
|
||||
bool NetworkInterfaceImpl::hasAddress(const IPAddress& rAddress) const
|
||||
bool NetworkInterfaceImpl::hasAddress(const IPAddress& address) const
|
||||
{
|
||||
NetworkInterface::ConstAddressIterator it = _addressList.begin();
|
||||
NetworkInterface::ConstAddressIterator end = _addressList.end();
|
||||
for (; it != end; ++it)
|
||||
{
|
||||
if (it->get<NetworkInterface::IP_ADDRESS>() == rAddress)
|
||||
if (it->get<NetworkInterface::IP_ADDRESS>() == address)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
inline const IPAddress& NetworkInterfaceImpl::address(unsigned interfaceIndex) const
|
||||
inline const IPAddress& NetworkInterfaceImpl::address(unsigned index) const
|
||||
{
|
||||
if (interfaceIndex < _addressList.size()) return _addressList[interfaceIndex].get<NetworkInterface::IP_ADDRESS>();
|
||||
else throw NotFoundException(Poco::format("No address with index %u.", interfaceIndex));
|
||||
if (index < _addressList.size()) return _addressList[index].get<NetworkInterface::IP_ADDRESS>();
|
||||
else throw NotFoundException(Poco::format("No address with index %u.", index));
|
||||
}
|
||||
|
||||
|
||||
@ -356,32 +356,32 @@ inline const NetworkInterface::AddressList& NetworkInterfaceImpl::addressList()
|
||||
}
|
||||
|
||||
|
||||
const IPAddress& NetworkInterfaceImpl::subnetMask(unsigned interfaceIndex) const
|
||||
const IPAddress& NetworkInterfaceImpl::subnetMask(unsigned index) const
|
||||
{
|
||||
if (interfaceIndex < _addressList.size())
|
||||
return _addressList[interfaceIndex].get<NetworkInterface::SUBNET_MASK>();
|
||||
if (index < _addressList.size())
|
||||
return _addressList[index].get<NetworkInterface::SUBNET_MASK>();
|
||||
|
||||
throw NotFoundException(Poco::format("No subnet mask with index %u.", interfaceIndex));
|
||||
throw NotFoundException(Poco::format("No subnet mask with index %u.", index));
|
||||
}
|
||||
|
||||
|
||||
const IPAddress& NetworkInterfaceImpl::broadcastAddress(unsigned interfaceIndex) const
|
||||
const IPAddress& NetworkInterfaceImpl::broadcastAddress(unsigned index) const
|
||||
{
|
||||
if (interfaceIndex < _addressList.size())
|
||||
return _addressList[interfaceIndex].get<NetworkInterface::BROADCAST_ADDRESS>();
|
||||
if (index < _addressList.size())
|
||||
return _addressList[index].get<NetworkInterface::BROADCAST_ADDRESS>();
|
||||
|
||||
throw NotFoundException(Poco::format("No subnet mask with index %u.", interfaceIndex));
|
||||
throw NotFoundException(Poco::format("No subnet mask with index %u.", index));
|
||||
}
|
||||
|
||||
|
||||
const IPAddress& NetworkInterfaceImpl::destAddress(unsigned interfaceIndex) const
|
||||
const IPAddress& NetworkInterfaceImpl::destAddress(unsigned index) const
|
||||
{
|
||||
if (!pointToPoint())
|
||||
throw InvalidAccessException("Only PPP addresses have destination address.");
|
||||
else if (interfaceIndex < _addressList.size())
|
||||
return _addressList[interfaceIndex].get<NetworkInterface::BROADCAST_ADDRESS>();
|
||||
else if (index < _addressList.size())
|
||||
return _addressList[index].get<NetworkInterface::BROADCAST_ADDRESS>();
|
||||
|
||||
throw NotFoundException(Poco::format("No address with index %u.", interfaceIndex));
|
||||
throw NotFoundException(Poco::format("No address with index %u.", index));
|
||||
}
|
||||
|
||||
|
||||
@ -491,45 +491,45 @@ void NetworkInterfaceImpl::setFlags(short flags)
|
||||
#endif
|
||||
|
||||
|
||||
inline void NetworkInterfaceImpl::setUp(bool isUp)
|
||||
inline void NetworkInterfaceImpl::setUp(bool up)
|
||||
{
|
||||
_up = isUp;
|
||||
_up = up;
|
||||
}
|
||||
|
||||
|
||||
inline void NetworkInterfaceImpl::setMTU(unsigned interfaceMTU)
|
||||
inline void NetworkInterfaceImpl::setMTU(unsigned mtu)
|
||||
{
|
||||
_mtu = interfaceMTU;
|
||||
_mtu = mtu;
|
||||
}
|
||||
|
||||
|
||||
inline void NetworkInterfaceImpl::setType(Type interfaceType)
|
||||
inline void NetworkInterfaceImpl::setType(Type type)
|
||||
{
|
||||
_type = interfaceType;
|
||||
_type = type;
|
||||
}
|
||||
|
||||
|
||||
inline void NetworkInterfaceImpl::setIndex(unsigned interfaceIndex)
|
||||
inline void NetworkInterfaceImpl::setIndex(unsigned index)
|
||||
{
|
||||
_index = interfaceIndex;
|
||||
_index = index;
|
||||
}
|
||||
|
||||
|
||||
inline void NetworkInterfaceImpl::setName(const std::string& rName)
|
||||
inline void NetworkInterfaceImpl::setName(const std::string& name)
|
||||
{
|
||||
_name = rName;
|
||||
_name = name;
|
||||
}
|
||||
|
||||
|
||||
inline void NetworkInterfaceImpl::setDisplayName(const std::string& rName)
|
||||
inline void NetworkInterfaceImpl::setDisplayName(const std::string& name)
|
||||
{
|
||||
_displayName = rName;
|
||||
_displayName = name;
|
||||
}
|
||||
|
||||
|
||||
inline void NetworkInterfaceImpl::setAdapterName(const std::string& rName)
|
||||
inline void NetworkInterfaceImpl::setAdapterName(const std::string& name)
|
||||
{
|
||||
_adapterName = rName;
|
||||
_adapterName = name;
|
||||
}
|
||||
|
||||
|
||||
@ -560,8 +560,8 @@ inline void NetworkInterfaceImpl::setMACAddress(const void *addr, std::size_t le
|
||||
FastMutex NetworkInterface::_mutex;
|
||||
|
||||
|
||||
NetworkInterface::NetworkInterface(unsigned interfaceIndex):
|
||||
_pImpl(new NetworkInterfaceImpl(interfaceIndex))
|
||||
NetworkInterface::NetworkInterface(unsigned index):
|
||||
_pImpl(new NetworkInterfaceImpl(index))
|
||||
{
|
||||
}
|
||||
|
||||
@ -573,44 +573,44 @@ NetworkInterface::NetworkInterface(const NetworkInterface& interfc):
|
||||
}
|
||||
|
||||
|
||||
NetworkInterface::NetworkInterface(const std::string& rName, const std::string& rDisplayName, const std::string& rAdapterName, const IPAddress& rAddress, unsigned interfaceIndex, MACAddress* pMACAddress):
|
||||
_pImpl(new NetworkInterfaceImpl(rName, rDisplayName, rAdapterName, rAddress, interfaceIndex, pMACAddress))
|
||||
NetworkInterface::NetworkInterface(const std::string& name, const std::string& displayName, const std::string& adapterName, const IPAddress& address, unsigned index, MACAddress* pMACAddress):
|
||||
_pImpl(new NetworkInterfaceImpl(name, displayName, adapterName, address, index, pMACAddress))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NetworkInterface::NetworkInterface(const std::string& rName, const std::string& rDisplayName, const std::string& rAdapterName, unsigned interfaceIndex, MACAddress* pMACAddress):
|
||||
_pImpl(new NetworkInterfaceImpl(rName, rDisplayName, rAdapterName, interfaceIndex, pMACAddress))
|
||||
NetworkInterface::NetworkInterface(const std::string& name, const std::string& displayName, const std::string& adapterName, unsigned index, MACAddress* pMACAddress):
|
||||
_pImpl(new NetworkInterfaceImpl(name, displayName, adapterName, index, pMACAddress))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NetworkInterface::NetworkInterface(const std::string& rName, const IPAddress& rAddress, unsigned interfaceIndex, MACAddress* pMACAddress):
|
||||
_pImpl(new NetworkInterfaceImpl(rName, rName, rName, rAddress, interfaceIndex, pMACAddress))
|
||||
NetworkInterface::NetworkInterface(const std::string& name, const IPAddress& address, unsigned index, MACAddress* pMACAddress):
|
||||
_pImpl(new NetworkInterfaceImpl(name, name, name, address, index, pMACAddress))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NetworkInterface::NetworkInterface(const std::string& rName,
|
||||
const std::string& rDisplayName,
|
||||
const std::string& rAdapterName,
|
||||
const IPAddress& rAddress,
|
||||
const IPAddress& rSubnetMask,
|
||||
const IPAddress& rBroadcastAddress,
|
||||
unsigned interfaceIndex,
|
||||
NetworkInterface::NetworkInterface(const std::string& name,
|
||||
const std::string& displayName,
|
||||
const std::string& adapterName,
|
||||
const IPAddress& address,
|
||||
const IPAddress& subnetMask,
|
||||
const IPAddress& broadcastAddress,
|
||||
unsigned index,
|
||||
MACAddress* pMACAddress):
|
||||
_pImpl(new NetworkInterfaceImpl(rName, rDisplayName, rAdapterName, rAddress, rSubnetMask, rBroadcastAddress, interfaceIndex, pMACAddress))
|
||||
_pImpl(new NetworkInterfaceImpl(name, displayName, adapterName, address, subnetMask, broadcastAddress, index, pMACAddress))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NetworkInterface::NetworkInterface(const std::string& rName,
|
||||
const IPAddress& rAddress,
|
||||
const IPAddress& rSubnetMask,
|
||||
const IPAddress& rBroadcastAddress,
|
||||
unsigned interfaceIndex,
|
||||
NetworkInterface::NetworkInterface(const std::string& name,
|
||||
const IPAddress& address,
|
||||
const IPAddress& subnetMask,
|
||||
const IPAddress& broadcastAddress,
|
||||
unsigned index,
|
||||
MACAddress* pMACAddress):
|
||||
_pImpl(new NetworkInterfaceImpl(rName, rName, rName, rAddress, rSubnetMask, rBroadcastAddress, interfaceIndex, pMACAddress))
|
||||
_pImpl(new NetworkInterfaceImpl(name, name, name, address, subnetMask, broadcastAddress, index, pMACAddress))
|
||||
{
|
||||
}
|
||||
|
||||
@ -679,21 +679,21 @@ void NetworkInterface::firstAddress(IPAddress& addr, IPAddress::Family family) c
|
||||
}
|
||||
|
||||
|
||||
void NetworkInterface::addAddress(const IPAddress& rAddress)
|
||||
void NetworkInterface::addAddress(const IPAddress& address)
|
||||
{
|
||||
_pImpl->addAddress(AddressTuple(rAddress, IPAddress(), IPAddress()));
|
||||
_pImpl->addAddress(AddressTuple(address, IPAddress(), IPAddress()));
|
||||
}
|
||||
|
||||
|
||||
void NetworkInterface::addAddress(const IPAddress& rAddress, const IPAddress& rSubnetMask, const IPAddress& rBroadcastAddress)
|
||||
void NetworkInterface::addAddress(const IPAddress& address, const IPAddress& subnetMask, const IPAddress& broadcastAddress)
|
||||
{
|
||||
_pImpl->addAddress(AddressTuple(rAddress, rSubnetMask, rBroadcastAddress));
|
||||
_pImpl->addAddress(AddressTuple(address, subnetMask, broadcastAddress));
|
||||
}
|
||||
|
||||
|
||||
const IPAddress& NetworkInterface::address(unsigned interfaceIndex) const
|
||||
const IPAddress& NetworkInterface::address(unsigned index) const
|
||||
{
|
||||
return _pImpl->address(interfaceIndex);
|
||||
return _pImpl->address(index);
|
||||
}
|
||||
|
||||
|
||||
@ -703,15 +703,15 @@ const NetworkInterface::AddressList& NetworkInterface::addressList() const
|
||||
}
|
||||
|
||||
|
||||
const IPAddress& NetworkInterface::subnetMask(unsigned interfaceIndex) const
|
||||
const IPAddress& NetworkInterface::subnetMask(unsigned index) const
|
||||
{
|
||||
return _pImpl->subnetMask(interfaceIndex);
|
||||
return _pImpl->subnetMask(index);
|
||||
}
|
||||
|
||||
|
||||
const IPAddress& NetworkInterface::broadcastAddress(unsigned interfaceIndex) const
|
||||
const IPAddress& NetworkInterface::broadcastAddress(unsigned index) const
|
||||
{
|
||||
return _pImpl->broadcastAddress(interfaceIndex);
|
||||
return _pImpl->broadcastAddress(index);
|
||||
}
|
||||
|
||||
|
||||
@ -721,9 +721,9 @@ const NetworkInterface::MACAddress& NetworkInterface::macAddress() const
|
||||
}
|
||||
|
||||
|
||||
const IPAddress& NetworkInterface::destAddress(unsigned interfaceIndex) const
|
||||
const IPAddress& NetworkInterface::destAddress(unsigned index) const
|
||||
{
|
||||
return _pImpl->destAddress(interfaceIndex);
|
||||
return _pImpl->destAddress(index);
|
||||
}
|
||||
|
||||
|
||||
@ -793,14 +793,14 @@ bool NetworkInterface::isUp() const
|
||||
}
|
||||
|
||||
|
||||
NetworkInterface NetworkInterface::forName(const std::string& rName, bool requireIPv6)
|
||||
NetworkInterface NetworkInterface::forName(const std::string& name, bool requireIPv6)
|
||||
{
|
||||
if (requireIPv6) return forName(rName, IPv6_ONLY);
|
||||
else return forName(rName, IPv4_OR_IPv6);
|
||||
if (requireIPv6) return forName(name, IPv6_ONLY);
|
||||
else return forName(name, IPv4_OR_IPv6);
|
||||
}
|
||||
|
||||
|
||||
NetworkInterface NetworkInterface::forName(const std::string& rName, IPVersion ipVersion)
|
||||
NetworkInterface NetworkInterface::forName(const std::string& name, IPVersion ipVersion)
|
||||
{
|
||||
Map map = NetworkInterface::map(false, false);
|
||||
Map::const_iterator it = map.begin();
|
||||
@ -808,7 +808,7 @@ NetworkInterface NetworkInterface::forName(const std::string& rName, IPVersion i
|
||||
|
||||
for (; it != end; ++it)
|
||||
{
|
||||
if (it->second.name() == rName)
|
||||
if (it->second.name() == name)
|
||||
{
|
||||
if (ipVersion == IPv4_ONLY && it->second.supportsIPv4())
|
||||
return it->second;
|
||||
@ -818,7 +818,7 @@ NetworkInterface NetworkInterface::forName(const std::string& rName, IPVersion i
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
throw InterfaceNotFoundException(rName);
|
||||
throw InterfaceNotFoundException(name);
|
||||
}
|
||||
|
||||
|
||||
@ -864,10 +864,10 @@ NetworkInterface::List NetworkInterface::list(bool ipOnly, bool upOnly)
|
||||
NetworkInterface::Map::const_iterator end = m.end();
|
||||
for (; it != end; ++it)
|
||||
{
|
||||
int interfaceIndex = it->second.index();
|
||||
std::string interfaceName = it->second.name();
|
||||
std::string interfaceDisplayName = it->second.displayName();
|
||||
std::string interfaceAdapterName = it->second.adapterName();
|
||||
int index = it->second.index();
|
||||
std::string name = it->second.name();
|
||||
std::string displayName = it->second.displayName();
|
||||
std::string adapterName = it->second.adapterName();
|
||||
NetworkInterface::MACAddress mac = it->second.macAddress();
|
||||
|
||||
typedef NetworkInterface::AddressList List;
|
||||
@ -881,12 +881,12 @@ NetworkInterface::List NetworkInterface::list(bool ipOnly, bool upOnly)
|
||||
NetworkInterface ni;
|
||||
if (mask.isWildcard())
|
||||
{
|
||||
ni = NetworkInterface(interfaceName, interfaceDisplayName, interfaceAdapterName, addr, interfaceIndex, &mac);
|
||||
ni = NetworkInterface(name, displayName, adapterName, addr, index, &mac);
|
||||
}
|
||||
else
|
||||
{
|
||||
IPAddress broadcast = ipIt->get<NetworkInterface::BROADCAST_ADDRESS>();
|
||||
ni = NetworkInterface(interfaceName, interfaceDisplayName, interfaceAdapterName, addr, mask, broadcast, interfaceIndex, &mac);
|
||||
ni = NetworkInterface(name, displayName, adapterName, addr, mask, broadcast, index, &mac);
|
||||
}
|
||||
|
||||
ni._pImpl->_broadcast = it->second._pImpl->_broadcast;
|
||||
@ -984,7 +984,7 @@ NetworkInterface::Type fromNative(DWORD type)
|
||||
}
|
||||
|
||||
|
||||
IPAddress subnetMaskForInterface(const std::string& rName, bool isLoopback)
|
||||
IPAddress subnetMaskForInterface(const std::string& name, bool isLoopback)
|
||||
{
|
||||
if (isLoopback)
|
||||
{
|
||||
@ -994,7 +994,7 @@ IPAddress subnetMaskForInterface(const std::string& rName, bool isLoopback)
|
||||
{
|
||||
#if !defined(_WIN32_WCE)
|
||||
std::string subKey("SYSTEM\\CurrentControlSet\\services\\Tcpip\\Parameters\\Interfaces\\");
|
||||
subKey += rName;
|
||||
subKey += name;
|
||||
std::string netmask;
|
||||
HKEY hKey;
|
||||
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
|
||||
@ -1081,9 +1081,9 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
|
||||
poco_assert (NO_ERROR == dwRetVal);
|
||||
for (; pAddress; pAddress = pAddress->Next)
|
||||
{
|
||||
IPAddress ipAddress;
|
||||
IPAddress ipSubnetMask;
|
||||
IPAddress ipBroadcastAddress;
|
||||
IPAddress address;
|
||||
IPAddress subnetMask;
|
||||
IPAddress broadcastAddress;
|
||||
unsigned ifIndex = 0;
|
||||
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
@ -1138,26 +1138,26 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
|
||||
#endif
|
||||
if (ifIndex == 0) continue;
|
||||
|
||||
std::string interfaceName;
|
||||
std::string interfaceDisplayName;
|
||||
std::string interfaceAdapterName(pAddress->AdapterName);
|
||||
std::string name;
|
||||
std::string displayName;
|
||||
std::string adapterName(pAddress->AdapterName);
|
||||
#ifdef POCO_WIN32_UTF8
|
||||
Poco::UnicodeConverter::toUTF8(pAddress->FriendlyName, interfaceName);
|
||||
Poco::UnicodeConverter::toUTF8(pAddress->Description, interfaceDisplayName);
|
||||
Poco::UnicodeConverter::toUTF8(pAddress->FriendlyName, name);
|
||||
Poco::UnicodeConverter::toUTF8(pAddress->Description, displayName);
|
||||
#else
|
||||
char nameBuffer[1024];
|
||||
int rc = WideCharToMultiByte(CP_ACP, 0, pAddress->FriendlyName, -1, nameBuffer, sizeof(nameBuffer), NULL, NULL);
|
||||
if (rc) interfaceName = nameBuffer;
|
||||
if (rc) name = nameBuffer;
|
||||
char displayNameBuffer[1024];
|
||||
rc = WideCharToMultiByte(CP_ACP, 0, pAddress->Description, -1, displayNameBuffer, sizeof(displayNameBuffer), NULL, NULL);
|
||||
if (rc) interfaceDisplayName = displayNameBuffer;
|
||||
if (rc) displayName = displayNameBuffer;
|
||||
#endif
|
||||
|
||||
bool isUp = (pAddress->OperStatus == IfOperStatusUp);
|
||||
bool isIP = (0 != pAddress->FirstUnicastAddress);
|
||||
if (((ipOnly && isIP) || !ipOnly) && ((upOnly && isUp) || !upOnly))
|
||||
{
|
||||
NetworkInterface ni(interfaceName, interfaceDisplayName, interfaceAdapterName, ifIndex);
|
||||
NetworkInterface ni(name, displayName, adapterName, ifIndex);
|
||||
// Create interface even if it has an empty list of addresses; also, set
|
||||
// physical attributes which are protocol independent (name, media type,
|
||||
// MAC address, MTU, operational status, etc).
|
||||
@ -1184,7 +1184,7 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
|
||||
pUniAddr;
|
||||
pUniAddr = pUniAddr->Next)
|
||||
{
|
||||
ipAddress = IPAddress(pUniAddr->Address);
|
||||
address = IPAddress(pUniAddr->Address);
|
||||
ADDRESS_FAMILY family = pUniAddr->Address.lpSockaddr->sa_family;
|
||||
switch (family)
|
||||
{
|
||||
@ -1201,67 +1201,67 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
|
||||
#if defined(_WIN32_WCE)
|
||||
#if _WIN32_WCE >= 0x0800
|
||||
prefixLength = pUniAddr->OnLinkPrefixLength;
|
||||
ipBroadcastAddress = getBroadcastAddress(pAddress->FirstPrefix, ipAddress);
|
||||
broadcastAddress = getBroadcastAddress(pAddress->FirstPrefix, address);
|
||||
#else
|
||||
ipBroadcastAddress = getBroadcastAddress(pAddress->FirstPrefix, ipAddress, &prefixLength);
|
||||
broadcastAddress = getBroadcastAddress(pAddress->FirstPrefix, address, &prefixLength);
|
||||
#endif
|
||||
// if previous call did not do it, make last-ditch attempt for prefix and broadcast
|
||||
if (prefixLength == 0 && pAddress->FirstPrefix)
|
||||
prefixLength = pAddress->FirstPrefix->PrefixLength;
|
||||
poco_assert (prefixLength <= 32);
|
||||
if (ipBroadcastAddress.isWildcard())
|
||||
if (broadcastAddress.isWildcard())
|
||||
{
|
||||
IPAddress mask(static_cast<unsigned>(prefixLength), IPAddress::IPv4);
|
||||
IPAddress host(mask & ipAddress);
|
||||
ipBroadcastAddress = host | ~mask;
|
||||
IPAddress host(mask & address);
|
||||
broadcastAddress = host | ~mask;
|
||||
}
|
||||
#elif (_WIN32_WINNT >= 0x0501) && (NTDDI_VERSION >= 0x05010100) // Win XP SP1
|
||||
#if (_WIN32_WINNT >= 0x0600) // Vista and newer
|
||||
if (osvi.dwMajorVersion >= 6)
|
||||
{
|
||||
prefixLength = pUniAddr->OnLinkPrefixLength;
|
||||
ipBroadcastAddress = getBroadcastAddress(pAddress->FirstPrefix, ipAddress);
|
||||
broadcastAddress = getBroadcastAddress(pAddress->FirstPrefix, address);
|
||||
}
|
||||
else
|
||||
{
|
||||
ipBroadcastAddress = getBroadcastAddress(pAddress->FirstPrefix, ipAddress, &prefixLength);
|
||||
broadcastAddress = getBroadcastAddress(pAddress->FirstPrefix, address, &prefixLength);
|
||||
}
|
||||
#else
|
||||
ipBroadcastAddress = getBroadcastAddress(pAddress->FirstPrefix, ipAddress, &prefixLength);
|
||||
broadcastAddress = getBroadcastAddress(pAddress->FirstPrefix, address, &prefixLength);
|
||||
#endif
|
||||
poco_assert (prefixLength <= 32);
|
||||
if (ipBroadcastAddress.isWildcard())
|
||||
if (broadcastAddress.isWildcard())
|
||||
{
|
||||
IPAddress mask(static_cast<unsigned>(prefixLength), IPAddress::IPv4);
|
||||
IPAddress host(mask & ipAddress);
|
||||
ipBroadcastAddress = host | ~mask;
|
||||
IPAddress host(mask & address);
|
||||
broadcastAddress = host | ~mask;
|
||||
}
|
||||
#endif // (_WIN32_WINNT >= 0x0501) && (NTDDI_VERSION >= 0x05010100)
|
||||
if (prefixLength)
|
||||
{
|
||||
ipSubnetMask = IPAddress(static_cast<unsigned>(prefixLength), IPAddress::IPv4);
|
||||
subnetMask = IPAddress(static_cast<unsigned>(prefixLength), IPAddress::IPv4);
|
||||
}
|
||||
else // if all of the above fails, look up the subnet mask in the registry
|
||||
{
|
||||
ipAddress = IPAddress(&reinterpret_cast<struct sockaddr_in*>(pUniAddr->Address.lpSockaddr)->sin_addr, sizeof(in_addr));
|
||||
ipSubnetMask = subnetMaskForInterface(interfaceName, ipAddress.isLoopback());
|
||||
if (!ipAddress.isLoopback())
|
||||
address = IPAddress(&reinterpret_cast<struct sockaddr_in*>(pUniAddr->Address.lpSockaddr)->sin_addr, sizeof(in_addr));
|
||||
subnetMask = subnetMaskForInterface(name, address.isLoopback());
|
||||
if (!address.isLoopback())
|
||||
{
|
||||
ipBroadcastAddress = ipAddress;
|
||||
ipBroadcastAddress.mask(ipSubnetMask, IPAddress::broadcast());
|
||||
broadcastAddress = address;
|
||||
broadcastAddress.mask(subnetMask, IPAddress::broadcast());
|
||||
}
|
||||
}
|
||||
ifIt->second.addAddress(ipAddress, ipSubnetMask, ipBroadcastAddress);
|
||||
ifIt->second.addAddress(address, subnetMask, broadcastAddress);
|
||||
}
|
||||
else
|
||||
{
|
||||
ifIt->second.addAddress(ipAddress);
|
||||
ifIt->second.addAddress(address);
|
||||
}
|
||||
}
|
||||
break;
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
case AF_INET6:
|
||||
ifIt->second.addAddress(ipAddress);
|
||||
ifIt->second.addAddress(address);
|
||||
break;
|
||||
#endif
|
||||
} // switch family
|
||||
@ -1408,7 +1408,7 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
|
||||
{
|
||||
if (!currIface->ifa_addr) continue;
|
||||
|
||||
IPAddress ipAddress, ipSubnetMask, ipBroadcastAddress;
|
||||
IPAddress address, subnetMask, broadcastAddress;
|
||||
unsigned family = currIface->ifa_addr->sa_family;
|
||||
switch (family)
|
||||
{
|
||||
@ -1432,17 +1432,17 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
|
||||
if ((ifIt == result.end()) && ((upOnly && intf.isUp()) || !upOnly))
|
||||
ifIt = result.insert(Map::value_type(ifIndex, intf)).first;
|
||||
|
||||
ipAddress = IPAddress(*(currIface->ifa_addr));
|
||||
address = IPAddress(*(currIface->ifa_addr));
|
||||
|
||||
if (( currIface->ifa_flags & IFF_LOOPBACK ) == 0 && currIface->ifa_netmask)
|
||||
ipSubnetMask = IPAddress(*(currIface->ifa_netmask));
|
||||
subnetMask = IPAddress(*(currIface->ifa_netmask));
|
||||
|
||||
if (currIface->ifa_flags & IFF_BROADCAST && currIface->ifa_broadaddr)
|
||||
ipBroadcastAddress = IPAddress(*(currIface->ifa_broadaddr));
|
||||
broadcastAddress = IPAddress(*(currIface->ifa_broadaddr));
|
||||
else if (currIface->ifa_flags & IFF_POINTOPOINT && currIface->ifa_dstaddr)
|
||||
ipBroadcastAddress = IPAddress(*(currIface->ifa_dstaddr));
|
||||
broadcastAddress = IPAddress(*(currIface->ifa_dstaddr));
|
||||
else
|
||||
ipBroadcastAddress = IPAddress();
|
||||
broadcastAddress = IPAddress();
|
||||
break;
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
case AF_INET6:
|
||||
@ -1453,10 +1453,10 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
|
||||
if ((ifIt == result.end()) && ((upOnly && intf.isUp()) || !upOnly))
|
||||
ifIt = result.insert(Map::value_type(ifIndex, intf)).first;
|
||||
|
||||
ipAddress = IPAddress(&reinterpret_cast<const struct sockaddr_in6*>(currIface->ifa_addr)->sin6_addr,
|
||||
address = IPAddress(&reinterpret_cast<const struct sockaddr_in6*>(currIface->ifa_addr)->sin6_addr,
|
||||
sizeof(struct in6_addr), ifIndex);
|
||||
ipSubnetMask = IPAddress(*(currIface->ifa_netmask));
|
||||
ipBroadcastAddress = IPAddress();
|
||||
subnetMask = IPAddress(*(currIface->ifa_netmask));
|
||||
broadcastAddress = IPAddress();
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
@ -1472,7 +1472,7 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
|
||||
if ((upOnly && intf.isUp()) || !upOnly)
|
||||
{
|
||||
if ((ifIt = result.find(ifIndex)) != result.end())
|
||||
ifIt->second.addAddress(ipAddress, ipSubnetMask, ipBroadcastAddress);
|
||||
ifIt->second.addAddress(address, subnetMask, broadcastAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1582,7 +1582,7 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
|
||||
{
|
||||
if (!iface->ifa_addr) continue;
|
||||
|
||||
IPAddress ipAddress, ipSubnetMask, ipBroadcastAddress;
|
||||
IPAddress address, subnetMask, broadcastAddress;
|
||||
unsigned family = iface->ifa_addr->sa_family;
|
||||
switch (family)
|
||||
{
|
||||
@ -1607,15 +1607,15 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
|
||||
if ((ifIt == result.end()) && ((upOnly && intf.isUp()) || !upOnly))
|
||||
ifIt = result.insert(Map::value_type(ifIndex, intf)).first;
|
||||
|
||||
ipAddress = IPAddress(*(iface->ifa_addr));
|
||||
ipSubnetMask = IPAddress(*(iface->ifa_netmask));
|
||||
address = IPAddress(*(iface->ifa_addr));
|
||||
subnetMask = IPAddress(*(iface->ifa_netmask));
|
||||
|
||||
if (iface->ifa_flags & IFF_BROADCAST && iface->ifa_broadaddr)
|
||||
ipBroadcastAddress = IPAddress(*(iface->ifa_broadaddr));
|
||||
broadcastAddress = IPAddress(*(iface->ifa_broadaddr));
|
||||
else if (iface->ifa_flags & IFF_POINTOPOINT && iface->ifa_dstaddr)
|
||||
ipBroadcastAddress = IPAddress(*(iface->ifa_dstaddr));
|
||||
broadcastAddress = IPAddress(*(iface->ifa_dstaddr));
|
||||
else
|
||||
ipBroadcastAddress = IPAddress();
|
||||
broadcastAddress = IPAddress();
|
||||
|
||||
break;
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
@ -1628,9 +1628,9 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
|
||||
if ((ifIt == result.end()) && ((upOnly && intf.isUp()) || !upOnly))
|
||||
result.insert(Map::value_type(ifIndex, intf));
|
||||
|
||||
ipAddress = IPAddress(&reinterpret_cast<const struct sockaddr_in6*>(iface->ifa_addr)->sin6_addr, sizeof(struct in6_addr), ifIndex);
|
||||
ipSubnetMask = IPAddress(*(iface->ifa_netmask));
|
||||
ipBroadcastAddress = IPAddress();
|
||||
address = IPAddress(&reinterpret_cast<const struct sockaddr_in6*>(iface->ifa_addr)->sin6_addr, sizeof(struct in6_addr), ifIndex);
|
||||
subnetMask = IPAddress(*(iface->ifa_netmask));
|
||||
broadcastAddress = IPAddress();
|
||||
|
||||
break;
|
||||
#endif
|
||||
@ -1644,11 +1644,11 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
intf = NetworkInterface(std::string(iface->ifa_name), ipAddress, ipSubnetMask, ipBroadcastAddress, ifIndex);
|
||||
intf = NetworkInterface(std::string(iface->ifa_name), address, subnetMask, broadcastAddress, ifIndex);
|
||||
if ((upOnly && intf.isUp()) || !upOnly)
|
||||
{
|
||||
if ((ifIt = result.find(ifIndex)) != result.end())
|
||||
ifIt->second.addAddress(ipAddress, ipSubnetMask, ipBroadcastAddress);
|
||||
ifIt->second.addAddress(address, subnetMask, broadcastAddress);
|
||||
}
|
||||
}
|
||||
} // for interface
|
||||
|
@ -30,8 +30,8 @@ PartSource::PartSource():
|
||||
}
|
||||
|
||||
|
||||
PartSource::PartSource(const std::string& rMediaType):
|
||||
_mediaType(rMediaType)
|
||||
PartSource::PartSource(const std::string& mediaType):
|
||||
_mediaType(mediaType)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ namespace Net {
|
||||
//
|
||||
|
||||
|
||||
PartStore::PartStore(const std::string& rMediaType): PartSource(rMediaType)
|
||||
PartStore::PartStore(const std::string& mediaType): PartSource(mediaType)
|
||||
{
|
||||
}
|
||||
|
||||
@ -44,9 +44,9 @@ PartStore::~PartStore()
|
||||
//
|
||||
|
||||
|
||||
FilePartStore::FilePartStore(const std::string& content, const std::string& rMediaType, const std::string& rFilename):
|
||||
PartStore(rMediaType),
|
||||
_filename(rFilename),
|
||||
FilePartStore::FilePartStore(const std::string& content, const std::string& mediaType, const std::string& filename):
|
||||
PartStore(mediaType),
|
||||
_filename(filename),
|
||||
_path(TemporaryFile::tempName()),
|
||||
_fstr(_path)
|
||||
{
|
||||
|
@ -38,10 +38,10 @@ RawSocket::RawSocket(SocketAddress::Family family, int proto):
|
||||
}
|
||||
|
||||
|
||||
RawSocket::RawSocket(const SocketAddress& rAddress, bool reuseAddress):
|
||||
Socket(new RawSocketImpl(rAddress.family()))
|
||||
RawSocket::RawSocket(const SocketAddress& address, bool reuseAddress):
|
||||
Socket(new RawSocketImpl(address.family()))
|
||||
{
|
||||
bind(rAddress, reuseAddress);
|
||||
bind(address, reuseAddress);
|
||||
}
|
||||
|
||||
|
||||
@ -74,15 +74,15 @@ RawSocket& RawSocket::operator = (const Socket& socket)
|
||||
}
|
||||
|
||||
|
||||
void RawSocket::connect(const SocketAddress& rAddress)
|
||||
void RawSocket::connect(const SocketAddress& address)
|
||||
{
|
||||
impl()->connect(rAddress);
|
||||
impl()->connect(address);
|
||||
}
|
||||
|
||||
|
||||
void RawSocket::bind(const SocketAddress& rAddress, bool reuseAddress)
|
||||
void RawSocket::bind(const SocketAddress& address, bool reuseAddress)
|
||||
{
|
||||
impl()->bind(rAddress, reuseAddress);
|
||||
impl()->bind(address, reuseAddress);
|
||||
}
|
||||
|
||||
|
||||
@ -98,15 +98,15 @@ int RawSocket::receiveBytes(void* buffer, int length, int flags)
|
||||
}
|
||||
|
||||
|
||||
int RawSocket::sendTo(const void* buffer, int length, const SocketAddress& rAddress, int flags)
|
||||
int RawSocket::sendTo(const void* buffer, int length, const SocketAddress& address, int flags)
|
||||
{
|
||||
return impl()->sendTo(buffer, length, rAddress, flags);
|
||||
return impl()->sendTo(buffer, length, address, flags);
|
||||
}
|
||||
|
||||
|
||||
int RawSocket::receiveFrom(void* buffer, int length, SocketAddress& rAddress, int flags)
|
||||
int RawSocket::receiveFrom(void* buffer, int length, SocketAddress& address, int flags)
|
||||
{
|
||||
return impl()->receiveFrom(buffer, length, rAddress, flags);
|
||||
return impl()->receiveFrom(buffer, length, address, flags);
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,8 +44,8 @@ RawSocketImpl::RawSocketImpl(SocketAddress::Family family, int proto)
|
||||
}
|
||||
|
||||
|
||||
RawSocketImpl::RawSocketImpl(poco_socket_t socketfd):
|
||||
SocketImpl(socketfd)
|
||||
RawSocketImpl::RawSocketImpl(poco_socket_t sockfd):
|
||||
SocketImpl(sockfd)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -43,15 +43,15 @@ namespace Net {
|
||||
class MessageNotification: public Poco::Notification
|
||||
{
|
||||
public:
|
||||
MessageNotification(const char* buffer, std::size_t length, const Poco::Net::SocketAddress& rSourceAddress):
|
||||
MessageNotification(const char* buffer, std::size_t length, const Poco::Net::SocketAddress& sourceAddress):
|
||||
_message(buffer, length),
|
||||
_sourceAddress(rSourceAddress)
|
||||
_sourceAddress(sourceAddress)
|
||||
{
|
||||
}
|
||||
|
||||
MessageNotification(const std::string& rMessage, const Poco::Net::SocketAddress& rSourceAddress):
|
||||
_message(rMessage),
|
||||
_sourceAddress(rSourceAddress)
|
||||
MessageNotification(const std::string& message, const Poco::Net::SocketAddress& sourceAddress):
|
||||
_message(message),
|
||||
_sourceAddress(sourceAddress)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -51,8 +51,8 @@ namespace Poco {
|
||||
namespace Net {
|
||||
|
||||
|
||||
SMTPClientSession::SMTPClientSession(const StreamSocket& rSocket):
|
||||
_socket(rSocket),
|
||||
SMTPClientSession::SMTPClientSession(const StreamSocket& socket):
|
||||
_socket(socket),
|
||||
_isOpen(false)
|
||||
{
|
||||
}
|
||||
@ -346,8 +346,8 @@ void SMTPClientSession::sendCommands(const MailMessage& message, const Recipient
|
||||
for (Recipients::const_iterator it = pRecipients->begin(); it != pRecipients->end(); ++it)
|
||||
{
|
||||
recipient << '<' << *it << '>';
|
||||
int commandStatus = sendCommand("RCPT TO:", recipient.str(), response);
|
||||
if (!isPositiveCompletion(commandStatus)) throw SMTPException(std::string("Recipient rejected: ") + recipient.str(), response, commandStatus);
|
||||
int status = sendCommand("RCPT TO:", recipient.str(), response);
|
||||
if (!isPositiveCompletion(status)) throw SMTPException(std::string("Recipient rejected: ") + recipient.str(), response, status);
|
||||
recipient.str("");
|
||||
}
|
||||
}
|
||||
@ -356,8 +356,8 @@ void SMTPClientSession::sendCommands(const MailMessage& message, const Recipient
|
||||
for (MailMessage::Recipients::const_iterator it = message.recipients().begin(); it != message.recipients().end(); ++it)
|
||||
{
|
||||
recipient << '<' << it->getAddress() << '>';
|
||||
int commandStatus = sendCommand("RCPT TO:", recipient.str(), response);
|
||||
if (!isPositiveCompletion(commandStatus)) throw SMTPException(std::string("Recipient rejected: ") + recipient.str(), response, commandStatus);
|
||||
int status = sendCommand("RCPT TO:", recipient.str(), response);
|
||||
if (!isPositiveCompletion(status)) throw SMTPException(std::string("Recipient rejected: ") + recipient.str(), response, status);
|
||||
recipient.str("");
|
||||
}
|
||||
}
|
||||
@ -393,8 +393,8 @@ void SMTPClientSession::sendAddresses(const std::string& from, const Recipients&
|
||||
{
|
||||
|
||||
recipient << '<' << *it << '>';
|
||||
int commandStatus = sendCommand("RCPT TO:", recipient.str(), response);
|
||||
if (!isPositiveCompletion(commandStatus)) throw SMTPException(std::string("Recipient rejected: ") + recipient.str(), response, commandStatus);
|
||||
int status = sendCommand("RCPT TO:", recipient.str(), response);
|
||||
if (!isPositiveCompletion(status)) throw SMTPException(std::string("Recipient rejected: ") + recipient.str(), response, status);
|
||||
recipient.str("");
|
||||
}
|
||||
}
|
||||
|
@ -38,9 +38,9 @@ ServerSocket::ServerSocket(const Socket& socket): Socket(socket)
|
||||
}
|
||||
|
||||
|
||||
ServerSocket::ServerSocket(const SocketAddress& rAddress, int backlog): Socket(new ServerSocketImpl)
|
||||
ServerSocket::ServerSocket(const SocketAddress& address, int backlog): Socket(new ServerSocketImpl)
|
||||
{
|
||||
impl()->bind(rAddress, true);
|
||||
impl()->bind(address, true);
|
||||
impl()->listen(backlog);
|
||||
}
|
||||
|
||||
@ -48,8 +48,8 @@ ServerSocket::ServerSocket(const SocketAddress& rAddress, int backlog): Socket(n
|
||||
ServerSocket::ServerSocket(Poco::UInt16 port, int backlog): Socket(new ServerSocketImpl)
|
||||
{
|
||||
IPAddress wildcardAddr;
|
||||
SocketAddress socketAddress(wildcardAddr, port);
|
||||
impl()->bind(socketAddress, true);
|
||||
SocketAddress address(wildcardAddr, port);
|
||||
impl()->bind(address, true);
|
||||
impl()->listen(backlog);
|
||||
}
|
||||
|
||||
@ -74,23 +74,23 @@ ServerSocket& ServerSocket::operator = (const Socket& socket)
|
||||
}
|
||||
|
||||
|
||||
void ServerSocket::bind(const SocketAddress& rAddress, bool reuseAddress)
|
||||
void ServerSocket::bind(const SocketAddress& address, bool reuseAddress)
|
||||
{
|
||||
impl()->bind(rAddress, reuseAddress);
|
||||
impl()->bind(address, reuseAddress);
|
||||
}
|
||||
|
||||
|
||||
void ServerSocket::bind(Poco::UInt16 port, bool reuseAddress)
|
||||
{
|
||||
IPAddress wildcardAddr;
|
||||
SocketAddress socketAddress(wildcardAddr, port);
|
||||
impl()->bind(socketAddress, reuseAddress);
|
||||
SocketAddress address(wildcardAddr, port);
|
||||
impl()->bind(address, reuseAddress);
|
||||
}
|
||||
|
||||
|
||||
void ServerSocket::bind6(const SocketAddress& rAddress, bool reuseAddress, bool ipV6Only)
|
||||
void ServerSocket::bind6(const SocketAddress& address, bool reuseAddress, bool ipV6Only)
|
||||
{
|
||||
impl()->bind6(rAddress, reuseAddress, ipV6Only);
|
||||
impl()->bind6(address, reuseAddress, ipV6Only);
|
||||
}
|
||||
|
||||
|
||||
@ -98,8 +98,8 @@ void ServerSocket::bind6(Poco::UInt16 port, bool reuseAddress, bool ipV6Only)
|
||||
{
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
IPAddress wildcardAddr(IPAddress::IPv6);
|
||||
SocketAddress socketAddress(wildcardAddr, port);
|
||||
impl()->bind6(socketAddress, reuseAddress, ipV6Only);
|
||||
SocketAddress address(wildcardAddr, port);
|
||||
impl()->bind6(address, reuseAddress, ipV6Only);
|
||||
#else
|
||||
throw Poco::NotImplementedException("No IPv6 support available");
|
||||
#endif // POCO_HAVE_IPv6
|
||||
|
@ -101,9 +101,9 @@ SocketAddress::SocketAddress(const std::string& hostAddress, const std::string&
|
||||
}
|
||||
|
||||
|
||||
SocketAddress::SocketAddress(Family addressFamily, const std::string& rAddr)
|
||||
SocketAddress::SocketAddress(Family family, const std::string& addr)
|
||||
{
|
||||
init(addressFamily, rAddr);
|
||||
init(family, addr);
|
||||
}
|
||||
|
||||
|
||||
@ -128,16 +128,16 @@ SocketAddress::SocketAddress(const SocketAddress& socketAddress)
|
||||
}
|
||||
|
||||
|
||||
SocketAddress::SocketAddress(const struct sockaddr* sockAddr, poco_socklen_t addressLength)
|
||||
SocketAddress::SocketAddress(const struct sockaddr* sockAddr, poco_socklen_t length)
|
||||
{
|
||||
if (addressLength == sizeof(struct sockaddr_in) && sockAddr->sa_family == AF_INET)
|
||||
if (length == sizeof(struct sockaddr_in) && sockAddr->sa_family == AF_INET)
|
||||
newIPv4(reinterpret_cast<const struct sockaddr_in*>(sockAddr));
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
else if (addressLength == sizeof(struct sockaddr_in6) && sockAddr->sa_family == AF_INET6)
|
||||
else if (length == sizeof(struct sockaddr_in6) && sockAddr->sa_family == AF_INET6)
|
||||
newIPv6(reinterpret_cast<const struct sockaddr_in6*>(sockAddr));
|
||||
#endif
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
else if (addressLength > 0 && addressLength <= sizeof(struct sockaddr_un) && sockAddr->sa_family == AF_UNIX)
|
||||
else if (length > 0 && length <= sizeof(struct sockaddr_un) && sockAddr->sa_family == AF_UNIX)
|
||||
newLocal(reinterpret_cast<const sockaddr_un*>(sockAddr));
|
||||
#endif
|
||||
else throw Poco::InvalidArgumentException("Invalid address length or family passed to SocketAddress()");
|
||||
@ -281,8 +281,8 @@ void SocketAddress::init(const std::string& hostAndPort)
|
||||
{
|
||||
poco_assert (!hostAndPort.empty());
|
||||
|
||||
std::string socketHost;
|
||||
std::string socketPort;
|
||||
std::string host;
|
||||
std::string port;
|
||||
std::string::const_iterator it = hostAndPort.begin();
|
||||
std::string::const_iterator end = hostAndPort.end();
|
||||
|
||||
@ -296,30 +296,30 @@ void SocketAddress::init(const std::string& hostAndPort)
|
||||
if (*it == '[')
|
||||
{
|
||||
++it;
|
||||
while (it != end && *it != ']') socketHost += *it++;
|
||||
while (it != end && *it != ']') host += *it++;
|
||||
if (it == end) throw InvalidArgumentException("Malformed IPv6 address");
|
||||
++it;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (it != end && *it != ':') socketHost += *it++;
|
||||
while (it != end && *it != ':') host += *it++;
|
||||
}
|
||||
if (it != end && *it == ':')
|
||||
{
|
||||
++it;
|
||||
while (it != end) socketPort += *it++;
|
||||
while (it != end) port += *it++;
|
||||
}
|
||||
else throw InvalidArgumentException("Missing port number");
|
||||
init(socketHost, resolveService(socketPort));
|
||||
init(host, resolveService(port));
|
||||
}
|
||||
|
||||
|
||||
Poco::UInt16 SocketAddress::resolveService(const std::string& service)
|
||||
{
|
||||
unsigned socketPort;
|
||||
if (NumberParser::tryParseUnsigned(service, socketPort) && socketPort <= 0xFFFF)
|
||||
unsigned port;
|
||||
if (NumberParser::tryParseUnsigned(service, port) && port <= 0xFFFF)
|
||||
{
|
||||
return (UInt16) socketPort;
|
||||
return (UInt16) port;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -53,19 +53,19 @@ IPv4SocketAddressImpl::IPv4SocketAddressImpl()
|
||||
}
|
||||
|
||||
|
||||
IPv4SocketAddressImpl::IPv4SocketAddressImpl(const struct sockaddr_in* pAddr)
|
||||
IPv4SocketAddressImpl::IPv4SocketAddressImpl(const struct sockaddr_in* addr)
|
||||
{
|
||||
std::memcpy(&_addr, pAddr, sizeof(_addr));
|
||||
std::memcpy(&_addr, addr, sizeof(_addr));
|
||||
}
|
||||
|
||||
|
||||
IPv4SocketAddressImpl::IPv4SocketAddressImpl(const void* pAddr, UInt16 socketPort)
|
||||
IPv4SocketAddressImpl::IPv4SocketAddressImpl(const void* addr, UInt16 port)
|
||||
{
|
||||
std::memset(&_addr, 0, sizeof(_addr));
|
||||
_addr.sin_family = AF_INET;
|
||||
poco_set_sin_len(&_addr);
|
||||
std::memcpy(&_addr.sin_addr, pAddr, sizeof(_addr.sin_addr));
|
||||
_addr.sin_port = socketPort;
|
||||
std::memcpy(&_addr.sin_addr, addr, sizeof(_addr.sin_addr));
|
||||
_addr.sin_port = port;
|
||||
}
|
||||
|
||||
|
||||
@ -87,29 +87,29 @@ std::string IPv4SocketAddressImpl::toString() const
|
||||
//
|
||||
|
||||
|
||||
IPv6SocketAddressImpl::IPv6SocketAddressImpl(const struct sockaddr_in6* pAddr)
|
||||
IPv6SocketAddressImpl::IPv6SocketAddressImpl(const struct sockaddr_in6* addr)
|
||||
{
|
||||
std::memcpy(&_addr, pAddr, sizeof(_addr));
|
||||
std::memcpy(&_addr, addr, sizeof(_addr));
|
||||
}
|
||||
|
||||
|
||||
IPv6SocketAddressImpl::IPv6SocketAddressImpl(const void* pAddr, UInt16 socketPort)
|
||||
IPv6SocketAddressImpl::IPv6SocketAddressImpl(const void* addr, UInt16 port)
|
||||
{
|
||||
std::memset(&_addr, 0, sizeof(_addr));
|
||||
_addr.sin6_family = AF_INET6;
|
||||
poco_set_sin6_len(&_addr);
|
||||
std::memcpy(&_addr.sin6_addr, pAddr, sizeof(_addr.sin6_addr));
|
||||
_addr.sin6_port = socketPort;
|
||||
std::memcpy(&_addr.sin6_addr, addr, sizeof(_addr.sin6_addr));
|
||||
_addr.sin6_port = port;
|
||||
}
|
||||
|
||||
|
||||
IPv6SocketAddressImpl::IPv6SocketAddressImpl(const void* pAddr, UInt16 socketPort, UInt32 scope)
|
||||
IPv6SocketAddressImpl::IPv6SocketAddressImpl(const void* addr, UInt16 port, UInt32 scope)
|
||||
{
|
||||
std::memset(&_addr, 0, sizeof(_addr));
|
||||
_addr.sin6_family = AF_INET6;
|
||||
poco_set_sin6_len(&_addr);
|
||||
std::memcpy(&_addr.sin6_addr, pAddr, sizeof(_addr.sin6_addr));
|
||||
_addr.sin6_port = socketPort;
|
||||
std::memcpy(&_addr.sin6_addr, addr, sizeof(_addr.sin6_addr));
|
||||
_addr.sin6_port = port;
|
||||
_addr.sin6_scope_id = scope;
|
||||
}
|
||||
|
||||
@ -137,19 +137,19 @@ std::string IPv6SocketAddressImpl::toString() const
|
||||
//
|
||||
|
||||
|
||||
LocalSocketAddressImpl::LocalSocketAddressImpl(const struct sockaddr_un* pAddr)
|
||||
LocalSocketAddressImpl::LocalSocketAddressImpl(const struct sockaddr_un* addr)
|
||||
{
|
||||
_pAddr = new sockaddr_un;
|
||||
std::memcpy(_pAddr, pAddr, sizeof(struct sockaddr_un));
|
||||
std::memcpy(_pAddr, addr, sizeof(struct sockaddr_un));
|
||||
}
|
||||
|
||||
|
||||
LocalSocketAddressImpl::LocalSocketAddressImpl(const char* pPath)
|
||||
LocalSocketAddressImpl::LocalSocketAddressImpl(const char* path)
|
||||
{
|
||||
_pAddr = new sockaddr_un;
|
||||
poco_set_sun_len(_pAddr, std::strlen(pPath) + sizeof(struct sockaddr_un) - sizeof(_pAddr->sun_path) + 1);
|
||||
poco_set_sun_len(_pAddr, std::strlen(path) + sizeof(struct sockaddr_un) - sizeof(_pAddr->sun_path) + 1);
|
||||
_pAddr->sun_family = AF_UNIX;
|
||||
std::strcpy(_pAddr->sun_path, pPath);
|
||||
std::strcpy(_pAddr->sun_path, path);
|
||||
}
|
||||
|
||||
|
||||
|
@ -73,8 +73,8 @@ SocketImpl::SocketImpl():
|
||||
}
|
||||
|
||||
|
||||
SocketImpl::SocketImpl(poco_socket_t socketfd):
|
||||
_sockfd(socketfd),
|
||||
SocketImpl::SocketImpl(poco_socket_t sockfd):
|
||||
_sockfd(sockfd),
|
||||
_blocking(true),
|
||||
_isBrokenTimeout(checkIsBrokenTimeout())
|
||||
{
|
||||
@ -110,51 +110,51 @@ SocketImpl* SocketImpl::acceptConnection(SocketAddress& clientAddr)
|
||||
}
|
||||
|
||||
|
||||
void SocketImpl::connect(const SocketAddress& rAddress)
|
||||
void SocketImpl::connect(const SocketAddress& address)
|
||||
{
|
||||
if (_sockfd == POCO_INVALID_SOCKET)
|
||||
{
|
||||
init(rAddress.af());
|
||||
init(address.af());
|
||||
}
|
||||
int rc;
|
||||
do
|
||||
{
|
||||
#if defined(POCO_VXWORKS)
|
||||
rc = ::connect(_sockfd, (sockaddr*) rAddress.addr(), rAddress.length());
|
||||
rc = ::connect(_sockfd, (sockaddr*) address.addr(), address.length());
|
||||
#else
|
||||
rc = ::connect(_sockfd, rAddress.addr(), rAddress.length());
|
||||
rc = ::connect(_sockfd, address.addr(), address.length());
|
||||
#endif
|
||||
}
|
||||
while (rc != 0 && lastError() == POCO_EINTR);
|
||||
if (rc != 0)
|
||||
{
|
||||
int err = lastError();
|
||||
error(err, rAddress.toString());
|
||||
error(err, address.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SocketImpl::connect(const SocketAddress& rAddress, const Poco::Timespan& timeout)
|
||||
void SocketImpl::connect(const SocketAddress& address, const Poco::Timespan& timeout)
|
||||
{
|
||||
if (_sockfd == POCO_INVALID_SOCKET)
|
||||
{
|
||||
init(rAddress.af());
|
||||
init(address.af());
|
||||
}
|
||||
setBlocking(false);
|
||||
try
|
||||
{
|
||||
#if defined(POCO_VXWORKS)
|
||||
int rc = ::connect(_sockfd, (sockaddr*) rAddress.addr(), rAddress.length());
|
||||
int rc = ::connect(_sockfd, (sockaddr*) address.addr(), address.length());
|
||||
#else
|
||||
int rc = ::connect(_sockfd, rAddress.addr(), rAddress.length());
|
||||
int rc = ::connect(_sockfd, address.addr(), address.length());
|
||||
#endif
|
||||
if (rc != 0)
|
||||
{
|
||||
int err = lastError();
|
||||
if (err != POCO_EINPROGRESS && err != POCO_EWOULDBLOCK)
|
||||
error(err, rAddress.toString());
|
||||
error(err, address.toString());
|
||||
if (!poll(timeout, SELECT_READ | SELECT_WRITE | SELECT_ERROR))
|
||||
throw Poco::TimeoutException("connect timed out", rAddress.toString());
|
||||
throw Poco::TimeoutException("connect timed out", address.toString());
|
||||
err = socketError();
|
||||
if (err != 0) error(err);
|
||||
}
|
||||
@ -168,32 +168,32 @@ void SocketImpl::connect(const SocketAddress& rAddress, const Poco::Timespan& ti
|
||||
}
|
||||
|
||||
|
||||
void SocketImpl::connectNB(const SocketAddress& rAddress)
|
||||
void SocketImpl::connectNB(const SocketAddress& address)
|
||||
{
|
||||
if (_sockfd == POCO_INVALID_SOCKET)
|
||||
{
|
||||
init(rAddress.af());
|
||||
init(address.af());
|
||||
}
|
||||
setBlocking(false);
|
||||
#if defined(POCO_VXWORKS)
|
||||
int rc = ::connect(_sockfd, (sockaddr*) rAddress.addr(), rAddress.length());
|
||||
int rc = ::connect(_sockfd, (sockaddr*) address.addr(), address.length());
|
||||
#else
|
||||
int rc = ::connect(_sockfd, rAddress.addr(), rAddress.length());
|
||||
int rc = ::connect(_sockfd, address.addr(), address.length());
|
||||
#endif
|
||||
if (rc != 0)
|
||||
{
|
||||
int err = lastError();
|
||||
if (err != POCO_EINPROGRESS && err != POCO_EWOULDBLOCK)
|
||||
error(err, rAddress.toString());
|
||||
error(err, address.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SocketImpl::bind(const SocketAddress& rAddress, bool reuseAddress)
|
||||
void SocketImpl::bind(const SocketAddress& address, bool reuseAddress)
|
||||
{
|
||||
if (_sockfd == POCO_INVALID_SOCKET)
|
||||
{
|
||||
init(rAddress.af());
|
||||
init(address.af());
|
||||
}
|
||||
if (reuseAddress)
|
||||
{
|
||||
@ -201,23 +201,23 @@ void SocketImpl::bind(const SocketAddress& rAddress, bool reuseAddress)
|
||||
setReusePort(true);
|
||||
}
|
||||
#if defined(POCO_VXWORKS)
|
||||
int rc = ::bind(_sockfd, (sockaddr*) rAddress.addr(), rAddress.length());
|
||||
int rc = ::bind(_sockfd, (sockaddr*) address.addr(), address.length());
|
||||
#else
|
||||
int rc = ::bind(_sockfd, rAddress.addr(), rAddress.length());
|
||||
int rc = ::bind(_sockfd, address.addr(), address.length());
|
||||
#endif
|
||||
if (rc != 0) error(rAddress.toString());
|
||||
if (rc != 0) error(address.toString());
|
||||
}
|
||||
|
||||
|
||||
void SocketImpl::bind6(const SocketAddress& rAddress, bool reuseAddress, bool ipV6Only)
|
||||
void SocketImpl::bind6(const SocketAddress& address, bool reuseAddress, bool ipV6Only)
|
||||
{
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
if (rAddress.family() != SocketAddress::IPv6)
|
||||
if (address.family() != SocketAddress::IPv6)
|
||||
throw Poco::InvalidArgumentException("SocketAddress must be an IPv6 address");
|
||||
|
||||
if (_sockfd == POCO_INVALID_SOCKET)
|
||||
{
|
||||
init(rAddress.af());
|
||||
init(address.af());
|
||||
}
|
||||
#ifdef IPV6_V6ONLY
|
||||
setOption(IPPROTO_IPV6, IPV6_V6ONLY, ipV6Only ? 1 : 0);
|
||||
@ -229,8 +229,8 @@ void SocketImpl::bind6(const SocketAddress& rAddress, bool reuseAddress, bool ip
|
||||
setReuseAddress(true);
|
||||
setReusePort(true);
|
||||
}
|
||||
int rc = ::bind(_sockfd, rAddress.addr(), rAddress.length());
|
||||
if (rc != 0) error(rAddress.toString());
|
||||
int rc = ::bind(_sockfd, address.addr(), address.length());
|
||||
if (rc != 0) error(address.toString());
|
||||
#else
|
||||
throw Poco::NotImplementedException("No IPv6 support available");
|
||||
#endif
|
||||
@ -338,16 +338,16 @@ int SocketImpl::receiveBytes(void* buffer, int length, int flags)
|
||||
}
|
||||
|
||||
|
||||
int SocketImpl::sendTo(const void* buffer, int length, const SocketAddress& rAddress, int flags)
|
||||
int SocketImpl::sendTo(const void* buffer, int length, const SocketAddress& address, int flags)
|
||||
{
|
||||
int rc;
|
||||
do
|
||||
{
|
||||
if (_sockfd == POCO_INVALID_SOCKET) throw InvalidSocketException();
|
||||
#if defined(POCO_VXWORKS)
|
||||
rc = ::sendto(_sockfd, (char*) buffer, length, flags, (sockaddr*) rAddress.addr(), rAddress.length());
|
||||
rc = ::sendto(_sockfd, (char*) buffer, length, flags, (sockaddr*) address.addr(), address.length());
|
||||
#else
|
||||
rc = ::sendto(_sockfd, reinterpret_cast<const char*>(buffer), length, flags, rAddress.addr(), rAddress.length());
|
||||
rc = ::sendto(_sockfd, reinterpret_cast<const char*>(buffer), length, flags, address.addr(), address.length());
|
||||
#endif
|
||||
}
|
||||
while (_blocking && rc < 0 && lastError() == POCO_EINTR);
|
||||
@ -356,7 +356,7 @@ int SocketImpl::sendTo(const void* buffer, int length, const SocketAddress& rAdd
|
||||
}
|
||||
|
||||
|
||||
int SocketImpl::receiveFrom(void* buffer, int length, SocketAddress& rAddress, int flags)
|
||||
int SocketImpl::receiveFrom(void* buffer, int length, SocketAddress& address, int flags)
|
||||
{
|
||||
if (_isBrokenTimeout)
|
||||
{
|
||||
@ -379,7 +379,7 @@ int SocketImpl::receiveFrom(void* buffer, int length, SocketAddress& rAddress, i
|
||||
while (_blocking && rc < 0 && lastError() == POCO_EINTR);
|
||||
if (rc >= 0)
|
||||
{
|
||||
rAddress = SocketAddress(pSA, saLen);
|
||||
address = SocketAddress(pSA, saLen);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -420,8 +420,8 @@ bool SocketImpl::secure() const
|
||||
|
||||
bool SocketImpl::poll(const Poco::Timespan& timeout, int mode)
|
||||
{
|
||||
poco_socket_t socketfd = _sockfd;
|
||||
if (socketfd == POCO_INVALID_SOCKET) throw InvalidSocketException();
|
||||
poco_socket_t sockfd = _sockfd;
|
||||
if (sockfd == POCO_INVALID_SOCKET) throw InvalidSocketException();
|
||||
|
||||
#if defined(POCO_HAVE_FD_EPOLL)
|
||||
|
||||
@ -443,7 +443,7 @@ bool SocketImpl::poll(const Poco::Timespan& timeout, int mode)
|
||||
if (mode & SELECT_ERROR)
|
||||
evin.events |= EPOLLERR;
|
||||
|
||||
if (epoll_ctl(epollfd, EPOLL_CTL_ADD, socketfd, &evin) < 0)
|
||||
if (epoll_ctl(epollfd, EPOLL_CTL_ADD, sockfd, &evin) < 0)
|
||||
{
|
||||
char buf[1024];
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
@ -516,15 +516,15 @@ bool SocketImpl::poll(const Poco::Timespan& timeout, int mode)
|
||||
FD_ZERO(&fdExcept);
|
||||
if (mode & SELECT_READ)
|
||||
{
|
||||
FD_SET(socketfd, &fdRead);
|
||||
FD_SET(sockfd, &fdRead);
|
||||
}
|
||||
if (mode & SELECT_WRITE)
|
||||
{
|
||||
FD_SET(socketfd, &fdWrite);
|
||||
FD_SET(sockfd, &fdWrite);
|
||||
}
|
||||
if (mode & SELECT_ERROR)
|
||||
{
|
||||
FD_SET(socketfd, &fdExcept);
|
||||
FD_SET(sockfd, &fdExcept);
|
||||
}
|
||||
Poco::Timespan remainingTime(timeout);
|
||||
int errorCode = POCO_ENOERR;
|
||||
@ -535,7 +535,7 @@ bool SocketImpl::poll(const Poco::Timespan& timeout, int mode)
|
||||
tv.tv_sec = (long) remainingTime.totalSeconds();
|
||||
tv.tv_usec = (long) remainingTime.useconds();
|
||||
Poco::Timestamp start;
|
||||
rc = ::select(int(socketfd) + 1, &fdRead, &fdWrite, &fdExcept, &tv);
|
||||
rc = ::select(int(sockfd) + 1, &fdRead, &fdWrite, &fdExcept, &tv);
|
||||
if (rc < 0 && (errorCode = lastError()) == POCO_EINTR)
|
||||
{
|
||||
Poco::Timestamp end;
|
||||
|
@ -32,9 +32,9 @@ SocketNotification::~SocketNotification()
|
||||
}
|
||||
|
||||
|
||||
void SocketNotification::setSocket(const Socket& rSocket)
|
||||
void SocketNotification::setSocket(const Socket& socket)
|
||||
{
|
||||
_socket = rSocket;
|
||||
_socket = socket;
|
||||
}
|
||||
|
||||
|
||||
|
@ -66,8 +66,8 @@ int SocketStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
|
||||
//
|
||||
|
||||
|
||||
SocketIOS::SocketIOS(const Socket& rSocket):
|
||||
_buf(rSocket)
|
||||
SocketIOS::SocketIOS(const Socket& socket):
|
||||
_buf(socket)
|
||||
{
|
||||
poco_ios_init(&_buf);
|
||||
}
|
||||
@ -109,8 +109,8 @@ StreamSocket SocketIOS::socket() const
|
||||
//
|
||||
|
||||
|
||||
SocketOutputStream::SocketOutputStream(const Socket& rSocket):
|
||||
SocketIOS(rSocket),
|
||||
SocketOutputStream::SocketOutputStream(const Socket& socket):
|
||||
SocketIOS(socket),
|
||||
std::ostream(&_buf)
|
||||
{
|
||||
}
|
||||
@ -126,8 +126,8 @@ SocketOutputStream::~SocketOutputStream()
|
||||
//
|
||||
|
||||
|
||||
SocketInputStream::SocketInputStream(const Socket& rSocket):
|
||||
SocketIOS(rSocket),
|
||||
SocketInputStream::SocketInputStream(const Socket& socket):
|
||||
SocketIOS(socket),
|
||||
std::istream(&_buf)
|
||||
{
|
||||
}
|
||||
@ -143,8 +143,8 @@ SocketInputStream::~SocketInputStream()
|
||||
//
|
||||
|
||||
|
||||
SocketStream::SocketStream(const Socket& rSocket):
|
||||
SocketIOS(rSocket),
|
||||
SocketStream::SocketStream(const Socket& socket):
|
||||
SocketIOS(socket),
|
||||
std::iostream(&_buf)
|
||||
{
|
||||
}
|
||||
|
@ -35,9 +35,9 @@ StreamSocket::StreamSocket(): Socket(new StreamSocketImpl)
|
||||
}
|
||||
|
||||
|
||||
StreamSocket::StreamSocket(const SocketAddress& rAddress): Socket(new StreamSocketImpl(rAddress.family()))
|
||||
StreamSocket::StreamSocket(const SocketAddress& address): Socket(new StreamSocketImpl(address.family()))
|
||||
{
|
||||
connect(rAddress);
|
||||
connect(address);
|
||||
}
|
||||
|
||||
|
||||
@ -75,21 +75,21 @@ StreamSocket& StreamSocket::operator = (const Socket& socket)
|
||||
}
|
||||
|
||||
|
||||
void StreamSocket::connect(const SocketAddress& rAddress)
|
||||
void StreamSocket::connect(const SocketAddress& address)
|
||||
{
|
||||
impl()->connect(rAddress);
|
||||
impl()->connect(address);
|
||||
}
|
||||
|
||||
|
||||
void StreamSocket::connect(const SocketAddress& rAddress, const Poco::Timespan& timeout)
|
||||
void StreamSocket::connect(const SocketAddress& address, const Poco::Timespan& timeout)
|
||||
{
|
||||
impl()->connect(rAddress, timeout);
|
||||
impl()->connect(address, timeout);
|
||||
}
|
||||
|
||||
|
||||
void StreamSocket::connectNB(const SocketAddress& rAddress)
|
||||
void StreamSocket::connectNB(const SocketAddress& address)
|
||||
{
|
||||
impl()->connectNB(rAddress);
|
||||
impl()->connectNB(address);
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,7 +44,7 @@ StreamSocketImpl::StreamSocketImpl(SocketAddress::Family family)
|
||||
}
|
||||
|
||||
|
||||
StreamSocketImpl::StreamSocketImpl(poco_socket_t socketfd): SocketImpl(socketfd)
|
||||
StreamSocketImpl::StreamSocketImpl(poco_socket_t sockfd): SocketImpl(sockfd)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -28,17 +28,17 @@ StringPartSource::StringPartSource(const std::string& str):
|
||||
}
|
||||
|
||||
|
||||
StringPartSource::StringPartSource(const std::string& str, const std::string& rMediaType):
|
||||
PartSource(rMediaType),
|
||||
StringPartSource::StringPartSource(const std::string& str, const std::string& mediaType):
|
||||
PartSource(mediaType),
|
||||
_istr(str)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
StringPartSource::StringPartSource(const std::string& str, const std::string& rMediaType, const std::string& rFilename):
|
||||
PartSource(rMediaType),
|
||||
StringPartSource::StringPartSource(const std::string& str, const std::string& mediaType, const std::string& filename):
|
||||
PartSource(mediaType),
|
||||
_istr(str),
|
||||
_filename(rFilename)
|
||||
_filename(filename)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -46,9 +46,9 @@ TCPServer::TCPServer(TCPServerConnectionFactory::Ptr pFactory, Poco::UInt16 port
|
||||
}
|
||||
|
||||
|
||||
TCPServer::TCPServer(TCPServerConnectionFactory::Ptr pFactory, const ServerSocket& rSocket, TCPServerParams::Ptr pParams):
|
||||
_socket(rSocket),
|
||||
_thread(threadName(rSocket)),
|
||||
TCPServer::TCPServer(TCPServerConnectionFactory::Ptr pFactory, const ServerSocket& socket, TCPServerParams::Ptr pParams):
|
||||
_socket(socket),
|
||||
_thread(threadName(socket)),
|
||||
_stopped(true)
|
||||
{
|
||||
Poco::ThreadPool& pool = Poco::ThreadPool::defaultPool();
|
||||
@ -61,10 +61,10 @@ TCPServer::TCPServer(TCPServerConnectionFactory::Ptr pFactory, const ServerSocke
|
||||
}
|
||||
|
||||
|
||||
TCPServer::TCPServer(TCPServerConnectionFactory::Ptr pFactory, Poco::ThreadPool& threadPool, const ServerSocket& rSocket, TCPServerParams::Ptr pParams):
|
||||
_socket(rSocket),
|
||||
TCPServer::TCPServer(TCPServerConnectionFactory::Ptr pFactory, Poco::ThreadPool& threadPool, const ServerSocket& socket, TCPServerParams::Ptr pParams):
|
||||
_socket(socket),
|
||||
_pDispatcher(new TCPServerDispatcher(pFactory, threadPool, pParams)),
|
||||
_thread(threadName(rSocket)),
|
||||
_thread(threadName(socket)),
|
||||
_stopped(true)
|
||||
{
|
||||
}
|
||||
|
@ -27,8 +27,8 @@ namespace Poco {
|
||||
namespace Net {
|
||||
|
||||
|
||||
TCPServerConnection::TCPServerConnection(const StreamSocket& rSocket):
|
||||
_socket(rSocket)
|
||||
TCPServerConnection::TCPServerConnection(const StreamSocket& socket):
|
||||
_socket(socket)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,8 @@ namespace Net {
|
||||
class TCPConnectionNotification: public Notification
|
||||
{
|
||||
public:
|
||||
TCPConnectionNotification(const StreamSocket& rSocket):
|
||||
_socket(rSocket)
|
||||
TCPConnectionNotification(const StreamSocket& socket):
|
||||
_socket(socket)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -29,11 +29,11 @@ namespace Poco {
|
||||
namespace Net {
|
||||
|
||||
|
||||
WebSocketImpl::WebSocketImpl(StreamSocketImpl* pStreamSocketImpl, bool isMustMaskPayload):
|
||||
WebSocketImpl::WebSocketImpl(StreamSocketImpl* pStreamSocketImpl, bool mustMaskPayload):
|
||||
StreamSocketImpl(pStreamSocketImpl->sockfd()),
|
||||
_pStreamSocketImpl(pStreamSocketImpl),
|
||||
_frameFlags(0),
|
||||
_mustMaskPayload(isMustMaskPayload)
|
||||
_mustMaskPayload(mustMaskPayload)
|
||||
{
|
||||
poco_check_ptr(pStreamSocketImpl);
|
||||
_pStreamSocketImpl->duplicate();
|
||||
@ -233,31 +233,31 @@ SocketImpl* WebSocketImpl::acceptConnection(SocketAddress& clientAddr)
|
||||
}
|
||||
|
||||
|
||||
void WebSocketImpl::connect(const SocketAddress& rAddress)
|
||||
void WebSocketImpl::connect(const SocketAddress& address)
|
||||
{
|
||||
throw Poco::InvalidAccessException("Cannot connect() a WebSocketImpl");
|
||||
}
|
||||
|
||||
|
||||
void WebSocketImpl::connect(const SocketAddress& rAddress, const Poco::Timespan& timeout)
|
||||
void WebSocketImpl::connect(const SocketAddress& address, const Poco::Timespan& timeout)
|
||||
{
|
||||
throw Poco::InvalidAccessException("Cannot connect() a WebSocketImpl");
|
||||
}
|
||||
|
||||
|
||||
void WebSocketImpl::connectNB(const SocketAddress& rAddress)
|
||||
void WebSocketImpl::connectNB(const SocketAddress& address)
|
||||
{
|
||||
throw Poco::InvalidAccessException("Cannot connectNB() a WebSocketImpl");
|
||||
}
|
||||
|
||||
|
||||
void WebSocketImpl::bind(const SocketAddress& rAddress, bool reuseAddress)
|
||||
void WebSocketImpl::bind(const SocketAddress& address, bool reuseAddress)
|
||||
{
|
||||
throw Poco::InvalidAccessException("Cannot bind() a WebSocketImpl");
|
||||
}
|
||||
|
||||
|
||||
void WebSocketImpl::bind6(const SocketAddress& rAddress, bool reuseAddress, bool ipV6Only)
|
||||
void WebSocketImpl::bind6(const SocketAddress& address, bool reuseAddress, bool ipV6Only)
|
||||
{
|
||||
throw Poco::InvalidAccessException("Cannot bind6() a WebSocketImpl");
|
||||
}
|
||||
@ -294,13 +294,13 @@ void WebSocketImpl::shutdown()
|
||||
}
|
||||
|
||||
|
||||
int WebSocketImpl::sendTo(const void* buffer, int length, const SocketAddress& rAddress, int flags)
|
||||
int WebSocketImpl::sendTo(const void* buffer, int length, const SocketAddress& address, int flags)
|
||||
{
|
||||
throw Poco::InvalidAccessException("Cannot sendTo() on a WebSocketImpl");
|
||||
}
|
||||
|
||||
|
||||
int WebSocketImpl::receiveFrom(void* buffer, int length, SocketAddress& rAddress, int flags)
|
||||
int WebSocketImpl::receiveFrom(void* buffer, int length, SocketAddress& address, int flags)
|
||||
{
|
||||
throw Poco::InvalidAccessException("Cannot receiveFrom() on a WebSocketImpl");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user