24 #ifndef LXCPP_NETWORK_HPP
25 #define LXCPP_NETWORK_HPP
36 #include <arpa/inet.h>
40 std::string
toString(
const in_addr& addr);
41 std::string
toString(
const in6_addr& addr);
42 void fromString(
const std::string& s, in_addr& addr);
43 void fromString(
const std::string& s, in6_addr& addr);
63 std::uint8_t *v = addr.data();
64 return *(
reinterpret_cast<T*
>(v));
68 const std::uint8_t *v = addr.data();
69 return *(
reinterpret_cast<const T*
>(v));
85 std::array<std::uint8_t,sizeof(in6_addr)> addr;
88 static inline
bool operator==(const in_addr& a, const in_addr& b)
90 return ::memcmp(&a, &b,
sizeof(a)) == 0;
93 static inline bool operator==(
const in6_addr& a,
const in6_addr& b)
95 return ::memcmp(&a, &b,
sizeof(a)) == 0;
218 const std::string&
getName()
const {
return mIfname; }
220 bool exists() const noexcept;
253 void moveToContainer(pid_t pid);
259 void renameFrom(const std::
string& oldif);
265 void addToBridge(const std::
string& bridge);
271 void delFromBridge();
284 void addInetAddr(const
InetAddr& addr);
290 void delInetAddr(const
InetAddr& addr);
296 std::vector<
InetAddr> getInetAddressList() const;
338 void setMACAddress(const std::
string& macaddr);
344 void setMTU(
int mtu);
350 void setTxLength(
int txlen);
356 static std::vector<std::
string> getInterfaces(pid_t initpid);
367 void createMacVLan(const std::
string& masterif,
MacVLanMode mode);
371 const std::
string mIfname;
377 #endif // LXCPP_NETWORK_HPP
std::string toString(const in_addr &addr)
Definition: network.cpp:220
int cmd
Definition: initctl.cpp:38
RoutingTable
Definition: network.hpp:111
AttrName name
Definition: network.hpp:170
static bool operator==(const in_addr &a, const in_addr &b)
Definition: network.hpp:88
AttrName
Definition: network.hpp:146
InetAddr src
Definition: network.hpp:140
void createVeth(const pid_t &nsPid, const std::string &nsDev, const std::string &hostDev)
Definition: netdev.cpp:375
Attrs getAttrs(const pid_t nsPid, const std::string &netdev)
Definition: netdev.cpp:476
const T & getAddr() const
Definition: network.hpp:67
Unified ip address.
Definition: network.hpp:56
InetAddr dst
Definition: network.hpp:139
Configuration file for the code.
Network interface information structure.
Definition: vasum-client-impl.hpp:69
InetAddrType
Suported address types.
Definition: network.hpp:48
T & getAddr()
Definition: network.hpp:62
Definition: network.hpp:138
std::string ifname
Definition: network.hpp:142
std::string value
Definition: network.hpp:171
#define CARGO_REGISTER(...)
Registers cargo fields within class.
Definition: fields.hpp:74
std::ostream & operator<<(std::ostream &os, const AttrName &a)
Definition: network.hpp:156
const std::string & getName() const
Definition: network.hpp:218
std::vector< Attr > Attrs
Definition: network.hpp:174
InetAddrType type
Definition: network.hpp:72
NetStatus
Definition: network.hpp:195
InetAddr()
Definition: network.hpp:58
RoutingTable table
Definition: network.hpp:143
void setAttrs(const pid_t nsPid, const std::string &netdev, const Attrs &attrs)
Definition: netdev.cpp:540
unsigned prefix
Definition: network.hpp:73
Definition: network.hpp:169
MacVLanMode
Suported MacVLan modes.
Definition: network.hpp:188
uint32_t flags
Definition: network.hpp:74
unsigned metric
Definition: network.hpp:141
void createBridge(const std::string &netdev)
Create bridge.
Definition: netdev.cpp:454
NetworkInterface(const std::string &ifname, pid_t pid=0)
Create network interface object for the ifname in the container (network namespace) ...
Definition: network.hpp:212
InterfaceType
Created interface type.
Definition: network.hpp:179
void fromString(const std::string &s, in_addr &addr)
Definition: network.cpp:244
Network operations to be performed on given container and interface operates on netlink device...
Definition: network.hpp:206