blob: 94c8eaebc3754289e48667f4fbb2519a5c70085c [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
Michael Tritz29f2fd62017-05-22 15:27:26 -05005#include <fstream>
6#include <string>
7
8namespace phosphor
9{
10namespace network
11{
12
13namespace bmc
14{
Gunnar Mills57d9c502018-09-14 14:42:34 -050015void writeDHCPDefault(const std::string& filename, const std::string& interface)
16{
17 std::ofstream filestream;
Michael Tritz29f2fd62017-05-22 15:27:26 -050018
Gunnar Mills57d9c502018-09-14 14:42:34 -050019 filestream.open(filename);
Johnathan Mantey200678a2021-04-28 13:59:46 -070020 // Add the following line to your phosphor-network bbappend file
21 // to control IPV6_ACCEPT_RA
22 // EXTRA_OECONF_append = " --enable-ipv6-accept-ra=yes"
23 // If this switch is not present or set to 'no'
24 // ENABLE_IPV6_ACCEPT_RA will be undefined.
25 // The new value is only assigned on first boot, when the default
26 // file is not present, or after the default file has been
27 // manually removed.
Gunnar Mills57d9c502018-09-14 14:42:34 -050028 filestream << "[Match]\nName=" << interface <<
Oskar Senftad21fc22018-07-26 16:32:23 -040029 "\n[Network]\nDHCP=true\n"
30#ifdef LINK_LOCAL_AUTOCONFIGURATION
31 "LinkLocalAddressing=yes\n"
32#else
33 "LinkLocalAddressing=no\n"
34#endif
Johnathan Mantey200678a2021-04-28 13:59:46 -070035#ifdef ENABLE_IPV6_ACCEPT_RA
36 "IPv6AcceptRA=true\n"
37#else
Ratan Guptae9629412017-12-21 08:20:25 +053038 "IPv6AcceptRA=false\n"
Johnathan Mantey200678a2021-04-28 13:59:46 -070039
40#endif
Ratan Guptac35481d2017-08-18 06:12:26 +053041 "[DHCP]\nClientIdentifier=mac\n";
Gunnar Mills57d9c502018-09-14 14:42:34 -050042 filestream.close();
Michael Tritz29f2fd62017-05-22 15:27:26 -050043}
Gunnar Mills57d9c502018-09-14 14:42:34 -050044} // namespace bmc
Michael Tritz29f2fd62017-05-22 15:27:26 -050045
Gunnar Mills57d9c502018-09-14 14:42:34 -050046} // namespace network
47} // namespace phosphor