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