Exemple #1
0
 shared::CDataContainer CSystem::getNetworkInterfaces(bool includeLoopback)
 {
    try
    {
       shared::CDataContainer result;
       Poco::Net::NetworkInterface::NetworkInterfaceList netlist = Poco::Net::NetworkInterface::list();
       for (Poco::Net::NetworkInterface::NetworkInterfaceList::iterator nit = netlist.begin(); nit != netlist.end(); ++nit)
       {
          if (includeLoopback || nit->address().isLoopback())
             result.set(nit->name(), (boost::format("%1% (%2%)") % nit->displayName() % nit->address().toString()).str(), 0x00); //in case of key contains a dot, just ensure the full key is taken into account
       }
       return CResult::GenerateSuccess(result);
    }
    catch (std::exception &ex)
    {
       return CResult::GenerateError(ex);
    }
    catch (...)
    {
       return CResult::GenerateError("unknown exception in retreiving all serial ports");
    }
 }