hwsd  1.1.1
 All Classes Files Functions Variables Enumerations Enumerator Pages
netInfo.h
1 
2 /* Copyright (c) 2012, Daniel Nachbaur <danielnachbaur@gmail.com>
3  * 2013, Stefan.Eilemann@epfl.ch
4  *
5  * This library is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU Lesser General Public License version 2.1 as published
7  * by the Free Software Foundation.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef HWSD_NETINFO_H
20 #define HWSD_NETINFO_H
21 
22 #include <hwsd/api.h>
23 #include <hwsd/nodeInfo.h> // base class
24 
25 #include <lunchbox/debug.h>
26 #include <climits>
27 #include <ostream>
28 
29 namespace hwsd
30 {
32 struct NetInfo : public NodeInfo
33 {
34  enum Type
35  {
36  TYPE_ETHERNET = LB_BIT1,
37  TYPE_INFINIBAND = LB_BIT2,
38  TYPE_LOOPBACK = LB_BIT3,
40  TYPE_TUNNEL_6TO4 = LB_BIT5,
41  TYPE_UNKNOWN = LB_BIT31,
42  TYPE_ALL = LB_BIT_ALL_32
43  };
44 
46  static const unsigned defaultValue = UINT_MAX;
47 
49  HWSD_API NetInfo();
50 
52  HWSD_API bool operator == ( const NetInfo& rhs ) const;
53 
55  HWSD_API bool operator != ( const NetInfo& rhs ) const;
56 
57  HWSD_API std::string getType() const;
58 
59  HWSD_API void setType( const std::string& strType );
60 
63 
65  std::string name;
66 
68  std::string hostname;
69 
71  std::string hwAddress;
72 
74  std::string inetAddress;
75 
77  std::string inet6Address;
78 
80  unsigned int linkspeed;
81 
83  bool up;
84 };
85 
86 inline std::ostream& operator << ( std::ostream& os, const NetInfo& info )
87 {
88  os << "NetInfo\n" << static_cast< const NodeInfo& >( info );
89  os << " Type " << info.getType() << std::endl;
90  os << " Status " << (info.up ? "UP" : "DOWN") << std::endl;
91  if( !info.name.empty( ))
92  os << " Name " << info.name << std::endl;
93  if( !info.hostname.empty( ))
94  os << " Hostname " << info.hostname << std::endl;
95  if( !info.hwAddress.empty( ))
96  os << " HWaddr " << info.hwAddress << std::endl;
97  if( !info.inetAddress.empty( ))
98  os << " IPv4 " << info.inetAddress << std::endl;
99  if( !info.inet6Address.empty( ))
100  os << " IPv6 " << info.inet6Address << std::endl;
101  if( info.linkspeed != NetInfo::defaultValue )
102  os << " Linkspeed " << info.linkspeed << "Mbps" << std::endl;
103 
104  return os;
105 }
106 }
107 
108 #endif // HWSD_NETINFO_H
std::string hostname
The hostname assigned to this interface.
Definition: netInfo.h:68
Defines export visibility macros for hwsd.
static const unsigned defaultValue
A non-enumerated value.
Definition: netInfo.h:46
gif interface on Darwin
Definition: netInfo.h:39
HWSD_API NetInfo()
Default constructor pointing to the default display.
HWSD_API bool operator==(const NetInfo &rhs) const
HWSD_API bool operator!=(const NetInfo &rhs) const
unsigned int linkspeed
The interface link speed in Megabits per second.
Definition: netInfo.h:80
A structure containing node-specific information.
Definition: nodeInfo.h:31
std::string name
The name of the interface (e.g.
Definition: netInfo.h:65
std::string inet6Address
The IPv6 address (':' as separator) of the interface.
Definition: netInfo.h:77
stf interface on Darwin
Definition: netInfo.h:40
A structure containing network-specific information.
Definition: netInfo.h:32
Type type
The type of the network interface.
Definition: netInfo.h:62
bool up
Whether the interface is up or down.
Definition: netInfo.h:83
std::string hwAddress
The MAC address (':' as separator) of the interface.
Definition: netInfo.h:71
std::string inetAddress
The IPv4 address (':' as separator) of the interface.
Definition: netInfo.h:74