blob: a2620a49c420e9adf8f7252d9a3ed3dcbc80b14c [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
sunharisa91c6542022-04-05 05:59:18 -050041 "[DHCP]\nClientIdentifier=mac\n"
42 "UseDNS=true\nUseDomains=true\n"
43 "UseNTP=true\nUseHostname=true\n"
44 "SendHostname=true\n";
45
Gunnar Mills57d9c502018-09-14 14:42:34 -050046 filestream.close();
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