Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
dhcp_client.c File Reference
DHCP client (Dynamic Host Configuration Protocol) More...
Go to the source code of this file.
Functions | |
| void | dhcpClientGetDefaultSettings (DhcpClientSettings *settings) |
| Initialize settings with default values. | |
| error_t | dhcpClientInit (DhcpClientContext *context, const DhcpClientSettings *settings) |
| DHCP client initialization. | |
| error_t | dhcpClientStart (DhcpClientContext *context) |
| Start DHCP client. | |
| error_t | dhcpClientStop (DhcpClientContext *context) |
| Stop DHCP client. | |
| DhcpState | dhcpClientGetState (DhcpClientContext *context) |
| Retrieve current state. | |
| void | dhcpClientTick (DhcpClientContext *context) |
| DHCP client timer handler. | |
| void | dhcpClientLinkChangeEvent (DhcpClientContext *context) |
| Callback function for link change event. | |
| void | dhcpClientStateInit (DhcpClientContext *context) |
| INIT state. | |
| void | dhcpClientStateSelecting (DhcpClientContext *context) |
| SELECTING state. | |
| void | dhcpClientStateRequesting (DhcpClientContext *context) |
| REQUESTING state. | |
| void | dhcpClientStateInitReboot (DhcpClientContext *context) |
| INIT-REBOOT state. | |
| void | dhcpClientStateRebooting (DhcpClientContext *context) |
| REBOOTING state. | |
| void | dhcpClientStateProbing (DhcpClientContext *context) |
| PROBING state. | |
| void | dhcpClientStateBound (DhcpClientContext *context) |
| BOUND state. | |
| void | dhcpClientStateRenewing (DhcpClientContext *context) |
| RENEWING state. | |
| void | dhcpClientStateRebinding (DhcpClientContext *context) |
| REBINDING state. | |
| error_t | dhcpClientSendDiscover (DhcpClientContext *context) |
| Send DHCPDISCOVER message. | |
| error_t | dhcpClientSendRequest (DhcpClientContext *context) |
| Send DHCPREQUEST message. | |
| error_t | dhcpClientSendDecline (DhcpClientContext *context) |
| Send DHCPDECLINE message. | |
| void | dhcpClientProcessMessage (NetInterface *interface, const IpPseudoHeader *pseudoHeader, const UdpHeader *udpHeader, const NetBuffer *buffer, size_t offset, void *params) |
| Process incoming DHCP message. | |
| void | dhcpClientParseOffer (DhcpClientContext *context, const DhcpMessage *message, size_t length) |
| Parse DHCPOFFER message. | |
| void | dhcpClientParseAck (DhcpClientContext *context, const DhcpMessage *message, size_t length) |
| Parse DHCPACK message. | |
| void | dhcpClientParseNak (DhcpClientContext *context, const DhcpMessage *message, size_t length) |
| Parse DHCPNAK message. | |
| void | dhcpClientCheckTimeout (DhcpClientContext *context) |
| Manage DHCP configuration timeout. | |
| uint16_t | dhcpClientComputeElapsedTime (DhcpClientContext *context) |
| Compute the appropriate secs field. | |
| void | dhcpClientChangeState (DhcpClientContext *context, DhcpState newState, systime_t delay) |
| Update DHCP FSM state. | |
| void | dhcpClientDumpConfig (DhcpClientContext *context) |
| Dump DHCP configuration for debugging purpose. | |
Detailed Description
DHCP client (Dynamic Host Configuration Protocol)
License
Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.
This file is part of CycloneTCP Open.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Description
The Dynamic Host Configuration Protocol is used to provide configuration parameters to hosts. Refer to the following RFCs for complete details:
- RFC 2131: Dynamic Host Configuration Protocol
- RFC 2132: DHCP Options and BOOTP Vendor Extensions
- RFC 4039: Rapid Commit Option for the DHCP version 4
- Version:
- 1.7.6
Definition in file dhcp_client.c.
Function Documentation
| void dhcpClientChangeState | ( | DhcpClientContext * | context, |
| DhcpState | newState, | ||
| systime_t | delay | ||
| ) |
Update DHCP FSM state.
- Parameters:
-
[in] context Pointer to the DHCP client context [in] newState New DHCP state to switch to [in] delay Initial delay
Definition at line 1733 of file dhcp_client.c.
| void dhcpClientCheckTimeout | ( | DhcpClientContext * | context ) |
Manage DHCP configuration timeout.
- Parameters:
-
[in] context Pointer to the DHCP client context
Definition at line 1665 of file dhcp_client.c.
| uint16_t dhcpClientComputeElapsedTime | ( | DhcpClientContext * | context ) |
Compute the appropriate secs field.
Compute the number of seconds elapsed since the client began address acquisition or renewal process
- Parameters:
-
[in] context Pointer to the DHCP client context
- Returns:
- The elapsed time expressed in seconds
Definition at line 1710 of file dhcp_client.c.
| void dhcpClientDumpConfig | ( | DhcpClientContext * | context ) |
Dump DHCP configuration for debugging purpose.
- Parameters:
-
[in] context Pointer to the DHCP client context
Definition at line 1797 of file dhcp_client.c.
| void dhcpClientGetDefaultSettings | ( | DhcpClientSettings * | settings ) |
Initialize settings with default values.
- Parameters:
-
[out] settings Structure that contains DHCP client settings
Definition at line 73 of file dhcp_client.c.
| DhcpState dhcpClientGetState | ( | DhcpClientContext * | context ) |
Retrieve current state.
- Parameters:
-
[in] context Pointer to the DHCP client context
- Returns:
- Current DHCP client state
Definition at line 230 of file dhcp_client.c.
| error_t dhcpClientInit | ( | DhcpClientContext * | context, |
| const DhcpClientSettings * | settings | ||
| ) |
DHCP client initialization.
- Parameters:
-
[in] context Pointer to the DHCP client context [in] settings DHCP client specific settings
- Returns:
- Error code
Definition at line 103 of file dhcp_client.c.
| void dhcpClientLinkChangeEvent | ( | DhcpClientContext * | context ) |
Callback function for link change event.
- Parameters:
-
[in] context Pointer to the DHCP client context
Definition at line 333 of file dhcp_client.c.
| void dhcpClientParseAck | ( | DhcpClientContext * | context, |
| const DhcpMessage * | message, | ||
| size_t | length | ||
| ) |
Parse DHCPACK message.
- Parameters:
-
[in] context Pointer to the DHCP client context [in] message Pointer to the incoming DHCP message [in] length Length of the incoming message to parse
- Returns:
- Error code
Definition at line 1380 of file dhcp_client.c.
| void dhcpClientParseNak | ( | DhcpClientContext * | context, |
| const DhcpMessage * | message, | ||
| size_t | length | ||
| ) |
Parse DHCPNAK message.
- Parameters:
-
[in] context Pointer to the DHCP client context [in] message Pointer to the incoming DHCP message [in] length Length of the incoming message to parse
- Returns:
- Error code
Definition at line 1601 of file dhcp_client.c.
| void dhcpClientParseOffer | ( | DhcpClientContext * | context, |
| const DhcpMessage * | message, | ||
| size_t | length | ||
| ) |
Parse DHCPOFFER message.
- Parameters:
-
[in] context Pointer to the DHCP client context [in] message Pointer to the incoming DHCP message [in] length Length of the incoming message to parse
Definition at line 1331 of file dhcp_client.c.
| void dhcpClientProcessMessage | ( | NetInterface * | interface, |
| const IpPseudoHeader * | pseudoHeader, | ||
| const UdpHeader * | udpHeader, | ||
| const NetBuffer * | buffer, | ||
| size_t | offset, | ||
| void * | params | ||
| ) |
Process incoming DHCP message.
- Parameters:
-
[in] interface Underlying network interface [in] pseudoHeader UDP pseudo header [in] udpHeader UDP header [in] buffer Multi-part buffer containing the incoming DHCP message [in] offset Offset to the first byte of the DHCP message [in] params Pointer to the DHCP client context
Definition at line 1248 of file dhcp_client.c.
| error_t dhcpClientSendDecline | ( | DhcpClientContext * | context ) |
Send DHCPDECLINE message.
- Parameters:
-
[in] context Pointer to the DHCP client context
- Returns:
- Error code
Definition at line 1165 of file dhcp_client.c.
| error_t dhcpClientSendDiscover | ( | DhcpClientContext * | context ) |
Send DHCPDISCOVER message.
- Parameters:
-
[in] context Pointer to the DHCP client context
- Returns:
- Error code
Definition at line 944 of file dhcp_client.c.
| error_t dhcpClientSendRequest | ( | DhcpClientContext * | context ) |
Send DHCPREQUEST message.
- Parameters:
-
[in] context Pointer to the DHCP client context
- Returns:
- Error code
Definition at line 1037 of file dhcp_client.c.
| error_t dhcpClientStart | ( | DhcpClientContext * | context ) |
Start DHCP client.
- Parameters:
-
[in] context Pointer to the DHCP client context
- Returns:
- Error code
Definition at line 168 of file dhcp_client.c.
| void dhcpClientStateBound | ( | DhcpClientContext * | context ) |
BOUND state.
Client has a valid lease and is in its normal operating state
- Parameters:
-
[in] context Pointer to the DHCP client context
Definition at line 761 of file dhcp_client.c.
| void dhcpClientStateInit | ( | DhcpClientContext * | context ) |
INIT state.
This is the initialization state, where a client begins the process of acquiring a lease. It also returns here when a lease ends, or when a lease negotiation fails
- Parameters:
-
[in] context Pointer to the DHCP client context
Definition at line 395 of file dhcp_client.c.
| void dhcpClientStateInitReboot | ( | DhcpClientContext * | context ) |
INIT-REBOOT state.
When a client that already has a valid lease starts up after a power-down or reboot, it starts here instead of the INIT state
- Parameters:
-
[in] context Pointer to the DHCP client context
Definition at line 576 of file dhcp_client.c.
| void dhcpClientStateProbing | ( | DhcpClientContext * | context ) |
PROBING state.
The client probes the newly received address
- Parameters:
-
[in] context Pointer to the DHCP client context
Definition at line 694 of file dhcp_client.c.
| void dhcpClientStateRebinding | ( | DhcpClientContext * | context ) |
REBINDING state.
The client has failed to renew its lease with the server that originally granted it, and now seeks a lease extension with any server that can hear it. It periodically sends DHCPREQUEST messages with no server specified until it gets a reply or the lease ends
- Parameters:
-
[in] context Pointer to the DHCP client context
Definition at line 867 of file dhcp_client.c.
| void dhcpClientStateRebooting | ( | DhcpClientContext * | context ) |
REBOOTING state.
A client that has rebooted with an assigned address is waiting for a confirming reply from a server
- Parameters:
-
[in] context Pointer to the DHCP client context
Definition at line 616 of file dhcp_client.c.
| void dhcpClientStateRenewing | ( | DhcpClientContext * | context ) |
RENEWING state.
Client is trying to renew its lease. It regularly sends DHCPREQUEST messages with the server that gave it its current lease specified, and waits for a reply
- Parameters:
-
[in] context Pointer to the DHCP client context
Definition at line 802 of file dhcp_client.c.
| void dhcpClientStateRequesting | ( | DhcpClientContext * | context ) |
REQUESTING state.
The client is waiting to hear back from the server to which it sent its request
- Parameters:
-
[in] context Pointer to the DHCP client context
Definition at line 497 of file dhcp_client.c.
| void dhcpClientStateSelecting | ( | DhcpClientContext * | context ) |
SELECTING state.
The client is waiting to receive DHCPOFFER messages from one or more DHCP servers, so it can choose one
- Parameters:
-
[in] context Pointer to the DHCP client context
Definition at line 435 of file dhcp_client.c.
| error_t dhcpClientStop | ( | DhcpClientContext * | context ) |
Stop DHCP client.
- Parameters:
-
[in] context Pointer to the DHCP client context
- Returns:
- Error code
Definition at line 199 of file dhcp_client.c.
| void dhcpClientTick | ( | DhcpClientContext * | context ) |
DHCP client timer handler.
This routine must be periodically called by the TCP/IP stack to manage DHCP client operation
- Parameters:
-
[in] context Pointer to the DHCP client context
Definition at line 256 of file dhcp_client.c.
Generated on Tue Jul 12 2022 17:10:19 by
1.7.2