UIPEthernet library for Arduino IDE, Eclipse with arduino plugin and MBED/SMeshStudio (AVR,STM32F,ESP8266,Intel ARC32,Nordic nRF51,Teensy boards,Realtek Ameba(RTL8195A,RTL8710)), ENC28j60 network chip. Compatible with Wiznet W5100 Ethernet library API. Compiled and tested on Nucleo-F302R8. Master repository is: https://github.com/UIPEthernet/UIPEthernet/
Diff: Dhcp.h
- Revision:
- 38:645b253e6b50
- Parent:
- 33:7ba5d53df0f2
--- a/Dhcp.h Wed Feb 22 13:40:36 2017 +0000 +++ b/Dhcp.h Mon Mar 27 22:31:01 2017 +0200 @@ -46,6 +46,8 @@ #define HOST_NAME "ENC28J" #define DEFAULT_LEASE (900) //default lease time in seconds +#define DHCP_TIMEOUT 60000 +#define DHCP_RESPONSE_TIMEOUT 4000 #define DHCP_CHECK_NONE (0) #define DHCP_CHECK_RENEW_FAIL (1) @@ -139,23 +141,26 @@ uint8_t chaddr[6]; }RIP_MSG_FIXED; +typedef struct +{ + uint8_t LocalIp[4]; + uint8_t SubnetMask[4]; + uint8_t GatewayIp[4]; + uint8_t DhcpServerIp[4]; + uint8_t DnsServerIp[4]; +} TIPV4Struct; + class DhcpClass { private: uint32_t _dhcpInitialTransactionId; uint32_t _dhcpTransactionId; uint8_t _dhcpMacAddr[6]; - uint8_t _dhcpLocalIp[4]; - uint8_t _dhcpSubnetMask[4]; - uint8_t _dhcpGatewayIp[4]; - uint8_t _dhcpDhcpServerIp[4]; - uint8_t _dhcpDnsServerIp[4]; + TIPV4Struct _dhcpipv4struct; uint32_t _dhcpLeaseTime; uint32_t _dhcpT1, _dhcpT2; signed long _renewInSec; signed long _rebindInSec; signed long _lastCheck; - unsigned long _timeout; - unsigned long _responseTimeout; unsigned long _secTimeout; uint8_t _dhcp_state; UIPUDP _dhcpUdpSocket; @@ -166,7 +171,7 @@ void send_DHCP_MESSAGE(uint8_t, uint16_t); void printByte(char *, uint8_t); - uint8_t parseDHCPResponse(unsigned long responseTimeout, uint32_t& transactionId); + uint8_t parseDHCPResponse(uint32_t& transactionId); public: IPAddress getLocalIp(void); IPAddress getSubnetMask(void); @@ -174,7 +179,7 @@ IPAddress getDhcpServerIp(void); IPAddress getDnsServerIp(void); - int beginWithDHCP(uint8_t *, unsigned long timeout = 60000, unsigned long responseTimeout = 4000); + int beginWithDHCP(uint8_t *); int checkLease(void); }; #endif