]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/libsystemd-network/dhcp6-internal.h
cb5b359cbe4ffc8976687e809e592b95aad7fe79
[thirdparty/systemd.git] / src / libsystemd-network / dhcp6-internal.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 This file is part of systemd.
6
7 Copyright (C) 2014-2015 Intel Corporation. All rights reserved.
8
9 systemd is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
13
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21 ***/
22
23 #include <net/ethernet.h>
24 #include <netinet/in.h>
25
26 #include "sd-event.h"
27
28 #include "list.h"
29 #include "macro.h"
30 #include "sparse-endian.h"
31
32 typedef struct DHCP6Address DHCP6Address;
33
34 struct DHCP6Address {
35 LIST_FIELDS(DHCP6Address, addresses);
36
37 struct {
38 struct in6_addr address;
39 be32_t lifetime_preferred;
40 be32_t lifetime_valid;
41 } iaaddr _packed_;
42 };
43
44 struct DHCP6IA {
45 uint16_t type;
46 struct {
47 be32_t id;
48 be32_t lifetime_t1;
49 be32_t lifetime_t2;
50 } _packed_;
51 sd_event_source *timeout_t1;
52 sd_event_source *timeout_t2;
53
54 LIST_HEAD(DHCP6Address, addresses);
55 };
56
57 typedef struct DHCP6IA DHCP6IA;
58
59 #define log_dhcp6_client_errno(p, error, fmt, ...) log_internal(LOG_DEBUG, error, __FILE__, __LINE__, __func__, "DHCPv6 CLIENT: " fmt, ##__VA_ARGS__)
60 #define log_dhcp6_client(p, fmt, ...) log_dhcp6_client_errno(p, 0, fmt, ##__VA_ARGS__)
61
62 int dhcp6_option_append(uint8_t **buf, size_t *buflen, uint16_t code,
63 size_t optlen, const void *optval);
64 int dhcp6_option_append_ia(uint8_t **buf, size_t *buflen, DHCP6IA *ia);
65 int dhcp6_option_append_fqdn(uint8_t **buf, size_t *buflen, const char *fqdn);
66 int dhcp6_option_parse(uint8_t **buf, size_t *buflen, uint16_t *optcode,
67 size_t *optlen, uint8_t **optvalue);
68 int dhcp6_option_parse_ia(uint8_t **buf, size_t *buflen, uint16_t iatype,
69 DHCP6IA *ia);
70 int dhcp6_option_parse_ip6addrs(uint8_t *optval, uint16_t optlen,
71 struct in6_addr **addrs, size_t count,
72 size_t *allocated);
73 int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen,
74 char ***str_arr);
75
76 int dhcp6_network_bind_udp_socket(int index, struct in6_addr *address);
77 int dhcp6_network_send_udp_socket(int s, struct in6_addr *address,
78 const void *packet, size_t len);
79
80 const char *dhcp6_message_type_to_string(int s) _const_;
81 int dhcp6_message_type_from_string(const char *s) _pure_;
82 const char *dhcp6_message_status_to_string(int s) _const_;
83 int dhcp6_message_status_from_string(const char *s) _pure_;