@@ -1192,24 +1192,20 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
11921192 {
11931193 struct sockaddr_dl * sdl = (struct sockaddr_dl *) currIface->ifa_addr ;
11941194 ifIndex = sdl->sdl_index ;
1195+ intf = NetworkInterface (ifIndex);
1196+ setInterfaceParams (currIface, intf.impl ());
11951197 if ((result.find (ifIndex) == result.end ()) && ((upOnly && intf.isUp ()) || !upOnly) && !ipOnly)
1196- {
1197- intf = NetworkInterface (ifIndex);
1198- setInterfaceParams (currIface, intf.impl ());
11991198 ifIt = result.insert (Map::value_type (ifIndex, intf)).first ;
1200- }
12011199 break ;
12021200 }
12031201#endif
12041202 case AF_INET :
12051203 ifIndex = if_nametoindex (currIface->ifa_name );
12061204 ifIt = result.find (ifIndex);
1205+ intf = NetworkInterface (ifIndex);
1206+ setInterfaceParams (currIface, intf.impl ());
12071207 if ((ifIt == result.end ()) && ((upOnly && intf.isUp ()) || !upOnly))
1208- {
1209- intf = NetworkInterface (ifIndex);
1210- setInterfaceParams (currIface, intf.impl ());
12111208 ifIt = result.insert (Map::value_type (ifIndex, intf)).first ;
1212- }
12131209
12141210 address = IPAddress (*(currIface->ifa_addr ));
12151211 subnetMask = IPAddress (*(currIface->ifa_netmask ));
@@ -1225,12 +1221,10 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
12251221 case AF_INET6 :
12261222 ifIndex = if_nametoindex (currIface->ifa_name );
12271223 ifIt = result.find (ifIndex);
1224+ intf = NetworkInterface (ifIndex);
1225+ setInterfaceParams (currIface, intf.impl ());
12281226 if ((ifIt == result.end ()) && ((upOnly && intf.isUp ()) || !upOnly))
1229- {
1230- intf = NetworkInterface (ifIndex);
1231- setInterfaceParams (currIface, intf.impl ());
12321227 ifIt = result.insert (Map::value_type (ifIndex, intf)).first ;
1233- }
12341228
12351229 address = IPAddress (&reinterpret_cast <const struct sockaddr_in6 *>(currIface->ifa_addr )->sin6_addr ,
12361230 sizeof (struct in6_addr ), ifIndex);
@@ -1248,7 +1242,6 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
12481242#endif
12491243 )
12501244 {
1251- intf = NetworkInterface (std::string (currIface->ifa_name ), address, subnetMask, broadcastAddress, ifIndex);
12521245 if ((upOnly && intf.isUp ()) || !upOnly)
12531246 {
12541247 if ((ifIt = result.find (ifIndex)) != result.end ())
@@ -1348,23 +1341,22 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
13481341 {
13491342 struct sockaddr_ll * sll = (struct sockaddr_ll *)iface->ifa_addr ;
13501343 ifIndex = sll->sll_ifindex ;
1344+ intf = NetworkInterface (ifIndex);
1345+ setInterfaceParams (iface, intf.impl ());
1346+
13511347 if ((result.find (ifIndex) == result.end ()) && ((upOnly && intf.isUp ()) || !upOnly) && !ipOnly)
1352- {
1353- intf = NetworkInterface (ifIndex);
1354- setInterfaceParams (iface, intf.impl ());
13551348 ifIt = result.insert (Map::value_type (ifIndex, intf)).first ;
1356- }
1349+
13571350 break ;
13581351 }
13591352 case AF_INET :
13601353 ifIndex = if_nametoindex (iface->ifa_name );
13611354 ifIt = result.find (ifIndex);
1355+ intf = NetworkInterface (ifIndex);
1356+ setInterfaceParams (iface, intf.impl ());
1357+
13621358 if ((ifIt == result.end ()) && ((upOnly && intf.isUp ()) || !upOnly))
1363- {
1364- intf = NetworkInterface (ifIndex);
1365- setInterfaceParams (iface, intf.impl ());
13661359 ifIt = result.insert (Map::value_type (ifIndex, intf)).first ;
1367- }
13681360
13691361 address = IPAddress (*(iface->ifa_addr ));
13701362 subnetMask = IPAddress (*(iface->ifa_netmask ));
@@ -1381,15 +1373,16 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
13811373 case AF_INET6 :
13821374 ifIndex = if_nametoindex (iface->ifa_name );
13831375 ifIt = result.find (ifIndex);
1376+ intf = NetworkInterface (ifIndex);
1377+ setInterfaceParams (iface, intf.impl ());
1378+
13841379 if ((ifIt == result.end ()) && ((upOnly && intf.isUp ()) || !upOnly))
1385- {
1386- intf = NetworkInterface (ifIndex);
1387- setInterfaceParams (iface, intf.impl ());
13881380 result.insert (Map::value_type (ifIndex, intf)).first ;
1389- }
1381+
13901382 address = IPAddress (&reinterpret_cast <const struct sockaddr_in6 *>(iface->ifa_addr )->sin6_addr , sizeof (struct in6_addr ), ifIndex);
13911383 subnetMask = IPAddress (*(iface->ifa_netmask ));
13921384 broadcastAddress = IPAddress ();
1385+
13931386 break ;
13941387#endif
13951388 default :
0 commit comments