fix ICMP tests

This commit is contained in:
Alex Fabijanic
2018-06-01 13:01:43 -05:00
parent 5bf7a0e8fd
commit 0084c75471
7 changed files with 12 additions and 14 deletions

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="NetCore">
<UniqueIdentifier>{c94a716b-53e1-4386-9dd9-c34b92252f38}</UniqueIdentifier>
<UniqueIdentifier>{c94a716b-53e1-4386-9dd9-c34b92252f38}</UniqueIdentifier>
</Filter>
<Filter Include="NetCore\Header Files">
<UniqueIdentifier>{c19f980f-ac2d-438a-bd97-e0b5e5fa3fab}</UniqueIdentifier>

View File

@@ -102,7 +102,7 @@ Poco::UInt16 ICMPSocket::mtu(const SocketAddress& address, Poco::UInt16 sz)
{
if (address.family() != IPAddress::IPv4) return 0;
SocketAddress returnAddress;
SocketAddress returnAddress(address);
for (; sz >= 68 /*RFC791*/; --sz)
{
ICMPSocket icmpSocket(address.family(), sz);

View File

@@ -68,12 +68,12 @@ int ICMPSocketImpl::receiveFrom(void*, int, SocketAddress& address, int flags)
if (ts.isElapsed(_timeout)) throw TimeoutException();
buffer.clear();
SocketAddress respAddr;
rc = SocketImpl::receiveFrom(buffer.begin(), expected, respAddr, flags);
rc = SocketImpl::receiveFrom(buffer.begin(), maxPacketSize, respAddr, flags);
if (rc == 0) break;
if (respAddr == address)
{
expected -= rc;
if (expected == 0)
if (expected <= 0)
{
if (_icmpPacket.validReplyID(buffer.begin(), maxPacketSize)) break;
int type = 0, code = 0;

View File

@@ -422,7 +422,7 @@ SocketBuf Socket::makeBuffer(void* buffer, std::size_t length)
SocketBuf ret;
#if defined(POCO_OS_FAMILY_WINDOWS)
ret.buf = reinterpret_cast<char*>(buffer);
ret.len = length;
ret.len = static_cast<ULONG>(length);
#elif defined(POCO_OS_FAMILY_UNIX)
ret.iov_base = buffer;
ret.iov_len = length;

View File

@@ -431,7 +431,7 @@ int SocketImpl::receiveBytes(Poco::Buffer<char>& buffer, int flags, const Poco::
do
{
if (_sockfd == POCO_INVALID_SOCKET) throw InvalidSocketException();
rc = ::recv(_sockfd, buffer.begin(), buffer.size(), flags);
rc = ::recv(_sockfd, buffer.begin(), static_cast<int>(buffer.size()), flags);
}
while (_blocking && rc < 0 && lastError() == POCO_EINTR);
if (rc < 0)

View File

@@ -52,6 +52,7 @@ void ICMPSocketTest::testAssign()
ICMPSocket s2(s1);
}
void ICMPSocketTest::testSendToReceiveFrom()
{
ICMPSocket ss(IPAddress::IPv4);
@@ -64,12 +65,9 @@ void ICMPSocketTest::testSendToReceiveFrom()
ss.receiveFrom(sa);
fail("must throw");
}
catch(ICMPException&)
{
}
catch(TimeoutException&)
{
}
catch (ICMPException&) { }
catch (TimeoutException&) { }
catch (Exception&) { }
ss.sendTo(sa);
ss.receiveFrom(sa);

Submodule openssl updated: 0c6d16ec85...26b1673caa