mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-23 16:48:06 +02:00
backport initialisation of _seq member and some static checking for ICMP packet
This commit is contained in:
@@ -43,6 +43,7 @@
|
|||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/Net/Socket.h"
|
#include "Poco/Net/Socket.h"
|
||||||
#include "Poco/Net/ICMPPacketImpl.h"
|
#include "Poco/Net/ICMPPacketImpl.h"
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
@@ -67,6 +68,12 @@ public:
|
|||||||
Poco::UInt16 seq;
|
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
|
enum MessageType
|
||||||
{
|
{
|
||||||
ECHO_REPLY,
|
ECHO_REPLY,
|
||||||
@@ -175,7 +182,7 @@ private:
|
|||||||
static const std::string REDIRECT_MESSAGE_CODE[REDIRECT_MESSAGE_LENGTH];
|
static const std::string REDIRECT_MESSAGE_CODE[REDIRECT_MESSAGE_LENGTH];
|
||||||
static const std::string TIME_EXCEEDED_CODE[TIME_EXCEEDED_LENGTH];
|
static const std::string TIME_EXCEEDED_CODE[TIME_EXCEEDED_LENGTH];
|
||||||
static const std::string PARAMETER_PROBLEM_CODE[PARAMETER_PROBLEM_LENGTH];
|
static const std::string PARAMETER_PROBLEM_CODE[PARAMETER_PROBLEM_LENGTH];
|
||||||
|
|
||||||
Poco::UInt16 _seq;
|
Poco::UInt16 _seq;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -125,8 +125,9 @@ const std::string ICMPv4PacketImpl::PARAMETER_PROBLEM_CODE[] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
ICMPv4PacketImpl::ICMPv4PacketImpl(int dataSize):
|
ICMPv4PacketImpl::ICMPv4PacketImpl(int dataSize)
|
||||||
ICMPPacketImpl(dataSize)
|
: ICMPPacketImpl(dataSize),
|
||||||
|
_seq(0)
|
||||||
{
|
{
|
||||||
initPacket();
|
initPacket();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user