Blame src/systemd/nm-sd-utils-dhcp.c
|
Packit Service |
87a54e |
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
Packit |
5756e2 |
/*
|
|
Packit |
5756e2 |
* Copyright (C) 2019 Red Hat, Inc.
|
|
Packit |
5756e2 |
*/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#include "nm-default.h"
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#include "nm-sd-utils-dhcp.h"
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#include "sd-adapt-core/nm-sd-adapt-core.h"
|
|
Packit |
5756e2 |
#include "src/libsystemd-network/dhcp-lease-internal.h"
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
int
|
|
Packit Service |
a1bd4f |
nm_sd_dhcp_lease_get_private_options(sd_dhcp_lease *lease, nm_sd_dhcp_option **out_options)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
struct sd_dhcp_raw_option *raw_option;
|
|
Packit Service |
a1bd4f |
int cnt = 0;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(lease, -EINVAL);
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(out_options, -EINVAL);
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(*out_options == NULL, -EINVAL);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
if (lease->private_options == NULL)
|
|
Packit Service |
a1bd4f |
return -ENODATA;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
LIST_FOREACH(options, raw_option, lease->private_options)
|
|
Packit Service |
a1bd4f |
cnt++;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
*out_options = g_new(nm_sd_dhcp_option, cnt);
|
|
Packit Service |
a1bd4f |
cnt = 0;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
LIST_FOREACH(options, raw_option, lease->private_options)
|
|
Packit Service |
a1bd4f |
{
|
|
Packit Service |
a1bd4f |
(*out_options)[cnt].code = raw_option->tag;
|
|
Packit Service |
a1bd4f |
(*out_options)[cnt].data = raw_option->data;
|
|
Packit Service |
a1bd4f |
(*out_options)[cnt].data_len = raw_option->length;
|
|
Packit Service |
a1bd4f |
cnt++;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
return cnt;
|
|
Packit |
5756e2 |
}
|