Wiesner András ab8d45932f Timestamping and bunch of bugfix and optimization
- Timestamping management added
- Errors due to reading uninitialized data in ARP fixed
- EthInterface reworked, incoming packet notification and payload readout separated (through which fixing concurrent access problems)
- RX and TX offloads added
- Capability to add a packet sieve layer without prior registration of specific packet class added (this makes it possible to register arbitrary EtherType connection blocks, for example)
2023-04-27 09:38:26 +02:00

47 lines
1.3 KiB
C

#ifndef ETHERLIB_ICMP_PACKET_H
#define ETHERLIB_ICMP_PACKET_H
#include <stdint.h>
#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, PcktProcFnPassbackData *pb);
/**
* 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, struct EthInterface_ *intf);
#endif //ETHERLIB_ICMP_PACKET_H