Loading...
Searching...
No Matches
client.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2018 Freie Universität Berlin
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
19
20#include "byteorder.h"
21#include "event.h"
22#include "net/ipv6/addr.h"
23#include "thread.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
33#ifndef DHCPV6_CLIENT_STACK_SIZE
34#define DHCPV6_CLIENT_STACK_SIZE (THREAD_STACKSIZE_DEFAULT)
35#endif
36
37#ifndef DHCPV6_CLIENT_PRIORITY
38#define DHCPV6_CLIENT_PRIORITY (THREAD_PRIORITY_MAIN - 2)
39#endif
41
45#define DHCPV6_CLIENT_DUID_LEN (sizeof(dhcpv6_duid_l2_t) + 8U)
46#define DHCPV6_CLIENT_BUFLEN (256)
47
59#ifndef CONFIG_DHCPV6_CLIENT_PFX_LEASE_MAX
60#define CONFIG_DHCPV6_CLIENT_PFX_LEASE_MAX (1U)
61#endif
62
66#ifndef CONFIG_DHCPV6_CLIENT_ADDR_LEASE_MAX
67#define CONFIG_DHCPV6_CLIENT_ADDR_LEASE_MAX (1U)
68#endif
69
76#if defined(MODULE_DHCPV6_CLIENT_IA_NA) || defined(DOXYGEN)
77#define DHCPV6_CLIENT_ADDRS_NUMOF ((int)(CONFIG_DHCPV6_CLIENT_ADDR_LEASE_MAX))
78#else
79#define DHCPV6_CLIENT_ADDRS_NUMOF (0)
80#endif
81
86#ifndef CONFIG_DHCPV6_CLIENT_MUD_URL
87#define CONFIG_DHCPV6_CLIENT_MUD_URL "https://example.org"
88#endif
89
91
100typedef struct __attribute__((packed)) {
103 /* link-layer address follows this header */
105
106#if defined(MODULE_AUTO_INIT_DHCPV6_CLIENT) || defined(DOXYGEN)
115void dhcpv6_client_set_init_hook(void (*_hook)(void), uint16_t netif);
116
124#endif /* MODULE_DHCPV6_CLIENT_AUTO_INIT */
125
136void dhcpv6_client_init(event_queue_t *event_queue, uint16_t netif);
137
148
173int dhcpv6_client_req_ia_pd(unsigned netif, unsigned pfx_len);
175
188int dhcpv6_client_req_ia_na(unsigned netif);
190
207unsigned dhcpv6_client_get_duid_l2(unsigned netif, dhcpv6_duid_l2_t *duid);
208
218void dhcpv6_client_conf_prefix(unsigned netif, const ipv6_addr_t *pfx,
219 unsigned pfx_len, uint32_t valid,
220 uint32_t pref);
221
230static inline void dhcpv6_client_conf_addr(unsigned netif, const ipv6_addr_t *addr,
231 uint32_t valid, uint32_t pref)
232{
233 dhcpv6_client_conf_prefix(netif, addr, IPV6_ADDR_BIT_LEN, valid, pref);
234}
235
244bool dhcpv6_client_check_ia_na(unsigned netif);
245
255uint32_t dhcpv6_client_prefix_valid_until(unsigned netif,
256 const ipv6_addr_t *pfx,
257 unsigned pfx_len);
258
267static inline uint32_t dhcpv6_client_addr_valid_until(unsigned netif,
268 const ipv6_addr_t *addr)
269{
271}
272
274
281
287#if defined(MODULE_DHCPV6_CLIENT_MUD_URL) || defined(DOXYGEN)
288#define DHCPV6_CLIENT_SEND_BUFLEN (DHCPV6_CLIENT_BUFLEN + 256)
289#else
290#define DHCPV6_CLIENT_SEND_BUFLEN (DHCPV6_CLIENT_BUFLEN)
291#endif
292
296#define MAX_MUD_URL_LENGTH (0xFF - sizeof(dhcpv6_opt_mud_url_t))
297
301enum {
302 DHCPV6_CLIENT_CONF_MODE_INACTIVE,
303 DHCPV6_CLIENT_CONF_MODE_STATEFUL,
304 DHCPV6_CLIENT_CONF_MODE_STATELESS,
305};
306
312void dhcpv6_client_set_conf_mode(uint8_t configuration_mode);
313
320
322
323#ifdef __cplusplus
324}
325#endif
326
Functions to work with different byte orders.
be_uint16_t network_uint16_t
A 16 bit integer in network byte order.
Definition byteorder.h:104
uint8_t dhcpv6_client_get_conf_mode(void)
Retrieves the DHCPv6 client's current configuration mode.
bool dhcpv6_client_check_ia_na(unsigned netif)
Checks if the given network interface is configured to use DHCPv6 IA_NA.
unsigned dhcpv6_client_get_duid_l2(unsigned netif, dhcpv6_duid_l2_t *duid)
Get the link-layer address DUID for the client.
static void dhcpv6_client_conf_addr(unsigned netif, const ipv6_addr_t *addr, uint32_t valid, uint32_t pref)
Configures a address lease that is provided by the server.
Definition client.h:230
uint32_t dhcpv6_client_prefix_valid_until(unsigned netif, const ipv6_addr_t *pfx, unsigned pfx_len)
Determines how long the prefix delegation lease is still valid.
void dhcpv6_client_set_conf_mode(uint8_t configuration_mode)
Changes the DHCPv6 client's configuration mode.
static uint32_t dhcpv6_client_addr_valid_until(unsigned netif, const ipv6_addr_t *addr)
Determines how long the address lease is still valid.
Definition client.h:267
void dhcpv6_client_conf_prefix(unsigned netif, const ipv6_addr_t *pfx, unsigned pfx_len, uint32_t valid, uint32_t pref)
Configures a prefix delegation lease that is provided by the server.
int dhcpv6_client_req_ia_na(unsigned netif)
Configures the client to request non-temporary addresses for a network interface from a server.
void dhcpv6_client_auto_init(void)
Auto-initializes the client in its own thread.
void dhcpv6_client_start(void)
Let the server start listening.
void dhcpv6_client_init(event_queue_t *event_queue, uint16_t netif)
Initializes the client.
int dhcpv6_client_req_ia_pd(unsigned netif, unsigned pfx_len)
Configures the client to request prefix delegation for a network interface from a server.
void dhcpv6_client_set_init_hook(void(*_hook)(void), uint16_t netif)
Configure a hook function to be executed during dhcpv6 client's auto init.
#define IPV6_ADDR_BIT_LEN
Length of an IPv6 address in bit.
Definition addr.h:36
struct PTRTAG event_queue_t
event queue structure
Definitions for IPv6 addresses.
DUID based on link-layer address plus time.
Definition client.h:100
network_uint16_t l2type
hardware type)
Definition client.h:102
network_uint16_t type
DHCPV6_DUID_TYPE_L2
Definition client.h:101
Data type to represent an IPv6 address.
Definition addr.h:64