1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 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 "conf-parser.h"
23 #include "networkd-util.h"
24 #include "parse-util.h"
25 #include "string-table.h"
26 #include "string-util.h"
29 const char *address_family_boolean_to_string(AddressFamilyBoolean b
) {
30 if (b
== ADDRESS_FAMILY_YES
||
31 b
== ADDRESS_FAMILY_NO
)
32 return yes_no(b
== ADDRESS_FAMILY_YES
);
34 if (b
== ADDRESS_FAMILY_IPV4
)
36 if (b
== ADDRESS_FAMILY_IPV6
)
42 AddressFamilyBoolean
address_family_boolean_from_string(const char *s
) {
45 /* Make this a true superset of a boolean */
49 return ADDRESS_FAMILY_YES
;
51 return ADDRESS_FAMILY_NO
;
54 return ADDRESS_FAMILY_IPV4
;
56 return ADDRESS_FAMILY_IPV6
;
58 return _ADDRESS_FAMILY_BOOLEAN_INVALID
;
61 DEFINE_CONFIG_PARSE_ENUM(config_parse_address_family_boolean
, address_family_boolean
, AddressFamilyBoolean
, "Failed to parse option");
63 int config_parse_address_family_boolean_with_kernel(
68 unsigned section_line
,
75 AddressFamilyBoolean
*fwd
= data
, s
;
82 /* This function is mostly obsolete now. It simply redirects
83 * "kernel" to "no". In older networkd versions we used to
84 * distuingish IPForward=off from IPForward=kernel, where the
85 * former would explicitly turn off forwarding while the
86 * latter would simply not touch the setting. But that logic
87 * is gone, hence silently accept the old setting, but turn it
90 s
= address_family_boolean_from_string(rvalue
);
92 if (streq(rvalue
, "kernel"))
93 s
= ADDRESS_FAMILY_NO
;
95 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Failed to parse IPForward= option, ignoring: %s", rvalue
);