Lines Matching defs:std
39 const std::string IFACE_MATCH = "eth\\d";
40 const std::string CONFIG_KEY_ETH_COMPONENT_FLAG = "config_ethernet_interfaces";
41 const std::string CONFIG_KEY_ETH_IFACE = "iface";
42 const std::string CONFIG_KEY_ETH_LANIFACE = "laniface";
43 const std::string CONFIG_KEY_ETH_CAPS = "caps";
44 const std::string CONFIG_KEY_ETH_IP = "ip";
45 const std::string CONFIG_KEY_ETH_GATEWAY = "gateway";
46 const std::string CONFIG_KEY_ETH_DNS = "dns";
47 const std::string CONFIG_KEY_ETH_NETMASK = "netmask";
48 const std::string CONFIG_KEY_ETH_ROUTE = "route";
49 const std::string CONFIG_KEY_ETH_ROUTE_MASK = "routemask";
82 bool EthernetConfiguration::ReadEthernetInterfaces(std::map<std::string, std::set<NetCap>> &devCaps,
83 std::map<std::string, sptr<InterfaceConfiguration>> &devCfgs,
91 std::string iface;
103 std::set<NetCap> caps;
126 std::regex re(IFACE_MATCH);
127 if (cJSON_GetObjectItem(item, CONFIG_KEY_ETH_IP.c_str()) && std::regex_search(iface, re)) {
134 bool EthernetConfiguration::ReadSystemConfiguration(std::map<std::string, std::set<NetCap>> &devCaps,
135 std::map<std::string, sptr<InterfaceConfiguration>> &devCfgs)
160 sptr<InterfaceConfiguration> config = new (std::nothrow) InterfaceConfiguration();
171 std::string ip = cJSON_GetObjectItem(jsonData, CONFIG_KEY_ETH_IP.c_str())->valuestring;
172 std::string route = cJSON_GetObjectItem(jsonData, CONFIG_KEY_ETH_ROUTE.c_str())->valuestring;
173 std::string gateway = cJSON_GetObjectItem(jsonData, CONFIG_KEY_ETH_GATEWAY.c_str())->valuestring;
174 std::string netmask = cJSON_GetObjectItem(jsonData, CONFIG_KEY_ETH_NETMASK.c_str())->valuestring;
175 std::string dns = cJSON_GetObjectItem(jsonData, CONFIG_KEY_ETH_DNS.c_str())->valuestring;
181 std::string routeMask = cJSON_GetObjectItem(jsonData, CONFIG_KEY_ETH_ROUTE_MASK.c_str())->valuestring;
186 bool EthernetConfiguration::ReadUserConfiguration(std::map<std::string, sptr<InterfaceConfiguration>> &devCfgs)
194 std::string iface;
200 std::string filePath = std::string(USER_CONFIG_DIR) + FILE_OBLIQUE_LINE + ptr->d_name;
201 std::string fileContent;
205 std::string().swap(iface);
206 sptr<InterfaceConfiguration> cfg = new (std::nothrow) InterfaceConfiguration();
212 std::regex re(IFACE_MATCH);
213 if (!iface.empty() && std::regex_search(iface, re)) {
223 bool EthernetConfiguration::WriteUserConfiguration(const std::string &iface, sptr<InterfaceConfiguration> &cfg)
235 ParserIfaceIpAndRoute(cfg, std::string());
238 std::string fileContent;
241 std::string filePath = std::string(USER_CONFIG_DIR) + FILE_OBLIQUE_LINE + iface;
301 std::vector<INetAddr> EthernetConfiguration::GetGatewayFromMap(const std::unordered_map<std::string, INetAddr> &temp)
303 std::vector<INetAddr> t;
310 std::vector<INetAddr> EthernetConfiguration::GetGatewayFromRouteList(std::list<Route> &routeList)
312 std::unordered_map<std::string, INetAddr> temp;
332 sptr<InterfaceConfiguration> cfg = new (std::nothrow) InterfaceConfiguration();
361 std::string EthernetConfiguration::ReadJsonFile(const std::string &filePath)
363 std::ifstream infile;
364 std::string strLine;
365 std::string strAll;
378 bool EthernetConfiguration::IsDirExist(const std::string &dirPath)
387 bool EthernetConfiguration::CreateDir(const std::string &dirPath)
399 bool EthernetConfiguration::DelDir(const std::string &dirPath)
409 std::string filePath = dirPath + FILE_OBLIQUE_LINE + entry->d_name;
420 bool EthernetConfiguration::IsFileExist(const std::string &filePath, std::string &realPath)
435 bool EthernetConfiguration::ReadFile(const std::string &filePath, std::string &fileContent)
437 std::unique_lock<std::mutex> lock(mutex_);
442 std::string realPath;
447 std::fstream file(realPath.c_str(), std::fstream::in);
452 std::stringstream buffer;
459 bool EthernetConfiguration::WriteFile(const std::string &filePath, const std::string &fileContent)
461 std::fstream file(filePath.c_str(), std::fstream::out | std::fstream::trunc);
473 void EthernetConfiguration::ParserFileConfig(const std::string &fileContent, std::string &iface,
482 void EthernetConfiguration::ParseDevice(const std::string &fileContent, std::string &iface)
484 std::string::size_type pos = fileContent.find(KEY_DEVICE);
485 if (pos == std::string::npos) {
493 void EthernetConfiguration::ParseBootProto(const std::string &fileContent, sptr<InterfaceConfiguration> cfg)
495 std::string::size_type pos = fileContent.find(KEY_BOOTPROTO);
496 if (pos == std::string::npos) {
512 void EthernetConfiguration::ParseStaticConfig(const std::string &fileContent, sptr<InterfaceConfiguration> cfg)
517 std::string ipAddresses, netMasks, gateways, routes, routeMasks, dnsServers;
519 if (pos != std::string::npos) {
525 if (pos != std::string::npos) {
531 if (pos != std::string::npos) {
537 if (pos != std::string::npos) {
543 if (pos != std::string::npos) {
549 if (pos != std::string::npos) {
562 void EthernetConfiguration::ParserFileHttpProxy(const std::string &fileContent, const sptr<InterfaceConfiguration> &cfg)
564 std::string::size_type pos = fileContent.find(KEY_PROXY_HOST);
565 if (pos != std::string::npos) {
571 if (pos != std::string::npos) {
578 if (pos != std::string::npos) {
581 std::list<std::string> exclusionList;
589 void EthernetConfiguration::ParserIfaceIpAndRoute(sptr<InterfaceConfiguration> &cfg, const std::string &rootNetMask)
596 std::for_each(cfg->ipStatic_.netMaskList_.begin(), cfg->ipStatic_.netMaskList_.end(), [&cfg](const auto &netMask) {
623 std::string EthernetConfiguration::GetIfaceMode(IPSetMode mode)
637 void EthernetConfiguration::GenCfgContent(const std::string &iface, sptr<InterfaceConfiguration> cfg,
638 std::string &fileContent)
644 std::string().swap(fileContent);
646 std::string mode = GetIfaceMode(cfg->mode_);
649 std::string ipAddresses = AccumulateNetAddress(cfg->ipStatic_.ipAddrList_);
650 std::string netMasks = AccumulateNetAddress(cfg->ipStatic_.netMaskList_);
651 std::string gateways = AccumulateNetAddress(cfg->ipStatic_.gatewayList_);
652 std::string routes = AccumulateNetAddress(cfg->ipStatic_.routeList_);
653 std::string routeMasks =
654 std::accumulate(cfg->ipStatic_.routeList_.begin(), cfg->ipStatic_.routeList_.end(), std::string(),
655 [](const std::string &routeMask, const INetAddr &iter) {
657 std::string mask = (family == AF_INET6) ? DEFAULT_IPV6_ADDR : DEFAULT_IPV4_ADDR;
660 std::string dnsServers = AccumulateNetAddress(cfg->ipStatic_.dnsServers_);
672 void EthernetConfiguration::GenHttpProxyContent(const sptr<InterfaceConfiguration> &cfg, std::string &fileContent)
675 std::string exclusions =
676 std::accumulate(exclusionList.begin(), exclusionList.end(), std::string(),
677 [](const std::string &exclusion, const std::string &next) {
682 fileContent = fileContent + KEY_PROXY_PORT + std::to_string(cfg->httpProxy_.GetPort()) + WRAP;
686 std::string EthernetConfiguration::AccumulateNetAddress(const std::vector<INetAddr> &netAddrList)
688 return std::accumulate(netAddrList.begin(), netAddrList.end(), std::string(),
689 [](const std::string &addr, const INetAddr &iter) {
708 if (std::any_of(config->ipAddrList_.begin(), config->ipAddrList_.end(), [&dhcpResult](const auto &ipAddr) {
715 if (std::any_of(config->gatewayList_.begin(), config->gatewayList_.end(), [&dhcpResult](const auto &gateway) {