Leosac  0.8.0
Open Source Access Control
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
Leosac::NetworkConfig::reload
void reload()
Definition: networkconfig.cpp:64
Leosac::NetworkConfig::_ip
std::string _ip
Definition: networkconfig.hpp:72
Leosac::NetworkConfig::_netmask
std::string _netmask
Definition: networkconfig.hpp:71
Leosac::NetworkConfig::operator=
NetworkConfig & operator=(const NetworkConfig &other)=delete
Leosac::NetworkConfig::config_
boost::property_tree::ptree config_
Network configuration.
Definition: networkconfig.hpp:66
Leosac::NetworkConfig::~NetworkConfig
~NetworkConfig()=default
Leosac::NetworkConfig::setDHCP
void setDHCP(bool enabled)
Definition: networkconfig.cpp:88
Leosac::NetworkConfig::setEnabled
void setEnabled(bool state)
Definition: networkconfig.cpp:83
Leosac::NetworkConfig::_enabled
bool _enabled
Definition: networkconfig.hpp:68
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::NetworkConfig
Class that helps configuring the network.
Definition: networkconfig.hpp:40
Leosac::NetworkConfig::NetCfgFile
static constexpr const char * NetCfgFile
Definition: networkconfig.hpp:42
Leosac::NetworkConfig::setCustomIP
void setCustomIP(bool enabled)
Definition: networkconfig.cpp:98
Leosac::Kernel
Core of Leosac.
Definition: kernel.hpp:73
Leosac::NetworkConfig::NetworkConfig
NetworkConfig(const Kernel &k, const boost::property_tree::ptree &cfg)
Definition: networkconfig.cpp:35
Leosac::NetworkConfig::_defaultIp
std::string _defaultIp
Definition: networkconfig.hpp:73
Leosac::NetworkConfig::_dhcpEnabled
bool _dhcpEnabled
Definition: networkconfig.hpp:70
Leosac::NetworkConfig::_gateway
std::string _gateway
Definition: networkconfig.hpp:74
Leosac::NetworkConfig::kernel_
const Kernel & kernel_
Definition: networkconfig.hpp:76
Leosac::NetworkConfig::_interface
std::string _interface
Definition: networkconfig.hpp:69