void ClientIpBook::getAllAddress( vector<u32> &myListen, vector< pair<u32, u32> > &peer ) { std::vector<MCD_STR> localip;//=CFiContext::GetStringArr(_T("/fiScm")); //CFiContext::GetString(_T("/fiScm/LocalIp")); localip.push_back(CFiContext::GetString(_T("/fiScm/LocalIp"))); vector<u32> internalIpLocal; vector<u32> internalIpOther; vector<u32> externalIpLocal; vector<u32> externalIpOther; m_cfg.getIpSummary(internalIpLocal,internalIpOther,externalIpLocal,externalIpOther); for (std::vector<MCD_STR>::iterator it=localip.begin(); it!=localip.end();++it) { for (vector<u32>::iterator looper=externalIpOther.begin();looper!=externalIpOther.end(); ++looper) { CStdString temp = (tstring)(*it); peer.push_back(make_pair(ConvertIPtoDWORD(temp),*looper)); } } }
FicsCfgParser::FicsCfgParser( MCD_CSTR cfgName ) { m_nodeNum = 0; CMarkup xml; tstring strTmp; const u32 invalidNodeNo = -1; u32 curNode = invalidNodeNo, backupNode = invalidNodeNo; bool brTmp = false; if (!xml.Load(cfgName)) { VTRACE(_T("load ficsconfig xml[%s] failed \n"), cfgName); return; } if (xml.FindElem(_T("/fics/NodeServersInfo"))){ xml.IntoElem(); while (xml.FindElem(_T("OneNodeServer"))) { xml.IntoElem(); brTmp = xml.FindElem(_T("NodeSeq")); assert(brTmp); strTmp = xml.GetData(); curNode = MCD_TTOI(strTmp.c_str()); //½âÎöInternalIPs brTmp = xml.FindElem(_T("InternalIPs")); assert(brTmp); xml.IntoElem(); vector<u32> tmp; tmp.clear(); while (xml.FindElem(_T("IP"))) { strTmp = xml.GetData(); CStdString ipTmp = strTmp.c_str(); tmp.push_back(ConvertIPtoDWORD(ipTmp)); m_ipToNode[ConvertIPtoDWORD(ipTmp)] = curNode; } if (isLocalNodeIp(tmp)){ m_internalIpLocal.insert(m_internalIpLocal.end(), tmp.begin(), tmp.end()); }else { m_internalIpOther.insert(m_internalIpOther.end(), tmp.begin(), tmp.end()); } m_nodeToInternalIp[curNode] = tmp; xml.OutOfElem(); //½âÎöExternalIps brTmp = xml.FindElem(_T("ExternalIps")); assert(brTmp); xml.IntoElem(); tmp.clear(); while (xml.FindElem(_T("IP"))) { strTmp = xml.GetData(); CStdString ipTmp = strTmp.c_str(); tmp.push_back(ConvertIPtoDWORD(ipTmp)); m_ipToNode[ConvertIPtoDWORD(ipTmp)] = curNode; } if (isLocalNodeIp(tmp)){ m_externalIpLocal.insert(m_externalIpLocal.end(), tmp.begin(), tmp.end()); }else { m_externalIpOther.insert(m_externalIpOther.end(), tmp.begin(), tmp.end()); } m_nodeToExternalIp[curNode] = tmp; brTmp = xml.FindElem(_T("MdsBackNodeSeq")); if (brTmp){ strTmp = xml.GetData(); backupNode = MCD_TTOI(strTmp.c_str()); }else{ backupNode = invalidNodeNo; } m_nodeToBackup[curNode] = backupNode; xml.OutOfElem(); xml.OutOfElem(); } } if (xml.FindElem(_T("/fics/nodeStripPar"))) { xml.IntoElem(); strTmp = xmlNode.GetData(); m_nodeStripPar = atoi(strTmp); xml.OutOfElem(); } else { m_nodeStripPar = 2 * 1024 * 1024; } }
BOOL CNetConfig::ReadXml() { CMarkup xml; tstring strTmp; if (!xml.Load(_T("finet.xml"))) { printf("load finet xml failed \n"); return FALSE; } if (xml.FindChildElem(_T("iocpnum"))) { xml.IntoElem(); strTmp = xml.GetData(); if (!strTmp.empty()) { #if (defined(_WIN32) || defined(_WIN64)) char tmp[64]; memset(tmp,0,64); UTF16ConvertANSI((WCHAR*)strTmp.c_str(), strTmp.length(), tmp, 64); m_iocp_num = atoi(tmp); #else m_iocp_num = atoi(strTmp.c_str()); #endif } xml.OutOfElem(); } if (xml.FindChildElem(_T("local"))) { xml.IntoElem(); CHostInfo hs; if (xml.FindChildElem(_T("host"))) { xml.IntoElem(); while (xml.FindChildElem(_T("ip"))) { xml.IntoElem(); strTmp = xml.GetData(); CStdString aa = strTmp.c_str(); CNetCard nc(ConvertIPtoDWORD(aa)); hs.AddCard(nc,FiGetPid()); xml.OutOfElem(); } xml.OutOfElem(); } CProcId cid = hs.m_mapProcId.begin()->second; hs.m_identify = cid.m_mapIp.begin()->first; m_LocalIp = hs; xml.OutOfElem(); } if (xml.FindChildElem(_T("remote"))) { xml.IntoElem(); while (xml.FindChildElem(_T("host"))) { CHostInfo *hs = new CHostInfo; xml.IntoElem(); while (xml.FindChildElem(_T("ip"))) { xml.IntoElem(); strTmp = xml.GetData(); CStdString bb = strTmp.c_str(); CNetCard nc(ConvertIPtoDWORD(bb)); hs->AddCard(nc, FiGetPid()); xml.OutOfElem(); /// all remote ip can be indexed by ip (ip to all ip (hostinfo class)) m_RemoteIp.insert(make_pair(nc.GetIp(),hs)); } xml.OutOfElem(); } xml.OutOfElem(); } return TRUE; }