EtherLib/packet.h
Epagris 8044d8a8b6 - RawPckt: force FCS computation feature added
- IGMP transmission reworked
- IPv4: method for filling in checksum in rendered binary data added
2024-10-20 15:38:36 +02:00

59 lines
2.0 KiB
C

#ifndef ETHERLIB_PACKET_H
#define ETHERLIB_PACKET_H
#include <stdint.h>
#include <stdbool.h>
/**
* \struct RawPckt
* \brief Raw packet received on wire
*/
typedef struct {
uint8_t * payload; ///> Pointer to raw packet payload.
uint32_t size; ///> Raw packet size.
union {
struct {
uint32_t time_s; ///> Timestamp seconds field
uint32_t time_ns; ///> Timestamp nanoseconds field
} rx;
struct {
void(*txTsCb)(uint32_t ts_s, uint32_t ts_ns, uint32_t tag); ///> Transmit timestamp callback pointer
uint32_t arg; ///> User-defined argument
} tx;
} ext; ///> Extensions
struct {
bool calculate_ethernet_CRC : 1; ///> Instruct the packet assembler to always computer FCS regardless of device capabilities
} opts;
} RawPckt;
struct PcktHeaderElement_;
/**
* @struct Pckt
* @brief Generic packet
*
* Fields have been reordered so that fields are aligned.
*/
typedef struct {
uint64_t time_s; ///< Timestamp seconds part
uint32_t time_ns; ///< Timestamp nanoseconds part.
struct PcktHeaderElement_ * header; ///< Pointer to packet header. Points to the innermost header
const uint8_t * payload; ///< Pointer to (innermost) payload.
uint16_t headerSize; ///< Packet header size in bytes.
uint16_t payloadSize; ///< Payload size in bytes.
//uint16_t type; ///< Packet class indicator (e.g. UDP, TCP, IPv4 etc.)
} Pckt;
// typedef struct {
// uint64_t time_s; ///< Timestamp seconds part
// uint32_t time_ns; ///< Timestamp nanoseconds part.
// struct PcktHeaderElement_ * header; ///< Pointer to packet header. Points to the innermost header
// const uint8_t * payload; ///< Pointer to (innermost) payload.
// uint16_t headerSize; ///< Packet header size in bytes.
// uint16_t payloadSize; ///< Payload size in bytes.
// //uint16_t type; ///< Packet class indicator (e.g. UDP, TCP, IPv4 etc.)
// } ConstPckt;
#endif //ETHERLIB_PACKET_H