dhcpv6_client_misc.c File Reference

Helper functions for DHCPv6 client. More...

#include "core/net.h"
#include "ipv6/ipv6.h"
#include "ipv6/ipv6_misc.h"
#include "ipv6/ndp.h"
#include "dhcpv6/dhcpv6_client.h"
#include "dhcpv6/dhcpv6_client_fsm.h"
#include "dhcpv6/dhcpv6_client_misc.h"
#include "dhcpv6/dhcpv6_common.h"
#include "dhcpv6/dhcpv6_debug.h"
#include "dns/dns_common.h"
#include "date_time.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   DHCPV6_TRACE_LEVEL
 

Functions

void dhcpv6ClientTick (Dhcpv6ClientContext *context)
 DHCPv6 client timer handler. More...
 
void dhcpv6ClientLinkChangeEvent (Dhcpv6ClientContext *context)
 Callback function for link change event. More...
 
error_t dhcpv6ClientSendMessage (Dhcpv6ClientContext *context, Dhcpv6MessageType type)
 Send Solicit message. More...
 
void dhcpv6ClientProcessMessage (NetInterface *interface, const IpPseudoHeader *pseudoHeader, const UdpHeader *udpHeader, const NetBuffer *buffer, size_t offset, const NetRxAncillary *ancillary, void *param)
 Process incoming DHCPv6 message. More...
 
void dhcpv6ClientParseAdvertise (Dhcpv6ClientContext *context, const Dhcpv6Message *message, size_t length)
 Parse Advertise message. More...
 
void dhcpv6ClientParseReply (Dhcpv6ClientContext *context, const Dhcpv6Message *message, size_t length)
 Parse Reply message. More...
 
error_t dhcpv6ClientParseIaNaOption (Dhcpv6ClientContext *context, const Dhcpv6Option *option)
 Parse IA_NA option. More...
 
error_t dhcpv6ClientParseIaAddrOption (Dhcpv6ClientContext *context, const Dhcpv6Option *option)
 Parse IA Address option. More...
 
void dhcpv6ClientAddAddr (Dhcpv6ClientContext *context, const Ipv6Addr *addr, uint32_t validLifetime, uint32_t preferredLifetime)
 Add an IPv6 address to the IA. More...
 
void dhcpv6ClientRemoveAddr (Dhcpv6ClientContext *context, const Ipv6Addr *addr)
 Remove an IPv6 address from the IA. More...
 
void dhcpv6ClientFlushAddrList (Dhcpv6ClientContext *context)
 Flush the list of IPv6 addresses from the IA. More...
 
error_t dhcpv6ClientGenerateDuid (Dhcpv6ClientContext *context)
 Generate client's DUID. More...
 
error_t dhcpv6ClientGenerateLinkLocalAddr (Dhcpv6ClientContext *context)
 Generate a link-local address. More...
 
bool_t dhcpv6ClientCheckServerId (Dhcpv6ClientContext *context, Dhcpv6Option *serverIdOption)
 Check the Server Identifier option. More...
 
void dhcpv6ClientCheckTimeout (Dhcpv6ClientContext *context)
 Manage DHCPv6 configuration timeout. More...
 
uint16_t dhcpv6ClientComputeElapsedTime (Dhcpv6ClientContext *context)
 Compute the time elapsed since the client sent the first message. More...
 
void dhcpv6ClientChangeState (Dhcpv6ClientContext *context, Dhcpv6State newState, systime_t delay)
 Update DHCPv6 FSM state. More...
 
void dhcpv6ClientDumpConfig (Dhcpv6ClientContext *context)
 Dump DHCPv6 configuration for debugging purpose. More...
 

Variables

systime_t dhcpv6ClientTickCounter
 

Detailed Description

Helper functions for DHCPv6 client.

License

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

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

Definition in file dhcpv6_client_misc.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   DHCPV6_TRACE_LEVEL

Definition at line 32 of file dhcpv6_client_misc.c.

Function Documentation

◆ dhcpv6ClientAddAddr()

void dhcpv6ClientAddAddr ( Dhcpv6ClientContext context,
const Ipv6Addr addr,
uint32_t  validLifetime,
uint32_t  preferredLifetime 
)

Add an IPv6 address to the IA.

Parameters
[in]contextPointer to the DHCPv6 client context
[in]addrIPv6 address to be added
[in]validLifetimeValid lifetime, in seconds
[in]preferredLifetimePreferred lifetime, in seconds

Definition at line 1249 of file dhcpv6_client_misc.c.

◆ dhcpv6ClientChangeState()

void dhcpv6ClientChangeState ( Dhcpv6ClientContext context,
Dhcpv6State  newState,
systime_t  delay 
)

Update DHCPv6 FSM state.

Parameters
[in]contextPointer to the DHCPv6 client context
[in]newStateNew DHCPv6 state to switch to
[in]delayInitial delay

Definition at line 1574 of file dhcpv6_client_misc.c.

◆ dhcpv6ClientCheckServerId()

bool_t dhcpv6ClientCheckServerId ( Dhcpv6ClientContext context,
Dhcpv6Option serverIdOption 
)

Check the Server Identifier option.

Parameters
[in]contextPointer to the DHCPv6 client context
[in]serverIdOptionPointer to the Server Identifier option
Returns
TRUE if the option matches the server's DUID, else FALSE

Definition at line 1474 of file dhcpv6_client_misc.c.

◆ dhcpv6ClientCheckTimeout()

void dhcpv6ClientCheckTimeout ( Dhcpv6ClientContext context)

