2020-12-23 22:21:36 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2019-09-25 13:13:40 +02:00
|
|
|
/*
|
2015-04-14 22:34:01 +02:00
|
|
|
* Copyright (C) 2015 Red Hat, Inc.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __NM_PLATFORM_UTILS_H__
|
|
|
|
|
#define __NM_PLATFORM_UTILS_H__
|
|
|
|
|
|
2021-02-18 08:13:35 +01:00
|
|
|
#include "libnm-base/nm-base.h"
|
2021-02-18 08:13:35 +01:00
|
|
|
#include "libnm-platform/nmp-base.h"
|
2018-07-16 15:42:07 +02:00
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2015-04-14 22:34:01 +02:00
|
|
|
|
2016-12-11 22:46:14 +01:00
|
|
|
const char *nmp_utils_ethtool_get_driver(int ifindex);
|
|
|
|
|
gboolean nmp_utils_ethtool_supports_carrier_detect(int ifindex);
|
|
|
|
|
gboolean nmp_utils_ethtool_supports_vlans(int ifindex);
|
|
|
|
|
int nmp_utils_ethtool_get_peer_ifindex(int ifindex);
|
|
|
|
|
gboolean nmp_utils_ethtool_get_wake_on_lan(int ifindex);
|
2021-01-08 17:01:45 +01:00
|
|
|
gboolean nmp_utils_ethtool_set_wake_on_lan(int ifindex,
|
|
|
|
|
_NMSettingWiredWakeOnLan wol,
|
2021-11-09 13:28:54 +01:00
|
|
|
const char *wol_password);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2021-01-08 20:24:36 +01:00
|
|
|
const char *nm_platform_link_duplex_type_to_string(NMPlatformLinkDuplexType duplex);
|
|
|
|
|
|
2021-08-30 17:31:49 +02:00
|
|
|
extern const guint8 _nmp_link_mode_all_advertised_modes_bits[79];
|
|
|
|
|
extern const guint32 _nmp_link_mode_all_advertised_modes[3];
|
|
|
|
|
|
2016-12-11 22:46:14 +01:00
|
|
|
gboolean nmp_utils_ethtool_get_link_settings(int ifindex,
|
2021-11-09 13:28:54 +01:00
|
|
|
gboolean *out_autoneg,
|
|
|
|
|
guint32 *out_speed,
|
2016-12-11 22:46:14 +01:00
|
|
|
NMPlatformLinkDuplexType *out_duplex);
|
|
|
|
|
gboolean nmp_utils_ethtool_set_link_settings(int ifindex,
|
|
|
|
|
gboolean autoneg,
|
|
|
|
|
guint32 speed,
|
|
|
|
|
NMPlatformLinkDuplexType duplex);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2016-12-11 22:46:14 +01:00
|
|
|
gboolean nmp_utils_ethtool_get_permanent_address(int ifindex, guint8 *buf, size_t *length);
|
2018-07-16 15:42:07 +02:00
|
|
|
|
2016-12-11 22:46:14 +01:00
|
|
|
gboolean nmp_utils_ethtool_get_driver_info(int ifindex, NMPUtilsEthtoolDriverInfo *data);
|
2015-05-02 07:59:59 +02:00
|
|
|
|
2018-07-16 15:42:07 +02:00
|
|
|
NMEthtoolFeatureStates *nmp_utils_ethtool_get_features(int ifindex);
|
|
|
|
|
|
|
|
|
|
gboolean nmp_utils_ethtool_set_features(
|
|
|
|
|
int ifindex,
|
|
|
|
|
const NMEthtoolFeatureStates *features,
|
2021-01-10 16:51:37 +01:00
|
|
|
const NMOptionBool *requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */,
|
|
|
|
|
gboolean do_set /* or reset */);
|
2018-07-16 15:42:07 +02:00
|
|
|
|
2020-05-14 09:16:30 +02:00
|
|
|
gboolean nmp_utils_ethtool_get_coalesce(int ifindex, NMEthtoolCoalesceState *coalesce);
|
2020-05-07 17:11:34 +02:00
|
|
|
|
|
|
|
|
gboolean nmp_utils_ethtool_set_coalesce(int ifindex, const NMEthtoolCoalesceState *coalesce);
|
|
|
|
|
|
2020-05-14 18:27:54 +02:00
|
|
|
gboolean nmp_utils_ethtool_get_ring(int ifindex, NMEthtoolRingState *ring);
|
|
|
|
|
|
|
|
|
|
gboolean nmp_utils_ethtool_set_ring(int ifindex, const NMEthtoolRingState *ring);
|
|
|
|
|
|
2021-05-11 15:45:22 +08:00
|
|
|
gboolean nmp_utils_ethtool_get_pause(int ifindex, NMEthtoolPauseState *pause);
|
|
|
|
|
|
|
|
|
|
gboolean nmp_utils_ethtool_set_pause(int ifindex, const NMEthtoolPauseState *pause);
|
|
|
|
|
|
2018-07-16 15:42:07 +02:00
|
|
|
/*****************************************************************************/
|
2015-05-02 07:59:59 +02:00
|
|
|
|
2016-12-11 22:46:14 +01:00
|
|
|
gboolean nmp_utils_mii_supports_carrier_detect(int ifindex);
|
2015-05-03 12:49:46 +02:00
|
|
|
|
2017-03-12 15:54:02 +01:00
|
|
|
struct udev_device;
|
|
|
|
|
|
|
|
|
|
const char *nmp_utils_udev_get_driver(struct udev_device *udevice);
|
2015-05-02 07:59:59 +02:00
|
|
|
|
2016-05-16 13:16:49 +02:00
|
|
|
NMIPConfigSource nmp_utils_ip_config_source_from_rtprot(guint8 rtprot) _nm_const;
|
|
|
|
|
guint8 nmp_utils_ip_config_source_coerce_to_rtprot(NMIPConfigSource source) _nm_const;
|
|
|
|
|
NMIPConfigSource nmp_utils_ip_config_source_coerce_from_rtprot(NMIPConfigSource source) _nm_const;
|
|
|
|
|
NMIPConfigSource nmp_utils_ip_config_source_round_trip_rtprot(NMIPConfigSource source) _nm_const;
|
platform: extend NMIPConfigSource to preserve the rtm_protocol field
For addresses (NMPlatformIPAddress) the @addr_source field is ignored
on a platform level. That is, all addresses inside the platform cache
have this value set to NM_IP_CONFIG_SOURCE_KERNEL. Maybe, for that reason,
the source should not be a part of the NMPlatformIPAddress structure, but
it is convenient for users to piggy back the source inside the platform
address structure.
For routes, the source is stored in NMPlatformIPRoute's @rt_source
field. When adding a route to kernel, we set the @rtm_protocol of the
route depending on the source. However, we want to map different source
values to the same protocol value.
On the other hand, when kernel sends us a route that gets put inside
the cache, we must preserve the protocol value and must not map
different protocol values to the same source.
The reason is, that a user can add two routes that only differ by
@rtm_protocol. In that sense, the @rtm_protocol fields is part of the
unique ID of a kernel route, and thus different values must map to
different sources.
Fix this, by extending the range of NMIPConfigSource to contain
a range of protocol fields.
2016-04-11 17:35:29 +02:00
|
|
|
const char *nmp_utils_ip_config_source_to_string(NMIPConfigSource source, char *buf, gsize len);
|
2016-04-10 12:01:51 +02:00
|
|
|
|
2016-12-26 11:54:30 +01:00
|
|
|
const char *nmp_utils_if_indextoname(int ifindex, char *out_ifname /*IFNAMSIZ*/);
|
|
|
|
|
int nmp_utils_if_nametoindex(const char *ifname);
|
|
|
|
|
|
2016-12-08 13:55:17 +01:00
|
|
|
int nmp_utils_sysctl_open_netdir(int ifindex, const char *ifname_guess, char *out_ifname);
|
2016-12-07 18:15:13 +08:00
|
|
|
|
2021-11-09 13:28:54 +01:00
|
|
|
char *nmp_utils_new_vlan_name(const char *parent_iface, guint32 vlan_id);
|
2021-03-04 10:00:39 +01:00
|
|
|
const char *nmp_utils_new_infiniband_name(char *name, const char *parent_name, int p_key);
|
|
|
|
|
|
2021-03-04 10:05:18 +01:00
|
|
|
guint32
|
|
|
|
|
nmp_utils_lifetime_rebase_relative_time_on_now(guint32 timestamp, guint32 duration, gint32 now);
|
|
|
|
|
|
|
|
|
|
guint32 nmp_utils_lifetime_get(guint32 timestamp,
|
|
|
|
|
guint32 lifetime,
|
|
|
|
|
guint32 preferred,
|
platform: make "now" timestamp an in/out parameter to nmp_utils_lifetime_get()
nmp_utils_lifetime_get() calculates the lifetime of addresses,
and it bases the result on a "now" timestamp.
If you have two addresses and calculate their expiry, then we want to
base it on top of the same "now" timestamp, meaning, we should
only call nm_utils_get_monotonic_timestamp_sec() once. This is also a
performance optimization. But much more importantly, when we make a
comparison at a certain moment, we need that all sides have the same
understanding of the current timestamp.
But nmp_utils_lifetime_get() does not always require the now timestamp.
And the caller doesn't know, whether it will need it (short of knowing
how nmp_utils_lifetime_get() is implemented). So, make the now parameter
an in/out argument. If we pass in an already valid now timestamp, use
that. Otherwise, fetch the current time and also return it.
(cherry picked from commit deb37401e95d4ea0025e406424c8da7c10bc9712)
2022-03-29 22:45:56 +02:00
|
|
|
gint32 *cached_now,
|
2021-03-04 10:05:18 +01:00
|
|
|
guint32 *out_preferred);
|
|
|
|
|
|
2021-03-04 10:49:31 +01:00
|
|
|
int nmp_utils_modprobe(GError **error, gboolean suppress_error_logging, const char *arg1, ...)
|
|
|
|
|
G_GNUC_NULL_TERMINATED;
|
|
|
|
|
|
2015-04-14 22:34:01 +02:00
|
|
|
#endif /* __NM_PLATFORM_UTILS_H__ */
|