@@ -93,10 +93,11 @@ class NetworkInterfaceImpl: public Poco::RefCountedObject
9393 typedef NetworkInterface::Type Type;
9494
9595 NetworkInterfaceImpl (unsigned index);
96- NetworkInterfaceImpl (const std::string& name, const std::string& displayName, const IPAddress& address, unsigned index, NetworkInterface::MACAddress* pMACAddress = 0 );
97- NetworkInterfaceImpl (const std::string& name, const std::string& displayName, unsigned index = 0 , NetworkInterface::MACAddress* pMACAddress = 0 );
96+ NetworkInterfaceImpl (const std::string& name, const std::string& displayName, const std::string& adapterName, const IPAddress& address, unsigned index, NetworkInterface::MACAddress* pMACAddress = 0 );
97+ NetworkInterfaceImpl (const std::string& name, const std::string& displayName, const std::string& adapterName, unsigned index = 0 , NetworkInterface::MACAddress* pMACAddress = 0 );
9898 NetworkInterfaceImpl (const std::string& name,
9999 const std::string& displayName,
100+ const std::string& adapterName,
100101 const IPAddress& address,
101102 const IPAddress& subnetMask,
102103 const IPAddress& broadcastAddress,
@@ -106,6 +107,7 @@ class NetworkInterfaceImpl: public Poco::RefCountedObject
106107 unsigned index () const ;
107108 const std::string& name () const ;
108109 const std::string& displayName () const ;
110+ const std::string& adapterName () const ;
109111 const IPAddress& firstAddress (IPAddress::Family family) const ;
110112 void addAddress (const AddressTuple& address);
111113 const IPAddress& address (unsigned index) const ;
@@ -120,6 +122,7 @@ class NetworkInterfaceImpl: public Poco::RefCountedObject
120122
121123 void setName (const std::string& name);
122124 void setDisplayName (const std::string& name);
125+ void setAdapterName (const std::string& name);
123126 void addAddress (const IPAddress& addr);
124127 void setMACAddress (const NetworkInterface::MACAddress& addr);
125128 void setMACAddress (const void *addr, std::size_t len);
@@ -154,6 +157,7 @@ class NetworkInterfaceImpl: public Poco::RefCountedObject
154157private:
155158 std::string _name;
156159 std::string _displayName;
160+ std::string _adapterName;
157161 AddressList _addressList;
158162 unsigned _index;
159163 bool _broadcast;
@@ -178,9 +182,10 @@ NetworkInterfaceImpl::NetworkInterfaceImpl(unsigned index):
178182}
179183
180184
181- NetworkInterfaceImpl::NetworkInterfaceImpl (const std::string& name, const std::string& displayName, const IPAddress& address, unsigned index, NetworkInterface::MACAddress* pMACAddress):
185+ NetworkInterfaceImpl::NetworkInterfaceImpl (const std::string& name, const std::string& displayName, const std::string& adapterName, const IPAddress& address, unsigned index, NetworkInterface::MACAddress* pMACAddress):
182186 _name (name),
183187 _displayName (displayName),
188+ _adapterName (adapterName),
184189 _index (index),
185190 _broadcast (false ),
186191 _loopback (false ),
@@ -196,9 +201,10 @@ NetworkInterfaceImpl::NetworkInterfaceImpl(const std::string& name, const std::s
196201}
197202
198203
199- NetworkInterfaceImpl::NetworkInterfaceImpl (const std::string& name, const std::string& displayName, unsigned index, NetworkInterface::MACAddress* pMACAddress):
204+ NetworkInterfaceImpl::NetworkInterfaceImpl (const std::string& name, const std::string& displayName, const std::string& adapterName, unsigned index, NetworkInterface::MACAddress* pMACAddress):
200205 _name (name),
201206 _displayName (displayName),
207+ _adapterName (adapterName),
202208 _index (index),
203209 _broadcast (false ),
204210 _loopback (false ),
@@ -215,13 +221,15 @@ NetworkInterfaceImpl::NetworkInterfaceImpl(const std::string& name, const std::s
215221
216222NetworkInterfaceImpl::NetworkInterfaceImpl (const std::string& name,
217223 const std::string& displayName,
224+ const std::string& adapterName,
218225 const IPAddress& address,
219226 const IPAddress& subnetMask,
220227 const IPAddress& broadcastAddress,
221228 unsigned index,
222229 NetworkInterface::MACAddress* pMACAddress):
223230 _name (name),
224231 _displayName (displayName),
232+ _adapterName (adapterName),
225233 _index (index),
226234 _broadcast (false ),
227235 _loopback (false ),
@@ -305,6 +313,12 @@ inline const std::string& NetworkInterfaceImpl::displayName() const
305313}
306314
307315
316+ inline const std::string& NetworkInterfaceImpl::adapterName () const
317+ {
318+ return _adapterName;
319+ }
320+
321+
308322const IPAddress& NetworkInterfaceImpl::firstAddress (IPAddress::Family family) const
309323{
310324 AddressList::const_iterator it = _addressList.begin ();
@@ -517,6 +531,12 @@ inline void NetworkInterfaceImpl::setDisplayName(const std::string& name)
517531}
518532
519533
534+ inline void NetworkInterfaceImpl::setAdapterName (const std::string& name)
535+ {
536+ _adapterName = name;
537+ }
538+
539+
520540inline void NetworkInterfaceImpl::addAddress (const IPAddress& addr)
521541{
522542 _addressList.push_back (addr);
@@ -560,32 +580,33 @@ NetworkInterface::NetworkInterface(const NetworkInterface& interfc):
560580}
561581
562582
563- NetworkInterface::NetworkInterface (const std::string& name, const std::string& displayName, const IPAddress& address, unsigned index, MACAddress* pMACAddress):
564- _pImpl (new NetworkInterfaceImpl(name, displayName, address, index, pMACAddress))
583+ NetworkInterface::NetworkInterface (const std::string& name, const std::string& displayName, const std::string& adapterName, const IPAddress& address, unsigned index, MACAddress* pMACAddress):
584+ _pImpl (new NetworkInterfaceImpl(name, displayName, adapterName, address, index, pMACAddress))
565585{
566586}
567587
568588
569- NetworkInterface::NetworkInterface (const std::string& name, const std::string& displayName, unsigned index, MACAddress* pMACAddress):
570- _pImpl (new NetworkInterfaceImpl(name, displayName, index, pMACAddress))
589+ NetworkInterface::NetworkInterface (const std::string& name, const std::string& displayName, const std::string& adapterName, unsigned index, MACAddress* pMACAddress):
590+ _pImpl (new NetworkInterfaceImpl(name, displayName, adapterName, index, pMACAddress))
571591{
572592}
573593
574594
575595NetworkInterface::NetworkInterface (const std::string& name, const IPAddress& address, unsigned index, MACAddress* pMACAddress):
576- _pImpl (new NetworkInterfaceImpl(name, name, address, index, pMACAddress))
596+ _pImpl (new NetworkInterfaceImpl(name, name, name, address, index, pMACAddress))
577597{
578598}
579599
580600
581601NetworkInterface::NetworkInterface (const std::string& name,
582602 const std::string& displayName,
603+ const std::string& adapterName,
583604 const IPAddress& address,
584605 const IPAddress& subnetMask,
585606 const IPAddress& broadcastAddress,
586607 unsigned index,
587608 MACAddress* pMACAddress):
588- _pImpl (new NetworkInterfaceImpl(name, displayName, address, subnetMask, broadcastAddress, index, pMACAddress))
609+ _pImpl (new NetworkInterfaceImpl(name, displayName, adapterName, address, subnetMask, broadcastAddress, index, pMACAddress))
589610{
590611}
591612
@@ -596,7 +617,7 @@ NetworkInterface::NetworkInterface(const std::string& name,
596617 const IPAddress& broadcastAddress,
597618 unsigned index,
598619 MACAddress* pMACAddress):
599- _pImpl (new NetworkInterfaceImpl(name, name, address, subnetMask, broadcastAddress, index, pMACAddress))
620+ _pImpl (new NetworkInterfaceImpl(name, name, name, address, subnetMask, broadcastAddress, index, pMACAddress))
600621{
601622}
602623
@@ -640,6 +661,12 @@ const std::string& NetworkInterface::displayName() const
640661}
641662
642663
664+ const std::string& NetworkInterface::adapterName () const
665+ {
666+ return _pImpl->adapterName ();
667+ }
668+
669+
643670const IPAddress& NetworkInterface::firstAddress (IPAddress::Family family) const
644671{
645672 return _pImpl->firstAddress (family);
@@ -854,6 +881,7 @@ NetworkInterface::List NetworkInterface::list(bool ipOnly, bool upOnly)
854881 int index = it->second .index ();
855882 std::string name = it->second .name ();
856883 std::string displayName = it->second .displayName ();
884+ std::string adapterName = it->second .adapterName ();
857885 NetworkInterface::MACAddress mac = it->second .macAddress ();
858886
859887 typedef NetworkInterface::AddressList List;
@@ -866,11 +894,11 @@ NetworkInterface::List NetworkInterface::list(bool ipOnly, bool upOnly)
866894 IPAddress mask = ipIt->get <NetworkInterface::SUBNET_MASK >();
867895 NetworkInterface ni;
868896 if (mask.isWildcard ())
869- ni = NetworkInterface (name, displayName, addr, index, &mac);
897+ ni = NetworkInterface (name, displayName, adapterName, addr, index, &mac);
870898 else
871899 {
872900 IPAddress broadcast = ipIt->get <NetworkInterface::BROADCAST_ADDRESS >();
873- ni = NetworkInterface (name, displayName, addr, mask, broadcast, index, &mac);
901+ ni = NetworkInterface (name, displayName, adapterName, addr, mask, broadcast, index, &mac);
874902 }
875903
876904 list.push_back (ni);
@@ -1017,6 +1045,7 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
10171045
10181046 std::string name;
10191047 std::string displayName;
1048+ std::string adapterName (pAddress->AdapterName );
10201049#ifdef POCO_WIN32_UTF8
10211050 Poco::UnicodeConverter::toUTF8 (pAddress->FriendlyName , name);
10221051 Poco::UnicodeConverter::toUTF8 (pAddress->Description , displayName);
@@ -1033,7 +1062,7 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
10331062 bool isIP = (0 != pAddress->FirstUnicastAddress );
10341063 if (((ipOnly && isIP) || !ipOnly) && ((upOnly && isUp) || !upOnly))
10351064 {
1036- NetworkInterface ni (name, displayName, ifIndex);
1065+ NetworkInterface ni (name, displayName, adapterName, ifIndex);
10371066 // Create interface even if it has an empty list of addresses; also, set
10381067 // physical attributes which are protocol independent (name, media type,
10391068 // MAC address, MTU, operational status, etc).
@@ -1149,7 +1178,7 @@ NetworkInterface::NetworkInterfaceList NetworkInterface::list()
11491178 {
11501179 bcst = IPAddress(std::string(ifAddr));
11511180 }
1152- result.push_back(NetworkInterface(name, name, addr, mask, bcst));
1181+ result.push_back(NetworkInterface(name, name, name, addr, mask, bcst));
11531182 ifIndex++;
11541183 }
11551184 else break;
@@ -1207,6 +1236,7 @@ void setInterfaceParams(struct ifaddrs* iface, NetworkInterfaceImpl& impl)
12071236 struct sockaddr_dl * sdl = (struct sockaddr_dl *) iface->ifa_addr ;
12081237 impl.setName (iface->ifa_name );
12091238 impl.setDisplayName (iface->ifa_name );
1239+ impl.setAdapterName (iface->ifa_name );
12101240 impl.setPhyParams ();
12111241
12121242 impl.setMACAddress (LLADDR (sdl), sdl->sdl_alen );
@@ -1363,6 +1393,7 @@ void setInterfaceParams(struct ifaddrs* iface, NetworkInterfaceImpl& impl)
13631393 struct sockaddr_ll * sdl = (struct sockaddr_ll *) iface->ifa_addr ;
13641394 impl.setName (iface->ifa_name );
13651395 impl.setDisplayName (iface->ifa_name );
1396+ impl.setAdapterName (iface->ifa_name );
13661397 impl.setPhyParams ();
13671398
13681399 impl.setMACAddress (sdl->sll_addr , sdl->sll_halen );
@@ -1555,7 +1586,7 @@ NetworkInterface::NetworkInterfaceList NetworkInterface::list()
15551586 if (haveAddr)
15561587 {
15571588 std::string name(ifr->ifr_name);
1558- result.push_back(NetworkInterface(name, name, addr, ifIndex));
1589+ result.push_back(NetworkInterface(name, name, name, addr, ifIndex));
15591590 }
15601591 len += sizeof(ifr->ifr_name);
15611592 ptr += len;
0 commit comments