dhcp_server.h File Reference

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

#include "core/net.h"

Go to the source code of this file.

Data Structures

struct  DhcpServerBinding
 DHCP binding. More...
 
struct  DhcpServerSettings
 DHCP server settings. More...
 
struct  DhcpServerContext
 DHCP server context. More...
 

Macros

#define DHCP_SERVER_SUPPORT   DISABLED
 
#define DHCP_SERVER_TICK_INTERVAL   1000
 
#define DHCP_SERVER_MAX_CLIENTS   16
 
#define DHCP_SERVER_DEFAULT_LEASE_TIME   86400
 
#define DHCP_SERVER_MAX_DNS_SERVERS   2
 

Functions

void dhcpServerGetDefaultSettings (DhcpServerSettings *settings)
 Initialize settings with default values. More...
 
error_t dhcpServerInit (DhcpServerContext *context, const DhcpServerSettings *settings)
 DHCP server initialization. More...
 
error_t dhcpServerStart (DhcpServerContext *context)
 Start DHCP server. More...
 
error_t dhcpServerStop (DhcpServerContext *context)
 Stop DHCP server. More...
 
void dhcpServerTick (DhcpServerContext *context)
 DHCP server timer handler. More...
 
void dhcpServerProcessMessage (NetInterface *interface, const IpPseudoHeader *pseudoHeader, const UdpHeader *udpHeader, const NetBuffer *buffer, size_t offset, void *param)
 Process incoming DHCP message. More...
 
void dhcpServerParseDiscover (DhcpServerContext *context, const DhcpMessage *message, size_t length)
 Parse DHCPDISCOVER message. More...
 
void dhcpServerParseRequest (DhcpServerContext *context, const DhcpMessage *message, size_t length)
 Parse DHCPREQUEST message. More...
 
void dhcpServerParseDecline (DhcpServerContext *context, const DhcpMessage *message, size_t length)
 Parse DHCPDECLINE message. More...
 
void dhcpServerParseRelease (DhcpServerContext *context, const DhcpMessage *message, size_t length)
 Parse DHCPRELEASE message. More...
 
void dhcpServerParseInform (DhcpServerContext *context, const DhcpMessage *message, size_t length)
 Parse DHCPINFORM message. More...
 
error_t dhcpServerSendReply (DhcpServerContext *context, uint8_t type, Ipv4Addr yourIpAddr, const DhcpMessage *request, size_t length)
 Send DHCP reply message. More...
 
DhcpServerBindingdhcpServerCreateBinding (DhcpServerContext *context)
 Create a new binding. More...
 
DhcpServerBindingdhcpServerFindBindingByMacAddr (DhcpServerContext *context, const MacAddr *macAddr)
 Search the list of bindings for a given MAC address. More...
 
DhcpServerBindingdhcpServerFindBindingByIpAddr (DhcpServerContext *context, Ipv4Addr ipAddr)
 Search the list of bindings for a given IP address. More...
 
error_t dhcpServerGetNextIpAddr (DhcpServerContext *context, Ipv4Addr *ipAddr)
 Retrieve the next IP address to be used. More...
 

Variables

systime_t dhcpServerTickCounter
 

Detailed Description

DHCP server (Dynamic Host Configuration Protocol)

License

Copyright (C) 2010-2018 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
1.9.0

Definition in file dhcp_server.h.

Macro Definition Documentation

◆ DHCP_SERVER_DEFAULT_LEASE_TIME

#define DHCP_SERVER_DEFAULT_LEASE_TIME   86400

Definition at line 58 of file dhcp_server.h.

◆ DHCP_SERVER_MAX_CLIENTS

#define DHCP_SERVER_MAX_CLIENTS   16

Definition at line 51 of file dhcp_server.h.

◆ DHCP_SERVER_MAX_DNS_SERVERS

#define DHCP_SERVER_MAX_DNS_SERVERS   2

Definition at line 65 of file dhcp_server.h.

◆ DHCP_SERVER_SUPPORT

#define DHCP_SERVER_SUPPORT   DISABLED

Definition at line 37 of file dhcp_server.h.

◆ DHCP_SERVER_TICK_INTERVAL

#define DHCP_SERVER_TICK_INTERVAL   1000

Definition at line 44 of file dhcp_server.h.

Function Documentation

◆ dhcpServerCreateBinding()

DhcpServerBinding* dhcpServerCreateBinding ( DhcpServerContext context)

Create a new binding.

Parameters
[in]contextPointer to the DHCP server context
Returns
Pointer to the newly created binding

Definition at line 872 of file dhcp_server.c.

◆ dhcpServerFindBindingByIpAddr()

DhcpServerBinding* dhcpServerFindBindingByIpAddr ( DhcpServerContext context,
Ipv4Addr  ipAddr 
)

Search the list of bindings for a given IP address.

Parameters
[in]contextPointer to the DHCP server context
[in]ipAddrIP address
Returns
Pointer to the corresponding DHCP binding

Definition at line 972 of file dhcp_server.c.

◆ dhcpServerFindBindingByMacAddr()

DhcpServerBinding* dhcpServerFindBindingByMacAddr ( DhcpServerContext context,
const MacAddr macAddr 
)

