From db1f6609d13a888dd7212c9ed2840846e70a284e Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Wed, 2 Aug 2017 18:26:23 +0200 Subject: added an IPv4 module, currently containg an address to string function started to add ARP packet definition, reading and printing ARP request now some renames in networking layer --- src/net/arp.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/net/arp.h (limited to 'src/net/arp.h') diff --git a/src/net/arp.h b/src/net/arp.h new file mode 100644 index 0000000..ba8de42 --- /dev/null +++ b/src/net/arp.h @@ -0,0 +1,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 -- cgit v1.2.3-54-g00ecf