1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright (C) 2013 Tom Gundersen <teg@jklm.no>
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.
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.
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/>.
22 #include <netinet/ether.h>
29 #include "conf-parser.h"
31 bool net_match_config(const struct ether_addr *match_mac,
32 const char *match_path,
33 const char *match_driver,
34 const char *match_type,
35 const char *match_name,
38 const char *dev_driver,
40 const char *dev_name) {
43 if (!dev_mac || memcmp(match_mac, ether_aton(dev_mac), ETH_ALEN)) {
44 log_debug("Interface MAC address (%s) did not match MACAddress=%s",
45 dev_mac, ether_ntoa(match_mac));
51 if (!streq_ptr(match_path, dev_path)) {
52 log_debug("Interface persistent path (%s) did not match Path=%s",
53 dev_path, match_path);
59 if (!streq_ptr(match_driver, dev_driver)) {
60 log_debug("Interface device driver (%s) did not match Driver=%s",
61 dev_driver, match_driver);
67 if (!streq_ptr(match_type, dev_type)) {
68 log_debug("Interface type (%s) did not match Type=%s",
69 dev_type, match_type);
75 if (!streq_ptr(match_name, dev_name)) {
76 log_debug("Interface name (%s) did not match Name=%s",
77 dev_name, match_name);
85 int config_parse_ifname(const char *unit,
107 if (!ascii_is_valid(n) || strlen(n) >= IFNAMSIZ) {
108 log_syntax(unit, LOG_ERR, filename, line, EINVAL,
109 "Interface name is not ASCII clean or is too long, ignoring assignment: %s", rvalue);
125 int config_parse_hwaddr(const char *unit,
126 const char *filename,
134 struct ether_addr **hwaddr = data;
135 struct ether_addr *n;
143 n = new0(struct ether_addr, 1);
147 r = sscanf(rvalue, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
148 &n->ether_addr_octet[0],
149 &n->ether_addr_octet[1],
150 &n->ether_addr_octet[2],
151 &n->ether_addr_octet[3],
152 &n->ether_addr_octet[4],
153 &n->ether_addr_octet[5]);
155 log_syntax(unit, LOG_ERR, filename, line, EINVAL,
156 "Not a valid MAC address, ignoring assignment: %s", rvalue);