]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/vlan-util.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 This file is part of systemd.
5 Copyright 2016 Lennart Poettering
7 systemd is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 2.1 of the License, or
10 (at your option) any later version.
12 systemd is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public License
18 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21 #include "conf-parser.h"
22 #include "parse-util.h"
23 #include "string-util.h"
24 #include "vlan-util.h"
26 int parse_vlanid(const char *p
, uint16_t *ret
) {
30 r
= safe_atou16(p
, &id
);
33 if (!vlanid_is_valid(id
))
40 int config_parse_default_port_vlanid(
45 unsigned section_line
,
57 if (streq(rvalue
, "none")) {
62 return config_parse_vlanid(unit
, filename
, line
, section
, section_line
,
63 lvalue
, ltype
, rvalue
, data
, userdata
);
66 int config_parse_vlanid(
71 unsigned section_line
,
86 r
= parse_vlanid(rvalue
, id
);
88 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "VLAN identifier outside of valid range 0…4094, ignoring: %s", rvalue
);
92 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse VLAN identifier value, ignoring: %s", rvalue
);