dhcpv6_common.c File Reference

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

#include "core/net.h"
#include "dhcpv6/dhcpv6_client.h"
#include "dhcpv6/dhcpv6_relay.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)
 Search a DHCPv6 message for a given option. 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

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.

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
2.4.0

Definition in file dhcpv6_common.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   DHCPV6_TRACE_LEVEL

Definition at line 40 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]messageLenActual length of the 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 114 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 168 of file dhcpv6_common.c.

◆ dhcpv6GetOption()

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

Search a DHCPv6 message for a given option.

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 229 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 73 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:111

Definition at line 54 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)

Definition at line 58 of file dhcpv6_common.c.