dhcpv6_common.c File Reference

Definitions common to DHCPv6 client, server and relay agent. More...

#include "core/net.h"
#include "dhcpv6/dhcpv6_common.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   DHCPV6_TRACE_LEVEL
 

Functions

Dhcpv6StatusCode dhcpv6GetStatusCode (const uint8_t *options, size_t length)
 Retrieve status code. More...
 
Dhcpv6Optiondhcpv6AddOption (void *message, size_t *messageLen, uint16_t optionCode, const void *optionValue, size_t optionLen)
 Add an option to a DHCPv6 message. More...
 
Dhcpv6Optiondhcpv6AddSubOption (Dhcpv6Option *baseOption, size_t *messageLen, uint16_t optionCode, const void *optionValue, size_t optionLen)
 Add a suboption under an existing base option. More...
 
Dhcpv6Optiondhcpv6GetOption (const uint8_t *options, size_t optionsLength, uint16_t optionCode)
 Find the specified option in a DHCPv6 message. More...
 
int32_t dhcpv6Rand (int32_t value)
 Multiplication by a randomization factor. More...
 
int32_t dhcpv6RandRange (int32_t min, int32_t max)
 Get a random value in the specified range. More...
 

Variables

const Ipv6Addr DHCPV6_ALL_RELAY_AGENTS_AND_SERVERS_ADDR
 
const Ipv6Addr DHCPV6_ALL_SERVERS_ADDR
 

Detailed Description

Definitions common to DHCPv6 client, server and relay agent.

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.

Description

The Dynamic Host Configuration Protocol for IPv6 enables DHCP servers to pass configuration parameters such as IPv6 network addresses to IPv6 nodes. This protocol is a stateful counterpart to IPv6 Stateless Address Autoconfiguration (RFC 2462), and can be used separately or concurrently with the latter to obtain configuration parameters. Refer to RFC 3315

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

Definition in file dhcpv6_common.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   DHCPV6_TRACE_LEVEL

Definition at line 38 of file dhcpv6_common.c.

Function Documentation

◆ dhcpv6AddOption()

Dhcpv6Option* dhcpv6AddOption ( void *  message,
size_t *  messageLen,
uint16_t  optionCode,
const void *  optionValue,
size_t  optionLen 
)

Add an option to a DHCPv6 message.

Parameters
[in]messagePointer to the DHCPv6 message
[in,out]messageLenLength of the overall DHCPv6 message
[in]optionCodeOption code
[in]optionValueOption value
[in]optionLenLength of the option value
Returns
If the option was successfully added, a pointer to the freshly created option is returned. Otherwise NULL pointer is returned

Definition at line 109 of file dhcpv6_common.c.

◆ dhcpv6AddSubOption()

Dhcpv6Option* dhcpv6AddSubOption ( Dhcpv6Option baseOption,
size_t *  messageLen,
uint16_t  optionCode,
const void *  optionValue,
size_t  optionLen 
)

Add a suboption under an existing base option.

Parameters
[in]baseOptionPointer to the base option
[in,out]messageLenLength of the overall DHCPv6 message
[in]optionCodeOption code
[in]optionValueOption value
[in]optionLenLength of the option value
Returns
If the option was successfully added, a pointer to the freshly created option is returned. Otherwise NULL pointer is returned

Definition at line 151 of file dhcpv6_common.c.

◆ dhcpv6GetOption()

Dhcpv6Option* dhcpv6GetOption ( const uint8_t *  options,
size_t  optionsLength,
uint16_t  optionCode 
)

Find the specified option in a DHCPv6 message.

Parameters
[in]optionsPointer to the Options field
[in]optionsLengthLength of the Options field
[in]optionCodeCode of the option to find
Returns
If the specified option was found, a pointer to the corresponding option is returned. Otherwise NULL pointer is returned

Definition at line 204 of file dhcpv6_common.c.

◆ dhcpv6GetStatusCode()

Dhcpv6StatusCode dhcpv6GetStatusCode ( const uint8_t *  options,
size_t  length 
)

Retrieve status code.

This function returns a status indication related to the DHCPv6 message or option in which it appears

Parameters
[in]optionsPointer to the Options field
[in]lengthLength of the Options field
Returns
Status code

Definition at line 68 of file dhcpv6_common.c.

◆ dhcpv6Rand()

int32_t dhcpv6Rand ( int32_t  value)

Multiplication by a randomization factor.

Each of the computations of a new RT include a randomization factor RAND, which is a random number chosen with a uniform distribution between -0.1 and +0.1. The randomization factor is included to minimize synchronization of messages transmitted by DHCPv6 clients

Parameters
[in]valueInput value
Returns
Value resulting from the randomization process

Definition at line 248 of file dhcpv6_common.c.

◆ dhcpv6RandRange()

int32_t dhcpv6RandRange ( int32_t  min,
int32_t  max 
)

Get a random value in the specified range.

Parameters
[in]minLower bound
[in]maxUpper bound
Returns
Random value in the specified range

Definition at line 263 of file dhcpv6_common.c.

Variable Documentation

◆ DHCPV6_ALL_RELAY_AGENTS_AND_SERVERS_ADDR

const Ipv6Addr DHCPV6_ALL_RELAY_AGENTS_AND_SERVERS_ADDR
Initial value:
=
IPV6_ADDR(0xFF02, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0002)
#define IPV6_ADDR(a, b, c, d, e, f, g, h)
Definition: ipv6.h:110

Definition at line 49 of file dhcpv6_common.c.

◆ DHCPV6_ALL_SERVERS_ADDR

const Ipv6Addr DHCPV6_ALL_SERVERS_ADDR
Initial value:
=
IPV6_ADDR(0xFF05, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0003)
#define IPV6_ADDR(a, b, c, d, e, f, g, h)
Definition: ipv6.h:110

Definition at line 53 of file dhcpv6_common.c.