Wiesner András ac5fc9c529 -IP reassembler added
-PcktSieve special return functionality added
-ARP multicast learning bug fixed
-include guards have been refactored
-Doxygen style tweaked
2023-02-04 11:04:26 +01:00

65 lines
1.5 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);
#endif //ETHERLIB_ARP_PACKET_H