#include "arp.h"
#include "checksum.h"
#include "config.h"
#include "ethernet.h"
#include "icmp.h"
#include "ip.h"
#include "macros.h"
#include "memcpy.h"
#include "nethelp.h"
#include "udp.h"
// timing parameters
#define IP_BUFFER_TICKS_MAX 50 // maximum age of buffered IP packet (in 200ms)
/**
* buffers for IP packets to transmit
* - used if MAC is unknown when packet shall be transmitted
* - packet is sent when MAC becomes known
* - some buffers with different length (packets have different lengths)
*/
//@{
unsigned int ip_buffer0[20];
unsigned int ip_buffer1[20];
unsigned int ip_buffer2[40];
unsigned int ip_buffer3[80];
//@}
/// table with buffers
struct ip_buffer_table
{
void *ptr; ///< pointer to buffer for packet
unsigned int buf_sz; ///< size of buffer
unsigned int pkg_sz; ///< size of packet in buffer, 0 for packet
unsigned int ticks; //< age of entry (in 200ms)
} ip_buffer_tab[] =
{ // put smaller buffers in front of larger buffers
// - then short packets will use smaller buffers more often
{ ip_buffer0, sizeof(ip_buffer0), 0, 0 },
{ ip_buffer1, sizeof(ip_buffer1), 0, 0 },
{ ip_buffer2, sizeof(ip_buffer2), 0, 0 },
{ ip_buffer3, sizeof(ip_buffer3), 0, 0 },
};
/// initialize
void ip_init(void)
{
unsigned int i;
for (i = 0; i < count(ip_buffer_tab ); i++)
ip_buffer_tab[i].pkg_sz = 0;
}
/// tick procedure - call every 200ms