summaryrefslogtreecommitdiffstats
path: root/dns_updater.hpp
blob: 84646c6a6d7ace678308e9f3a01a1df70bda6998 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once

#include <experimental/filesystem>

namespace phosphor
{
namespace network
{
namespace dns
{
namespace updater
{

namespace fs = std::experimental::filesystem;

constexpr auto RESOLV_CONF = "/etc/resolv.conf";

/** @brief Reads DNS entries supplied by DHCP and updates specified file
 *
 *  @param[in] inFile  - File having DNS entries supplied by DHCP
 *  @param[in] outFile - File to write the nameserver entries to
 */
void updateDNSEntries(const fs::path& inFile,
                      const fs::path& outFile);

/** @brief User callback handler invoked by inotify watcher
 *
 *  Needed to enable production and test code so that the right
 *  callback functions could be implemented
 *
 *  @param[in] inFile - File having DNS entries supplied by DHCP
 */
inline void processDNSEntries(const fs::path& inFile)
{
    return updateDNSEntries(inFile, RESOLV_CONF);
}

} // namepsace updater
} // namepsace dns
} // namespace network
} // namespace phosphor
OpenPOWER on IntegriCloud