This also fixes memleak.
#include "list.h"
#include "macro.h"
#include "network-common.h"
+#include "ordered-set.h"
#include "sparse-endian.h"
typedef struct sd_dhcp6_option {
usec_t information_request_time_usec;
usec_t information_refresh_time_usec;
OrderedHashmap *extra_options;
- OrderedHashmap *vendor_options;
+ OrderedSet *vendor_options;
/* Ignore ifindex when generating iaid. See dhcp_identifier_set_iaid(). */
bool test_mode;
int dhcp6_option_append_fqdn(uint8_t **buf, size_t *buflen, const char *fqdn);
int dhcp6_option_append_user_class(uint8_t **buf, size_t *buflen, char * const *user_class);
int dhcp6_option_append_vendor_class(uint8_t **buf, size_t *buflen, char * const *user_class);
-int dhcp6_option_append_vendor_option(uint8_t **buf, size_t *buflen, OrderedHashmap *vendor_options);
+int dhcp6_option_append_vendor_option(uint8_t **buf, size_t *buflen, OrderedSet *vendor_options);
int dhcp6_option_parse(
const uint8_t *buf,
return 0;
}
-int dhcp6_option_append_vendor_option(uint8_t **buf, size_t *buflen, OrderedHashmap *vendor_options) {
+int dhcp6_option_append_vendor_option(uint8_t **buf, size_t *buflen, OrderedSet *vendor_options) {
sd_dhcp6_option *options;
int r;
assert(buflen);
assert(vendor_options);
- ORDERED_HASHMAP_FOREACH(options, vendor_options) {
+ ORDERED_SET_FOREACH(options, vendor_options) {
_cleanup_free_ uint8_t *p = NULL;
size_t total;
assert_return(client, -EINVAL);
assert_return(!sd_dhcp6_client_is_running(client), -EBUSY);
- assert_return(v, -EINVAL);
- r = ordered_hashmap_ensure_put(&client->vendor_options, &dhcp6_option_hash_ops, v, v);
+ if (!v) {
+ /* Clear the previous assignments. */
+ ordered_set_clear(client->vendor_options);
+ return 0;
+ }
+
+ r = ordered_set_ensure_put(&client->vendor_options, &dhcp6_option_hash_ops, v);
if (r < 0)
return r;
return r;
}
- if (!ordered_hashmap_isempty(client->vendor_options)) {
+ if (!ordered_set_isempty(client->vendor_options)) {
r = dhcp6_option_append_vendor_option(opt, optlen, client->vendor_options);
if (r < 0)
return r;
free(client->mudurl);
dhcp6_ia_clear_addresses(&client->ia_pd);
ordered_hashmap_free(client->extra_options);
+ ordered_set_free(client->vendor_options);
strv_free(client->user_class);
strv_free(client->vendor_class);
free(client->ifname);