dhcp_client.h File Reference

DHCP client (Dynamic Host Configuration Protocol) More...

#include "core/net.h"
#include "core/socket.h"
#include "core/udp.h"
#include "dhcp/dhcp_common.h"

Go to the source code of this file.

Data Structures

struct  DhcpClientSettings
 DHCP client settings. More...
 
struct  _DhcpClientContext
 DHCP client context. More...
 

Macros

#define DHCP_CLIENT_SUPPORT   ENABLED
 
#define DHCP_CLIENT_TICK_INTERVAL   200
 
#define DHCP_CLIENT_INIT_DELAY   2000
 
#define DHCP_CLIENT_DISCOVER_INIT_RT   4000
 
#define DHCP_CLIENT_DISCOVER_MAX_RT   16000
 
#define DHCP_CLIENT_REQUEST_MAX_RC   4
 
#define DHCP_CLIENT_REQUEST_INIT_RT   4000
 
#define DHCP_CLIENT_REQUEST_MAX_RT   64000
 
#define DHCP_CLIENT_REQUEST_MIN_DELAY   60000
 
#define DHCP_CLIENT_PROBE_NUM   1
 
#define DHCP_CLIENT_PROBE_DELAY   1000
 
#define DHCP_CLIENT_RAND_FACTOR   1000
 
#define DhcpClientContext   struct _DhcpClientContext
 

Typedefs

typedef void(* DhcpTimeoutCallback) (DhcpClientContext *context, NetInterface *interface)
 DHCP configuration timeout callback. More...
 
typedef void(* DhcpLinkChangeCallback) (DhcpClientContext *context, NetInterface *interface, bool_t linkState)
 Link state change callback. More...
 
typedef void(* DhcpStateChangeCallback) (DhcpClientContext *context, NetInterface *interface, DhcpState state)
 FSM state change callback. More...
 
typedef void(* DhcpAddOptionsCallback) (DhcpClientContext *context, DhcpMessage *message, size_t *length, DhcpMessageType type)
 Add DHCP options callback. More...
 
typedef error_t(* DhcpParseOptionsCallback) (DhcpClientContext *context, const DhcpMessage *message, size_t length, DhcpMessageType type)
 Parse DHCP options callback. More...
 

Enumerations

enum  DhcpState {
  DHCP_STATE_INIT = 0, DHCP_STATE_SELECTING = 1, DHCP_STATE_REQUESTING = 2, DHCP_STATE_INIT_REBOOT = 3,
  DHCP_STATE_REBOOTING = 4, DHCP_STATE_PROBING = 5, DHCP_STATE_BOUND = 6, DHCP_STATE_RENEWING = 7,
  DHCP_STATE_REBINDING = 8
}
 DHCP FSM states. More...
 

Functions

void dhcpClientGetDefaultSettings (DhcpClientSettings *settings)
 Initialize settings with default values. More...
 
error_t dhcpClientInit (DhcpClientContext *context, const DhcpClientSettings *settings)
 DHCP client initialization. More...
 
error_t dhcpClientStart (DhcpClientContext *context)
 Start DHCP client. More...
 
error_t dhcpClientStop (DhcpClientContext *context)
 Stop DHCP client. More...
 
error_t dhcpClientRelease (DhcpClientContext *context)
 Release DHCP lease. More...
 
DhcpState dhcpClientGetState (DhcpClientContext *context)
 Retrieve current state. More...
 

Detailed Description

DHCP client (Dynamic Host Configuration Protocol)

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2022 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.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.1.6

Definition in file dhcp_client.h.

Macro Definition Documentation

◆ DHCP_CLIENT_DISCOVER_INIT_RT

#define DHCP_CLIENT_DISCOVER_INIT_RT   4000

Definition at line 63 of file dhcp_client.h.

◆ DHCP_CLIENT_DISCOVER_MAX_RT

#define DHCP_CLIENT_DISCOVER_MAX_RT   16000

Definition at line 70 of file dhcp_client.h.

◆ DHCP_CLIENT_INIT_DELAY

#define DHCP_CLIENT_INIT_DELAY   2000

Definition at line 56 of file dhcp_client.h.

◆ DHCP_CLIENT_PROBE_DELAY

#define DHCP_CLIENT_PROBE_DELAY   1000

Definition at line 112 of file dhcp_client.h.

◆ DHCP_CLIENT_PROBE_NUM

#define DHCP_CLIENT_PROBE_NUM   1

Definition at line 105 of file dhcp_client.h.

◆ DHCP_CLIENT_RAND_FACTOR

#define DHCP_CLIENT_RAND_FACTOR   1000

Definition at line 119 of file dhcp_client.h.

