]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/network/netdev/ipvlan.c
Merge pull request #7388 from keszybz/doc-tweak
[thirdparty/systemd.git] / src / network / netdev / ipvlan.c
1 /***
2 This file is part of systemd.
3
4 Copyright 2013-2015 Tom Gundersen <teg@jklm.no>
5
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
10
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
18 ***/
19
20 #include <net/if.h>
21
22 #include "conf-parser.h"
23 #include "netdev/ipvlan.h"
24 #include "string-table.h"
25
26 static const char* const ipvlan_mode_table[_NETDEV_IPVLAN_MODE_MAX] = {
27 [NETDEV_IPVLAN_MODE_L2] = "L2",
28 [NETDEV_IPVLAN_MODE_L3] = "L3",
29 };
30
31 DEFINE_STRING_TABLE_LOOKUP(ipvlan_mode, IPVlanMode);
32 DEFINE_CONFIG_PARSE_ENUM(config_parse_ipvlan_mode, ipvlan_mode, IPVlanMode, "Failed to parse ipvlan mode");
33
34 static int netdev_ipvlan_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *req) {
35 IPVlan *m;
36 int r;
37
38 assert(netdev);
39 assert(link);
40 assert(netdev->ifname);
41
42 m = IPVLAN(netdev);
43
44 assert(m);
45
46 if (m->mode != _NETDEV_IPVLAN_MODE_INVALID) {
47 r = sd_netlink_message_append_u16(req, IFLA_IPVLAN_MODE, m->mode);
48 if (r < 0)
49 return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPVLAN_MODE attribute: %m");
50 }
51
52 return 0;
53 }
54
55 static void ipvlan_init(NetDev *n) {
56 IPVlan *m;
57
58 assert(n);
59
60 m = IPVLAN(n);
61
62 assert(m);
63
64 m->mode = _NETDEV_IPVLAN_MODE_INVALID;
65 }
66
67 const NetDevVTable ipvlan_vtable = {
68 .object_size = sizeof(IPVlan),
69 .init = ipvlan_init,
70 .sections = "Match\0NetDev\0IPVLAN\0",
71 .fill_message_create = netdev_ipvlan_fill_message_create,
72 .create_type = NETDEV_CREATE_STACKED,
73 };