STM32Ethernet
Arduino Ethernet library for STM32 boards
Loading...
Searching...
No Matches
Dhcp.h
Go to the documentation of this file.
1
8// DHCP Library v0.3 - April 25, 2009
9// Author: Jordan Terrell - blog.jordanterrell.com
10
11#ifndef Dhcp_h
12#define Dhcp_h
13
14#include "EthernetUdp.h"
15
16/* DHCP state machine. */
17#define STATE_DHCP_STOP DHCP_OFF
18#define STATE_DHCP_START DHCP_START
19#define STATE_DHCP_DISCOVER DHCP_WAIT_ADDRESS
20#define STATE_DHCP_REQUEST 0
21#define STATE_DHCP_LEASED DHCP_ADDRESS_ASSIGNED
22#define STATE_DHCP_REREQUEST 0
23#define STATE_DHCP_RELEASE DHCP_ASK_RELEASE
24
25#define DHCP_CHECK_NONE (0)
26#define DHCP_CHECK_RENEW_FAIL (1)
27#define DHCP_CHECK_RENEW_OK (2)
28#define DHCP_CHECK_REBIND_FAIL (3)
29#define DHCP_CHECK_REBIND_OK (4)
30
31class DhcpClass {
32 private:
33 uint8_t _dhcpMacAddr[6];
34 unsigned long _timeout;
35 uint8_t _dhcp_lease_state;
36 uint8_t _dhcp_state;
37
46 int request_DHCP_lease();
50 void reset_DHCP_lease();
51
52 public:
58 IPAddress getLocalIp();
64 IPAddress getSubnetMask();
70 IPAddress getGatewayIp();
76 IPAddress getDhcpServerIp();
82 IPAddress getDnsServerIp();
83
95 int beginWithDHCP(uint8_t *mac, unsigned long timeout = 60000, unsigned long responseTimeout = 4000);
106 int checkLease();
107};
108
109#endif
UDP class of the Ethernet library.
Definition Dhcp.h:31
IPAddress getLocalIp()
Returns the local IP address assigned by DHCP.
Definition Dhcp.cpp:106
IPAddress getGatewayIp()
Returns the default gateway address assigned by DHCP.
Definition Dhcp.cpp:116
int beginWithDHCP(uint8_t *mac, unsigned long timeout=60000, unsigned long responseTimeout=4000)
Starts a DHCP lease request.
Definition Dhcp.cpp:14
IPAddress getDhcpServerIp()
Returns the address of the DHCP server.
Definition Dhcp.cpp:121
IPAddress getSubnetMask()
Returns the subnet mask assigned by DHCP.
Definition Dhcp.cpp:111
int checkLease()
Checks the DHCP lease for a renew or rebind result.
Definition Dhcp.cpp:65
IPAddress getDnsServerIp()
Returns the DNS server address assigned by DHCP.
Definition Dhcp.cpp:126