blob: 249be5810ed7dd1a2857fa8c554b53a913bd2cb9 [file] [log] [blame]
Patrick Venture189d44e2018-07-09 12:30:59 -07001#include "config.h"
2
Gunnar Mills57d9c502018-09-14 14:42:34 -05003#include "network_config.hpp"
4
William A. Kennington III87f68132022-08-21 02:20:43 -07005#include "config_parser.hpp"
Michael Tritz29f2fd62017-05-22 15:27:26 -05006
7namespace phosphor
8{
9namespace network
10{
11
12namespace bmc
13{
William A. Kennington III87f68132022-08-21 02:20:43 -070014void writeDHCPDefault(const std::filesystem::path& filename,
15 std::string_view interface)
Gunnar Mills57d9c502018-09-14 14:42:34 -050016{
William A. Kennington III87f68132022-08-21 02:20:43 -070017 config::Parser config;
18 config.map["Match"].emplace_back()["Name"].emplace_back(interface);
19 {
20 auto& network = config.map["Network"].emplace_back();
21 network["DHCP"].emplace_back("true");
22 auto& lla = network["LinkLocalAddressing"];
Oskar Senftad21fc22018-07-26 16:32:23 -040023#ifdef LINK_LOCAL_AUTOCONFIGURATION
William A. Kennington III87f68132022-08-21 02:20:43 -070024 lla.emplace_back("true");
Oskar Senftad21fc22018-07-26 16:32:23 -040025#else
William A. Kennington III87f68132022-08-21 02:20:43 -070026 lla.emplace_back("false");
Oskar Senftad21fc22018-07-26 16:32:23 -040027#endif
William A. Kennington III87f68132022-08-21 02:20:43 -070028 auto& ra = network["IPv6AcceptRA"];
Johnathan Mantey200678a2021-04-28 13:59:46 -070029#ifdef ENABLE_IPV6_ACCEPT_RA
William A. Kennington III87f68132022-08-21 02:20:43 -070030 ra.emplace_back("true");
Johnathan Mantey200678a2021-04-28 13:59:46 -070031#else
William A. Kennington III87f68132022-08-21 02:20:43 -070032 ra.emplace_back("false");
Johnathan Mantey200678a2021-04-28 13:59:46 -070033#endif
William A. Kennington III87f68132022-08-21 02:20:43 -070034 }
35 {
36 auto& dhcp = config.map["DHCP"].emplace_back();
37 dhcp["ClientIdentifier"].emplace_back("mac");
38 dhcp["UseDNS"].emplace_back("true");
39 dhcp["UseDomains"].emplace_back("true");
40 dhcp["UseNTP"].emplace_back("true");
41 dhcp["UseHostname"].emplace_back("true");
42 dhcp["SendHostname"].emplace_back("true");
43 }
44 config.map["IPv6AcceptRA"].emplace_back()["DHCPv6Client"].emplace_back(
45 "true");
46 config.writeFile(filename);
Michael Tritz29f2fd62017-05-22 15:27:26 -050047}
Gunnar Mills57d9c502018-09-14 14:42:34 -050048} // namespace bmc
Michael Tritz29f2fd62017-05-22 15:27:26 -050049
Gunnar Mills57d9c502018-09-14 14:42:34 -050050} // namespace network
51} // namespace phosphor