/* ICMP vrstva komunikacniho modulu pro Ethernet */

#ifndef __ICMP_H
#define __ICMP_H

#include "stdint.h"

// Definice
#define ICMP_Header_len			8			// Delka hlavicky ICMP paketu

// Definice offsetu polozek hlavicky ICMP paketu
#define OFFSET_ICMP_Header			0x22
#define OFFSET_ICMP_Type			OFFSET_ICMP_Header + 0x00	// Typ ICMP zpravy
#define OFFSET_ICMP_Code			OFFSET_ICMP_Header + 0x01	// Kod ICMP zpravy - zavisi na typu
#define OFFSET_ICMP_Checksum		OFFSET_ICMP_Header + 0x02	// Pocita se z ICMP hlavicky a ICMP Padding dat
#define OFFSET_ICMP_RestOfHeader	OFFSET_ICMP_Header + 0x04	// Identifer a seq. number
#define OFFSET_ICMP_PaddingData		OFFSET_ICMP_Header + 0x08	// Windows zde pri zadosti o ping standartne vklada 32 bytu ("ABCDEFG...")

// Definice ICMP typu a ICMP kodu jako podkategorie typu
#define ICMP_Type_EchoReply						0x00			// Typ = Odpoved na ping
#define ICMP_Type_EchoRequest					0x08			// Typ = Zadost o odpoved na ping
#define ICMP_Type_EchoReply_Code_EchoReply		0x00			// Code = Odpoved na ping
#define ICMP_Type_EchoRequest_Code_EchoRequest	0x00			// Code = Zadost o odpoved na ping

// Prototypy funkci
void ICMP_Set_ICMP_Header(unsigned char *TX_buffer, unsigned int len,	unsigned char type, unsigned char code);
void ICMP_Send_EchoReply(unsigned char *RX_buffer, unsigned char *TX_buffer, unsigned int len);
unsigned char ICMP_Check_PingRequest(unsigned char *buffer);

#endif

/* Konec souboru */
