dhcpv6_common.h File Reference

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

#include "core/net.h"
#include "core/ethernet.h"
#include "ipv6/ipv6.h"

Go to the source code of this file.

Macros

#define DHCPV6_CLIENT_PORT   546
 
#define DHCPV6_SERVER_PORT   547
 
#define DHCPV6_MAX_MSG_SIZE   1232
 
#define DHCPV6_MAX_DUID_SIZE   130
 
#define DHCPV6_HOP_COUNT_LIMIT   8
 
#define DHCPV6_MAX_SERVER_PREFERENCE   255
 
#define DHCPV6_INFINITE_TIME   0xFFFFFFFF
 

Enumerations

enum  Dhcpv6DuidType { DHCPV6_DUID_LLT = 1 , DHCPV6_DUID_EN = 2 , DHCPV6_DUID_LL = 3 }
 DUID types. More...
 
enum  Dhcpv6HardwareType { DHCPV6_HARDWARE_TYPE_ETH = 1 , DHCPV6_HARDWARE_TYPE_EUI64 = 27 }
 Hardware types. More...
 
enum  Dhcpv6MessageType {
  DHCPV6_MSG_TYPE_SOLICIT = 1 , DHCPV6_MSG_TYPE_ADVERTISE = 2 , DHCPV6_MSG_TYPE_REQUEST = 3 , DHCPV6_MSG_TYPE_CONFIRM = 4 ,
  DHCPV6_MSG_TYPE_RENEW = 5 , DHCPV6_MSG_TYPE_REBIND = 6 , DHCPV6_MSG_TYPE_REPLY = 7 , DHCPV6_MSG_TYPE_RELEASE = 8 ,
  DHCPV6_MSG_TYPE_DECLINE = 9 , DHCPV6_MSG_TYPE_RECONFIGURE = 10 , DHCPV6_MSG_TYPE_INFO_REQUEST = 11 , DHCPV6_MSG_TYPE_RELAY_FORW = 12 ,
  DHCPV6_MSG_TYPE_RELAY_REPL = 13
}
 DHCPv6 message types. More...
 
enum  Dhcpv6OptionCode {
  DHCPV6_OPT_CLIENT_ID = 1 , DHCPV6_OPT_SERVER_ID = 2 , DHCPV6_OPT_IA_NA = 3 , DHCPV6_OPT_IA_TA = 4 ,
  DHCPV6_OPT_IA_ADDR = 5 , DHCPV6_OPT_ORO = 6 , DHCPV6_OPT_PREFERENCE = 7 , DHCPV6_OPT_ELAPSED_TIME = 8 ,
  DHCPV6_OPT_RELAY_MSG = 9 , DHCPV6_OPT_AUTH = 11 , DHCPV6_OPT_UNICAST = 12 , DHCPV6_OPT_STATUS_CODE = 13 ,
  DHCPV6_OPT_RAPID_COMMIT = 14 , DHCPV6_OPT_USER_CLASS = 15 , DHCPV6_OPT_VENDOR_CLASS = 16 , DHCPV6_OPT_VENDOR_OPTS = 17 ,
  DHCPV6_OPT_INTERFACE_ID = 18 , DHCPV6_OPT_RECONF_MSG = 19 , DHCPV6_OPT_RECONF_ACCEPT = 20 , DHCPV6_OPT_DNS_SERVERS = 23 ,
  DHCPV6_OPT_DOMAIN_LIST = 24 , DHCPV6_OPT_IA_PD = 25 , DHCPV6_OPT_IA_PREFIX = 26 , DHCPV6_OPT_INFO_REFRESH_TIME = 32 ,
  DHCPV6_OPT_FQDN = 39 , DHCPV6_OPT_CAPTIVE_PORTAL = 103
}
 DHCPv6 option codes. More...
 
enum  Dhcpv6StatusCode {
  DHCPV6_STATUS_SUCCESS = 0 , DHCPV6_STATUS_UNSPEC_FAILURE = 1 , DHCPV6_STATUS_NO_ADDRS_AVAILABLE = 2 , DHCPV6_STATUS_NO_BINDING = 3 ,
  DHCPV6_STATUS_NOT_ON_LINK = 4 , DHCPV6_STATUS_USE_MULTICAST = 5
}
 Status code. More...
 

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

typedef __packed_struct
 DUID-LLT structure. More...
 
uint16_t hardwareType
 
uint32_t time
 
