1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3 
4 /***
5   Copyright © 2014-2015 Intel Corporation. All rights reserved.
6 ***/
7 
8 #include <inttypes.h>
9 
10 #include "sd-dhcp6-lease.h"
11 
12 #include "dhcp6-option.h"
13 #include "macro.h"
14 #include "time-util.h"
15 
16 struct sd_dhcp6_lease {
17         unsigned n_ref;
18 
19         uint8_t *clientid;
20         size_t clientid_len;
21         uint8_t *serverid;
22         size_t serverid_len;
23         uint8_t preference;
24         bool rapid_commit;
25         triple_timestamp timestamp;
26         usec_t lifetime_t1;
27         usec_t lifetime_t2;
28         usec_t lifetime_valid;
29         struct in6_addr server_address;
30 
31         DHCP6IA *ia_na; /* Identity association non-temporary addresses */
32         DHCP6IA *ia_pd; /* Identity association prefix delegation */
33 
34         DHCP6Address *addr_iter;
35         DHCP6Address *prefix_iter;
36 
37         struct in6_addr *dns;
38         size_t dns_count;
39         char **domains;
40         struct in6_addr *ntp;
41         size_t ntp_count;
42         char **ntp_fqdn;
43         struct in6_addr *sntp;
44         size_t sntp_count;
45         char *fqdn;
46 };
47 
48 int dhcp6_lease_get_lifetime(sd_dhcp6_lease *lease, usec_t *ret_t1, usec_t *ret_t2, usec_t *ret_valid);
49 int dhcp6_lease_set_clientid(sd_dhcp6_lease *lease, const uint8_t *id, size_t len);
50 int dhcp6_lease_get_clientid(sd_dhcp6_lease *lease, uint8_t **ret_id, size_t *ret_len);
51 int dhcp6_lease_set_serverid(sd_dhcp6_lease *lease, const uint8_t *id, size_t len);
52 int dhcp6_lease_get_serverid(sd_dhcp6_lease *lease, uint8_t **ret_id, size_t *ret_len);
53 int dhcp6_lease_set_preference(sd_dhcp6_lease *lease, uint8_t preference);
54 int dhcp6_lease_get_preference(sd_dhcp6_lease *lease, uint8_t *ret);
55 int dhcp6_lease_set_rapid_commit(sd_dhcp6_lease *lease);
56 int dhcp6_lease_get_rapid_commit(sd_dhcp6_lease *lease, bool *ret);
57 
58 int dhcp6_lease_add_dns(sd_dhcp6_lease *lease, const uint8_t *optval, size_t optlen);
59 int dhcp6_lease_add_domains(sd_dhcp6_lease *lease, const uint8_t *optval, size_t optlen);
60 int dhcp6_lease_add_ntp(sd_dhcp6_lease *lease, const uint8_t *optval, size_t optlen);
61 int dhcp6_lease_add_sntp(sd_dhcp6_lease *lease, const uint8_t *optval, size_t optlen);
62 int dhcp6_lease_set_fqdn(sd_dhcp6_lease *lease, const uint8_t *optval, size_t optlen);
63 
64 int dhcp6_lease_new(sd_dhcp6_lease **ret);
65 int dhcp6_lease_new_from_message(
66                 sd_dhcp6_client *client,
67                 const DHCP6Message *message,
68                 size_t len,
69                 const triple_timestamp *timestamp,
70                 const struct in6_addr *server_address,
71                 sd_dhcp6_lease **ret);
72