#ifndef ETHERLIB_TEST_ICMP_PACKET_H #define ETHERLIB_TEST_ICMP_PACKET_H #include #include "ipv4_types.h" #include "ethernet_frame.h" #define ETH_ICMP_PACKET_CLASS (0x0001) #define ETH_ICMP_HEADER_SIZE (8) typedef enum { ICMP_MT_ECHO_REPLY = 0x00, ICMP_MT_ECHO_REQUEST = 0x08 } IcmpMsgType; /** * ICMP packet properties. */ typedef struct { PcktPropsHeader uint8_t type; ///< ICMP message type uint8_t code; ///< ICMP message code (~subtype) uint16_t checksum; ///< Checksum for the entire packet uint16_t identifier; ///< Identifier uint16_t sequenceNumber; ///< Sequence number } IcmpProps; /** * Parse ICMP packet header * @param hdr pointer to the beginning of ICMP header * @param size packet size * @param pcktHdrLe linked list of packet headers * @param intf Ethernet interface through which transmission and reception is carried out * @return always 0 */ int parse_icmp(const uint8_t *hdr, uint32_t size, PcktHeaderElement *pcktHdrLe, struct EthInterface_ *intf); /** * Insert ICMP header. * @param hdr pointer to message header * @param headers linked list of recursively encapsulated packet headers */ void insert_icmp_header(uint8_t * hdr, const PcktHeaderElement * headers); #endif //ETHERLIB_TEST_ICMP_PACKET_H