|
@@ -1,5 +1,9 @@
|
|
|
#include "netinterfaces.h"
|
|
|
|
|
|
+#ifndef _countof
|
|
|
+#define _countof(a) (sizeof(a) / sizeof(*a))
|
|
|
+#endif // _countof
|
|
|
+
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
@@ -78,6 +82,20 @@ QVariantList NetInterfaces::getInterface(const QString &itfName)
|
|
|
Interface::Interface(ITF_IFACE_BLOCK &ifb, QObject *pParent) : QObject(pParent), m_ifb(ifb)
|
|
|
{
|
|
|
setObjectName("Interface");
|
|
|
+
|
|
|
+ for(size_t i = 0; i < _countof(m_ifb.inet4s.namesvr); i++)
|
|
|
+ {
|
|
|
+ if(m_ifb.inet4s.namesvr[i].s_addr)
|
|
|
+ {
|
|
|
+ QString qs(inet_ntoa(m_ifb.inet4s.namesvr[i]));
|
|
|
+ m_dnsList.append(qs);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ QString qs("");
|
|
|
+ m_dnsList.append(qs);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
Interface::~Interface(void)
|
|
@@ -89,20 +107,35 @@ QString Interface::name(void) const
|
|
|
return QString::fromStdString(m_ifb.cfgName);
|
|
|
}
|
|
|
|
|
|
+QString Interface::family(void) const
|
|
|
+{
|
|
|
+ return ::GetIfaceProtoStr(m_ifb.proto);
|
|
|
+}
|
|
|
+
|
|
|
+QString Interface::method(void) const
|
|
|
+{
|
|
|
+ return ::GetIfaceMethodStr(m_ifb.method);
|
|
|
+}
|
|
|
+
|
|
|
QString Interface::ipAddress(void) const
|
|
|
{
|
|
|
- if(m_ifb.proto == IFP_Inet && m_ifb.method == IFM_Static)
|
|
|
+// if(m_ifb.proto == IFP_Inet && m_ifb.method == IFM_Static)
|
|
|
return inet_ntoa(m_ifb.inet4s.addr);
|
|
|
- else
|
|
|
- return "";
|
|
|
+// else
|
|
|
+// return "";
|
|
|
}
|
|
|
|
|
|
-QString Interface::family(void) const
|
|
|
+QString Interface::netMask(void) const
|
|
|
{
|
|
|
- return ::GetIfaceProtoStr(m_ifb.proto);
|
|
|
+ return inet_ntoa(m_ifb.inet4s.netmask);
|
|
|
}
|
|
|
|
|
|
-QString Interface::method(void) const
|
|
|
+QString Interface::gateway(void) const
|
|
|
{
|
|
|
- return ::GetIfaceMethodStr(m_ifb.method);
|
|
|
+ return inet_ntoa(m_ifb.inet4s.gate);
|
|
|
+}
|
|
|
+
|
|
|
+QStringList Interface::dnsServers(void) const
|
|
|
+{
|
|
|
+ return m_dnsList;
|
|
|
}
|