mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
network-util: introduce network_link_get_operational_state()
This commit is contained in:
@@ -135,3 +135,23 @@ int parse_operational_state_range(const char *str, LinkOperationalStateRange *ou
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int network_link_get_operational_state(int ifindex, LinkOperationalState *ret) {
|
||||
_cleanup_free_ char *str = NULL;
|
||||
LinkOperationalState s;
|
||||
int r;
|
||||
|
||||
assert(ifindex > 0);
|
||||
assert(ret);
|
||||
|
||||
r = sd_network_link_get_operational_state(ifindex, &str);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
s = link_operstate_from_string(str);
|
||||
if (s < 0)
|
||||
return s;
|
||||
|
||||
*ret = s;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -83,3 +83,4 @@ typedef struct LinkOperationalStateRange {
|
||||
LINK_OPERSTATE_ROUTABLE }
|
||||
|
||||
int parse_operational_state_range(const char *str, LinkOperationalStateRange *out);
|
||||
int network_link_get_operational_state(int ifindex, LinkOperationalState *ret);
|
||||
|
||||
Reference in New Issue
Block a user