MacAddr linkLayerAddr
 
 Dhcpv6DuidLlt
 
uint32_t enterpriseNumber
 
uint8_t identifier []
 
 Dhcpv6DuidEn
 
 Dhcpv6DuidLl
 
uint8_t transactionId [3]
 
uint8_t options []
 
 Dhcpv6Message
 
uint8_t hopCount
 
Ipv6Addr linkAddress
 
Ipv6Addr peerAddress
 
 Dhcpv6RelayMessage
 
uint16_t length
 
uint8_t value []
 
 Dhcpv6Option
 
uint32_t t1
 
uint32_t t2
 
 Dhcpv6IaNaOption
 
 Dhcpv6IaTaOption
 
uint32_t preferredLifetime
 
uint32_t validLifetime
 
 Dhcpv6IaAddrOption
 
 Dhcpv6OroOption
 
 Dhcpv6PreferenceOption
 
 Dhcpv6ElapsedTimeOption
 
uint8_t algorithm
 
uint8_t rdm
 
uint8_t replayDetection [8]
 
uint8_t authInfo []
 
 Dhcpv6AuthOption
 
 Dhcpv6ServerUnicastOption
 
char_t statusMessage []
 
 Dhcpv6StatusCodeOption
 
 Dhcpv6ReconfMessageOption
 
 Dhcpv6DnsServersOption
 
 Dhcpv6DomainListOption
 
 Dhcpv6IaPdOption
 
uint8_t prefixLen
 
Ipv6Addr prefix
 
 Dhcpv6IaPrefixOption
 
uint8_t o
 
uint8_t n
 
uint8_t mbz
 
uint8_t domainName []
 
 Dhcpv6FqdnOption
 
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.

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

Definition in file dhcpv6_common.h.

Macro Definition Documentation

◆ DHCPV6_CLIENT_PORT

#define DHCPV6_CLIENT_PORT   546

Definition at line 40 of file dhcpv6_common.h.

◆ DHCPV6_HOP_COUNT_LIMIT

#define DHCPV6_HOP_COUNT_LIMIT   8

Definition at line 49 of file dhcpv6_common.h.

◆ DHCPV6_INFINITE_TIME

#define DHCPV6_INFINITE_TIME   0xFFFFFFFF

Definition at line 53 of file dhcpv6_common.h.

◆ DHCPV6_MAX_DUID_SIZE

#define DHCPV6_MAX_DUID_SIZE   130

Definition at line 46 of file dhcpv6_common.h.

◆ DHCPV6_MAX_MSG_SIZE

#define DHCPV6_MAX_MSG_SIZE   1232

Definition at line 44 of file dhcpv6_common.h.

◆ DHCPV6_MAX_SERVER_PREFERENCE

#define DHCPV6_MAX_SERVER_PREFERENCE   255

Definition at line 51 of file dhcpv6_common.h.

◆ DHCPV6_SERVER_PORT

#define DHCPV6_SERVER_PORT   547

Definition at line 41 of file dhcpv6_common.h.

Enumeration Type Documentation

◆ Dhcpv6DuidType

DUID types.

Enumerator
DHCPV6_DUID_LLT 
DHCPV6_DUID_EN 
DHCPV6_DUID_LL 

Definition at line 65 of file dhcpv6_common.h.

◆ Dhcpv6HardwareType

Hardware types.

Enumerator
DHCPV6_HARDWARE_TYPE_ETH 
DHCPV6_HARDWARE_TYPE_EUI64 

Definition at line 77 of file dhcpv6_common.h.

◆ Dhcpv6MessageType

DHCPv6 message types.

Enumerator
DHCPV6_MSG_TYPE_SOLICIT 
DHCPV6_MSG_TYPE_ADVERTISE 
DHCPV6_MSG_TYPE_REQUEST 
DHCPV6_MSG_TYPE_CONFIRM 
DHCPV6_MSG_TYPE_RENEW 
DHCPV6_MSG_TYPE_REBIND 
DHCPV6_MSG_TYPE_REPLY 
DHCPV6_MSG_TYPE_RELEASE 
DHCPV6_MSG_TYPE_DECLINE 
DHCPV6_MSG_TYPE_RECONFIGURE 
DHCPV6_MSG_TYPE_INFO_REQUEST 
DHCPV6_MSG_TYPE_RELAY_FORW 
DHCPV6_MSG_TYPE_RELAY_REPL 

Definition at line 88 of file dhcpv6_common.h.

