AnCH Framework  0.1
Another C++ Hack Framework
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
networkInterface.hpp
1 /*
2  ANCH Framework: ANother C++ Hack is a C++ framework based on C++11 standard
3  Copyright (C) 2012 Vincent Lachenal
4 
5  This file is part of ANCH Framework.
6 
7  ANCH Framework is free software: you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  ANCH Framework is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with ANCH Framework. If not, see <http://www.gnu.org/licenses/>.
19 */
20 #ifndef _ANCH_DEVICE_NETWORK_INTERFACE_H_
21 #define _ANCH_DEVICE_NETWORK_INTERFACE_H_
22 
23 #include <iostream>
24 
25 #include <net/if.h>
26 
27 #include "device/deviceException.hpp"
28 
29 
30 namespace anch {
31  namespace device {
32 
39  private:
40  // Attributes +
42  std::string _name;
43 
45  std::string _ipAddress;
46 
48  std::string _macAddress;
49 
51  std::string _broadcastAddress;
52 
54  std::string _netmask;
55 
57  int _mtu;
58 
60  int _metric;
61 
63  bool _localhost;
64  // Attributes -
65 
66  public:
67  // Constructor +
76  NetworkInterface(const struct ifreq& interface, bool isLocalhost)
78  // Constructor -
79 
80  // Destructor +
84  virtual ~NetworkInterface();
85  // Destructor -
86 
87  public:
88  // Accessors +
94  inline const std::string& getName() const {
95  return _name;
96  }
97 
103  inline const std::string& getIpAddress() const {
104  return _ipAddress;
105  }
106 
112  inline const std::string& getMacAddress() const {
113  return _macAddress;
114  }
115 
121  inline const std::string& getBroadcastAddress() const {
122  return _broadcastAddress;
123  }
124 
130  inline const std::string& getNetmask() const {
131  return _netmask;
132  }
133 
139  inline int getMtu() const {
140  return _mtu;
141  }
142 
148  inline int getMetric() const {
149  return _metric;
150  }
151 
157  inline bool isLocalhost() const {
158  return _localhost;
159  }
160  // Accessors -
161 
162  };
163 
164  }
165 }
166 
167 #endif // _ANCH_DEVICE_NETWORK_INTERFACE_H_
Definition: networkInterface.hpp:38
const std::string & getMacAddress() const
Definition: networkInterface.hpp:112
const std::string & getBroadcastAddress() const
Definition: networkInterface.hpp:121
int getMetric() const
Definition: networkInterface.hpp:148
const std::string & getNetmask() const
Definition: networkInterface.hpp:130
Definition: deviceException.hpp:34
AnCH framework base namespace.
Definition: base64.hpp:28
const std::string & getName() const
Definition: networkInterface.hpp:94
bool isLocalhost() const
Definition: networkInterface.hpp:157
virtual ~NetworkInterface()
Definition: networkInterface.cpp:122
int getMtu() const
Definition: networkInterface.hpp:139
const std::string & getIpAddress() const
Definition: networkInterface.hpp:103
NetworkInterface(const struct ifreq &interface, bool isLocalhost)
Definition: networkInterface.cpp:43