Lines Matching refs:cfg

206             sptr<InterfaceConfiguration> cfg = new (std::nothrow) InterfaceConfiguration();
207 if (cfg == nullptr) {
208 NETMGR_EXT_LOG_E("cfg new failed for devname[%{public}s]", iface.c_str());
211 ParserFileConfig(fileContent, iface, cfg);
215 devCfgs[iface] = cfg;
223 bool EthernetConfiguration::WriteUserConfiguration(const std::string &iface, sptr<InterfaceConfiguration> &cfg)
225 if (cfg == nullptr) {
226 NETMGR_EXT_LOG_E("cfg is nullptr");
234 if (cfg->mode_ == STATIC || cfg->mode_ == LAN_STATIC) {
235 ParserIfaceIpAndRoute(cfg, std::string());
239 GenCfgContent(iface, cfg, fileContent);
332 sptr<InterfaceConfiguration> cfg = new (std::nothrow) InterfaceConfiguration();
333 if (cfg == nullptr) {
334 NETMGR_EXT_LOG_E("cfg new failed");
337 cfg->mode_ = devCfg->mode_;
339 cfg->ipStatic_.ipAddrList_.push_back(ipAddr);
347 cfg->ipStatic_.netMaskList_.push_back(netMask);
350 cfg->ipStatic_.routeList_.push_back(route.destination_);
352 cfg->ipStatic_.gatewayList_ = GetGatewayFromRouteList(devLinkInfo->routeList_);
354 cfg->ipStatic_.domain_ = devLinkInfo->domain_;
356 cfg->ipStatic_.dnsServers_.push_back(addr);
358 return cfg;
474 sptr<InterfaceConfiguration> cfg)
477 ParseBootProto(fileContent, cfg);
478 ParseStaticConfig(fileContent, cfg);
479 ParserFileHttpProxy(fileContent, cfg);
493 void EthernetConfiguration::ParseBootProto(const std::string &fileContent, sptr<InterfaceConfiguration> cfg)
502 cfg->mode_ = LAN_STATIC;
504 cfg->mode_ = LAN_DHCP;
506 cfg->mode_ = STATIC;
508 cfg->mode_ = DHCP;
512 void EthernetConfiguration::ParseStaticConfig(const std::string &fileContent, sptr<InterfaceConfiguration> cfg)
514 if (cfg->mode_ != STATIC && cfg->mode_ != LAN_STATIC) {
554 StaticConfiguration::ExtractNetAddrBySeparator(ipAddresses, cfg->ipStatic_.ipAddrList_);
555 StaticConfiguration::ExtractNetAddrBySeparator(routes, cfg->ipStatic_.routeList_);
556 StaticConfiguration::ExtractNetAddrBySeparator(gateways, cfg->ipStatic_.gatewayList_);
557 StaticConfiguration::ExtractNetAddrBySeparator(netMasks, cfg->ipStatic_.netMaskList_);
558 StaticConfiguration::ExtractNetAddrBySeparator(dnsServers, cfg->ipStatic_.dnsServers_);
559 ParserIfaceIpAndRoute(cfg, routeMasks);
562 void EthernetConfiguration::ParserFileHttpProxy(const std::string &fileContent, const sptr<InterfaceConfiguration> &cfg)
567 cfg->httpProxy_.SetHost(fileContent.substr(pos, fileContent.find(WRAP, pos) - pos));
574 cfg->httpProxy_.SetPort(static_cast<uint16_t>(port));
585 cfg->httpProxy_.SetExclusionList(exclusionList);
589 void EthernetConfiguration::ParserIfaceIpAndRoute(sptr<InterfaceConfiguration> &cfg, const std::string &rootNetMask)
591 if (cfg == nullptr) {
592 NETMGR_EXT_LOG_E("cfg is nullptr");
596 std::for_each(cfg->ipStatic_.netMaskList_.begin(), cfg->ipStatic_.netMaskList_.end(), [&cfg](const auto &netMask) {
598 for (auto &ipAddr : cfg->ipStatic_.ipAddrList_) {
612 for (auto &route : cfg->ipStatic_.routeList_) {
637 void EthernetConfiguration::GenCfgContent(const std::string &iface, sptr<InterfaceConfiguration> cfg,
640 if (cfg == nullptr) {
641 NETMGR_EXT_LOG_E("cfg is nullptr");
646 std::string mode = GetIfaceMode(cfg->mode_);
648 if (cfg->mode_ == STATIC || cfg->mode_ == LAN_STATIC) {
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_);
654 std::accumulate(cfg->ipStatic_.routeList_.begin(), cfg->ipStatic_.routeList_.end(), std::string(),
660 std::string dnsServers = AccumulateNetAddress(cfg->ipStatic_.dnsServers_);
669 GenHttpProxyContent(cfg, fileContent);
672 void EthernetConfiguration::GenHttpProxyContent(const sptr<InterfaceConfiguration> &cfg, std::string &fileContent)
674 const auto &exclusionList = cfg->httpProxy_.GetExclusionList();
681 fileContent = fileContent + KEY_PROXY_HOST + cfg->httpProxy_.GetHost() + WRAP;
682 fileContent = fileContent + KEY_PROXY_PORT + std::to_string(cfg->httpProxy_.GetPort()) + WRAP;