]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/network/networkd-conf.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 Copyright © 2014 Vinay Kulkarni <kulkarniv@vmware.com>
8 #include "conf-parser.h"
10 #include "dhcp-identifier.h"
11 #include "extract-word.h"
12 #include "hexdecoct.h"
13 #include "networkd-conf.h"
14 #include "networkd-network.h"
15 #include "string-table.h"
17 int manager_parse_config_file(Manager
*m
) {
20 return config_parse_many_nulstr(PKGSYSCONFDIR
"/networkd.conf",
21 CONF_PATHS_NULSTR("systemd/networkd.conf.d"),
23 config_item_perf_lookup
, networkd_gperf_lookup
,
24 CONFIG_PARSE_WARN
, m
);
27 static const char* const duid_type_table
[_DUID_TYPE_MAX
] = {
28 [DUID_TYPE_LLT
] = "link-layer-time",
29 [DUID_TYPE_EN
] = "vendor",
30 [DUID_TYPE_LL
] = "link-layer",
31 [DUID_TYPE_UUID
] = "uuid",
33 DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(duid_type
, DUIDType
);
34 DEFINE_CONFIG_PARSE_ENUM(config_parse_duid_type
, duid_type
, DUIDType
, "Failed to parse DUID type");
36 int config_parse_duid_rawdata(
41 unsigned section_line
,
49 uint8_t raw_data
[MAX_DUID_LEN
];
57 /* RawData contains DUID in format "NN:NN:NN..." */
61 _cleanup_free_
char *cbyte
= NULL
;
63 r
= extract_first_word(&rvalue
, &cbyte
, ":", 0);
65 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to read DUID, ignoring assignment: %s.", rvalue
);
70 if (count
>= MAX_DUID_LEN
) {
71 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Max DUID length exceeded, ignoring assignment: %s.", rvalue
);
76 if (!IN_SET(len
, 1, 2)) {
77 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Invalid length - DUID byte: %s, ignoring assignment: %s.", cbyte
, rvalue
);
80 n1
= unhexchar(cbyte
[0]);
82 n2
= unhexchar(cbyte
[1]);
86 if (n1
< 0 || n2
< 0) {
87 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Invalid DUID byte: %s. Ignoring assignment: %s.", cbyte
, rvalue
);
91 byte
= ((uint8_t) n1
<< (4 * (len
-1))) | (uint8_t) n2
;
92 raw_data
[count
++] = byte
;
95 assert_cc(sizeof(raw_data
) == sizeof(ret
->raw_data
));
96 memcpy(ret
->raw_data
, raw_data
, count
);
97 ret
->raw_data_len
= count
;