Patrick Venture | 189d44e | 2018-07-09 12:30:59 -0700 | [diff] [blame] | 1 | #include "config.h" |
| 2 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 3 | #include "network_config.hpp" |
| 4 | |
William A. Kennington III | 87f6813 | 2022-08-21 02:20:43 -0700 | [diff] [blame] | 5 | #include "config_parser.hpp" |
Michael Tritz | 29f2fd6 | 2017-05-22 15:27:26 -0500 | [diff] [blame] | 6 | |
| 7 | namespace phosphor |
| 8 | { |
| 9 | namespace network |
| 10 | { |
| 11 | |
| 12 | namespace bmc |
| 13 | { |
William A. Kennington III | 87f6813 | 2022-08-21 02:20:43 -0700 | [diff] [blame] | 14 | void writeDHCPDefault(const std::filesystem::path& filename, |
| 15 | std::string_view interface) |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 16 | { |
William A. Kennington III | 87f6813 | 2022-08-21 02:20:43 -0700 | [diff] [blame] | 17 | 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 Senft | ad21fc2 | 2018-07-26 16:32:23 -0400 | [diff] [blame] | 23 | #ifdef LINK_LOCAL_AUTOCONFIGURATION |
William A. Kennington III | 87f6813 | 2022-08-21 02:20:43 -0700 | [diff] [blame] | 24 | lla.emplace_back("true"); |
Oskar Senft | ad21fc2 | 2018-07-26 16:32:23 -0400 | [diff] [blame] | 25 | #else |
William A. Kennington III | 87f6813 | 2022-08-21 02:20:43 -0700 | [diff] [blame] | 26 | lla.emplace_back("false"); |
Oskar Senft | ad21fc2 | 2018-07-26 16:32:23 -0400 | [diff] [blame] | 27 | #endif |
William A. Kennington III | 87f6813 | 2022-08-21 02:20:43 -0700 | [diff] [blame] | 28 | auto& ra = network["IPv6AcceptRA"]; |
Johnathan Mantey | 200678a | 2021-04-28 13:59:46 -0700 | [diff] [blame] | 29 | #ifdef ENABLE_IPV6_ACCEPT_RA |
William A. Kennington III | 87f6813 | 2022-08-21 02:20:43 -0700 | [diff] [blame] | 30 | ra.emplace_back("true"); |
Johnathan Mantey | 200678a | 2021-04-28 13:59:46 -0700 | [diff] [blame] | 31 | #else |
William A. Kennington III | 87f6813 | 2022-08-21 02:20:43 -0700 | [diff] [blame] | 32 | ra.emplace_back("false"); |
Johnathan Mantey | 200678a | 2021-04-28 13:59:46 -0700 | [diff] [blame] | 33 | #endif |
William A. Kennington III | 87f6813 | 2022-08-21 02:20:43 -0700 | [diff] [blame] | 34 | } |
| 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 Tritz | 29f2fd6 | 2017-05-22 15:27:26 -0500 | [diff] [blame] | 47 | } |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 48 | } // namespace bmc |
Michael Tritz | 29f2fd6 | 2017-05-22 15:27:26 -0500 | [diff] [blame] | 49 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 50 | } // namespace network |
| 51 | } // namespace phosphor |