-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathNetworkInterface.h
56 lines (43 loc) · 1.06 KB
/
NetworkInterface.h
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* Network.h
*
* Created on: 12 ott 2015
* Author: Stefano Ceccherini
*/
#ifndef NETWORKINTERFACE_H_
#define NETWORKINTERFACE_H_
#include <list>
#include <string>
#include <net/if.h>
#include <netinet/in.h>
struct route_info {
struct in_addr dstAddr;
struct in_addr srcAddr;
struct in_addr gateway;
char ifName[IF_NAMESIZE];
};
class NetworkInterface {
public:
NetworkInterface();
NetworkInterface(const char* name);
~NetworkInterface();
std::string Name() const;
std::string HardwareAddress() const;
bool HasIPAddress() const;
std::string IPAddress() const;
std::string NetMask() const;
std::string Network() const;
std::string BroadcastAddress() const;
bool HasDefaultGateway() const;
std::string DefaultGateway() const;
std::string Type() const;
std::string Speed() const;
std::string SpeedWithUnit() const;
std::string Status() const;
bool IsLoopback() const;
private:
int _GetRoutes(std::list<route_info>& routeList) const;
int _DoRequest(int request, struct ifreq& ifr) const;
std::string fName;
};
#endif /* NETWORKINTERFACE_H_ */