![]() |
io6Library
WIZnet Dual Stack TCP/IP Ethernet Controller Driver
|
DHCP APIs implement file. More...
Go to the source code of this file.
Data Structures | |
| struct | RIP_MSG |
Macros | |
| #define | STATE_DHCPV4_INIT 0 |
| Initialize. More... | |
| #define | STATE_DHCPV4_DISCOVER 1 |
| send DISCOVER and wait OFFER More... | |
| #define | STATE_DHCPV4_REQUEST 2 |
| send REQEUST and wait ACK or NACK More... | |
| #define | STATE_DHCPV4_LEASED 3 |
| ReceiveD ACK and IP leased. More... | |
| #define | STATE_DHCPV4_REREQUEST 4 |
| send REQUEST for maintaining leased IP More... | |
| #define | STATE_DHCPV4_RELEASE 5 |
| No use. More... | |
| #define | STATE_DHCPV4_STOP 6 |
| Stop processing DHCP. More... | |
| #define | DHCPV4_FLAGSBROADCAST 0x8000 |
| The broadcast value of flags in RIP_MSG. More... | |
| #define | DHCPV4_FLAGSUNICAST 0x0000 |
| The unicast value of flags in RIP_MSG. More... | |
| #define | DHCPV4_BOOTREQUEST 1 |
| Request Message used in op of RIP_MSG. More... | |
| #define | DHCPV4_BOOTREPLY 2 |
| Reply Message used i op of RIP_MSG. More... | |
| #define | DHCPV4_DISCOVER 1 |
| DISCOVER message in OPT of RIP_MSG. More... | |
| #define | DHCPV4_OFFER 2 |
| OFFER message in OPT of RIP_MSG. More... | |
| #define | DHCPV4_REQUEST 3 |
| REQUEST message in OPT of RIP_MSG. More... | |
| #define | DHCPV4_DECLINE 4 |
| DECLINE message in OPT of RIP_MSG. More... | |
| #define | DHCPV4_ACK 5 |
| ACK message in OPT of RIP_MSG. More... | |
| #define | DHCPV4_NAK 6 |
| NACK message in OPT of RIP_MSG. More... | |
| #define | DHCPV4_RELEASE 7 |
| RELEASE message in OPT of RIP_MSG. No use. More... | |
| #define | DHCPV4_INFORM 8 |
| INFORM message in OPT of RIP_MSG. No use. More... | |
| #define | DHCPV4_HTYPE10MB 1 |
| Used in type of RIP_MSG. More... | |
| #define | DHCPV4_HTYPE100MB 2 |
| Used in type of RIP_MSG. More... | |
| #define | DHCPV4_HLENETHERNET 6 |
| Used in hlen of RIP_MSG. More... | |
| #define | DHCPV4_HOPS 0 |
| Used in hops of RIP_MSG. More... | |
| #define | DHCPV4_SECS 0 |
| Used in secs of RIP_MSG. More... | |
| #define | INFINITE_LEASETIME 0xffffffff |
| Infinite lease time. More... | |
| #define | OPT_SIZE 312 |
| #define | RIP_MSG_SIZE (236+OPT_SIZE) |
Functions | |
| void | default_ipv4_assign (void) |
| void | default_ipv4_update (void) |
| void | default_ipv4_conflict (void) |
| void | reg_dhcpv4_cbfunc (void(*ip_assign)(void), void(*ip_update)(void), void(*ip_conflict)(void)) |
| void | makeDHCPV4MSG (void) |
| void | send_DHCPv4_DISCOVER (void) |
| void | send_DHCPv4_REQUEST (void) |
| void | send_DHCPv4_DECLINE (void) |
| int8_t | parseDHCPv4MSG (void) |
| uint8_t | DHCPv4_run (void) |
| void | DHCPv4_stop (void) |
| uint8_t | check_DHCPv4_timeout (void) |
| int8_t | check_DHCPv4_leasedIP (void) |
| void | DHCPv4_init (uint8_t s, uint8_t *buf) |
| void | reset_DHCPv4_timeout (void) |
| void | DHCPv4_time_handler (void) |
| void | getIPfromDHCPv4 (uint8_t *ip) |
| void | getGWfromDHCPv4 (uint8_t *ip) |
| void | getSNfromDHCPv4 (uint8_t *ip) |
| void | getDNSfromDHCPv4 (uint8_t *ip) |
| uint32_t | getDHCPv4Leasetime (void) |
| char | NibbleToHex (uint8_t nibble) |
Variables | |
| uint8_t | DHCPV4_SOCKET |
| uint8_t | DHCPV4_SIP [4] |
| uint8_t | DHCPV4_REAL_SIP [4] |
| uint8_t | OLD_allocated_ip [4] = {0, } |
| uint8_t | DHCPv4_allocated_ip [4] = {0, } |
| uint8_t | DHCPv4_allocated_gw [4] = {0, } |
| uint8_t | DHCPv4_allocated_sn [4] = {0, } |
| uint8_t | DHCPv4_allocated_dns [4] = {0, } |
| int8_t | dhcpv4_state = STATE_DHCPV4_INIT |
| int8_t | dhcpv4_retry_count = 0 |
| uint32_t | dhcpv4_lease_time = INFINITE_LEASETIME |
| volatile uint32_t | dhcpv4_tick_1s = 0 |
| uint32_t | dhcpv4_tick_next = DHCPV4_WAIT_TIME |
| uint32_t | DHCPV4_XID |
| RIP_MSG * | pDHCPv4MSG |
| uint8_t | HOST_NAMEv4 [] = DCHPV4_HOST_NAME |
| uint8_t | DHCPv4_CHADDR [6] |
| void(* | dhcp_ipv4_assign )(void) |
DHCP APIs implement file.
Processing DHCP protocol as DISCOVER, OFFER, REQUEST, ACK, NACK and DECLINE.
Copyright (c) 2013, WIZnet Co., LTD. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition in file dhcpv4.c.
| #define STATE_DHCPV4_DISCOVER 1 |
| #define STATE_DHCPV4_REQUEST 2 |
| #define STATE_DHCPV4_REREQUEST 4 |
| #define DHCPV4_FLAGSBROADCAST 0x8000 |
| #define DHCPV4_FLAGSUNICAST 0x0000 |
| #define DHCPV4_BOOTREQUEST 1 |
| #define DHCPV4_BOOTREPLY 2 |
| #define DHCPV4_DISCOVER 1 |
| #define DHCPV4_RELEASE 7 |
| #define DHCPV4_INFORM 8 |
| anonymous enum |
| void default_ipv4_assign | ( | void | ) |
Referenced by default_ipv4_update(), and reg_dhcpv4_cbfunc().
| void default_ipv4_update | ( | void | ) |
Definition at line 265 of file dhcpv4.c.
References default_ipv4_assign(), DHCPv4_CHADDR, getSYCR0, setSHAR, setSYCR0, and SYCR0_RST.
Referenced by reg_dhcpv4_cbfunc().
| void default_ipv4_conflict | ( | void | ) |
Definition at line 275 of file dhcpv4.c.
References DHCPv4_CHADDR, getSYCR0, setSHAR, setSYCR0, and SYCR0_RST.
Referenced by reg_dhcpv4_cbfunc().
| void reg_dhcpv4_cbfunc | ( | void(*)(void) | ip_assign, |
| void(*)(void) | ip_update, | ||
| void(*)(void) | ip_conflict | ||
| ) |
Definition at line 284 of file dhcpv4.c.
References default_ipv4_assign(), default_ipv4_conflict(), default_ipv4_update(), and dhcp_ipv4_assign.
| void makeDHCPV4MSG | ( | void | ) |
Definition at line 295 of file dhcpv4.c.
References RIP_MSG::chaddr, RIP_MSG::ciaddr, DHCPV4_BOOTREQUEST, DHCPv4_CHADDR, DHCPV4_FLAGSBROADCAST, DHCPV4_HLENETHERNET, DHCPV4_HOPS, DHCPV4_HTYPE10MB, DHCPV4_SECS, DHCPV4_XID, RIP_MSG::file, RIP_MSG::flags, getSHAR, RIP_MSG::giaddr, RIP_MSG::hlen, RIP_MSG::hops, RIP_MSG::htype, MAGIC_COOKIE, RIP_MSG::op, RIP_MSG::OPT, pDHCPv4MSG, RIP_MSG::secs, RIP_MSG::siaddr, RIP_MSG::sname, RIP_MSG::xid, and RIP_MSG::yiaddr.
Referenced by send_DHCPv4_DECLINE(), send_DHCPv4_DISCOVER(), and send_DHCPv4_REQUEST().
| void send_DHCPv4_DISCOVER | ( | void | ) |
Definition at line 354 of file dhcpv4.c.
References dhcpClientIdentifier, dhcpMessageType, dhcpParamRequest, dhcpT1value, dhcpT2value, DHCPv4_CHADDR, DHCPV4_DISCOVER, DHCPV4_REAL_SIP, DHCPV4_SERVER_PORT, DHCPV4_SIP, DHCPV4_SOCKET, dns, domainName, endOption, HOST_NAMEv4, hostName, makeDHCPV4MSG(), NibbleToHex(), RIP_MSG::OPT, OPT_SIZE, pDHCPv4MSG, RIP_MSG_SIZE, routersOnSubnet, sendto(), and subnetMask.
Referenced by check_DHCPv4_timeout(), and DHCPv4_run().
| void send_DHCPv4_REQUEST | ( | void | ) |
Definition at line 427 of file dhcpv4.c.
References RIP_MSG::ciaddr, dhcpClientIdentifier, dhcpMessageType, dhcpParamRequest, dhcpRequestedIPaddr, dhcpServerIdentifier, dhcpT1value, dhcpT2value, DHCPv4_allocated_ip, DHCPv4_CHADDR, DHCPV4_FLAGSUNICAST, DHCPV4_REQUEST, DHCPV4_SERVER_PORT, DHCPV4_SIP, DHCPV4_SOCKET, dhcpv4_state, dns, domainName, endOption, RIP_MSG::flags, HOST_NAMEv4, hostName, makeDHCPV4MSG(), NibbleToHex(), RIP_MSG::OPT, OPT_SIZE, pDHCPv4MSG, performRouterDiscovery, RIP_MSG_SIZE, routersOnSubnet, sendto(), STATE_DHCPV4_LEASED, STATE_DHCPV4_REREQUEST, staticRoute, and subnetMask.
Referenced by check_DHCPv4_timeout(), and DHCPv4_run().
| void send_DHCPv4_DECLINE | ( | void | ) |
Definition at line 526 of file dhcpv4.c.
References dhcpClientIdentifier, dhcpMessageType, dhcpRequestedIPaddr, dhcpServerIdentifier, DHCPv4_allocated_ip, DHCPv4_CHADDR, DHCPV4_DECLINE, DHCPV4_FLAGSUNICAST, DHCPV4_SERVER_PORT, DHCPV4_SIP, DHCPV4_SOCKET, endOption, RIP_MSG::flags, makeDHCPV4MSG(), RIP_MSG::OPT, OPT_SIZE, pDHCPv4MSG, RIP_MSG_SIZE, and sendto().
Referenced by check_DHCPv4_leasedIP().
| int8_t parseDHCPv4MSG | ( | void | ) |
Definition at line 586 of file dhcpv4.c.
References RIP_MSG::chaddr, dhcpIPaddrLeaseTime, dhcpMessageType, dhcpServerIdentifier, DHCPv4_allocated_dns, DHCPv4_allocated_gw, DHCPv4_allocated_sn, DHCPv4_CHADDR, dhcpv4_lease_time, DHCPV4_REAL_SIP, DHCPV4_SERVER_PORT, DHCPV4_SIP, DHCPV4_SOCKET, dns, endOption, getSn_RX_RSR(), RIP_MSG::op, padOption, pDHCPv4MSG, recvfrom(), routersOnSubnet, and subnetMask.
Referenced by DHCPv4_run().
| uint8_t DHCPv4_run | ( | void | ) |
Definition at line 707 of file dhcpv4.c.
References check_DHCPv4_leasedIP(), check_DHCPv4_timeout(), dhcp_ipv4_assign, DHCP_IPV4_CHANGED, DHCP_IPV4_LEASED, DHCPV4_ACK, DHCPv4_allocated_ip, DHCPV4_CLIENT_PORT, dhcpv4_lease_time, DHCPV4_NAK, DHCPV4_OFFER, dhcpv4_retry_count, DHCPV4_RUNNING, DHCPV4_SOCKET, dhcpv4_state, DHCPV4_STOPPED, dhcpv4_tick_1s, DHCPV4_XID, getSn_SR, INFINITE_LEASETIME, OLD_allocated_ip, parseDHCPv4MSG(), pDHCPv4MSG, reset_DHCPv4_timeout(), send_DHCPv4_DISCOVER(), send_DHCPv4_REQUEST(), Sn_MR_UDP, SOCK_UDP, socket(), STATE_DHCPV4_DISCOVER, STATE_DHCPV4_INIT, STATE_DHCPV4_LEASED, STATE_DHCPV4_REQUEST, STATE_DHCPV4_REREQUEST, STATE_DHCPV4_STOP, and RIP_MSG::yiaddr.
| void DHCPv4_stop | ( | void | ) |
Definition at line 838 of file dhcpv4.c.
References close(), DHCPV4_SOCKET, dhcpv4_state, and STATE_DHCPV4_STOP.
| uint8_t check_DHCPv4_timeout | ( | void | ) |
Definition at line 844 of file dhcpv4.c.
References DHCPV4_FAILED, dhcpv4_retry_count, DHCPV4_RUNNING, dhcpv4_state, dhcpv4_tick_1s, dhcpv4_tick_next, DHCPV4_WAIT_TIME, MAX_DHCPV4_RETRY, reset_DHCPv4_timeout(), send_DHCPv4_DISCOVER(), send_DHCPv4_REQUEST(), STATE_DHCPV4_DISCOVER, STATE_DHCPV4_INIT, STATE_DHCPV4_REQUEST, and STATE_DHCPV4_REREQUEST.
Referenced by DHCPv4_run().
| int8_t check_DHCPv4_leasedIP | ( | void | ) |
Definition at line 897 of file dhcpv4.c.
References DHCPv4_allocated_ip, DHCPV4_SOCKET, dhcpv4_tick_1s, getRCR, send_DHCPv4_DECLINE(), sendto(), setRCR, and SOCKERR_TIMEOUT.
Referenced by DHCPv4_run().
| void DHCPv4_init | ( | uint8_t | s, |
| uint8_t * | buf | ||
| ) |
Definition at line 932 of file dhcpv4.c.
References DHCPv4_CHADDR, DHCPV4_SOCKET, dhcpv4_state, DHCPV4_XID, getSHAR, pDHCPv4MSG, reset_DHCPv4_timeout(), setGAR, setSHAR, setSIPR, and STATE_DHCPV4_INIT.
| void reset_DHCPv4_timeout | ( | void | ) |
Definition at line 962 of file dhcpv4.c.
References dhcpv4_retry_count, dhcpv4_tick_1s, dhcpv4_tick_next, and DHCPV4_WAIT_TIME.
Referenced by check_DHCPv4_timeout(), DHCPv4_init(), and DHCPv4_run().
| void DHCPv4_time_handler | ( | void | ) |
Definition at line 969 of file dhcpv4.c.
References dhcpv4_tick_1s.
| void getIPfromDHCPv4 | ( | uint8_t * | ip | ) |
Definition at line 974 of file dhcpv4.c.
References DHCPv4_allocated_ip.
| void getGWfromDHCPv4 | ( | uint8_t * | ip | ) |
Definition at line 982 of file dhcpv4.c.
References DHCPv4_allocated_gw.
| void getSNfromDHCPv4 | ( | uint8_t * | ip | ) |
Definition at line 990 of file dhcpv4.c.
References DHCPv4_allocated_sn.
| void getDNSfromDHCPv4 | ( | uint8_t * | ip | ) |
Definition at line 998 of file dhcpv4.c.
References DHCPv4_allocated_dns.
| uint32_t getDHCPv4Leasetime | ( | void | ) |
Definition at line 1006 of file dhcpv4.c.
References dhcpv4_lease_time.
| char NibbleToHex | ( | uint8_t | nibble | ) |
Definition at line 1011 of file dhcpv4.c.
Referenced by send_DHCPv4_DISCOVER(), and send_DHCPv4_REQUEST().
| uint8_t DHCPV4_SOCKET |
Definition at line 193 of file dhcpv4.c.
Referenced by check_DHCPv4_leasedIP(), DHCPv4_init(), DHCPv4_run(), DHCPv4_stop(), parseDHCPv4MSG(), send_DHCPv4_DECLINE(), send_DHCPv4_DISCOVER(), and send_DHCPv4_REQUEST().
| uint8_t DHCPV4_SIP[4] |
Definition at line 195 of file dhcpv4.c.
Referenced by parseDHCPv4MSG(), send_DHCPv4_DECLINE(), send_DHCPv4_DISCOVER(), and send_DHCPv4_REQUEST().
| uint8_t DHCPV4_REAL_SIP[4] |
Definition at line 196 of file dhcpv4.c.
Referenced by parseDHCPv4MSG(), and send_DHCPv4_DISCOVER().
| uint8_t OLD_allocated_ip[4] = {0, } |
Definition at line 199 of file dhcpv4.c.
Referenced by DHCPv4_run().
| uint8_t DHCPv4_allocated_ip[4] = {0, } |
Definition at line 200 of file dhcpv4.c.
Referenced by check_DHCPv4_leasedIP(), DHCPv4_run(), getIPfromDHCPv4(), send_DHCPv4_DECLINE(), and send_DHCPv4_REQUEST().
| uint8_t DHCPv4_allocated_gw[4] = {0, } |
Definition at line 201 of file dhcpv4.c.
Referenced by getGWfromDHCPv4(), and parseDHCPv4MSG().
| uint8_t DHCPv4_allocated_sn[4] = {0, } |
Definition at line 202 of file dhcpv4.c.
Referenced by getSNfromDHCPv4(), and parseDHCPv4MSG().
| uint8_t DHCPv4_allocated_dns[4] = {0, } |
Definition at line 203 of file dhcpv4.c.
Referenced by getDNSfromDHCPv4(), and parseDHCPv4MSG().
| int8_t dhcpv4_state = STATE_DHCPV4_INIT |
Definition at line 206 of file dhcpv4.c.
Referenced by check_DHCPv4_timeout(), DHCPv4_init(), DHCPv4_run(), DHCPv4_stop(), and send_DHCPv4_REQUEST().
| int8_t dhcpv4_retry_count = 0 |
Definition at line 207 of file dhcpv4.c.
Referenced by check_DHCPv4_timeout(), DHCPv4_run(), and reset_DHCPv4_timeout().
| uint32_t dhcpv4_lease_time = INFINITE_LEASETIME |
Definition at line 209 of file dhcpv4.c.
Referenced by DHCPv4_run(), getDHCPv4Leasetime(), and parseDHCPv4MSG().
| volatile uint32_t dhcpv4_tick_1s = 0 |
Definition at line 210 of file dhcpv4.c.
Referenced by check_DHCPv4_leasedIP(), check_DHCPv4_timeout(), DHCPv4_run(), DHCPv4_time_handler(), and reset_DHCPv4_timeout().
| uint32_t dhcpv4_tick_next = DHCPV4_WAIT_TIME |
Definition at line 211 of file dhcpv4.c.
Referenced by check_DHCPv4_timeout(), and reset_DHCPv4_timeout().
| uint32_t DHCPV4_XID |
Definition at line 213 of file dhcpv4.c.
Referenced by DHCPv4_init(), DHCPv4_run(), and makeDHCPV4MSG().
| RIP_MSG* pDHCPv4MSG |
Definition at line 215 of file dhcpv4.c.
Referenced by DHCPv4_init(), DHCPv4_run(), makeDHCPV4MSG(), parseDHCPv4MSG(), send_DHCPv4_DECLINE(), send_DHCPv4_DISCOVER(), and send_DHCPv4_REQUEST().
| uint8_t HOST_NAMEv4[] = DCHPV4_HOST_NAME |
Definition at line 217 of file dhcpv4.c.
Referenced by send_DHCPv4_DISCOVER(), and send_DHCPv4_REQUEST().
| uint8_t DHCPv4_CHADDR[6] |
Definition at line 219 of file dhcpv4.c.
Referenced by default_ipv4_conflict(), default_ipv4_update(), DHCPv4_init(), makeDHCPV4MSG(), parseDHCPv4MSG(), send_DHCPv4_DECLINE(), send_DHCPv4_DISCOVER(), and send_DHCPv4_REQUEST().
|
default |
Definition at line 227 of file dhcpv4.c.
Referenced by DHCPv4_run(), and reg_dhcpv4_cbfunc().
1.8.17