32 static_assert(
sizeof(
icmphdr) == 4,
"icmphdr size is not 4 bytes");
114 #pragma pack(push, 1)
125 static_assert(
sizeof(
icmp_echo_hdr) == 16,
"icmp_echo_hdr size is not 16 bytes");
145 #pragma pack(push, 1)
169 #pragma pack(push, 1)
182 #pragma pack(push, 1)
189 static_assert(
sizeof(
icmp_time_exceeded) == 8,
"icmp_time_exceeded size is not 8 bytes");
194 static_assert(
sizeof(
icmp_source_quench) == 8,
"icmp_source_quench size is not 8 bytes");
198 #pragma pack(push, 1)
210 static_assert(
sizeof(
icmp_param_problem) == 8,
"icmp_param_problem size is not 8 bytes");
219 #pragma pack(push, 1)
226 static_assert(
sizeof(
icmp_redirect) == 8,
"icmp_redirect size is not 8 bytes");
230 #pragma pack(push, 1)
252 static_assert(
sizeof(icmp_router_address_structure) == 8,
"icmp_router_address_structure size is not 8 bytes");
256 #pragma pack(push, 1)
288 #pragma pack(push, 1)
307 #pragma pack(push, 1)
316 static_assert(
sizeof(
icmp_info_request) == 8,
"icmp_info_request size is not 8 bytes");
321 static_assert(
sizeof(
icmp_info_reply) == 8,
"icmp_info_reply size is not 8 bytes");
331 bool cleanIcmpLayer();
333 bool setEchoData(
IcmpMessageType echoType, uint16_t
id, uint16_t sequence, uint64_t timestamp,
334 const uint8_t* data,
size_t dataLen);
346 :
Layer(data, dataLen, prevLayer, packet,
ICMP)
360 return reinterpret_cast<icmphdr*
>(m_Data);
424 timeval receiveTimestamp, timeval transmitTimestamp);
493 uint8_t code, uint16_t lifetimeInSeconds,
494 const std::vector<icmp_router_address_structure>& routerAddresses);
592 static inline bool isDataValid(
const uint8_t* data,
size_t dataLen);
624 uint8_t type = data[0];
627 if (type == 8 || type == 0 || type == 10 || type == 15 || type == 16)
631 if (type == 13 || type == 14)
635 if (type == 17 || type == 18)
647 if (type == 4 || type == 11)
Definition: IpAddress.h:28
Definition: IPv4Layer.h:408
Definition: IcmpLayer.h:326
icmp_router_solicitation * getRouterSolicitationData()
icmp_address_mask_request * setAddressMaskRequestData(uint16_t id, uint16_t sequence, IPv4Address mask)
icmp_echo_request * getEchoRequestData()
icmp_info_reply * getInfoReplyData()
icmp_info_request * setInfoRequestData(uint16_t id, uint16_t sequence)
icmp_echo_reply * getEchoReplyData()
size_t getHeaderLen() const override
icmp_source_quench * getSourceQuenchdata()
icmp_echo_reply * setEchoReplyData(uint16_t id, uint16_t sequence, uint64_t timestamp, const uint8_t *data, size_t dataLen)
icmp_echo_request * setEchoRequestData(uint16_t id, uint16_t sequence, uint64_t timestamp, const uint8_t *data, size_t dataLen)
IcmpLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: IcmpLayer.h:345
icmp_router_solicitation * setRouterSolicitationData()
icmp_address_mask_reply * setAddressMaskReplyData(uint16_t id, uint16_t sequence, IPv4Address mask)
icmp_router_advertisement * setRouterAdvertisementData(uint8_t code, uint16_t lifetimeInSeconds, const std::vector< icmp_router_address_structure > &routerAddresses)
icmp_redirect * getRedirectData()
icmp_address_mask_request * getAddressMaskRequestData()
icmp_address_mask_reply * getAddressMaskReplyData()
icmp_timestamp_request * getTimestampRequestData()
bool isMessageOfType(IcmpMessageType type) const
Definition: IcmpLayer.h:368
icmp_redirect * setRedirectData(uint8_t code, IPv4Address gatewayAddress, IPv4Layer *ipHeader, Layer *l4Header)
icmp_timestamp_reply * getTimestampReplyData()
icmp_destination_unreachable * setDestUnreachableData(IcmpDestUnreachableCodes code, uint16_t nextHopMTU, IPv4Layer *ipHeader, Layer *l4Header)
icmphdr * getIcmpHeader() const
Definition: IcmpLayer.h:358
icmp_timestamp_request * setTimestampRequestData(uint16_t id, uint16_t sequence, timeval originateTimestamp)
icmp_router_advertisement * getRouterAdvertisementData() const
icmp_info_request * getInfoRequestData()
icmp_destination_unreachable * getDestUnreachableData()
icmp_time_exceeded * setTimeExceededData(uint8_t code, IPv4Layer *ipHeader, Layer *l4Header)
static bool isDataValid(const uint8_t *data, size_t dataLen)
Definition: IcmpLayer.h:619
icmp_param_problem * setParamProblemData(uint8_t code, uint8_t errorOctetPointer, IPv4Layer *ipHeader, Layer *l4Header)
void parseNextLayer() override
icmp_time_exceeded * getTimeExceededData()
icmp_param_problem * getParamProblemData()
void computeCalculateFields() override
Calculate ICMP checksum field.
icmp_timestamp_reply * setTimestampReplyData(uint16_t id, uint16_t sequence, timeval originateTimestamp, timeval receiveTimestamp, timeval transmitTimestamp)
icmp_info_reply * setInfoReplyData(uint16_t id, uint16_t sequence)
std::string toString() const override
IcmpMessageType getMessageType() const
icmp_source_quench * setSourceQuenchdata(IPv4Layer *ipHeader, Layer *l4Header)
OsiModelLayer getOsiModelLayer() const override
Definition: IcmpLayer.h:611
The main namespace for the PcapPlusPlus lib.
icmp_address_mask_request icmp_address_mask_reply
Definition: IcmpLayer.h:303
icmphdr icmp_router_solicitation
Definition: IcmpLayer.h:214
icmp_info_request icmp_info_reply
Definition: IcmpLayer.h:320
IcmpMessageType
An enum of all supported ICMP message types.
Definition: IcmpLayer.h:36
@ ICMP_DEST_UNREACHABLE
ICMP destination unreachable message.
Definition: IcmpLayer.h:40
@ ICMP_TIMESTAMP_REPLY
ICMP timestamp reply message.
Definition: IcmpLayer.h:58
@ ICMP_TIME_EXCEEDED
ICMP time-to-live excceded message.
Definition: IcmpLayer.h:52
@ ICMP_ECHO_REQUEST
ICMP echo (ping) request message.
Definition: IcmpLayer.h:46
@ ICMP_TIMESTAMP_REQUEST
ICMP timestamp request message.
Definition: IcmpLayer.h:56
@ ICMP_UNSUPPORTED
ICMP message type unsupported by PcapPlusPlus.
Definition: IcmpLayer.h:68
@ ICMP_PARAM_PROBLEM
ICMP parameter problem message.
Definition: IcmpLayer.h:54
@ ICMP_ADDRESS_MASK_REPLY
ICMP address mask reply message.
Definition: IcmpLayer.h:66
@ ICMP_ROUTER_SOL
ICMP router soliciatation message.
Definition: IcmpLayer.h:50
@ ICMP_ECHO_REPLY
ICMP echo (ping) reply message.
Definition: IcmpLayer.h:38
@ ICMP_INFO_REQUEST
ICMP information request message.
Definition: IcmpLayer.h:60
@ ICMP_ADDRESS_MASK_REQUEST
ICMP address mask request message.
Definition: IcmpLayer.h:64
@ ICMP_SOURCE_QUENCH
ICMP source quench message.
Definition: IcmpLayer.h:42
@ ICMP_REDIRECT
ICMP redirect message.
Definition: IcmpLayer.h:44
@ ICMP_ROUTER_ADV
ICMP router advertisement message.
Definition: IcmpLayer.h:48
@ ICMP_INFO_REPLY
ICMP information reply message.
Definition: IcmpLayer.h:62
OsiModelLayer
An enum representing OSI model layers.
Definition: ProtocolType.h:225
@ OsiModelNetworkLayer
Network layer (layer 3)
Definition: ProtocolType.h:231
icmp_timestamp_request icmp_timestamp_reply
Definition: IcmpLayer.h:164
icmp_time_exceeded icmp_source_quench
Definition: IcmpLayer.h:193
IcmpDestUnreachableCodes
Definition: IcmpLayer.h:74
@ IcmpDestinationNetworkProhibited
The destination network is administratively prohibited.
Definition: IcmpLayer.h:94
@ IcmpSourceHostIsolated
Source host isolated error.
Definition: IcmpLayer.h:92
@ IcmpPrecedenceCutoff
Definition: IcmpLayer.h:109
@ IcmpHostPrecedenceViolation
Definition: IcmpLayer.h:106
@ IcmpPortUnreachable
Port unreachable error (the designated protocol is unable to inform the host of the incoming message)
Definition: IcmpLayer.h:82
@ IcmpSourceRouteFailed
Source route failed error.
Definition: IcmpLayer.h:86
@ IcmpHostUnreachableForTypeOfService
The host is unreachable for Type Of Service.
Definition: IcmpLayer.h:100
@ IcmpDestinationHostProhibited
The destination host is administratively prohibited.
Definition: IcmpLayer.h:96
@ IcmpDestinationHostUnknown
Destination host unknown error.
Definition: IcmpLayer.h:90
@ IcmpProtocolUnreachable
Protocol unreachable error (the designated transport protocol is not supported)
Definition: IcmpLayer.h:80
@ IcmpCommunicationProhibited
Definition: IcmpLayer.h:103
@ IcmpDestinationNetworkUnknown
Destination network unknown error.
Definition: IcmpLayer.h:88
@ IcmpNetworkUnreachable
Network unreachable error.
Definition: IcmpLayer.h:76
@ IcmpNetworkUnreachableForTypeOfService
The network is unreachable for Type Of Service.
Definition: IcmpLayer.h:98
@ IcmpHostUnreachable
Host unreachable error.
Definition: IcmpLayer.h:78
@ IcmpDatagramTooBig
The datagram is too big. Packet fragmentation is required but the 'don't fragment' (DF) flag is on.
Definition: IcmpLayer.h:84
const ProtocolType ICMP
ICMP protocol.
Definition: ProtocolType.h:56
icmp_echo_request icmp_echo_reply
Definition: IcmpLayer.h:141
Definition: IcmpLayer.h:290
uint16_t id
the address mask request identifier
Definition: IcmpLayer.h:292
uint16_t sequence
the address mask request sequence
Definition: IcmpLayer.h:294
uint32_t addressMask
the subnet mask of the requesting host
Definition: IcmpLayer.h:296
Definition: IcmpLayer.h:171
uint16_t unused
unused 2 bytes
Definition: IcmpLayer.h:173
uint16_t nextHopMTU
contains the MTU of the next-hop network if a code 4 error occurs
Definition: IcmpLayer.h:175
Definition: IcmpLayer.h:116
uint64_t timestamp
a timestamp of when the message was sent
Definition: IcmpLayer.h:122
uint16_t id
the echo (ping) request identifier
Definition: IcmpLayer.h:118
uint16_t sequence
the echo (ping) request sequence number
Definition: IcmpLayer.h:120
Definition: IcmpLayer.h:130
icmp_echo_hdr * header
a pointer to the header data
Definition: IcmpLayer.h:132
size_t dataLength
most echo requests/replies contain some payload data. This is the data length
Definition: IcmpLayer.h:134
uint8_t * data
most echo requests/replies contain some payload data. This is a pointer to this data
Definition: IcmpLayer.h:136
Definition: IcmpLayer.h:309
uint16_t sequence
the information request sequence
Definition: IcmpLayer.h:313
uint16_t id
the information request identifier
Definition: IcmpLayer.h:311
Definition: IcmpLayer.h:200
uint8_t unused1
unused 1 byte
Definition: IcmpLayer.h:205
uint8_t pointer
Definition: IcmpLayer.h:203
uint16_t unused2
unused 2 bytes
Definition: IcmpLayer.h:207
Definition: IcmpLayer.h:221
uint32_t gatewayAddress
an IPv4 address of the gateway to which the redirection should be sent
Definition: IcmpLayer.h:223
Definition: IcmpLayer.h:232
void setRouterAddress(IPv4Address addr, uint32_t preference)
uint32_t routerAddress
the IPv4 address of the advertised router
Definition: IcmpLayer.h:234
IPv4Address getAddress() const
Definition: IcmpLayer.h:246
uint32_t preferenceLevel
Definition: IcmpLayer.h:238
Definition: IcmpLayer.h:258
uint8_t addressEntrySize
Definition: IcmpLayer.h:264
uint16_t lifetime
the maximum number of seconds that the router addresses in this list may be considered valid
Definition: IcmpLayer.h:266
uint8_t advertisementCount
Definition: IcmpLayer.h:261
Definition: IcmpLayer.h:274
icmp_router_advertisement_hdr * header
a pointer to the header data on the packet
Definition: IcmpLayer.h:276
icmp_router_address_structure * getRouterAddress(int index) const
Definition: IcmpLayer.h:184
uint32_t unused
unused 4 bytes
Definition: IcmpLayer.h:186
Definition: IcmpLayer.h:147
uint16_t id
the timestamp request identifier
Definition: IcmpLayer.h:149
uint32_t transmitTimestamp
relevant for timestamp reply only - the time the echoer last touched the message on sending it
Definition: IcmpLayer.h:157
uint16_t sequence
the timestamp request sequence number
Definition: IcmpLayer.h:151
uint32_t receiveTimestamp
relevant for timestamp reply only - the time the echoer first touched it on receipt
Definition: IcmpLayer.h:155
uint32_t originateTimestamp
the time (in milliseconds since midnight) the sender last touched the packet
Definition: IcmpLayer.h:153
Definition: IcmpLayer.h:23
uint8_t code
message code
Definition: IcmpLayer.h:27
uint8_t type
message type
Definition: IcmpLayer.h:25
uint16_t checksum
message checksum
Definition: IcmpLayer.h:29