Added ICMPv6 support to Linux.
This commit is contained in:
@@ -25,6 +25,8 @@ namespace ehs
|
||||
IP version;
|
||||
|
||||
public:
|
||||
virtual ~BaseICMP() = default;
|
||||
|
||||
BaseICMP();
|
||||
|
||||
BaseICMP(IP version);
|
||||
@@ -39,15 +41,17 @@ namespace ehs
|
||||
|
||||
virtual UInt_64 Send(const Str_8 &address, ICMP_Header header, const Byte *data, UInt_64 size);
|
||||
|
||||
virtual UInt_64 Receive(Str_8 &address, ICMP_Header header, Serializer<UInt_64> &data);
|
||||
virtual UInt_64 Receive(Str_8 &address, ICMP_Header &header, Serializer<UInt_64> &data);
|
||||
|
||||
void SendEchoRequest(const Str_8 &address, ICMP_EchoRequest er, const Byte *data, UInt_64 size);
|
||||
|
||||
virtual void SetReceiveTimeout(UInt_64 timeout);
|
||||
|
||||
IP GetVersion() const;
|
||||
|
||||
virtual bool IsValid() const;
|
||||
|
||||
protected:
|
||||
static UInt_16 ComputeChecksum(UInt_16 *buffer, Size length);
|
||||
static UInt_16 ComputeChecksumV4(UInt_16 *buffer, Size length);
|
||||
};
|
||||
}
|
||||
|
@@ -2,14 +2,26 @@
|
||||
|
||||
#include "BaseICMP.h"
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
class ICMP : public BaseICMP
|
||||
struct PseudoICMPv6_Header
|
||||
{
|
||||
sockaddr_in6 src;
|
||||
sockaddr_in6 dst;
|
||||
UInt_32 length;
|
||||
};
|
||||
|
||||
class ICMP final : public BaseICMP
|
||||
{
|
||||
private:
|
||||
Int_32 hdl;
|
||||
sockaddr_in6 src;
|
||||
|
||||
public:
|
||||
~ICMP();
|
||||
|
||||
ICMP();
|
||||
|
||||
ICMP(IP version);
|
||||
@@ -24,10 +36,27 @@ namespace ehs
|
||||
|
||||
UInt_64 Send(const Str_8 &address, ICMP_Header header, const Byte *data, UInt_64 size) override;
|
||||
|
||||
UInt_64 Receive(Str_8 &address, ICMP_Header header, Serializer<UInt_64> &data) override;
|
||||
UInt_64 Receive(Str_8 &address, ICMP_Header &header, Serializer<UInt_64> &data) override;
|
||||
|
||||
void SetReceiveTimeout(UInt_64 timeout) override;
|
||||
|
||||
bool IsValid() const override;
|
||||
|
||||
private:
|
||||
static bool IsLinkLocal(const in6_addr &addr);
|
||||
|
||||
static sockaddr_in6 RetrieveSrcAddress();
|
||||
|
||||
static UInt_32 CalculatePseudoHeaderChecksum(const PseudoICMPv6_Header &header);
|
||||
|
||||
UInt_16 ComputeChecksumV6(UInt_16* buffer, Size length, const sockaddr_in6& dst);
|
||||
|
||||
UInt_64 SendV6(const Str_8 &address, ICMP_Header header, const Byte *data, UInt_64 size);
|
||||
|
||||
UInt_64 SendV4(const Str_8 &address, ICMP_Header header, const Byte *data, UInt_64 size);
|
||||
|
||||
UInt_64 ReceiveV6(Str_8 &address, ICMP_Header &header, Serializer<UInt_64> &data) const;
|
||||
|
||||
UInt_64 ReceiveV4(Str_8 &address, ICMP_Header &header, Serializer<UInt_64> &data) const;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user