◆ Dhcpv6OptionCode

DHCPv6 option codes.

Enumerator
DHCPV6_OPT_CLIENT_ID 
DHCPV6_OPT_SERVER_ID 
DHCPV6_OPT_IA_NA 
DHCPV6_OPT_IA_TA 
DHCPV6_OPT_IA_ADDR 
DHCPV6_OPT_ORO 
DHCPV6_OPT_PREFERENCE 
DHCPV6_OPT_ELAPSED_TIME 
DHCPV6_OPT_RELAY_MSG 
DHCPV6_OPT_AUTH 
DHCPV6_OPT_UNICAST 
DHCPV6_OPT_STATUS_CODE 
DHCPV6_OPT_RAPID_COMMIT 
DHCPV6_OPT_USER_CLASS 
DHCPV6_OPT_VENDOR_CLASS 
DHCPV6_OPT_VENDOR_OPTS 
DHCPV6_OPT_INTERFACE_ID 
DHCPV6_OPT_RECONF_MSG 
DHCPV6_OPT_RECONF_ACCEPT 
DHCPV6_OPT_DNS_SERVERS 
DHCPV6_OPT_DOMAIN_LIST 
DHCPV6_OPT_IA_PD 
DHCPV6_OPT_IA_PREFIX 
DHCPV6_OPT_INFO_REFRESH_TIME 
DHCPV6_OPT_FQDN 
DHCPV6_OPT_CAPTIVE_PORTAL 

Definition at line 110 of file dhcpv6_common.h.

◆ Dhcpv6StatusCode

Status code.

Enumerator
DHCPV6_STATUS_SUCCESS 
DHCPV6_STATUS_UNSPEC_FAILURE 
DHCPV6_STATUS_NO_ADDRS_AVAILABLE 
DHCPV6_STATUS_NO_BINDING 
DHCPV6_STATUS_NOT_ON_LINK 
DHCPV6_STATUS_USE_MULTICAST 

Definition at line 145 of file dhcpv6_common.h.

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

◆ __packed_struct