Manage DHCPv6 configuration timeout.

Parameters
[in]contextPointer to the DHCPv6 client context

Definition at line 1500 of file dhcpv6_client_misc.c.

◆ dhcpv6ClientComputeElapsedTime()

uint16_t dhcpv6ClientComputeElapsedTime ( Dhcpv6ClientContext context)

Compute the time elapsed since the client sent the first message.

Parameters
[in]contextPointer to the DHCPv6 client context
Returns
The elapsed time expressed in hundredths of a second

Definition at line 1541 of file dhcpv6_client_misc.c.

◆ dhcpv6ClientDumpConfig()

void dhcpv6ClientDumpConfig ( Dhcpv6ClientContext context)

Dump DHCPv6 configuration for debugging purpose.

Parameters
[in]contextPointer to the DHCPv6 client context

Definition at line 1640 of file dhcpv6_client_misc.c.

◆ dhcpv6ClientFlushAddrList()

void dhcpv6ClientFlushAddrList ( Dhcpv6ClientContext context)

Flush the list of IPv6 addresses from the IA.

Parameters
[in]contextPointer to the DHCPv6 client context

Definition at line 1345 of file dhcpv6_client_misc.c.

◆ dhcpv6ClientGenerateDuid()

error_t dhcpv6ClientGenerateDuid ( Dhcpv6ClientContext context)

Generate client's DUID.

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

Definition at line 1380 of file dhcpv6_client_misc.c.

◆ dhcpv6ClientGenerateLinkLocalAddr()

error_t dhcpv6ClientGenerateLinkLocalAddr ( Dhcpv6ClientContext context)

Generate a link-local address.

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

Definition at line 1423 of file dhcpv6_client_misc.c.

◆ dhcpv6ClientLinkChangeEvent()

void dhcpv6ClientLinkChangeEvent ( Dhcpv6ClientContext context)

Callback function for link change event.

Parameters
[in]contextPointer to the DHCPv6 client context

Definition at line 177 of file dhcpv6_client_misc.c.

◆ dhcpv6ClientParseAdvertise()

void dhcpv6ClientParseAdvertise ( Dhcpv6ClientContext context,
const Dhcpv6Message message,
size_t  length 
)

Parse Advertise message.

Parameters
[in]contextPointer to the DHCPv6 client context
[in]messagePointer to the incoming message to parse
[in]lengthLength of the incoming message

Definition at line 517 of file dhcpv6_client_misc.c.

◆ dhcpv6ClientParseIaAddrOption()

error_t dhcpv6ClientParseIaAddrOption ( Dhcpv6ClientContext context,
const Dhcpv6Option option 
)

Parse IA Address option.

Parameters
[in]contextPointer to the DHCPv6 client context
[in]optionPointer to the IA Address option to parse
Returns
Error code

Definition at line 1187 of file dhcpv6_client_misc.c.

◆ dhcpv6ClientParseIaNaOption()

error_t dhcpv6ClientParseIaNaOption ( Dhcpv6ClientContext context,
const Dhcpv6Option option 
)

Parse IA_NA option.

Parameters
[in]contextPointer to the DHCPv6 client context
[in]optionPointer to the IA_NA option to parse
Returns
Error code

Definition at line 1073 of file dhcpv6_client_misc.c.

◆ dhcpv6ClientParseReply()

void dhcpv6ClientParseReply ( Dhcpv6ClientContext context,
const Dhcpv6Message message,
size_t  length 
)

Parse Reply message.

Parameters
[in]contextPointer to the DHCPv6 client context
[in]messagePointer to the incoming message to parse
[in]lengthLength of the incoming message

Definition at line 693 of file dhcpv6_client_misc.c.

◆ dhcpv6ClientProcessMessage()

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

Process incoming DHCPv6 message.

Parameters
[in]interfaceUnderlying network interface
[in]pseudoHeaderUDP pseudo header
[in]udpHeaderUDP header
[in]bufferMulti-part buffer containing the incoming DHCPv6 message
[in]offsetOffset to the first byte of the DHCPv6 message
[in]ancillaryAdditional options passed to the stack along with the packet
[in]paramPointer to the DHCPv6 client context

Definition at line 458 of file dhcpv6_client_misc.c.

◆ dhcpv6ClientRemoveAddr()

void dhcpv6ClientRemoveAddr ( Dhcpv6ClientContext context,
const Ipv6Addr addr 
)

Remove an IPv6 address from the IA.

Parameters
[in]contextPointer to the DHCPv6 client context
[in]addrIPv6 address to be removed

Definition at line 1307 of file dhcpv6_client_misc.c.

◆ dhcpv6ClientSendMessage()

error_t dhcpv6ClientSendMessage ( Dhcpv6ClientContext context,
Dhcpv6MessageType  type 
)

Send Solicit message.

Parameters
[in]contextPointer to the DHCPv6 client context
[in]typeDHCPv6 message type
Returns
Error code

Definition at line 253 of file dhcpv6_client_misc.c.

◆ dhcpv6ClientTick()

void dhcpv6ClientTick ( Dhcpv6ClientContext context)

DHCPv6 client timer handler.

This routine must be periodically called by the TCP/IP stack to manage DHCPv6 client operation

Parameters
[in]contextPointer to the DHCPv6 client context

Definition at line 71 of file dhcpv6_client_misc.c.

Variable Documentation

◆ dhcpv6ClientTickCounter

systime_t dhcpv6ClientTickCounter

Definition at line 52 of file dhcpv6_client_misc.c.