mirror of
https://github.com/systemd/systemd.git
synced 2025-03-29 06:50:16 +03:00
udev: move NamePolicy to netif-naming-scheme.[ch]
This commit is contained in:
parent
eb3e86ae2c
commit
ff516b4341
@ -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_;
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "log-link.h"
|
||||
#include "memory-util.h"
|
||||
#include "net-condition.h"
|
||||
#include "netif-naming-scheme.h"
|
||||
#include "netif-util.h"
|
||||
#include "netlink-util.h"
|
||||
#include "parse-util.h"
|
||||
@ -1032,30 +1031,10 @@ DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(
|
||||
MAC_ADDRESS_POLICY_NONE,
|
||||
"Failed to parse MAC address policy");
|
||||
|
||||
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);
|
||||
DEFINE_CONFIG_PARSE_ENUMV(config_parse_name_policy, name_policy, NamePolicy,
|
||||
_NAMEPOLICY_INVALID,
|
||||
"Failed to parse interface name policy");
|
||||
|
||||
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);
|
||||
DEFINE_CONFIG_PARSE_ENUMV(config_parse_alternative_names_policy, alternative_names_policy, NamePolicy,
|
||||
_NAMEPOLICY_INVALID,
|
||||
"Failed to parse alternative names policy");
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "ethtool-util.h"
|
||||
#include "list.h"
|
||||
#include "net-condition.h"
|
||||
#include "netif-naming-scheme.h"
|
||||
|
||||
typedef struct LinkConfigContext LinkConfigContext;
|
||||
typedef struct LinkConfig LinkConfig;
|
||||
@ -21,18 +22,6 @@ typedef enum MACAddressPolicy {
|
||||
_MAC_ADDRESS_POLICY_INVALID = -EINVAL,
|
||||
} MACAddressPolicy;
|
||||
|
||||
typedef enum NamePolicy {
|
||||
NAMEPOLICY_KERNEL,
|
||||
NAMEPOLICY_KEEP,
|
||||
NAMEPOLICY_DATABASE,
|
||||
NAMEPOLICY_ONBOARD,
|
||||
NAMEPOLICY_SLOT,
|
||||
NAMEPOLICY_PATH,
|
||||
NAMEPOLICY_MAC,
|
||||
_NAMEPOLICY_MAX,
|
||||
_NAMEPOLICY_INVALID = -EINVAL,
|
||||
} NamePolicy;
|
||||
|
||||
typedef struct Link {
|
||||
int ifindex;
|
||||
const char *ifname;
|
||||
@ -105,12 +94,6 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_free);
|
||||
int link_get_config(LinkConfigContext *ctx, Link *link);
|
||||
int link_apply_config(LinkConfigContext *ctx, sd_netlink **rtnl, Link *link);
|
||||
|
||||
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_;
|
||||
|
||||
const char *mac_address_policy_to_string(MACAddressPolicy p) _const_;
|
||||
MACAddressPolicy mac_address_policy_from_string(const char *p) _pure_;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user