]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/libsystemd-network/dhcp6-internal.h
sd-dhcp6-client: store PD prefix hint in ia_pd
[thirdparty/systemd.git] / src / libsystemd-network / dhcp6-internal.h
CommitLineData
db9ecf05 1/* SPDX-License-Identifier: LGPL-2.1-or-later */
e3169126
PF
2#pragma once
3
4/***
810adae9 5 Copyright © 2014-2015 Intel Corporation. All rights reserved.
e3169126
PF
6***/
7
8#include <net/ethernet.h>
f12abb48
PF
9#include <netinet/in.h>
10
f12abb48 11#include "sd-event.h"
35388783 12#include "sd-dhcp6-client.h"
07630cea 13
16de849f 14#include "dhcp6-protocol.h"
99ccb8ff 15#include "hashmap.h"
35388783 16#include "list.h"
a9aff361 17#include "macro.h"
5977b71f 18#include "network-common.h"
07630cea 19#include "sparse-endian.h"
f12abb48 20
e7d5fe17
AD
21typedef struct sd_dhcp6_option {
22 unsigned n_ref;
23
99ccb8ff 24 uint32_t enterprise_identifier;
e7d5fe17
AD
25 uint16_t option;
26 void *data;
27 size_t length;
28} sd_dhcp6_option;
29
30extern const struct hash_ops dhcp6_option_hash_ops;
31
3bc424a3
PF
32/* Common option header */
33typedef struct DHCP6Option {
34 be16_t code;
35 be16_t len;
36 uint8_t data[];
37} _packed_ DHCP6Option;
38
0dfe2a4b
PF
39/* Address option */
40struct iaaddr {
41 struct in6_addr address;
42 be32_t lifetime_preferred;
43 be32_t lifetime_valid;
44} _packed_;
45
f8ad4dd4
PF
46/* Prefix Delegation Prefix option */
47struct iapdprefix {
48 be32_t lifetime_preferred;
49 be32_t lifetime_valid;
50 uint8_t prefixlen;
51 struct in6_addr address;
52} _packed_;
53
f12abb48
PF
54typedef struct DHCP6Address DHCP6Address;
55
56struct DHCP6Address {
57 LIST_FIELDS(DHCP6Address, addresses);
58
f8ad4dd4
PF
59 union {
60 struct iaaddr iaaddr;
61 struct iapdprefix iapdprefix;
62 };
f12abb48
PF
63};
64
4b0f2717 65struct ia_header {
e0026dcb
PF
66 be32_t id;
67 be32_t lifetime_t1;
68 be32_t lifetime_t2;
69} _packed_;
70
35388783 71typedef struct DHCP6IA {
f12abb48 72 uint16_t type;
4b0f2717 73 struct ia_header header;
f12abb48
PF
74
75 LIST_HEAD(DHCP6Address, addresses);
35388783 76} DHCP6IA;
e3169126 77
8d71f2b3
YW
78typedef struct sd_dhcp6_client sd_dhcp6_client;
79
fea8c180 80bool dhcp6_option_can_request(uint16_t option);
f12ed3bf
PF
81int dhcp6_option_append(uint8_t **buf, size_t *buflen, uint16_t code,
82 size_t optlen, const void *optval);
e0a18b74 83int dhcp6_option_append_ia(uint8_t **buf, size_t *buflen, const DHCP6IA *ia);
877bfc78 84int dhcp6_option_append_pd(uint8_t **buf, size_t *buflen, const DHCP6IA *pd);
8006aa32 85int dhcp6_option_append_fqdn(uint8_t **buf, size_t *buflen, const char *fqdn);
5a99444e 86int dhcp6_option_append_user_class(uint8_t **buf, size_t *buflen, char * const *user_class);
019951ec 87int dhcp6_option_append_vendor_class(uint8_t **buf, size_t *buflen, char * const *user_class);
99ccb8ff 88int dhcp6_option_append_vendor_option(uint8_t **buf, size_t *buflen, OrderedHashmap *vendor_options);
b89a3758
YW
89
90int dhcp6_option_parse(
91 const uint8_t *buf,
92 size_t buflen,
93 size_t *offset,
94 uint16_t *ret_option_code,
95 size_t *ret_option_data_len,
96 const uint8_t **ret_option_data);
4af39cb8 97int dhcp6_option_parse_status(const uint8_t *data, size_t data_len, char **ret_status_message);
8a895550
YW
98int dhcp6_option_parse_ia(
99 sd_dhcp6_client *client,
100 be32_t iaid,
101 uint16_t option_code,
102 size_t option_data_len,
103 const uint8_t *option_data,
e5b0b87f 104 DHCP6IA **ret);
ad3c8420
YW
105int dhcp6_option_parse_addresses(
106 const uint8_t *optval,
107 size_t optlen,
108 struct in6_addr **addrs,
109 size_t *count);
b27dcf08
YW
110int dhcp6_option_parse_domainname_list(const uint8_t *optval, size_t optlen, char ***ret);
111int dhcp6_option_parse_domainname(const uint8_t *optval, size_t optlen, char **ret);
34e8c5a2 112
1a6c9136 113int dhcp6_network_bind_udp_socket(int ifindex, struct in6_addr *address);
34e8c5a2
PF
114int dhcp6_network_send_udp_socket(int s, struct in6_addr *address,
115 const void *packet, size_t len);
a9aff361 116
16de849f
YW
117int client_parse_message(
118 sd_dhcp6_client *client,
119 DHCP6Message *message,
120 size_t len,
121 sd_dhcp6_lease *lease);
122
a9aff361
PF
123const char *dhcp6_message_type_to_string(int s) _const_;
124int dhcp6_message_type_from_string(const char *s) _pure_;
631bbe71
PF
125const char *dhcp6_message_status_to_string(int s) _const_;
126int dhcp6_message_status_from_string(const char *s) _pure_;
35388783 127
8d71f2b3
YW
128void dhcp6_client_set_test_mode(sd_dhcp6_client *client, bool test_mode);
129
a0c2541b 130#define log_dhcp6_client_errno(client, error, fmt, ...) \
00dd6d77 131 log_interface_prefix_full_errno( \
a0c2541b 132 "DHCPv6 client: ", \
5977b71f 133 sd_dhcp6_client, client, \
a0c2541b
ZJS
134 error, fmt, ##__VA_ARGS__)
135#define log_dhcp6_client(client, fmt, ...) \
00dd6d77
ZJS
136 log_interface_prefix_full_errno_zerook( \
137 "DHCPv6 client: ", \
5977b71f 138 sd_dhcp6_client, client, \
00dd6d77 139 0, fmt, ##__VA_ARGS__)