summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-03-05 14:39:57 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-03-13 14:28:38 +0900
commit2cd6b9326c3555c4af6645beaa05ab482aff2e21 (patch)
tree15d372634628b4dd86c2d12b607f37019a91eb5d
parent4ddbf08cfd2904eb4317e222716c65deacf22513 (diff)
downloadsystemd-2cd6b9326c3555c4af6645beaa05ab482aff2e21.tar.gz
network: move LinkOperationalState and relevant functions to network-util.[ch]
-rw-r--r--src/libsystemd/sd-network/network-util.c13
-rw-r--r--src/libsystemd/sd-network/network-util.h17
-rw-r--r--src/network/networkd-link.c12
-rw-r--r--src/network/networkd-link.h16
4 files changed, 31 insertions, 27 deletions
diff --git a/src/libsystemd/sd-network/network-util.c b/src/libsystemd/sd-network/network-util.c
index df5ce86842..86e9b1a751 100644
--- a/src/libsystemd/sd-network/network-util.c
+++ b/src/libsystemd/sd-network/network-util.c
@@ -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);
diff --git a/src/libsystemd/sd-network/network-util.h b/src/libsystemd/sd-network/network-util.h
index e868bc2e27..82a16b092e 100644
--- a/src/libsystemd/sd-network/network-util.h
+++ b/src/libsystemd/sd-network/network-util.h
@@ -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_;
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index de112a2ef8..6704c5d8a8 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -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);
diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h
index b6b7c92b4f..c4e061ca13 100644
--- a/src/network/networkd-link.h
+++ b/src/network/networkd-link.h
@@ -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);