/* UDP stack */
#ifndef _UDP_H_
#define _UDP_H_

#include "stdint.h"
#include "net.h"

// Definice konstant
#define UDP_SendOK				1
#define UDP_SendFail			0

#define UDP_Header_len			8			// Delka hlavicky UDP datagramu

// Definice offsetu polozek hlavicky v TCP paketu
#define OFFSET_UDP_Header			0x22	// offset v bytech
#define OFFSET_UDP_SourcePort		OFFSET_UDP_Header + 0x00	// celkem 16 bit = 2 byte  1-65535
#define OFFSET_UDP_DestPort			OFFSET_UDP_Header + 2		// celkem 16 bit = 2 byte, 1-65536
#define OFFSET_UDP_Length			OFFSET_UDP_Header + 4		// celkem 16 bit = 2 byte, delka UDP hlavicky (8) + Data
#define OFFSET_UDP_CheckSum			OFFSET_UDP_Header + 6		// celkem 16 bit = 2 byte, volitelny 0x00 = checksum se nekontroluje
#define OFFSET_UDP_Data				OFFSET_UDP_Header + 8


// Prototypy funkci
void UDP_Set_UDP_Header(uint8_t *buffer, uint16_t SourcePort, uint16_t DestPort, uint16_t Length);
uint8_t UDP_Check_UDP_Port(uint8_t *buffer, uint16_t Port);
uint16_t UDP_Get_Length(uint8_t *buffer);
uint8_t UDP_Build_Datagram(uint8_t *buffer_TX, uint8_t *DestIP[IP_ADR_SIZE], uint16_t DestPort,
						   uint16_t SourcePort, uint8_t *data, uint16_t Delka_UDP_dat);
void UDP_Build_Datagram_From_RX(uint8_t *buffer_RX, uint8_t *buffer_TX, uint8_t *data, uint16_t Delka_UDP_dat, uint8_t DataVlozena);


#endif
/* Konec souboru */
