backport initialisation of _seq member and some static checking for ICMP packet

This commit is contained in:
Marian Krivos
2012-07-31 05:46:08 +00:00
parent 672d4758c3
commit fe0ba56dc4
2 changed files with 11 additions and 3 deletions

View File

@@ -43,6 +43,7 @@
#include "Poco/Foundation.h"
#include "Poco/Net/Socket.h"
#include "Poco/Net/ICMPPacketImpl.h"
#include <cstddef>
namespace Poco {
@@ -67,6 +68,12 @@ public:
Poco::UInt16 seq;
};
// compile-time shield against misalignment
poco_static_assert (offsetof(Header, code) == 0x01);
poco_static_assert (offsetof(Header, checksum) == 0x02);
poco_static_assert (offsetof(Header, id) == 0x04);
poco_static_assert (offsetof(Header, seq) == 0x06);
enum MessageType
{
ECHO_REPLY,

View File

@@ -125,8 +125,9 @@ const std::string ICMPv4PacketImpl::PARAMETER_PROBLEM_CODE[] =
};
ICMPv4PacketImpl::ICMPv4PacketImpl(int dataSize):
ICMPPacketImpl(dataSize)
ICMPv4PacketImpl::ICMPv4PacketImpl(int dataSize)
: ICMPPacketImpl(dataSize),
_seq(0)
{
initPacket();
}