typedef __packed_struct
Initial value:
{
uint16_t type
uint8_t type
Definition: coap_common.h:176

DUID-LLT structure.

Fully Qualified Domain Name option.

IA_PD Prefix option.

Identity Association for Prefix Delegation Option.

Domain Search List option.

DNS Recursive Name Server option.

Reconfigure Message option.

Status Code option.

Server Unicast option.

Authentication option.

Elapsed Time option.

Preference option.

Option Request option.

IA Address option.

Identity Association for Temporary Addresses option.

Identity Association for Non-temporary Addresses option.

DHCPv6 option.

DHCPv6 relay agent message.

DHCPv6 message.

DUID-LL structure.

DUID-EN structure.

Definition at line 168 of file dhcpv6_common.h.

◆ algorithm

uint8_t algorithm

Definition at line 317 of file dhcpv6_common.h.

◆ authInfo

uint8_t authInfo[]

Definition at line 320 of file dhcpv6_common.h.

◆ DHCPV6_ALL_RELAY_AGENTS_AND_SERVERS_ADDR

const Ipv6Addr DHCPV6_ALL_RELAY_AGENTS_AND_SERVERS_ADDR
extern

Definition at line 54 of file dhcpv6_common.c.

◆ DHCPV6_ALL_SERVERS_ADDR

const Ipv6Addr DHCPV6_ALL_SERVERS_ADDR
extern

Definition at line 58 of file dhcpv6_common.c.

◆ Dhcpv6AuthOption

Dhcpv6AuthOption

Definition at line 321 of file dhcpv6_common.h.

◆ Dhcpv6DnsServersOption

Dhcpv6DnsServersOption

Definition at line 362 of file dhcpv6_common.h.

◆ Dhcpv6DomainListOption

Dhcpv6DomainListOption

Definition at line 372 of file dhcpv6_common.h.

◆ Dhcpv6DuidEn

Dhcpv6DuidEn

Definition at line 186 of file dhcpv6_common.h.

◆ Dhcpv6DuidLl

Dhcpv6DuidLl

Definition at line 202 of file dhcpv6_common.h.

◆ Dhcpv6DuidLlt

Dhcpv6DuidLlt

Definition at line 174 of file dhcpv6_common.h.

◆ Dhcpv6ElapsedTimeOption

Dhcpv6ElapsedTimeOption

Definition at line 307 of file dhcpv6_common.h.

◆ Dhcpv6FqdnOption

Dhcpv6FqdnOption

Definition at line 420 of file dhcpv6_common.h.

◆ Dhcpv6IaAddrOption

Dhcpv6IaAddrOption

Definition at line 277 of file dhcpv6_common.h.

◆ Dhcpv6IaNaOption

Dhcpv6IaNaOption

Definition at line 253 of file dhcpv6_common.h.

◆ Dhcpv6IaPdOption

Dhcpv6IaPdOption

Definition at line 385 of file dhcpv6_common.h.

◆ Dhcpv6IaPrefixOption

Dhcpv6IaPrefixOption

Definition at line 399 of file dhcpv6_common.h.

◆ Dhcpv6IaTaOption

Dhcpv6IaTaOption

Definition at line 264 of file dhcpv6_common.h.

◆ Dhcpv6Message

Dhcpv6Message

Definition at line 214 of file dhcpv6_common.h.

◆ Dhcpv6Option

Dhcpv6Option

Definition at line 240 of file dhcpv6_common.h.

◆ Dhcpv6OroOption

Dhcpv6OroOption

Definition at line 287 of file dhcpv6_common.h.

◆ Dhcpv6PreferenceOption

Dhcpv6PreferenceOption

Definition at line 297 of file dhcpv6_common.h.

◆ Dhcpv6ReconfMessageOption

Dhcpv6ReconfMessageOption

Definition at line 352 of file dhcpv6_common.h.

◆ Dhcpv6RelayMessage

Dhcpv6RelayMessage

Definition at line 228 of file dhcpv6_common.h.

◆ Dhcpv6ServerUnicastOption

Dhcpv6ServerUnicastOption

Definition at line 331 of file dhcpv6_common.h.

◆ Dhcpv6StatusCodeOption

Dhcpv6StatusCodeOption

Definition at line 342 of file dhcpv6_common.h.

◆ domainName

uint8_t domainName[]

Definition at line 419 of file dhcpv6_common.h.

◆ enterpriseNumber

uint32_t enterpriseNumber

Definition at line 184 of file dhcpv6_common.h.

◆ hardwareType

uint16_t hardwareType

Definition at line 171 of file dhcpv6_common.h.

◆ hopCount

uint8_t hopCount

Definition at line 224 of file dhcpv6_common.h.

◆ identifier

uint8_t identifier

Definition at line 185 of file dhcpv6_common.h.

◆ length

uint16_t length

Definition at line 238 of file dhcpv6_common.h.

◆ linkAddress

Ipv6Addr linkAddress

Definition at line 225 of file dhcpv6_common.h.

◆ linkLayerAddr

MacAddr linkLayerAddr

Definition at line 173 of file dhcpv6_common.h.

◆ mbz

uint8_t mbz

Definition at line 417 of file dhcpv6_common.h.

◆ n

uint8_t n

Definition at line 416 of file dhcpv6_common.h.

◆ o

uint8_t o

Definition at line 415 of file dhcpv6_common.h.

◆ options

uint8_t options[]

Definition at line 213 of file dhcpv6_common.h.

◆ peerAddress

Ipv6Addr peerAddress

Definition at line 226 of file dhcpv6_common.h.

◆ preferredLifetime

uint32_t preferredLifetime

Definition at line 274 of file dhcpv6_common.h.

◆ prefix

Ipv6Addr prefix

Definition at line 397 of file dhcpv6_common.h.

◆ prefixLen

uint8_t prefixLen

Definition at line 396 of file dhcpv6_common.h.

◆ rdm

uint8_t rdm

Definition at line 318 of file dhcpv6_common.h.

◆ replayDetection

uint8_t replayDetection[8]

Definition at line 319 of file dhcpv6_common.h.

◆ statusMessage

char_t statusMessage[]

Definition at line 341 of file dhcpv6_common.h.

◆ t1

uint32_t t1

Definition at line 250 of file dhcpv6_common.h.

◆ t2

uint32_t t2

Definition at line 251 of file dhcpv6_common.h.

◆ time

uint32_t time

Definition at line 172 of file dhcpv6_common.h.

◆ transactionId

uint8_t transactionId[3]

Definition at line 212 of file dhcpv6_common.h.

◆ validLifetime

uint16_t validLifetime

Definition at line 275 of file dhcpv6_common.h.

◆ value

uint8_t value[]

Definition at line 239 of file dhcpv6_common.h.