]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/libsystemd-network/dhcp6-internal.h
udev: use path_make_relative()
[thirdparty/systemd.git] / src / libsystemd-network / dhcp6-internal.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 Copyright © 2014-2015 Intel Corporation. All rights reserved.
6 ***/
7
8 #include <net/ethernet.h>
9 #include <netinet/in.h>
10
11 #include "sd-event.h"
12
13 #include "list.h"
14 #include "macro.h"
15 #include "sparse-endian.h"
16
17 /* Common option header */
18 typedef struct DHCP6Option {
19 be16_t code;
20 be16_t len;
21 uint8_t data[];
22 } _packed_ DHCP6Option;
23
24 /* Address option */
25 struct iaaddr {
26 struct in6_addr address;
27 be32_t lifetime_preferred;
28 be32_t lifetime_valid;
29 } _packed_;
30
31 /* Prefix Delegation Prefix option */
32 struct iapdprefix {
33 be32_t lifetime_preferred;
34 be32_t lifetime_valid;
35 uint8_t prefixlen;
36 struct in6_addr address;
37 } _packed_;
38
39 typedef struct DHCP6Address DHCP6Address;
40
41 struct DHCP6Address {
42 LIST_FIELDS(DHCP6Address, addresses);
43
44 union {
45 struct iaaddr iaaddr;
46 struct iapdprefix iapdprefix;
47 };
48 };
49
50 /* Non-temporary Address option */
51 struct ia_na {
52 be32_t id;
53 be32_t lifetime_t1;
54 be32_t lifetime_t2;
55 } _packed_;
56
57 /* Prefix Delegation option */
58 struct ia_pd {
59 be32_t id;
60 be32_t lifetime_t1;
61 be32_t lifetime_t2;
62 } _packed_;
63
64 /* Temporary Address option */
65 struct ia_ta {
66 be32_t id;
67 } _packed_;
68
69 struct DHCP6IA {
70 uint16_t type;
71 union {
72 struct ia_na ia_na;
73 struct ia_pd ia_pd;
74 struct ia_ta ia_ta;
75 };
76
77 LIST_HEAD(DHCP6Address, addresses);
78 };
79
80 typedef struct DHCP6IA DHCP6IA;
81
82 #define log_dhcp6_client_errno(p, error, fmt, ...) log_internal(LOG_DEBUG, error, __FILE__, __LINE__, __func__, "DHCPv6 CLIENT: " fmt, ##__VA_ARGS__)
83 #define log_dhcp6_client(p, fmt, ...) log_dhcp6_client_errno(p, 0, fmt, ##__VA_ARGS__)
84
85 int dhcp6_option_append(uint8_t **buf, size_t *buflen, uint16_t code,
86 size_t optlen, const void *optval);
87 int dhcp6_option_append_ia(uint8_t **buf, size_t *buflen, DHCP6IA *ia);
88 int dhcp6_option_append_pd(uint8_t *buf, size_t len, DHCP6IA *pd);
89 int dhcp6_option_append_fqdn(uint8_t **buf, size_t *buflen, const char *fqdn);
90 int dhcp6_option_parse(uint8_t **buf, size_t *buflen, uint16_t *optcode,
91 size_t *optlen, uint8_t **optvalue);
92 int dhcp6_option_parse_status(DHCP6Option *option);
93 int dhcp6_option_parse_ia(DHCP6Option *iaoption, DHCP6IA *ia);
94 int dhcp6_option_parse_ip6addrs(uint8_t *optval, uint16_t optlen,
95 struct in6_addr **addrs, size_t count,
96 size_t *allocated);
97 int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen,
98 char ***str_arr);
99
100 int dhcp6_network_bind_udp_socket(int index, struct in6_addr *address);
101 int dhcp6_network_send_udp_socket(int s, struct in6_addr *address,
102 const void *packet, size_t len);
103
104 const char *dhcp6_message_type_to_string(int s) _const_;
105 int dhcp6_message_type_from_string(const char *s) _pure_;
106 const char *dhcp6_message_status_to_string(int s) _const_;
107 int dhcp6_message_status_from_string(const char *s) _pure_;