networkctl: factor out link_get_property()
The next patch is going to reuse it.
This commit is contained in:
parent
7be3261222
commit
090c923b4d
|
@ -471,9 +471,13 @@ static int decode_link(sd_netlink_message *m, LinkInfo *info, char **patterns, b
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int acquire_link_bitrates(sd_bus *bus, LinkInfo *link) {
|
static int link_get_property(
|
||||||
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
|
sd_bus *bus,
|
||||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
const LinkInfo *link,
|
||||||
|
sd_bus_error *error,
|
||||||
|
sd_bus_message **reply,
|
||||||
|
const char *iface,
|
||||||
|
const char *propname) {
|
||||||
_cleanup_free_ char *path = NULL, *ifindex_str = NULL;
|
_cleanup_free_ char *path = NULL, *ifindex_str = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -484,17 +488,25 @@ static int acquire_link_bitrates(sd_bus *bus, LinkInfo *link) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
return sd_bus_call_method(
|
||||||
bus,
|
bus,
|
||||||
"org.freedesktop.network1",
|
"org.freedesktop.network1",
|
||||||
path,
|
path,
|
||||||
"org.freedesktop.DBus.Properties",
|
"org.freedesktop.DBus.Properties",
|
||||||
"Get",
|
"Get",
|
||||||
&error,
|
error,
|
||||||
&reply,
|
reply,
|
||||||
"ss",
|
"ss",
|
||||||
"org.freedesktop.network1.Link",
|
iface,
|
||||||
"BitRates");
|
propname);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int acquire_link_bitrates(sd_bus *bus, LinkInfo *link) {
|
||||||
|
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
|
||||||
|
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
r = link_get_property(bus, link, &error, &reply, "org.freedesktop.network1.Link", "BitRates");
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
bool quiet = sd_bus_error_has_name(&error, SD_BUS_ERROR_UNKNOWN_PROPERTY) ||
|
bool quiet = sd_bus_error_has_name(&error, SD_BUS_ERROR_UNKNOWN_PROPERTY) ||
|
||||||
sd_bus_error_has_name(&error, BUS_ERROR_SPEED_METER_INACTIVE);
|
sd_bus_error_has_name(&error, BUS_ERROR_SPEED_METER_INACTIVE);
|
||||||
|
|
Loading…
Reference in a new issue