-PcktSieve special return functionality added -ARP multicast learning bug fixed -include guards have been refactored -Doxygen style tweaked
36 lines
1.4 KiB
C
36 lines
1.4 KiB
C
//
|
|
// Created by epagris on 2022.11.03..
|
|
//
|
|
|
|
#include <memory.h>
|
|
#include <stdbool.h>
|
|
#include "ethernet_frame.h"
|
|
#include "../../utils.h"
|
|
|
|
#define ETH_ETHERTYPE_LENGTH_THRESHOLD (1500)
|
|
#define ETH_ETHERNET_HEADER_SIZE (14)
|
|
|
|
EthernetAddress ETH_ETHERNET_IPMC_HWADDR = { 0x01, 0x00, 0x5E, 0x00, 0x00, 0x00 };
|
|
|
|
int parse_ethernet(const uint8_t *hdr, uint32_t size, PcktHeaderElement *pcktHdrLe, struct EthInterface_ *intf, PcktProcFnPassbackData * pb) {
|
|
EthernetProps * frameProps = (EthernetProps *) &pcktHdrLe->props;
|
|
FETCH_ADVANCE(frameProps->destAddr, hdr, ETH_HW_ADDR_LEN); // copy destination address
|
|
FETCH_ADVANCE(frameProps->sourceAddr, hdr, ETH_HW_ADDR_LEN); // copy destination address
|
|
FETCH_WORD_H2N_ADVANCE(&frameProps->length_type, hdr); // copy length/type field
|
|
|
|
// fill-in packet property header fields
|
|
frameProps->validityOK = true;
|
|
frameProps->containedPacketClass =
|
|
frameProps->length_type <= ETH_ETHERTYPE_LENGTH_THRESHOLD ? 0 : frameProps->length_type;
|
|
frameProps->headerSize = ETH_ETHERNET_HEADER_SIZE;
|
|
|
|
return frameProps->containedPacketClass;
|
|
}
|
|
|
|
void insert_ethernet_header(uint8_t *hdr, const PcktHeaderElement *headers) {
|
|
EthernetProps * ethProps = (EthernetProps *) &headers->props;
|
|
FILL_ADVANCE(hdr, ethProps->destAddr, ETH_HW_ADDR_LEN);
|
|
FILL_ADVANCE(hdr, ethProps->sourceAddr, ETH_HW_ADDR_LEN);
|
|
FILL_WORD_H2N_ADVANCE(hdr, ethProps->length_type);
|
|
}
|