simple-socket library 1.9.0
Loading...
Searching...
No Matches
NetworkInterface.h
Go to the documentation of this file.
1#ifndef NET_NetworkInterface_h__
2#define NET_NetworkInterface_h__
3
4#include "SimpleSocket.h"
5
6#include <string>
7#include <string_view>
8#include <vector>
9#include <cstdint>
10
11namespace NET
12{
14 {
15 std::string name;
16 std::string address;
17 std::string netmask;
18 std::string broadcast;
19 std::string destination;
21 unsigned int flags;
22 uint32_t scopeId = 0;
23 };
24
26
33 std::vector<NetworkAddressInfo> getNetworkAddresses();
34
35 class NetworkInterface;
36
38
43 std::vector<NetworkInterface> getNetworkInterfaces();
44
45
47 {
48 public:
49 NetworkInterface( std::string_view interface);
50
51 std::string name() const { return interface; }
52
54
58 std::string getInterfaceAddress() const;
59
61
65 void setInterfaceAddress( std::string_view address);
66
68
75 std::string getBroadcastAddress() const;
76
78
84 void setBroadcastAddress( std::string_view address);
85
87
91 std::string getNetmask() const;
92
94
100 void setNetmask( std::string_view address);
101
103
107 std::string getDestinationAddress() const;
108
110
116 void setDestinationAddress( std::string_view address);
117
119
122 int getMTU() const;
123
125
130 void setMTU( int mtu);
131
133
136 std::string getHardwareAddress() const;
137
138 private:
139 std::string interface;
140 };
141}
142#endif // NET_NetworkInterface_h__
NetworkInterface(std::string_view interface)
void setNetmask(std::string_view address)
Set the IPv4 netmask of the given network interface.
int getMTU() const
Return the MTU (Maximum Transmission Unit) of the given network interface in bytes.
void setBroadcastAddress(std::string_view address)
Set the IPv4 broadcast address of the given network interface.
void setDestinationAddress(std::string_view address)
Set the IPv4 destination address of the given network interface.
std::string getInterfaceAddress() const
Return the IPv4 address of the given network interface.
std::string getDestinationAddress() const
Return the IPv4 destination address of the given network interface.
std::string getHardwareAddress() const
Return the MAC address of the given network interfaces.
std::string name() const
void setMTU(int mtu)
Set the MTU (Maximum Transmission Unit) of the given network interface in bytes.
void setInterfaceAddress(std::string_view address)
Set the IPv4 address of the given network interface.
std::string getNetmask() const
Return the IPv4 netmask of the given network interface.
std::string getBroadcastAddress() const
Return the IPv4 broadcast address of the given network interface.
AddressFamily
used by internet socket types
std::vector< NetworkAddressInfo > getNetworkAddresses()
Return IPv4/IPv6 address entries for the local network interfaces.
std::vector< NetworkInterface > getNetworkInterfaces()
Returns list of all network interfaces regardless of their state.