mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-17 03:30:40 +01:00
dhcp: add systemd's dhcp-identifier.c for dhcp_identifier_set_duid_en()
Also patch dhcp_identifier_set_iaid() to get the ifname via if_indextoname(), instead of udev. This also makes our local modification sd_dhcp6_client_set_ifname() obsolete, which will be removed next.
This commit is contained in:
parent
c140f4599d
commit
9f2f751349
3 changed files with 16 additions and 0 deletions
|
|
@ -66,6 +66,8 @@ SYSTEMD_DHCP_CFLAGS = \
|
|||
|
||||
libsystemd_dhcp_la_SOURCES = \
|
||||
dhcp-manager/systemd-dhcp/src/libsystemd/sd-id128/sd-id128.c \
|
||||
dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-identifier.c \
|
||||
dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-identifier.h \
|
||||
dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-network.c \
|
||||
dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-packet.c \
|
||||
dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-internal.h \
|
||||
|
|
|
|||
|
|
@ -19,13 +19,18 @@
|
|||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include "nm-sd-adapt.h"
|
||||
|
||||
#include "sd-id128.h"
|
||||
#if 0 /* NM_IGNORED a*/
|
||||
#include "libudev.h"
|
||||
#include "udev-util.h"
|
||||
|
||||
#include "virt.h"
|
||||
#include "sparse-endian.h"
|
||||
#else /* NM_IGNORED */
|
||||
#include <net/if.h>
|
||||
#endif /* NM_IGNORED */
|
||||
#include "siphash24.h"
|
||||
|
||||
#include "dhcp6-protocol.h"
|
||||
|
|
@ -59,12 +64,17 @@ int dhcp_identifier_set_duid_en(struct duid *duid, size_t *len) {
|
|||
|
||||
|
||||
int dhcp_identifier_set_iaid(int ifindex, uint8_t *mac, size_t mac_len, uint32_t *_id) {
|
||||
#if 0 /* NM_IGNORED */
|
||||
/* name is a pointer to memory in the udev_device struct, so must
|
||||
have the same scope */
|
||||
_cleanup_udev_device_unref_ struct udev_device *device = NULL;
|
||||
#else /* NM_IGNORED */
|
||||
char name_buf[IF_NAMESIZE];
|
||||
#endif /* NM_IGNORED */
|
||||
const char *name = NULL;
|
||||
uint64_t id;
|
||||
|
||||
#if 0 /* NM_IGNORED */
|
||||
if (detect_container(NULL) <= 0) {
|
||||
/* not in a container, udev will be around */
|
||||
_cleanup_udev_unref_ struct udev *udev;
|
||||
|
|
@ -84,6 +94,9 @@ int dhcp_identifier_set_iaid(int ifindex, uint8_t *mac, size_t mac_len, uint32_t
|
|||
name = net_get_name(device);
|
||||
}
|
||||
}
|
||||
#else /* NM_IGNORED */
|
||||
name = if_indextoname(ifindex, name_buf);
|
||||
#endif /* NM_IGNORED */
|
||||
|
||||
if (name)
|
||||
siphash24((uint8_t*)&id, name, strlen(name), HASH_KEY.bytes);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include "nm-sd-adapt.h"
|
||||
|
||||
#include "macro.h"
|
||||
#include "sparse-endian.h"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue