This is Library using WIZnet Hardware TCP/IP chip, W5500 and WIZnet TCP/IP Offload Engine, W7500.
Dependents: HTTP_SDcard_file_server_WIZwiki-W7500 SSD1306_smart_watch TCPEchoServer-WIZwiki-W7500 httpServer-WIZwiki-W7500 ... more
Fork of WIZnetInterface by
This is WIZnet Ethernet Interface using Hardware TCP/IP chip, W5500 and TCP/IP Offload Engine, W7500.
[Users » embeddist » Code » WIZnetInterface](https://developer.mbed.org/users/embeddist/code/WIZnetInterface/) -> WIZnetInterface Lib will be released on [Team WIZnet](https://developer.mbed.org/teams/WIZnet/)
- WIZwiki_W7500 : /platforms/WIZwiki-W7500/
- WIZwiki_W7500P : /platforms/WIZwiki-W7500P/
- WIZwiki_W7500ECO : /platforms/WIZwiki-W7500ECO/
- W5500 Ethernet Shield : /components/W5500-Ethernet-Kit-for-IoT/
This library is an Ethernet Interface library port-based on [EthernetInterface](https://developer.mbed.org/users/mbed_official/code/EthernetInterface/docs/tip/).
For more detail, visit http://embeddist.blogspot.kr/2015/06/wiznetinterface-for-armmbed.html
Socket/DHCPClient.h@29:c91884bd2713, 2015-11-17 (annotated)
- Committer:
- embeddist
- Date:
- Tue Nov 17 06:35:55 2015 +0000
- Revision:
- 29:c91884bd2713
- Parent:
- 0:6f28332c466f
Fixed setMAC() functions
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Soohwan Kim |
0:6f28332c466f | 1 | // DHCPClient.h 2013/4/10 |
Soohwan Kim |
0:6f28332c466f | 2 | #ifndef DHCPCLIENT_H |
Soohwan Kim |
0:6f28332c466f | 3 | #define DHCPCLIENT_H |
Soohwan Kim |
0:6f28332c466f | 4 | #include "eth_arch.h" |
Soohwan Kim |
0:6f28332c466f | 5 | #include "UDPSocket.h" |
Soohwan Kim |
0:6f28332c466f | 6 | |
Soohwan Kim |
0:6f28332c466f | 7 | #define DHCP_OFFSET_OP 0 |
Soohwan Kim |
0:6f28332c466f | 8 | #define DHCP_OFFSET_XID 4 |
Soohwan Kim |
0:6f28332c466f | 9 | #define DHCP_OFFSET_YIADDR 16 |
Soohwan Kim |
0:6f28332c466f | 10 | #define DHCP_OFFSET_SIADDR 20 |
Soohwan Kim |
0:6f28332c466f | 11 | #define DHCP_OFFSET_OPTIONS 240 |
Soohwan Kim |
0:6f28332c466f | 12 | #define DHCP_MAX_PACKET_SIZE 600 |
Soohwan Kim |
0:6f28332c466f | 13 | |
Soohwan Kim |
0:6f28332c466f | 14 | // DHCP Message Type |
Soohwan Kim |
0:6f28332c466f | 15 | #define DHCPDISCOVER 1 |
Soohwan Kim |
0:6f28332c466f | 16 | #define DHCPOFFER 2 |
Soohwan Kim |
0:6f28332c466f | 17 | #define DHCPREQUEST 3 |
Soohwan Kim |
0:6f28332c466f | 18 | #define DHCPDECLINE 4 |
Soohwan Kim |
0:6f28332c466f | 19 | #define DHCPACK 5 |
Soohwan Kim |
0:6f28332c466f | 20 | #define DHCPNAK 6 |
Soohwan Kim |
0:6f28332c466f | 21 | #define DHCPRELEASE 7 |
Soohwan Kim |
0:6f28332c466f | 22 | #define DHCPINFORM 8 |
Soohwan Kim |
0:6f28332c466f | 23 | |
Soohwan Kim |
0:6f28332c466f | 24 | class DHCPClient { |
Soohwan Kim |
0:6f28332c466f | 25 | public: |
Soohwan Kim |
0:6f28332c466f | 26 | DHCPClient(); |
Soohwan Kim |
0:6f28332c466f | 27 | int setup(int timeout_ms = 15*1000); |
Soohwan Kim |
0:6f28332c466f | 28 | uint8_t chaddr[6]; // MAC |
Soohwan Kim |
0:6f28332c466f | 29 | uint8_t yiaddr[4]; // IP |
Soohwan Kim |
0:6f28332c466f | 30 | uint8_t dnsaddr[4]; // DNS |
Soohwan Kim |
0:6f28332c466f | 31 | uint8_t gateway[4]; |
Soohwan Kim |
0:6f28332c466f | 32 | uint8_t netmask[4]; |
Soohwan Kim |
0:6f28332c466f | 33 | uint8_t siaddr[4]; |
Soohwan Kim |
0:6f28332c466f | 34 | private: |
Soohwan Kim |
0:6f28332c466f | 35 | int discover(); |
Soohwan Kim |
0:6f28332c466f | 36 | int request(); |
Soohwan Kim |
0:6f28332c466f | 37 | int offer(uint8_t buf[], int size); |
Soohwan Kim |
0:6f28332c466f | 38 | void add_buf(uint8_t* buf, int len); |
Soohwan Kim |
0:6f28332c466f | 39 | void fill_buf(int len, uint8_t data = 0x00); |
Soohwan Kim |
0:6f28332c466f | 40 | void add_buf(uint8_t c); |
Soohwan Kim |
0:6f28332c466f | 41 | void add_option(uint8_t code, uint8_t* buf = NULL, int len = 0); |
Soohwan Kim |
0:6f28332c466f | 42 | bool verify(uint8_t buf[], int len); |
Soohwan Kim |
0:6f28332c466f | 43 | void callback(); |
Soohwan Kim |
0:6f28332c466f | 44 | UDPSocket* m_udp; |
Soohwan Kim |
0:6f28332c466f | 45 | Endpoint m_server; |
Soohwan Kim |
0:6f28332c466f | 46 | uint8_t xid[4]; |
Soohwan Kim |
0:6f28332c466f | 47 | bool exit_flag; |
Soohwan Kim |
0:6f28332c466f | 48 | Timer m_interval; |
Soohwan Kim |
0:6f28332c466f | 49 | int m_retry; |
Soohwan Kim |
0:6f28332c466f | 50 | uint8_t m_buf[DHCP_MAX_PACKET_SIZE]; |
Soohwan Kim |
0:6f28332c466f | 51 | int m_pos; |
Soohwan Kim |
0:6f28332c466f | 52 | WIZnet_Chip* eth; |
Soohwan Kim |
0:6f28332c466f | 53 | }; |
Soohwan Kim |
0:6f28332c466f | 54 | #endif //DHCPCLIENT_H |
Soohwan Kim |
0:6f28332c466f | 55 |