/* flaneth - flash and ethernet
   Copyright (C) 2007-2012 Stefan Schuermans <stefan@blinkenarea.org>
   Copyleft: GNU public license V2 - http://www.gnu.org/copyleft/gpl.html
   a BlinkenArea project - http://www.blinkenarea.org/ */

#ifndef INC_dhcp
#define INC_dhcp

#include "ethernet.h"
#include "ip.h"
#include "udp.h"

// header of an DHCP packet
struct DhcpHeader {
  unsigned char Op;
  unsigned char HType;
  unsigned char HLen;
  unsigned char HOps;
  unsigned long XId;
  unsigned int Secs;
  unsigned int Flags;
  unsigned char CIAddr[4];
  unsigned char YIAddr[4];
  unsigned char SIAddr[4];
  unsigned char GIAddr[4];
  unsigned char CHAddr[16];
  unsigned char SName[64];
  unsigned char File[128];
  unsigned long MCookie;
};

// a DHCP packet
struct DhcpPacket {
  struct EthernetHeader EthHdr;
  struct IpHeader IpHdr;
  struct UdpHeader UdpHdr;
  struct DhcpHeader DhcpHdr;
};

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

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

#endif // #ifdef INC_dhcp
