30 #ifndef _NETIF_H_INCLUDED_ 31 #define _NETIF_H_INCLUDED_ 46 #include <sys/socket.h> 47 #include <netinet/in.h> 50 #include "UpnpGlobal.h" 59 enum class Family {Invalid = -1, IPV4 = AF_INET, IPV6 = AF_INET6};
61 enum class Scope {Invalid = -1, LINK, SITE, GLOBAL};
64 explicit IPAddr(
const char *);
66 explicit IPAddr(
const std::string& s)
71 explicit IPAddr(
const struct sockaddr *sa,
bool unmapv4=
true);
80 bool setScopeIdx(
const IPAddr& other);
84 Scope scopetype()
const;
87 bool copyToStorage(
struct sockaddr_storage *dest)
const;
90 bool copyToAddr(
struct sockaddr *dest)
const;
93 const struct sockaddr_storage& getaddr()
const;
96 std::string straddr()
const;
99 std::string straddr(
bool setscope,
bool forurl)
const;
104 std::unique_ptr<Internal> m;
113 enum class Flags {NONE = 0, HASIPV4 = 1, HASIPV6 = 2, LOOPBACK=4,
114 UP=8, MULTICAST=0x10, HASHWADDR=0x20};
125 const std::string& getname()
const;
128 const std::string& getfriendlyname()
const;
133 const std::string& gethwaddr()
const;
135 std::string gethexhwaddr()
const;
137 bool hasflag(
Flags f)
const;
139 bool trimto(
const std::vector<IPAddr>& keep);
141 const IPAddr *firstipv4addr()
const;
143 const IPAddr *firstipv6addr(
147 std::pair<const std::vector<IPAddr>&,
const std::vector<IPAddr>&>
148 getaddresses()
const;
150 int getindex()
const;
153 std::ostream& print(std::ostream&)
const;
158 std::unique_ptr<Internal> m;
173 Interface *findByName(
const char*nm)
const;
176 return findByName(nm.c_str());
182 std::vector<Interface::Flags>
needs;
188 std::vector<Interface> select(
const Filter& f)
const;
191 std::ostream& print(std::ostream&);
200 static const Interface *interfaceForAddress(
201 const IPAddr& addr,
const std::vector<Interface>& vifs,
IPAddr& hostaddr);
211 static void setlogfp(FILE *fp);
220 std::unique_ptr<Internal> m;
Flags
Interface attributes.
Definition: netif.h:113
std::vector< Interface::Flags > needs
flags we want.
Definition: netif.h:182
Represent the system's network interfaces. Singleton class.
Definition: netif.h:163
Represent a system network interface, its attributes and its addresses. Usually built by the module i...
Definition: netif.h:110
Family
address family types. The values are identifal to the system's definitions
Definition: netif.h:59
IPAddr(const std::string &s)
Build from textual representation (e.g. 192.168.4.4)
Definition: netif.h:66
Scope
IPV6 address scope type.
Definition: netif.h:61
Argument to the select() method: flags which we want or don't.
Definition: netif.h:180
Represent an IPV4 or IPV6 address.
Definition: netif.h:55
Interface * findByName(const std::string &nm) const
Find interface by name or friendlyname.
Definition: netif.h:175
std::vector< Interface::Flags > rejects
flags we don't want.
Definition: netif.h:184