Search the list of bindings for a given MAC address.

Parameters
[in]contextPointer to the DHCP server context
[in]macAddrMAC address
Returns
Pointer to the corresponding DHCP binding

Definition at line 936 of file dhcp_server.c.

◆ dhcpServerGetDefaultSettings()

void dhcpServerGetDefaultSettings ( DhcpServerSettings settings)

Initialize settings with default values.

Parameters
[out]settingsStructure that contains DHCP server settings

Definition at line 60 of file dhcp_server.c.

◆ dhcpServerGetNextIpAddr()

error_t dhcpServerGetNextIpAddr ( DhcpServerContext context,
Ipv4Addr ipAddr 
)

Retrieve the next IP address to be used.

Parameters
[in]contextPointer to the DHCP server context
[out]ipAddrNext IP address to be used
Returns
Error code

Definition at line 1008 of file dhcp_server.c.

◆ dhcpServerInit()

error_t dhcpServerInit ( DhcpServerContext context,
const DhcpServerSettings settings 
)

DHCP server initialization.

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

Definition at line 95 of file dhcp_server.c.

◆ dhcpServerParseDecline()

void dhcpServerParseDecline ( DhcpServerContext context,
const DhcpMessage message,
size_t  length 
)

Parse DHCPDECLINE message.

Parameters
[in]contextPointer to the DHCP server context
[in]messagePointer to the incoming DHCP message
[in]lengthLength of the incoming message to parse

Definition at line 598 of file dhcp_server.c.

◆ dhcpServerParseDiscover()

void dhcpServerParseDiscover ( DhcpServerContext context,
const DhcpMessage message,
size_t  length 
)

Parse DHCPDISCOVER message.

Parameters
[in]contextPointer to the DHCP server context
[in]messagePointer to the incoming DHCP message
[in]lengthLength of the incoming message to parse

Definition at line 354 of file dhcp_server.c.

◆ dhcpServerParseInform()

void dhcpServerParseInform ( DhcpServerContext context,
const DhcpMessage message,
size_t  length 
)

Parse DHCPINFORM message.

Parameters
[in]contextPointer to the DHCP server context
[in]messagePointer to the incoming DHCP message
[in]lengthLength of the incoming message to parse

Definition at line 666 of file dhcp_server.c.

◆ dhcpServerParseRelease()

void dhcpServerParseRelease ( DhcpServerContext context,
const DhcpMessage message,
size_t  length 
)

Parse DHCPRELEASE message.

Parameters
[in]contextPointer to the DHCP server context
[in]messagePointer to the incoming DHCP message
[in]lengthLength of the incoming message to parse

Definition at line 638 of file dhcp_server.c.

◆ dhcpServerParseRequest()

void dhcpServerParseRequest ( DhcpServerContext context,
const DhcpMessage message,
size_t  length 
)

Parse DHCPREQUEST message.

Parameters
[in]contextPointer to the DHCP server context
[in]messagePointer to the incoming DHCP message
[in]lengthLength of the incoming message to parse

Definition at line 481 of file dhcp_server.c.

◆ dhcpServerProcessMessage()

void dhcpServerProcessMessage ( NetInterface interface,
const IpPseudoHeader pseudoHeader,
const UdpHeader udpHeader,
const NetBuffer buffer,
size_t  offset,
void *  param 
)

Process incoming DHCP message.

Parameters
[in]interfaceUnderlying network interface
[in]pseudoHeaderUDP pseudo header
[in]udpHeaderUDP header
[in]bufferMulti-part buffer containing the incoming DHCP message
[in]offsetOffset to the first byte of the DHCP message
[in]paramPointer to the DHCP server context

Definition at line 263 of file dhcp_server.c.

◆ dhcpServerSendReply()

error_t dhcpServerSendReply ( DhcpServerContext context,
uint8_t  type,
Ipv4Addr  yourIpAddr,
const DhcpMessage request,
size_t  length 
)

Send DHCP reply message.

Parameters
[in]contextPointer to the DHCP server context
[in]typeDHCP message type (DHCPOFFER, DHCPACK or DHCPNAK)
[in]yourIpAddrThe IP address to be placed in the 'yiaddr' field
[in]requestPointer to DHCP message received from the client
[in]lengthLength of the DHCP message received from the client
Returns
Error code

Definition at line 690 of file dhcp_server.c.

◆ dhcpServerStart()

error_t dhcpServerStart ( DhcpServerContext context)

Start DHCP server.

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

Definition at line 152 of file dhcp_server.c.

◆ dhcpServerStop()

error_t dhcpServerStop ( DhcpServerContext context)

Stop DHCP server.

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

Definition at line 179 of file dhcp_server.c.

◆ dhcpServerTick()

void dhcpServerTick ( DhcpServerContext context)

DHCP server timer handler.

This routine must be periodically called by the TCP/IP stack to manage DHCP server operation

Parameters
[in]contextPointer to the DHCP server context

Definition at line 209 of file dhcp_server.c.

Variable Documentation

◆ dhcpServerTickCounter

systime_t dhcpServerTickCounter

Definition at line 52 of file dhcp_server.c.