- 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)
65 lines
1.6 KiB
C
65 lines
1.6 KiB
C
//
|
|
// Created by epagris on 2022.12.08..
|
|
//
|
|
|
|
#ifndef ETHERLIB_ARP_PACKET_H
|
|
#define ETHERLIB_ARP_PACKET_H
|
|
|
|
#include <stdint.h>
|
|
#include "ipv4_types.h"
|
|
|
|
#include "../../packet_registry.h"
|
|
#include "../../packet_sieve.h"
|
|
|
|
#define ETH_ARP_PACKET_CLASS (0x0806)
|
|
#define ETH_ARP_HEADER_SIZE (28)
|
|
|
|
/**
|
|
* Arp operations
|
|
*/
|
|
typedef enum {
|
|
ARPOP_REQ = 1, ///< ARP Request
|
|
ARPOP_REP = 2 ///< ARP Reply
|
|
} ArpOp;
|
|
|
|
typedef enum {
|
|
ARP_HWTYPE_ETHERNET = 1
|
|
} ArpHwType;
|
|
|
|
/**
|
|
* ARP properties.
|
|
*/
|
|
typedef struct {
|
|
PcktPropsHeader
|
|
|
|
uint16_t HTYPE; ///< Hardware type (Ethernet: 1)
|
|
uint16_t PTYPE; ///< Protocol type (IP: 0x0800)
|
|
uint8_t HLEN; ///< Hardware address length
|
|
uint8_t PLEN; ///< Protocol address length
|
|
uint16_t OPER; ///< Operation
|
|
uint8_t SHA[6]; ///< Array of addresses (SHA, SPA, THA, TPA)
|
|
ip4_addr SPA;
|
|
uint8_t THA[6];
|
|
ip4_addr TPA;
|
|
} ArpProps;
|
|
|
|
/**
|
|
* Parse ARP packet.
|
|
* @param hdr pointer to the packet buffer beginning with ARP header
|
|
* @param size size of processable buffer area
|
|
* @param pcktHdrLe linked list of packet headers
|
|
* @param intf Ethernet interface
|
|
* @return always 0 OR -1 on failure
|
|
*/
|
|
int parse_arp(const uint8_t *hdr, uint32_t size, PcktHeaderElement *pcktHdrLe, struct EthInterface_ *intf, PcktProcFnPassbackData *pb);
|
|
|
|
/**
|
|
* Insert ARP header into packet.
|
|
* @param hdr pointer to the packet buffer where the ARP header is to be written
|
|
* @param headers linked list of packet headers
|
|
*/
|
|
void insert_arp_header(uint8_t *hdr, const PcktHeaderElement *headers, struct EthInterface_ *intf);
|
|
|
|
#endif //ETHERLIB_ARP_PACKET_H
|
|
|