Leosac  0.7.0
OpenSourceAccessControl
networkconfig.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014-2016 Leosac
3 
4  This file is part of Leosac.
5 
6  Leosac is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Affero General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Leosac is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Affero General Public License for more details.
15 
16  You should have received a copy of the GNU Affero General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
26 #include <boost/property_tree/ptree.hpp>
27 
28 #ifndef NETWORKCONFIG_HPP
29 #define NETWORKCONFIG_HPP
30 
31 namespace Leosac
32 {
33 class Kernel;
34 
41 {
42  static constexpr const char *NetCfgFile = "interfaces";
43 
44  public:
45  explicit NetworkConfig(const Kernel &k, const boost::property_tree::ptree &cfg);
46 
47  ~NetworkConfig() = default;
48 
49  NetworkConfig(const NetworkConfig &other) = delete;
50 
51  NetworkConfig &operator=(const NetworkConfig &other) = delete;
52 
53  public:
54  void reload();
55 
56  void setEnabled(bool state);
57 
58  void setDHCP(bool enabled);
59 
60  void setCustomIP(bool enabled);
61 
62  private:
66  boost::property_tree::ptree config_;
67 
68  bool _enabled;
69  std::string _interface;
71  std::string _netmask;
72  std::string _ip;
73  std::string _defaultIp;
74  std::string _gateway;
75 
76  const Kernel &kernel_;
77 };
78 }
79 
80 #endif // NETWORKCONFIG_HPP
This is the header file for a generated source file, GitSHA1.cpp.
static constexpr const char * NetCfgFile
Class that helps configuring the network.
void setEnabled(bool state)
Core of Leosac.
Definition: kernel.hpp:73
boost::property_tree::ptree config_
Network configuration.
void setDHCP(bool enabled)
const Kernel & kernel_
void setCustomIP(bool enabled)
NetworkConfig(const Kernel &k, const boost::property_tree::ptree &cfg)
NetworkConfig & operator=(const NetworkConfig &other)=delete