#pragma once #include "BaseICMP.h" #include "ehs/System/OS.h" #include #include #include namespace ehs { struct PseudoICMPv6_Header { sockaddr_in6 src; sockaddr_in6 dst; UInt_32 length; }; class ICMP : public BaseICMP { private: Socket hdl; sockaddr_in6 src; public: ~ICMP() override; ICMP(); ICMP(IP version); ICMP(ICMP &&icmp) noexcept; ICMP(const ICMP &icmp); ICMP &operator=(ICMP &&icmp) noexcept; ICMP &operator=(const ICMP &icmp); void Release() 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) override; UInt_64 SendV4(const Str_8 &address, ICMP_Header header, const Byte *data, UInt_64 size) override; UInt_64 ReceiveV6(Str_8 &address, ICMP_Header &header, Serializer &data) const override; UInt_64 ReceiveV4(Str_8 &address, ICMP_Header &header, Serializer &data) const override; }; }