]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/libsystemd-network/dhcp6-internal.h
Merge pull request #16336 from yuwata/ifindex-cleanups
[thirdparty/systemd.git] / src / libsystemd-network / dhcp6-internal.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
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"
07630cea 12
f12abb48 13#include "list.h"
99ccb8ff 14#include "hashmap.h"
a9aff361 15#include "macro.h"
07630cea 16#include "sparse-endian.h"
f12abb48 17
e7d5fe17
AD
18typedef struct sd_dhcp6_option {
19 unsigned n_ref;
20
99ccb8ff 21 uint32_t enterprise_identifier;
e7d5fe17
AD
22 uint16_t option;
23 void *data;
24 size_t length;
25} sd_dhcp6_option;
26
27extern const struct hash_ops dhcp6_option_hash_ops;
28
3bc424a3
PF
29/* Common option header */
30typedef struct DHCP6Option {
31 be16_t code;
32 be16_t len;
33 uint8_t data[];
34} _packed_ DHCP6Option;
35
0dfe2a4b
PF
36/* Address option */
37struct iaaddr {
38 struct in6_addr address;
39 be32_t lifetime_preferred;
40 be32_t lifetime_valid;
41} _packed_;
42
f8ad4dd4
PF
43/* Prefix Delegation Prefix option */
44struct iapdprefix {
45 be32_t lifetime_preferred;
46 be32_t lifetime_valid;
47 uint8_t prefixlen;
48 struct in6_addr address;
49} _packed_;
50
f12abb48
PF
51typedef struct DHCP6Address DHCP6Address;
52
53struct DHCP6Address {
54 LIST_FIELDS(DHCP6Address, addresses);
55
f8ad4dd4
PF
56 union {
57 struct iaaddr iaaddr;
58 struct iapdprefix iapdprefix;
59 };
f12abb48
PF
60};
61
e0026dcb
PF
62/* Non-temporary Address option */
63struct ia_na {
64 be32_t id;
65 be32_t lifetime_t1;
66 be32_t lifetime_t2;
67} _packed_;
68
f8ad4dd4
PF
69/* Prefix Delegation option */
70struct ia_pd {
71 be32_t id;
72 be32_t lifetime_t1;
73 be32_t lifetime_t2;
74} _packed_;
75
e0026dcb
PF
76/* Temporary Address option */
77struct ia_ta {
78 be32_t id;
79} _packed_;
80
f12abb48
PF
81struct DHCP6IA {
82 uint16_t type;
e0026dcb
PF
83 union {
84 struct ia_na ia_na;
f8ad4dd4 85 struct ia_pd ia_pd;
e0026dcb
PF
86 struct ia_ta ia_ta;
87 };
f12abb48
PF
88
89 LIST_HEAD(DHCP6Address, addresses);
90};
91
92typedef struct DHCP6IA DHCP6IA;
e3169126 93
62c6bbbc 94#define log_dhcp6_client_errno(p, error, fmt, ...) log_internal(LOG_DEBUG, error, PROJECT_FILE, __LINE__, __func__, "DHCPv6 CLIENT: " fmt, ##__VA_ARGS__)
bd9a7221 95#define log_dhcp6_client(p, fmt, ...) log_dhcp6_client_errno(p, 0, fmt, ##__VA_ARGS__)
e3169126 96
f12ed3bf
PF
97int dhcp6_option_append(uint8_t **buf, size_t *buflen, uint16_t code,
98 size_t optlen, const void *optval);
e0a18b74 99int dhcp6_option_append_ia(uint8_t **buf, size_t *buflen, const DHCP6IA *ia);
2805536b 100int dhcp6_option_append_pd(uint8_t *buf, size_t len, const DHCP6IA *pd, DHCP6Address *hint_pd_prefix);
8006aa32 101int dhcp6_option_append_fqdn(uint8_t **buf, size_t *buflen, const char *fqdn);
33923925 102int dhcp6_option_append_user_class(uint8_t **buf, size_t *buflen, char **user_class);
73c8ced7 103int dhcp6_option_append_vendor_class(uint8_t **buf, size_t *buflen, char **user_class);
99ccb8ff 104int dhcp6_option_append_vendor_option(uint8_t **buf, size_t *buflen, OrderedHashmap *vendor_options);
f12ed3bf
PF
105int dhcp6_option_parse(uint8_t **buf, size_t *buflen, uint16_t *optcode,
106 size_t *optlen, uint8_t **optvalue);
84452783 107int dhcp6_option_parse_status(DHCP6Option *option, size_t len);
5c95a913 108int dhcp6_option_parse_ia(DHCP6Option *iaoption, DHCP6IA *ia, uint16_t *ret_status_code);
b553817c
PF
109int dhcp6_option_parse_ip6addrs(uint8_t *optval, uint16_t optlen,
110 struct in6_addr **addrs, size_t count,
111 size_t *allocated);
f96ccab7
PF
112int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen,
113 char ***str_arr);
34e8c5a2 114
1a6c9136 115int dhcp6_network_bind_udp_socket(int ifindex, struct in6_addr *address);
34e8c5a2
PF
116int dhcp6_network_send_udp_socket(int s, struct in6_addr *address,
117 const void *packet, size_t len);
a9aff361
PF
118
119const char *dhcp6_message_type_to_string(int s) _const_;
120int dhcp6_message_type_from_string(const char *s) _pure_;
631bbe71
PF
121const char *dhcp6_message_status_to_string(int s) _const_;
122int dhcp6_message_status_from_string(const char *s) _pure_;