1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
4 #include <netinet/in.h>
5 #include <linux/if_arp.h>
7 #include "conf-parser.h"
9 #include "ipvlan-util.h"
10 #include "networkd-link.h"
11 #include "string-util.h"
13 DEFINE_CONFIG_PARSE_ENUM(config_parse_ipvlan_mode
, ipvlan_mode
, IPVlanMode
, "Failed to parse ipvlan mode");
14 DEFINE_CONFIG_PARSE_ENUM(config_parse_ipvlan_flags
, ipvlan_flags
, IPVlanFlags
, "Failed to parse ipvlan flags");
16 static int netdev_ipvlan_fill_message_create(NetDev
*netdev
, Link
*link
, sd_netlink_message
*req
) {
22 assert(netdev
->ifname
);
24 if (netdev
->kind
== NETDEV_KIND_IPVLAN
)
31 if (m
->mode
!= _NETDEV_IPVLAN_MODE_INVALID
) {
32 r
= sd_netlink_message_append_u16(req
, IFLA_IPVLAN_MODE
, m
->mode
);
37 if (m
->flags
!= _NETDEV_IPVLAN_FLAGS_INVALID
) {
38 r
= sd_netlink_message_append_u16(req
, IFLA_IPVLAN_FLAGS
, m
->flags
);
46 static void ipvlan_init(NetDev
*n
) {
51 if (n
->kind
== NETDEV_KIND_IPVLAN
)
58 m
->mode
= _NETDEV_IPVLAN_MODE_INVALID
;
59 m
->flags
= _NETDEV_IPVLAN_FLAGS_INVALID
;
62 const NetDevVTable ipvlan_vtable
= {
63 .object_size
= sizeof(IPVlan
),
65 .sections
= NETDEV_COMMON_SECTIONS
"IPVLAN\0",
66 .fill_message_create
= netdev_ipvlan_fill_message_create
,
67 .create_type
= NETDEV_CREATE_STACKED
,
68 .iftype
= ARPHRD_ETHER
,
72 const NetDevVTable ipvtap_vtable
= {
73 .object_size
= sizeof(IPVlan
),
75 .sections
= NETDEV_COMMON_SECTIONS
"IPVTAP\0",
76 .fill_message_create
= netdev_ipvlan_fill_message_create
,
77 .create_type
= NETDEV_CREATE_STACKED
,
78 .iftype
= ARPHRD_ETHER
,
82 IPVlanMode
link_get_ipvlan_mode(Link
*link
) {
87 ipvlan
= IPVLAN(link
->netdev
);
89 return _NETDEV_IPVLAN_MODE_INVALID
;