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   32
 
#define DHCPV6_MAX_SERVER_PREFERENCE   255
 
#define DHCPV6_INFINITE_TIME   0xFFFFFFFF
 

Typedefs

struct {
   uint16_t   type
 
   uint16_t   hardwareType
 
   uint32_t   time
 
   MacAddr   linkLayerAddr
 
Dhcpv6DuidLlt
 DUID-LLT structure. More...
 
struct {
   uint16_t   type
 
   uint32_t   enterpriseNumber
 
   uint8_t   identifier []
 
Dhcpv6DuidEn
 DUID-EN structure. More...
 
struct {
   uint16_t   type
 
   uint16_t   hardwareType
 
   MacAddr   linkLayerAddr
 
Dhcpv6DuidLl
 DUID-LL structure. More...
 
struct {
   uint8_t   msgType
 
   uint8_t   transactionId [3]
 
   uint8_t   options []
 
Dhcpv6Message
 DHCPv6 message. More...
 
struct {
   uint8_t   msgType
 
   uint8_t   hopCount
 
   Ipv6Addr   linkAddress
 
   Ipv6Addr   peerAddress
 
   uint8_t   options []
 
Dhcpv6RelayMessage
 DHCPv6 relay agent message. More...
 
struct {
   uint16_t   code
 
   uint16_t   length
 
   uint8_t   value []
 
Dhcpv6Option
 DHCPv6 option. More...
 
struct {
   uint32_t   iaId
 
   uint32_t   t1
 
   uint32_t   t2
 
   uint8_t   options []
 
Dhcpv6IaNaOption
 Identity Association for Non-temporary Addresses option. More...
 
struct {
   uint32_t   iaId
 
   uint8_t   options []
 
Dhcpv6IaTaOption
 Identity Association for Temporary Addresses option. More...
 
struct {
   Ipv6Addr   address
 
   uint32_t   preferredLifetime
 
   uint32_t   validLifetime
 
   uint8_t   options []
 
Dhcpv6IaAddrOption
 IA Address option. More...
 
struct {
   uint16_t   requestedOption [1]
 
Dhcpv6OroOption
 Option Request option. More...
 
struct {
   uint8_t   value
 
Dhcpv6PreferenceOption
 Preference option. More...
 
struct {
   uint16_t   value
 
Dhcpv6ElapsedTimeOption
 Elapsed Time option. More...
 
struct {
   uint8_t   protocol
 
   uint8_t   algorithm
 
   uint8_t   rdm
 
   uint8_t   replayDetection [8]
 
   uint8_t   authInfo []
 
Dhcpv6AuthOption
 Authentication option. More...
 
struct {
   Ipv6Addr   serverAddr
 
Dhcpv6ServerUnicastOption
 Server Unicast option. More...
 
struct {
   uint16_t   statusCode
 
   char_t   statusMessage []
 
Dhcpv6StatusCodeOption
 Status Code option. More...
 
struct {
   uint8_t   msgType
 
Dhcpv6ReconfMessageOption
 Reconfigure Message option. More...
 
struct {
   Ipv6Addr   address [1]
 
Dhcpv6DnsServersOption
 DNS Recursive Name Server option. More...
 
struct {
   uint8_t   searchList [1]
 
Dhcpv6DomainListOption
 Domain Search List option. More...
 
struct {
   uint32_t   iaId
 
   uint32_t   t1
 
   uint32_t   t2
 
   uint8_t   options []
 
Dhcpv6IaPdOption
 Identity Association for Prefix Delegation Option. More...
 
struct {
   uint32_t   preferredLifetime
 
   uint32_t   validLifetime
 
   uint8_t   prefixLen
 
   Ipv6Addr   prefix
 
   uint8_t   options []
 
Dhcpv6IaPrefixOption
 IA_PD Prefix option. More...
 
struct {
   uint8_t   s: 1
 
   uint8_t   o: 1
 
   uint8_t   n: 1
 