◆ DHCP_CLIENT_REQUEST_INIT_RT

#define DHCP_CLIENT_REQUEST_INIT_RT   4000

Definition at line 84 of file dhcp_client.h.

◆ DHCP_CLIENT_REQUEST_MAX_RC

#define DHCP_CLIENT_REQUEST_MAX_RC   4

Definition at line 77 of file dhcp_client.h.

◆ DHCP_CLIENT_REQUEST_MAX_RT

#define DHCP_CLIENT_REQUEST_MAX_RT   64000

Definition at line 91 of file dhcp_client.h.

◆ DHCP_CLIENT_REQUEST_MIN_DELAY

#define DHCP_CLIENT_REQUEST_MIN_DELAY   60000

Definition at line 98 of file dhcp_client.h.

◆ DHCP_CLIENT_SUPPORT

#define DHCP_CLIENT_SUPPORT   ENABLED

Definition at line 42 of file dhcp_client.h.

◆ DHCP_CLIENT_TICK_INTERVAL

#define DHCP_CLIENT_TICK_INTERVAL   200

Definition at line 49 of file dhcp_client.h.

◆ DhcpClientContext

#define DhcpClientContext   struct _DhcpClientContext

Definition at line 126 of file dhcp_client.h.

Typedef Documentation

◆ DhcpAddOptionsCallback

typedef void(* DhcpAddOptionsCallback) (DhcpClientContext *context, DhcpMessage *message, size_t *length, DhcpMessageType type)

Add DHCP options callback.

Definition at line 180 of file dhcp_client.h.

◆ DhcpLinkChangeCallback

typedef void(* DhcpLinkChangeCallback) (DhcpClientContext *context, NetInterface *interface, bool_t linkState)

Link state change callback.

Definition at line 164 of file dhcp_client.h.

◆ DhcpParseOptionsCallback

typedef error_t(* DhcpParseOptionsCallback) (DhcpClientContext *context, const DhcpMessage *message, size_t length, DhcpMessageType type)

Parse DHCP options callback.

Definition at line 188 of file dhcp_client.h.

◆ DhcpStateChangeCallback

typedef void(* DhcpStateChangeCallback) (DhcpClientContext *context, NetInterface *interface, DhcpState state)

FSM state change callback.

Definition at line 172 of file dhcp_client.h.

◆ DhcpTimeoutCallback

typedef void(* DhcpTimeoutCallback) (DhcpClientContext *context, NetInterface *interface)

DHCP configuration timeout callback.

Definition at line 156 of file dhcp_client.h.

Enumeration Type Documentation

◆ DhcpState

enum DhcpState

DHCP FSM states.

Enumerator
DHCP_STATE_INIT 
DHCP_STATE_SELECTING 
DHCP_STATE_REQUESTING 
DHCP_STATE_INIT_REBOOT 
DHCP_STATE_REBOOTING 
DHCP_STATE_PROBING 
DHCP_STATE_BOUND 
DHCP_STATE_RENEWING 
DHCP_STATE_REBINDING 

Definition at line 138 of file dhcp_client.h.

Function Documentation

◆ dhcpClientGetDefaultSettings()

void dhcpClientGetDefaultSettings ( DhcpClientSettings settings)

Initialize settings with default values.

Parameters
[out]settingsStructure that contains DHCP client settings

Definition at line 57 of file dhcp_client.c.

◆ dhcpClientGetState()

DhcpState dhcpClientGetState ( DhcpClientContext context)

Retrieve current state.

Parameters
[in]contextPointer to the DHCP client context
Returns
Current DHCP client state

Definition at line 293 of file dhcp_client.c.

◆ dhcpClientInit()

error_t dhcpClientInit ( DhcpClientContext context,
const DhcpClientSettings settings 
)

DHCP client initialization.

Parameters
[in]contextPointer to the DHCP client context
[in]settingsDHCP client specific settings
Returns
Error code

Definition at line 92 of file dhcp_client.c.

◆ dhcpClientRelease()

error_t dhcpClientRelease ( DhcpClientContext context)

Release DHCP lease.

Parameters
[in]contextPointer to the DHCP client context
Returns
Error code

Definition at line 237 of file dhcp_client.c.

◆ dhcpClientStart()

error_t dhcpClientStart ( DhcpClientContext context)

Start DHCP client.

Parameters
[in]contextPointer to the DHCP client context
Returns
Error code

Definition at line 135 of file dhcp_client.c.

◆ dhcpClientStop()

error_t dhcpClientStop ( DhcpClientContext context)

Stop DHCP client.

Parameters
[in]contextPointer to the DHCP client context
Returns
Error code

Definition at line 194 of file dhcp_client.c.