/* ETH vrstva komunikacniho modulu pro Ethernet */

#ifndef __ETH_H
#define __ETH_H

#include "stdint.h"

// Definice
#define ETH_Header_len			14			// Delka hlavicky Ethernetoveho ramce (paketu)
// Definice typu ethernetoveho paketu
#define ETH_Type_IPv4				0x0800
#define ETH_Type_ARP				0x0806
// Definice offsetu polozek hlavicky ethernetoveho paketu
#define OFFSET_ETH_DestMAC			0x00								// 6 byte
#define OFFSET_ETH_SourceMAC		0x06								// 6 byte
#define OFFSET_ETH_TypeLen			0x0C								// 2 byte
#define OFFSET_ETH_Data				0x0E								// 46 - 1500 byte
#define OFFSET_ETH_CRC				OFFSET_ETH_Data + MAX_PACKET_SIZE	// CRC32 - 4 byte

#define TxBuffer_Other				0
#define TxBuffer_TCP				1
// Makra
#define ETH_SendPacket(x, y, z)		enc28j60PacketSend(x,y,z)				// Odeslani	
#define ETH_ReSendPAcket(x)			enc28j60SendPacketAgain(x)				// Znovu odeslani paketu z bufferu ENC radice

// Prototypy funkci
void ETH_Set_ETH_Header(uint8_t *buffer, uint8_t *DestMAC, uint8_t *SourceMAC, uint16_t type);
void ETH_CopyETH_Header(uint8_t *TX_buffer, uint8_t *RX_buffer, uint16_t type);
uint8_t *ETH_Get_SourceMAC(uint8_t *buffer);

#endif

/* Konec souboru */