   uint8_t   mbz: 5
 
   uint8_t   domainName []
 
Dhcpv6FqdnOption
 Fully Qualified Domain Name option. More...
 

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_OPTION_CLIENTID = 1, DHCPV6_OPTION_SERVERID = 2, DHCPV6_OPTION_IA_NA = 3, DHCPV6_OPTION_IA_TA = 4,
  DHCPV6_OPTION_IAADDR = 5, DHCPV6_OPTION_ORO = 6, DHCPV6_OPTION_PREFERENCE = 7, DHCPV6_OPTION_ELAPSED_TIME = 8,
  DHCPV6_OPTION_RELAY_MSG = 9, DHCPV6_OPTION_AUTH = 11, DHCPV6_OPTION_UNICAST = 12, DHCPV6_OPTION_STATUS_CODE = 13,
  DHCPV6_OPTION_RAPID_COMMIT = 14, DHCPV6_OPTION_USER_CLASS = 15, DHCPV6_OPTION_VENDOR_CLASS = 16, DHCPV6_OPTION_VENDOR_OPTS = 17,
  DHCPV6_OPTION_INTERFACE_ID = 18, DHCPV6_OPTION_RECONF_MSG = 19, DHCPV6_OPTION_RECONF_ACCEPT = 20, DHCPV6_OPTION_DNS_SERVERS = 23,
  DHCPV6_OPTION_DOMAIN_LIST = 24, DHCPV6_OPTION_IA_PD = 25, DHCPV6_OPTION_IAPREFIX = 26, DHCPV6_OPTION_FQDN = 39
}
 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)
 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.

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

Definition in file dhcpv6_common.h.

Macro Definition Documentation

◆ DHCPV6_CLIENT_PORT

#define DHCPV6_CLIENT_PORT   546

Definition at line 38 of file dhcpv6_common.h.

◆ DHCPV6_HOP_COUNT_LIMIT

#define DHCPV6_HOP_COUNT_LIMIT   32

Definition at line 47 of file dhcpv6_common.h.

◆ DHCPV6_INFINITE_TIME

#define DHCPV6_INFINITE_TIME   0xFFFFFFFF

Definition at line 51 of file dhcpv6_common.h.

◆ DHCPV6_MAX_DUID_SIZE

#define DHCPV6_MAX_DUID_SIZE   130

Definition at line 44 of file dhcpv6_common.h.

◆ DHCPV6_MAX_MSG_SIZE

#define DHCPV6_MAX_MSG_SIZE   1232

Definition at line 42 of file dhcpv6_common.h.

◆ DHCPV6_MAX_SERVER_PREFERENCE

#define DHCPV6_MAX_SERVER_PREFERENCE   255

Definition at line 49 of file dhcpv6_common.h.

◆ DHCPV6_SERVER_PORT

#define DHCPV6_SERVER_PORT   547

Definition at line 39 of file dhcpv6_common.h.

Typedef Documentation

◆ Dhcpv6AuthOption

typedef { ... } Dhcpv6AuthOption

Authentication option.

◆ Dhcpv6DnsServersOption

typedef { ... } Dhcpv6DnsServersOption

DNS Recursive Name Server option.

◆ Dhcpv6DomainListOption

typedef { ... } Dhcpv6DomainListOption

Domain Search List option.

◆ Dhcpv6DuidEn

typedef { ... } Dhcpv6DuidEn

DUID-EN structure.

◆ Dhcpv6DuidLl

typedef { ... } Dhcpv6DuidLl

DUID-LL structure.

◆ Dhcpv6DuidLlt

typedef { ... } Dhcpv6DuidLlt

DUID-LLT structure.

◆ Dhcpv6ElapsedTimeOption

typedef { ... } Dhcpv6ElapsedTimeOption

Elapsed Time option.

◆ Dhcpv6FqdnOption

typedef { ... } Dhcpv6FqdnOption

Fully Qualified Domain Name option.

◆ Dhcpv6IaAddrOption

typedef { ... } Dhcpv6IaAddrOption

IA Address option.

◆ Dhcpv6IaNaOption

typedef { ... } Dhcpv6IaNaOption

Identity Association for Non-temporary Addresses option.

◆ Dhcpv6IaPdOption

typedef { ... } Dhcpv6IaPdOption

Identity Association for Prefix Delegation Option.

◆ Dhcpv6IaPrefixOption

typedef { ... } Dhcpv6IaPrefixOption

IA_PD Prefix option.

◆ Dhcpv6IaTaOption

typedef { ... } Dhcpv6IaTaOption

Identity Association for Temporary Addresses option.

◆ Dhcpv6Message

typedef { ... } Dhcpv6Message

DHCPv6 message.

◆ Dhcpv6Option

typedef { ... } Dhcpv6Option

DHCPv6 option.

◆ Dhcpv6OroOption

typedef { ... } Dhcpv6OroOption

Option Request option.

◆ Dhcpv6PreferenceOption

typedef { ... } Dhcpv6PreferenceOption

Preference option.

◆ Dhcpv6ReconfMessageOption

typedef { ... } Dhcpv6ReconfMessageOption

Reconfigure Message option.

◆ Dhcpv6RelayMessage

typedef { ... } Dhcpv6RelayMessage

DHCPv6 relay agent message.

◆ Dhcpv6ServerUnicastOption

typedef { ... } Dhcpv6ServerUnicastOption

Server Unicast option.

◆ Dhcpv6StatusCodeOption

typedef { ... } Dhcpv6StatusCodeOption

Status Code option.

Enumeration Type Documentation

◆ Dhcpv6DuidType

DUID types.

Enumerator
DHCPV6_DUID_LLT 
DHCPV6_DUID_EN 
DHCPV6_DUID_LL 

Definition at line 63 of file dhcpv6_common.h.

◆ Dhcpv6HardwareType

Hardware types.

Enumerator
DHCPV6_HARDWARE_TYPE_ETH 
DHCPV6_HARDWARE_TYPE_EUI64 

Definition at line 75 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 86 of file dhcpv6_common.h.

◆ Dhcpv6OptionCode

DHCPv6 option codes.

Enumerator
DHCPV6_OPTION_CLIENTID 
DHCPV6_OPTION_SERVERID 
DHCPV6_OPTION_IA_NA 
DHCPV6_OPTION_IA_TA 
DHCPV6_OPTION_IAADDR 
DHCPV6_OPTION_ORO 
DHCPV6_OPTION_PREFERENCE 
DHCPV6_OPTION_ELAPSED_TIME 
DHCPV6_OPTION_RELAY_MSG 
DHCPV6_OPTION_AUTH 
DHCPV6_OPTION_UNICAST 
DHCPV6_OPTION_STATUS_CODE 
DHCPV6_OPTION_RAPID_COMMIT 
DHCPV6_OPTION_USER_CLASS 
DHCPV6_OPTION_VENDOR_CLASS 
DHCPV6_OPTION_VENDOR_OPTS 
DHCPV6_OPTION_INTERFACE_ID 
DHCPV6_OPTION_RECONF_MSG 
DHCPV6_OPTION_RECONF_ACCEPT 
DHCPV6_OPTION_DNS_SERVERS 
DHCPV6_OPTION_DOMAIN_LIST 
DHCPV6_OPTION_IA_PD 
DHCPV6_OPTION_IAPREFIX 
DHCPV6_OPTION_FQDN 

Definition at line 108 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 141 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]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

◆ address

Ipv6Addr address[1]

Definition at line 267 of file dhcpv6_common.h.

◆ algorithm

uint8_t algorithm

Definition at line 311 of file dhcpv6_common.h.

◆ authInfo

uint8_t authInfo[]

Definition at line 314 of file dhcpv6_common.h.

◆ code

uint16_t code

Definition at line 231 of file dhcpv6_common.h.

◆ DHCPV6_ALL_RELAY_AGENTS_AND_SERVERS_ADDR

const Ipv6Addr DHCPV6_ALL_RELAY_AGENTS_AND_SERVERS_ADDR

Definition at line 49 of file dhcpv6_common.c.

◆ DHCPV6_ALL_SERVERS_ADDR

const Ipv6Addr DHCPV6_ALL_SERVERS_ADDR

Definition at line 53 of file dhcpv6_common.c.

◆ domainName

uint8_t domainName[]

Definition at line 413 of file dhcpv6_common.h.

◆ enterpriseNumber

uint32_t enterpriseNumber

Definition at line 178 of file dhcpv6_common.h.

◆ hardwareType

uint16_t hardwareType

Definition at line 165 of file dhcpv6_common.h.

◆ hopCount

uint8_t hopCount

Definition at line 218 of file dhcpv6_common.h.

◆ iaId

uint32_t iaId

Definition at line 243 of file dhcpv6_common.h.

◆ identifier

uint8_t identifier[]

Definition at line 179 of file dhcpv6_common.h.

◆ length

uint16_t length

Definition at line 232 of file dhcpv6_common.h.

◆ linkAddress

Ipv6Addr linkAddress

Definition at line 219 of file dhcpv6_common.h.

◆ linkLayerAddr

MacAddr linkLayerAddr

Definition at line 167 of file dhcpv6_common.h.

◆ mbz

uint8_t mbz

Definition at line 411 of file dhcpv6_common.h.

◆ msgType

uint8_t msgType

Definition at line 205 of file dhcpv6_common.h.

◆ n

uint8_t n

Definition at line 410 of file dhcpv6_common.h.

◆ o

uint8_t o

Definition at line 409 of file dhcpv6_common.h.

◆ options

uint8_t options[]

Definition at line 207 of file dhcpv6_common.h.

◆ peerAddress

Ipv6Addr peerAddress

Definition at line 220 of file dhcpv6_common.h.

◆ preferredLifetime

uint32_t preferredLifetime

Definition at line 268 of file dhcpv6_common.h.

◆ prefix

Ipv6Addr prefix

Definition at line 391 of file dhcpv6_common.h.

◆ prefixLen

uint8_t prefixLen

Definition at line 390 of file dhcpv6_common.h.

◆ protocol

uint8_t protocol

Definition at line 310 of file dhcpv6_common.h.

◆ rdm

uint8_t rdm

Definition at line 312 of file dhcpv6_common.h.

◆ replayDetection

uint8_t replayDetection[8]

Definition at line 313 of file dhcpv6_common.h.

◆ requestedOption

uint16_t requestedOption[1]

Definition at line 280 of file dhcpv6_common.h.

◆ s

uint8_t s

Definition at line 408 of file dhcpv6_common.h.

◆ searchList

uint8_t searchList[1]

Definition at line 365 of file dhcpv6_common.h.

◆ serverAddr

Ipv6Addr serverAddr

Definition at line 324 of file dhcpv6_common.h.

◆ statusCode

uint16_t statusCode

Definition at line 334 of file dhcpv6_common.h.

◆ statusMessage

char_t statusMessage[]

Definition at line 335 of file dhcpv6_common.h.

◆ t1

uint32_t t1

Definition at line 244 of file dhcpv6_common.h.

◆ t2

uint32_t t2

Definition at line 245 of file dhcpv6_common.h.

◆ time

uint32_t time

Definition at line 166 of file dhcpv6_common.h.

◆ transactionId

uint8_t transactionId[3]

Definition at line 206 of file dhcpv6_common.h.

◆ type

uint16_t type

Definition at line 164 of file dhcpv6_common.h.

◆ validLifetime

uint32_t validLifetime

Definition at line 269 of file dhcpv6_common.h.

◆ value

uint16_t value

Definition at line 233 of file dhcpv6_common.h.