network: Introduce ipvlan util
Move ipvlan common to shared
This commit is contained in:
parent
f00c36641a
commit
35072050e6
|
@ -4,25 +4,11 @@
|
|||
|
||||
#include "conf-parser.h"
|
||||
#include "ipvlan.h"
|
||||
#include "ipvlan-util.h"
|
||||
#include "networkd-link.h"
|
||||
#include "string-table.h"
|
||||
#include "string-util.h"
|
||||
|
||||
static const char* const ipvlan_mode_table[_NETDEV_IPVLAN_MODE_MAX] = {
|
||||
[NETDEV_IPVLAN_MODE_L2] = "L2",
|
||||
[NETDEV_IPVLAN_MODE_L3] = "L3",
|
||||
[NETDEV_IPVLAN_MODE_L3S] = "L3S",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(ipvlan_mode, IPVlanMode);
|
||||
DEFINE_CONFIG_PARSE_ENUM(config_parse_ipvlan_mode, ipvlan_mode, IPVlanMode, "Failed to parse ipvlan mode");
|
||||
|
||||
static const char* const ipvlan_flags_table[_NETDEV_IPVLAN_FLAGS_MAX] = {
|
||||
[NETDEV_IPVLAN_FLAGS_BRIGDE] = "bridge",
|
||||
[NETDEV_IPVLAN_FLAGS_PRIVATE] = "private",
|
||||
[NETDEV_IPVLAN_FLAGS_VEPA] = "vepa",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(ipvlan_flags, IPVlanFlags);
|
||||
DEFINE_CONFIG_PARSE_ENUM(config_parse_ipvlan_flags, ipvlan_flags, IPVlanFlags, "Failed to parse ipvlan flags");
|
||||
|
||||
static int netdev_ipvlan_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *req) {
|
||||
|
|
|
@ -4,24 +4,9 @@
|
|||
#include <netinet/in.h>
|
||||
#include <linux/if_link.h>
|
||||
|
||||
#include "ipvlan-util.h"
|
||||
#include "netdev.h"
|
||||
|
||||
typedef enum IPVlanMode {
|
||||
NETDEV_IPVLAN_MODE_L2 = IPVLAN_MODE_L2,
|
||||
NETDEV_IPVLAN_MODE_L3 = IPVLAN_MODE_L3,
|
||||
NETDEV_IPVLAN_MODE_L3S = IPVLAN_MODE_L3S,
|
||||
_NETDEV_IPVLAN_MODE_MAX,
|
||||
_NETDEV_IPVLAN_MODE_INVALID = -1
|
||||
} IPVlanMode;
|
||||
|
||||
typedef enum IPVlanFlags {
|
||||
NETDEV_IPVLAN_FLAGS_BRIGDE,
|
||||
NETDEV_IPVLAN_FLAGS_PRIVATE = IPVLAN_F_PRIVATE,
|
||||
NETDEV_IPVLAN_FLAGS_VEPA = IPVLAN_F_VEPA,
|
||||
_NETDEV_IPVLAN_FLAGS_MAX,
|
||||
_NETDEV_IPVLAN_FLAGS_INVALID = -1
|
||||
} IPVlanFlags;
|
||||
|
||||
typedef struct IPVlan {
|
||||
NetDev meta;
|
||||
|
||||
|
@ -34,12 +19,6 @@ DEFINE_NETDEV_CAST(IPVTAP, IPVlan);
|
|||
extern const NetDevVTable ipvlan_vtable;
|
||||
extern const NetDevVTable ipvtap_vtable;
|
||||
|
||||
const char *ipvlan_mode_to_string(IPVlanMode d) _const_;
|
||||
IPVlanMode ipvlan_mode_from_string(const char *d) _pure_;
|
||||
|
||||
const char *ipvlan_flags_to_string(IPVlanFlags d) _const_;
|
||||
IPVlanFlags ipvlan_flags_from_string(const char *d) _pure_;
|
||||
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_ipvlan_mode);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_ipvlan_flags);
|
||||
|
||||
|
|
22
src/shared/ipvlan-util.c
Normal file
22
src/shared/ipvlan-util.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include <net/if.h>
|
||||
|
||||
#include "ipvlan-util.h"
|
||||
#include "string-table.h"
|
||||
|
||||
static const char* const ipvlan_mode_table[_NETDEV_IPVLAN_MODE_MAX] = {
|
||||
[NETDEV_IPVLAN_MODE_L2] = "L2",
|
||||
[NETDEV_IPVLAN_MODE_L3] = "L3",
|
||||
[NETDEV_IPVLAN_MODE_L3S] = "L3S",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(ipvlan_mode, IPVlanMode);
|
||||
|
||||
static const char* const ipvlan_flags_table[_NETDEV_IPVLAN_FLAGS_MAX] = {
|
||||
[NETDEV_IPVLAN_FLAGS_BRIGDE] = "bridge",
|
||||
[NETDEV_IPVLAN_FLAGS_PRIVATE] = "private",
|
||||
[NETDEV_IPVLAN_FLAGS_VEPA] = "vepa",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(ipvlan_flags, IPVlanFlags);
|
29
src/shared/ipvlan-util.h
Normal file
29
src/shared/ipvlan-util.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <linux/if_link.h>
|
||||
|
||||
#include "macro.h"
|
||||
|
||||
typedef enum IPVlanMode {
|
||||
NETDEV_IPVLAN_MODE_L2 = IPVLAN_MODE_L2,
|
||||
NETDEV_IPVLAN_MODE_L3 = IPVLAN_MODE_L3,
|
||||
NETDEV_IPVLAN_MODE_L3S = IPVLAN_MODE_L3S,
|
||||
_NETDEV_IPVLAN_MODE_MAX,
|
||||
_NETDEV_IPVLAN_MODE_INVALID = -1
|
||||
} IPVlanMode;
|
||||
|
||||
typedef enum IPVlanFlags {
|
||||
NETDEV_IPVLAN_FLAGS_BRIGDE,
|
||||
NETDEV_IPVLAN_FLAGS_PRIVATE = IPVLAN_F_PRIVATE,
|
||||
NETDEV_IPVLAN_FLAGS_VEPA = IPVLAN_F_VEPA,
|
||||
_NETDEV_IPVLAN_FLAGS_MAX,
|
||||
_NETDEV_IPVLAN_FLAGS_INVALID = -1
|
||||
} IPVlanFlags;
|
||||
|
||||
const char *ipvlan_mode_to_string(IPVlanMode d) _const_;
|
||||
IPVlanMode ipvlan_mode_from_string(const char *d) _pure_;
|
||||
|
||||
const char *ipvlan_flags_to_string(IPVlanFlags d) _const_;
|
||||
IPVlanFlags ipvlan_flags_from_string(const char *d) _pure_;
|
|
@ -118,6 +118,8 @@ shared_sources = files('''
|
|||
install-printf.h
|
||||
install.c
|
||||
install.h
|
||||
ipvlan-util.c
|
||||
ipvlan-util.h
|
||||
ip-protocol-list.c
|
||||
ip-protocol-list.h
|
||||
journal-importer.c
|
||||
|
|
Loading…
Reference in a new issue