summaryrefslogtreecommitdiff
path: root/src/net/arp.h
blob: ba8de4294ef0ac3b730546ea7ee1dbe1d247bae7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef ARP_H
#define ARP_H

#include "ethernet.h"
#include "ipv4.h"

#if defined( __TINYC__ )
#pragma pack(1)
#endif

typedef uint16_t network_hardware_type_t;

// TODO: network order not host oder, so for now swap it
#define ARP_HARDWARE_TYPE_ETHERNET (network_hardware_type_t)0x0100

#define ARP_OPERATION_REQUEST 0x0100
#define ARP_OPERATION_ANSWER 0x0200

// TODO: fixed size structure, works for Ethernet MACs and IPv4 addresses
typedef struct {
	network_hardware_type_t hardware_type;
	network_ether_type_t protocol_type;
	uint8_t hardware_address_len;
	uint8_t protocol_address_len;
	uint16_t operation;
	network_mac_address_t source_hardware_address;
	network_ipv4_address_t source_protocol_address;
	network_mac_address_t destination_hardware_address;
	network_ipv4_address_t destination_protocol_address;
} __attribute__( ( packed ) ) network_arp_packet_t;

#if defined( __TINYC__ )
#pragma pack()
#endif

#endif // ARP_H