#ifndef UDP_H
#define UDP_H
#include "ethernet.h"
#include "ip.h"
/// header of UDP packet
struct udp_header
{
unsigned short src_port;
unsigned short dest_port;
unsigned short length;
unsigned short chk;
} __attribute__((packed));
/// UDP packet
struct udp_packet
{
struct ethernet_header eth_hdr;
struct ip_header ip_hdr;
struct udp_header udp_hdr;
} __attribute__((packed));
/// tick procedure - call every 200ms
void udp_tick200(void);
/**
* @brief process a received UDP packet
* @param[in] ptr pointer to data of packet
* @param[in] sz size of packet
*/
void udp_recv(void *ptr, unsigned int sz);
/**
* @brief send a UDP packet
* @param[in] ptr pointer to data of packet
* @param[in] sz size of packet
*
* ptr must point to a udp_packet
* with ip_hdr.proto and udp_hdr.src_port, udp_hdr.dest_port, ip_hdr.dest
* already initialized
*/
void udp_send(void *ptr, unsigned int sz);
#endif // #ifdef UDP_H