Sergey Pastor / 1

Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

dhcp_server.c File Reference

dhcp_server.c File Reference

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

Go to the source code of this file.

Functions

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

Detailed Description

DHCP server (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.

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

Definition in file dhcp_server.c.


Function Documentation

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 864 of file dhcp_server.c.

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 961 of file dhcp_server.c.

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 925 of file dhcp_server.c.

void dhcpServerGetDefaultSettings ( DhcpServerSettings settings )

Initialize settings with default values.

Parameters:
[out]settingsStructure that contains DHCP server settings

Definition at line 52 of file dhcp_server.c.

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 997 of file dhcp_server.c.

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 87 of file dhcp_server.c.

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 590 of file dhcp_server.c.

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 346 of file dhcp_server.c.

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 658 of file dhcp_server.c.

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 630 of file dhcp_server.c.

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 473 of file dhcp_server.c.

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

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]paramsPointer to the DHCP server context

Definition at line 255 of file dhcp_server.c.

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 682 of file dhcp_server.c.

error_t dhcpServerStart ( DhcpServerContext context )

Start DHCP server.

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

Definition at line 144 of file dhcp_server.c.

error_t dhcpServerStop ( DhcpServerContext context )

Stop DHCP server.

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

Definition at line 171 of file dhcp_server.c.

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 201 of file dhcp_server.c.