/* BlueDataDistributor - data distribution module from ethernet to 32 serial ports
 * version 0.1.1 date 2006-10-07
 * Copyright (C) 2006 Stefan Schuermans <stefan@blinkenarea.org>
 * a BlinkenArea project - http://www.blinkenarea.org/
 */

#ifndef INC_ip
#define INC_ip

#include "ethernet.h"

// header of an IP packet
struct IpHeader
{
  unsigned char Ver_HdrLen;
  unsigned char Tos;
  unsigned int TotalLen;
  unsigned int Id;
  unsigned int FragOfs;
  unsigned char Ttl;
  unsigned char Proto;
  unsigned int HdrChk;
  unsigned char Src[4];
  unsigned char Dest[4];
};

// an IP packet
struct IpPacket
{
  struct EthernetHeader EthHdr;
  struct IpHeader IpHdr;
};

// tick procedure - call every 200ms
extern void IpTick200( void );

// process a received IP packet
extern void IpRecv( unsigned char * pData, unsigned short Length );

// send an IP packet
// pData must point to a struct IpPacket with IpHdr.Proto and IpHdr.Dest already initialized
extern void IpSend( unsigned char * pData, unsigned short Length );

// a MAC address was discovered
// called by ARP to notify IP
extern void IpGotMac( unsigned char Ip[4], unsigned char Mac[6] );

#endif // #ifdef INC_ip

