network: move LinkOperationalState and relevant functions to network-util.[ch]

This commit is contained in:
Yu Watanabe
2019-03-05 14:39:57 +09:00
parent 4ddbf08cfd
commit 2cd6b9326c
4 changed files with 31 additions and 27 deletions

View File

@@ -3,6 +3,7 @@
#include "alloc-util.h"
#include "fd-util.h"
#include "network-util.h"
#include "string-table.h"
#include "strv.h"
bool network_is_online(void) {
@@ -18,3 +19,15 @@ bool network_is_online(void) {
return false;
}
static const char* const link_operstate_table[_LINK_OPERSTATE_MAX] = {
[LINK_OPERSTATE_OFF] = "off",
[LINK_OPERSTATE_NO_CARRIER] = "no-carrier",
[LINK_OPERSTATE_DORMANT] = "dormant",
[LINK_OPERSTATE_CARRIER] = "carrier",
[LINK_OPERSTATE_DEGRADED] = "degraded",
[LINK_OPERSTATE_ENSLAVED] = "enslaved",
[LINK_OPERSTATE_ROUTABLE] = "routable",
};
DEFINE_STRING_TABLE_LOOKUP(link_operstate, LinkOperationalState);

View File

@@ -3,4 +3,21 @@
#include "sd-network.h"
#include "macro.h"
bool network_is_online(void);
typedef enum LinkOperationalState {
LINK_OPERSTATE_OFF,
LINK_OPERSTATE_NO_CARRIER,
LINK_OPERSTATE_DORMANT,
LINK_OPERSTATE_CARRIER,
LINK_OPERSTATE_DEGRADED,
LINK_OPERSTATE_ENSLAVED,
LINK_OPERSTATE_ROUTABLE,
_LINK_OPERSTATE_MAX,
_LINK_OPERSTATE_INVALID = -1
} LinkOperationalState;
const char* link_operstate_to_string(LinkOperationalState s) _const_;
LinkOperationalState link_operstate_from_string(const char *s) _pure_;

View File

@@ -4306,15 +4306,3 @@ static const char* const link_state_table[_LINK_STATE_MAX] = {
};
DEFINE_STRING_TABLE_LOOKUP(link_state, LinkState);
static const char* const link_operstate_table[_LINK_OPERSTATE_MAX] = {
[LINK_OPERSTATE_OFF] = "off",
[LINK_OPERSTATE_NO_CARRIER] = "no-carrier",
[LINK_OPERSTATE_DORMANT] = "dormant",
[LINK_OPERSTATE_CARRIER] = "carrier",
[LINK_OPERSTATE_DEGRADED] = "degraded",
[LINK_OPERSTATE_ENSLAVED] = "enslaved",
[LINK_OPERSTATE_ROUTABLE] = "routable",
};
DEFINE_STRING_TABLE_LOOKUP(link_operstate, LinkOperationalState);

View File

@@ -15,6 +15,7 @@
#include "sd-netlink.h"
#include "list.h"
#include "network-util.h"
#include "set.h"
typedef enum LinkState {
@@ -28,18 +29,6 @@ typedef enum LinkState {
_LINK_STATE_INVALID = -1
} LinkState;
typedef enum LinkOperationalState {
LINK_OPERSTATE_OFF,
LINK_OPERSTATE_NO_CARRIER,
LINK_OPERSTATE_DORMANT,
LINK_OPERSTATE_CARRIER,
LINK_OPERSTATE_DEGRADED,
LINK_OPERSTATE_ENSLAVED,
LINK_OPERSTATE_ROUTABLE,
_LINK_OPERSTATE_MAX,
_LINK_OPERSTATE_INVALID = -1
} LinkOperationalState;
typedef struct Manager Manager;
typedef struct Network Network;
typedef struct Address Address;
@@ -180,9 +169,6 @@ int dhcp6_lease_pd_prefix_lost(sd_dhcp6_client *client, Link* link);
const char* link_state_to_string(LinkState s) _const_;
LinkState link_state_from_string(const char *s) _pure_;
const char* link_operstate_to_string(LinkOperationalState s) _const_;
LinkOperationalState link_operstate_from_string(const char *s) _pure_;
extern const sd_bus_vtable link_vtable[];
int link_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error);