]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/network/networkd-conf.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 This file is part of systemd.
5 Copyright 2014 Vinay Kulkarni <kulkarniv@vmware.com>
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/>.
23 #include "conf-parser.h"
25 #include "dhcp-identifier.h"
26 #include "extract-word.h"
27 #include "hexdecoct.h"
28 #include "networkd-conf.h"
29 #include "networkd-network.h"
30 #include "string-table.h"
32 int manager_parse_config_file(Manager
*m
) {
35 return config_parse_many_nulstr(PKGSYSCONFDIR
"/networkd.conf",
36 CONF_PATHS_NULSTR("systemd/networkd.conf.d"),
38 config_item_perf_lookup
, networkd_gperf_lookup
,
39 CONFIG_PARSE_WARN
, m
);
42 static const char* const duid_type_table
[_DUID_TYPE_MAX
] = {
43 [DUID_TYPE_LLT
] = "link-layer-time",
44 [DUID_TYPE_EN
] = "vendor",
45 [DUID_TYPE_LL
] = "link-layer",
46 [DUID_TYPE_UUID
] = "uuid",
48 DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(duid_type
, DUIDType
);
49 DEFINE_CONFIG_PARSE_ENUM(config_parse_duid_type
, duid_type
, DUIDType
, "Failed to parse DUID type");
51 int config_parse_duid_rawdata(
56 unsigned section_line
,
64 uint8_t raw_data
[MAX_DUID_LEN
];
72 /* RawData contains DUID in format "NN:NN:NN..." */
76 _cleanup_free_
char *cbyte
= NULL
;
78 r
= extract_first_word(&rvalue
, &cbyte
, ":", 0);
80 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to read DUID, ignoring assignment: %s.", rvalue
);
85 if (count
>= MAX_DUID_LEN
) {
86 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Max DUID length exceeded, ignoring assignment: %s.", rvalue
);
91 if (!IN_SET(len
, 1, 2)) {
92 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Invalid length - DUID byte: %s, ignoring assignment: %s.", cbyte
, rvalue
);
95 n1
= unhexchar(cbyte
[0]);
97 n2
= unhexchar(cbyte
[1]);
101 if (n1
< 0 || n2
< 0) {
102 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Invalid DUID byte: %s. Ignoring assignment: %s.", cbyte
, rvalue
);
106 byte
= ((uint8_t) n1
<< (4 * (len
-1))) | (uint8_t) n2
;
107 raw_data
[count
++] = byte
;
110 assert_cc(sizeof(raw_data
) == sizeof(ret
->raw_data
));
111 memcpy(ret
->raw_data
, raw_data
, count
);
112 ret
->raw_data_len
= count
;