udev: move NamePolicy to netif-naming-scheme.[ch]
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "netif-naming-scheme.h"
|
||||
#include "proc-cmdline.h"
|
||||
#include "string-util.h"
|
||||
#include "string-table.h"
|
||||
|
||||
#ifdef _DEFAULT_NET_NAMING_SCHEME_TEST
|
||||
/* The primary purpose of this check is to verify that _DEFAULT_NET_NAMING_SCHEME_TEST
|
||||
@@ -80,3 +81,25 @@ const NamingScheme* naming_scheme(void) {
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
||||
static const char* const name_policy_table[_NAMEPOLICY_MAX] = {
|
||||
[NAMEPOLICY_KERNEL] = "kernel",
|
||||
[NAMEPOLICY_KEEP] = "keep",
|
||||
[NAMEPOLICY_DATABASE] = "database",
|
||||
[NAMEPOLICY_ONBOARD] = "onboard",
|
||||
[NAMEPOLICY_SLOT] = "slot",
|
||||
[NAMEPOLICY_PATH] = "path",
|
||||
[NAMEPOLICY_MAC] = "mac",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(name_policy, NamePolicy);
|
||||
|
||||
static const char* const alternative_names_policy_table[_NAMEPOLICY_MAX] = {
|
||||
[NAMEPOLICY_DATABASE] = "database",
|
||||
[NAMEPOLICY_ONBOARD] = "onboard",
|
||||
[NAMEPOLICY_SLOT] = "slot",
|
||||
[NAMEPOLICY_PATH] = "path",
|
||||
[NAMEPOLICY_MAC] = "mac",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(alternative_names_policy, NamePolicy);
|
||||
|
||||
@@ -64,3 +64,21 @@ const NamingScheme* naming_scheme(void);
|
||||
static inline bool naming_scheme_has(NamingSchemeFlags flags) {
|
||||
return FLAGS_SET(naming_scheme()->flags, flags);
|
||||
}
|
||||
|
||||
typedef enum NamePolicy {
|
||||
NAMEPOLICY_KERNEL,
|
||||
NAMEPOLICY_KEEP,
|
||||
NAMEPOLICY_DATABASE,
|
||||
NAMEPOLICY_ONBOARD,
|
||||
NAMEPOLICY_SLOT,
|
||||
NAMEPOLICY_PATH,
|
||||
NAMEPOLICY_MAC,
|
||||
_NAMEPOLICY_MAX,
|
||||
_NAMEPOLICY_INVALID = -EINVAL,
|
||||
} NamePolicy;
|
||||
|
||||
const char *name_policy_to_string(NamePolicy p) _const_;
|
||||
NamePolicy name_policy_from_string(const char *p) _pure_;
|
||||
|
||||
const char *alternative_names_policy_to_string(NamePolicy p) _const_;
|
||||
NamePolicy alternative_names_policy_from_string(const char *p) _pure_;
|
||||
|
||||
Reference in New Issue
Block a user