EtherLib/prefab/packet_parsers/ethernet_frame.h

34 lines
850 B
C

//
// Created by epagris on 2022.11.03..
//
#ifndef ETHERLIB_ETHERNET_FRAME_H
#define ETHERLIB_ETHERNET_FRAME_H
#include <stdint.h>
#include "etherlib/packet_registry.h"
#define ETH_HW_ADDR_LEN (6)
/**
* @struct EthernetProps
* Ethernet frame properties
*/
typedef struct {
PcktPropsHeader
uint8_t destAddr[ETH_HW_ADDR_LEN]; ///< destination address
uint8_t sourceAddr[ETH_HW_ADDR_LEN]; ///< source address
uint16_t length_type; /// < frame length_type
} EthernetProps;
/**
* Parse raw Ethernet frames.
* @param hdr pointer to the Ethernet packet header
* @param size total frame size
* @param props pointer to property storage
* @return EtherType or 0 (if size is less than 1500) on success or -1 on error
*/
int parse_ethernet(const uint8_t *hdr, uint32_t size, PcktProps * props);
#endif //ETHERLIB_ETHERNET_FRAME_H