1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
5 Copyright © 2014-2015 Intel Corporation. All rights reserved.
8 #include <net/ethernet.h>
9 #include <netinet/in.h>
12 #include "sd-dhcp6-client.h"
18 #include "sparse-endian.h"
20 typedef struct sd_dhcp6_option
{
23 uint32_t enterprise_identifier
;
29 extern const struct hash_ops dhcp6_option_hash_ops
;
31 /* Common option header */
32 typedef struct DHCP6Option
{
36 } _packed_ DHCP6Option
;
40 struct in6_addr address
;
41 be32_t lifetime_preferred
;
42 be32_t lifetime_valid
;
45 /* Prefix Delegation Prefix option */
47 be32_t lifetime_preferred
;
48 be32_t lifetime_valid
;
50 struct in6_addr address
;
53 typedef struct DHCP6Address DHCP6Address
;
56 LIST_FIELDS(DHCP6Address
, addresses
);
60 struct iapdprefix iapdprefix
;
64 /* Non-temporary Address option */
71 /* Prefix Delegation option */
78 /* Temporary Address option */
83 typedef struct DHCP6IA
{
91 LIST_HEAD(DHCP6Address
, addresses
);
94 int dhcp6_option_append(uint8_t **buf
, size_t *buflen
, uint16_t code
,
95 size_t optlen
, const void *optval
);
96 int dhcp6_option_append_ia(uint8_t **buf
, size_t *buflen
, const DHCP6IA
*ia
);
97 int dhcp6_option_append_pd(uint8_t **buf
, size_t *buflen
, const DHCP6IA
*pd
, const DHCP6Address
*hint_pd_prefix
);
98 int dhcp6_option_append_fqdn(uint8_t **buf
, size_t *buflen
, const char *fqdn
);
99 int dhcp6_option_append_user_class(uint8_t **buf
, size_t *buflen
, char * const *user_class
);
100 int dhcp6_option_append_vendor_class(uint8_t **buf
, size_t *buflen
, char * const *user_class
);
101 int dhcp6_option_append_vendor_option(uint8_t **buf
, size_t *buflen
, OrderedHashmap
*vendor_options
);
102 int dhcp6_option_parse(uint8_t **buf
, size_t *buflen
, uint16_t *optcode
,
103 size_t *optlen
, uint8_t **optvalue
);
104 int dhcp6_option_parse_status(DHCP6Option
*option
, size_t len
);
105 int dhcp6_option_parse_ia(sd_dhcp6_client
*client
, DHCP6Option
*iaoption
, DHCP6IA
*ia
, uint16_t *ret_status_code
);
106 int dhcp6_option_parse_ip6addrs(uint8_t *optval
, uint16_t optlen
,
107 struct in6_addr
**addrs
, size_t count
,
109 int dhcp6_option_parse_domainname_list(const uint8_t *optval
, uint16_t optlen
,
111 int dhcp6_option_parse_domainname(const uint8_t *optval
, uint16_t optlen
, char **str
);
113 int dhcp6_network_bind_udp_socket(int ifindex
, struct in6_addr
*address
);
114 int dhcp6_network_send_udp_socket(int s
, struct in6_addr
*address
,
115 const void *packet
, size_t len
);
117 const char *dhcp6_message_type_to_string(int s
) _const_
;
118 int dhcp6_message_type_from_string(const char *s
) _pure_
;
119 const char *dhcp6_message_status_to_string(int s
) _const_
;
120 int dhcp6_message_status_from_string(const char *s
) _pure_
;
122 #define log_dhcp6_client_errno(client, error, fmt, ...) \
123 log_interface_prefix_full_errno( \
125 sd_dhcp6_client_get_ifname(client), \
126 error, fmt, ##__VA_ARGS__)
127 #define log_dhcp6_client(client, fmt, ...) \
128 log_interface_prefix_full_errno_zerook( \
130 sd_dhcp6_client_get_ifname(client), \
131 0, fmt, ##__VA_ARGS__)