Uint16 SubnetTopology::createSourcePath(Address32 source, Address32 destination, Uint16 traffic, bool managementPath, Uint8 maxHops) { LOG_DEBUG("createSourcePath(" << ToStr(source) << ", " << ToStr(destination) << ", traffic = " << traffic << ", maxHops = " << (int) maxHops << ")"); AddressList addressList; DijkstraSearch::searchDijkstra(source, destination, nodes, addressList); if (addressList.size() == 0) { LOG_DEBUG("createPath: There is no path between the " << ToStr(source) << " and " << ToStr(destination)); } else { //LOG_DEBUG("createPath() : the path is : " << NE::Model::Topology::nodesToString(sourcePath)); } Path path(getNextPathId(), source, destination, RoutingTypes::SOURCE_ROUTING, traffic); path.setSourcePath(addressList); paths[path.getGraphId()] = path; LOG_TRACE("createSourcePath end"); return path.getGraphId(); }
bool SubnetTopology::evaluateNextPath(EngineOperations& engineOperations, Path& path) { LOG_DEBUG("evaluateNextPath - " << path); if (getNode(path.getSource()).getNodeType() != NodeType::NODE && getNode(path.getDestination()).getNodeType() != NodeType::NODE) { return true; } path.updateLastEvalTime(); if (path.getType() == RoutingTypes::SOURCE_ROUTING) { AddressList addressList; DijkstraSearch::searchDijkstra(path.getSource(), path.getDestination(), nodes, addressList); if (addressList.size() == 0) { LOG_DEBUG("recreatePath: There is no path between the " << ToStr(path.getSource()) << " and " << ToStr( path.getDestination())); return false; } else if (path.getMaxHops() <= addressList.size()) { LOG_DEBUG("recreatePath: There path is too long for (" << ToStr(path.getSource()) << " -> " << ToStr( path.getDestination()) << " ), hops: " << (int) addressList.size() << " > " << (int) path.getMaxHops()); } else { path.setSourcePath(addressList); return true; } } else if (path.getType() == RoutingTypes::GRAPH_ROUTING || path.getType() == RoutingTypes::GRAPH_ROUTING_WITH_MIN_PATH_SELECTION) { return graphRoutingAlgorithm->evaluateGraphPath(engineOperations, path); } return false; }
int VBoxNetDhcp::hostDnsServers(const ComHostPtr& host, const RTNETADDRIPV4& networkid, const AddressToOffsetMapping& mapping, AddressList& servers) { ComBstrArray strs; HRESULT hrc = host->COMGETTER(NameServers)(ComSafeArrayAsOutParam(strs)); if (FAILED(hrc)) return VERR_NOT_FOUND; /* * Recent fashion is to run dnsmasq on 127.0.1.1 which we * currently can't map. If that's the only nameserver we've got, * we need to use DNS proxy for VMs to reach it. */ bool fUnmappedLoopback = false; for (size_t i = 0; i < strs.size(); ++i) { RTNETADDRIPV4 addr; int rc; rc = RTNetStrToIPv4Addr(com::Utf8Str(strs[i]).c_str(), &addr); if (RT_FAILURE(rc)) continue; if (addr.au8[0] == 127) { AddressToOffsetMapping::const_iterator remap(mapping.find(addr)); if (remap != mapping.end()) { int offset = remap->second; addr.u = RT_H2N_U32(RT_N2H_U32(networkid.u) + offset); } else { fUnmappedLoopback = true; continue; } } servers.push_back(addr); } if (servers.empty() && fUnmappedLoopback) { RTNETADDRIPV4 proxy; proxy.u = networkid.u | RT_H2N_U32_C(1U); servers.push_back(proxy); } return VINF_SUCCESS; }
/*** On abort, unroll allocs, clear lists, exit epoch */ void onTxAbort() { AddressList::iterator i, e; for (i = allocs.begin(), e = allocs.end(); i != e; ++i) { free(*i); } frees.reset(); allocs.reset(); *my_ts = 1+*my_ts; }
/*** On commit, perform frees, clear lists, exit epoch */ void onTxCommit() { AddressList::iterator i, e; for (i = frees.begin(), e = frees.end(); i != e; ++i) { schedForReclaim(*i); } frees.reset(); allocs.reset(); *my_ts = 1+*my_ts; }
void AutoCollectAddresses(const Message *message, MAction autocollectFlag, bool senderOnly, bool collectNamed, const String& bookName, const String& groupName, wxFrame *frame) { static const MessageAddressType addressTypesToCollect[] = { // In this array, the values corresponding to 'Sender' headers // (e.g. From and ReplyTo) must appear before the others. And if // some other 'sender' headers must be taken into account, the ending // index in the for loop below (named stopAt) must be changed. MAT_REPLYTO, MAT_FROM, MAT_TO, MAT_CC, }; // the email addresses we have already seen wxArrayString addressesSeen; const size_t stopAt = senderOnly ? 2 : WXSIZEOF(addressTypesToCollect); for ( size_t n = 0; n < stopAt; n++ ) { AddressList *addrList = message->GetAddressList(addressTypesToCollect[n]); if ( !addrList ) continue; for ( Address *addr = addrList->GetFirst(); addr; addr = addrList->GetNext(addr) ) { const String email = addr->GetEMail(); if ( addressesSeen.Index(email) == wxNOT_FOUND ) { addressesSeen.Add(email); AutoCollectAddress(email, addr->GetName(), autocollectFlag, collectNamed, bookName, groupName, frame); } } addrList->DecRef(); } }
AddrSpecList VacationDialog::mailAliases() const { QCString text = mMailAliasesEdit->text().latin1(); // ### IMAA: !ok AddressList al; const char * s = text.begin(); parseAddressList( s, text.end(), al ); AddrSpecList asl; for ( AddressList::const_iterator it = al.begin() ; it != al.end() ; ++it ) { const MailboxList & mbl = (*it).mailboxList; for ( MailboxList::const_iterator jt = mbl.begin() ; jt != mbl.end() ; ++jt ) asl.push_back( (*jt).addrSpec ); } return asl; }
/*** Wrapper to thread-specific allocator for freeing memory */ void txFree(void* ptr) { if ((*my_ts)&1) { frees.insert(ptr); } else { free(ptr); } }
const IpAddress& NetworkInterfaceImpl::get_dest_address(AddressList::size_type index) const { if (!is_p2p()) { throw NetException("Unsupported operation"); } else if (index < m_address_list.size()) { return std::get<NetworkInterface::BROADCAST_ADDRESS>(m_address_list[index]); } throw NetException("IpAddress of NetworkInterface not found"); }
/*** Wrapper to thread-specific allocator for allocating memory */ void* txAlloc(size_t const &size) { void* ptr = malloc(size); if ((*my_ts)&1) { allocs.insert(ptr); } return ptr; }
void AddressCluster::sList() { AddressList* newdlg = new AddressList(this, "AddressList", true); if (newdlg) { int id = newdlg->exec(); if (id != QDialog::Rejected) { setId(id); _selected = true; } } else QMessageBox::critical(this, tr("A System Error Occurred at %1::%2.") .arg(__FILE__) .arg(__LINE__), tr("Could not instantiate a List Dialog")); }
/*** Wrapper to thread-specific allocator for allocating memory */ void* txAlloc(size_t const &size) { void* ptr = sitemalloc(size); return ptr; // printf("-----------------------------------------------txAlloc %p meta %lx\n", ptr, *(((uint64_t*)ptr)-1)); if ((*my_ts)&1) allocs.insert(ptr); return ptr; }
/*** Wrapper to thread-specific allocator for freeing memory */ void txFree(void* ptr) { sitefree(ptr); return; if ((*my_ts)&1) frees.insert(ptr); else sitefree(ptr); }
/*** On abort, unroll allocs, clear lists, exit epoch */ void onTxAbort() { return; // printf("on tx abort\n"); AddressList::iterator i, e; /* if (allocs.size() > 0){ printf("WARNING: Aborted a transaction that allocated" "elements. Sitevm wont' free those elements (but support for" "this is coming soon!).\n"); } */ /* //This is already done as part of sitevm now. for (i = allocs.begin(), e = allocs.end(); i != e; ++i) sitefree(*i); */ frees.reset(); allocs.reset(); *my_ts = 1+*my_ts; }
void ProfileData::TryNextProfileServer() { if (++curServer == profileServers.end()) Done(); else { profileSocket->Close(0); profileSocket->ReleaseSession(); profileSocket->GetSocket()->SetRemoteAddress(*curServer); SendCreateProfileRequest(this, this->emailAddress.c_str()); } }
//---------------------------------------------------------------------------------------------------------------- /// @brief /// prints menu and takes appropriate action //---------------------------------------------------------------------------------------------------------------- int main(void) { AddressList addresses; int choice; printMenu(); cin>>choice; while(choice != 6) { switch (choice) { case 1: addresses.addAddress(); break; case 2: addresses.delAddress(); break; case 3: addresses.editAddress(); break; case 4: addresses.genBcards(); break; case 5: addresses.genAcards(); break; default: cout<<"invalid input"; break; } printMenu(); cin>>choice; } }
/** * @note: const dropped here, because of map<K,V>::operator[] which isn't const, map<K,V>::at() has const * variant but it's C++11. */ int hostDnsServers(const ComHostPtr& host, const RTNETADDRIPV4& networkid, /*const*/ AddressToOffsetMapping& mapping, AddressList& servers) { servers.clear(); ComBstrArray strs; if (SUCCEEDED(host->COMGETTER(NameServers)(ComSafeArrayAsOutParam(strs)))) { RTNETADDRIPV4 addr; int rc; for (unsigned int i = 0; i < strs.size(); ++i) { rc = RTNetStrToIPv4Addr(com::Utf8Str(strs[i]).c_str(), &addr); if (RT_SUCCESS(rc)) { if (addr.au8[0] == 127) { /* XXX: here we want map<K,V>::at(const K& k) const */ if (mapping[addr] != 0) { addr.u = RT_H2N_U32(RT_N2H_U32(networkid.u) + mapping[addr]); } else continue; /* XXX: Warning here (local mapping wasn't registered) */ } servers.push_back(addr); } } } else return VERR_NOT_FOUND; return VINF_SUCCESS; }
int VBoxNetDhcp::fetchAndUpdateDnsInfo() { ComHostPtr host; if (SUCCEEDED(virtualbox->COMGETTER(Host)(host.asOutParam()))) { AddressToOffsetMapping mapIp4Addr2Off; int rc = localMappings(m_NATNetwork, mapIp4Addr2Off); /* XXX: here could be several cases: 1. COM error, 2. not found (empty) 3. ? */ AssertMsgRCReturn(rc, ("Can't fetch local mappings"), rc); RTNETADDRIPV4 address = getIpv4Address(); RTNETADDRIPV4 netmask = getIpv4Netmask(); AddressList nameservers; rc = hostDnsServers(host, networkid(address, netmask), mapIp4Addr2Off, nameservers); AssertMsgRCReturn(rc, ("Debug me!!!"), rc); /* XXX: Search strings */ std::string domain; rc = hostDnsDomain(host, domain); AssertMsgRCReturn(rc, ("Debug me!!"), rc); { VBoxNetALock(this); ConfigurationManager *confManager = ConfigurationManager::getConfigurationManager(); confManager->flushAddressList(RTNET_DHCP_OPT_DNS); for (AddressList::iterator it = nameservers.begin(); it != nameservers.end(); ++it) confManager->addToAddressList(RTNET_DHCP_OPT_DNS, *it); confManager->setString(RTNET_DHCP_OPT_DOMAIN_NAME, domain); } } return VINF_SUCCESS; }
int SearchTask::valueSearchResults() { const int cbRate = 15; int scans = 0; int length; unsigned int readLen; unsigned long section, size; char finalDumpBytes[3]; char *dataBuf; switch (m_searchValueType) { case SEARCH_VALUE_TYPE_1BYTE: length = 1; break; case SEARCH_VALUE_TYPE_2BYTE: length = 2; break; default: length = 4; break; } unsigned resListSize = getNumberOfResults(*m_results); for (ResultList::iterator it=m_results->begin(); it!=m_results->end(); ++it) //read each section { if (it->second.size() == 0) continue; AddressList keep; m_valueSearcher.clear(); section = it->first; size = it->second.size(); if (size > 10) //lets grab the chunk! { if (m_cancel) return TASK_ERROR_CANCEL; if (section+RANGE_INTERVAL < 0xFFFFFFFF-3 && m_ccapi->readMemory(section+RANGE_INTERVAL, 3) == 0) { dataBuf = m_ccapi->getData(readLen); memcpy(finalDumpBytes, dataBuf, readLen); } if (m_ccapi->readMemory(section, RANGE_INTERVAL) == 0) { dataBuf = m_ccapi->getData(readLen); if (m_ccapi->insertData(readLen, finalDumpBytes, 3)) { for (AddressList::iterator addrIt = it->second.begin(); addrIt != it->second.end();) //read all addresses in a section { if (m_valueSearcher.digestValue(&dataBuf[((*addrIt)->address) - section], *addrIt, section)) //we need to keep it! keep.push_back(*addrIt); addrIt++; if (scans % cbRate == 0) progressCallback(this, scans, resListSize); scans++; } it->second = keep; } } } else { for (AddressList::iterator addrIt = it->second.begin(); addrIt != it->second.end();) //read all addresses in asection { if (m_cancel) return TASK_ERROR_CANCEL; if (m_ccapi->readMemory(((*addrIt)->address), length) == 0) { dataBuf = m_ccapi->getData(readLen); if (m_valueSearcher.digestValue(dataBuf, *addrIt, section)) //we need to keep it! keep.push_back(*addrIt); addrIt++; if (scans % cbRate == 0) progressCallback(this, scans, resListSize); scans++; } } it->second = keep; } } m_taskState = Task::COMPLETE; progressCallback(this, resListSize, resListSize); return TASK_ERROR_NONE; }
const IpAddress& NetworkInterfaceImpl::get_broadcast_address(AddressList::size_type index) const { if (index < m_address_list.size()) { return std::get<NetworkInterface::BROADCAST_ADDRESS>(m_address_list[index]); } throw NetException("IpAddress of NetworkInterface not found"); }
const IpAddress& NetworkInterfaceImpl::get_subnet_mask(AddressList::size_type index) const { if (index < m_address_list.size()) { return std::get<NetworkInterface::SUBNET_MASK>(m_address_list[index]); } throw NetException("IpAddress of NetworkInterface not found"); }
void NetworkInterfaceImpl::add_address(const AddressTuple& address) { m_address_list.emplace_back(address); }
/// main method for manual testing void test(const char* logname) { hostaddresslist_t& ntlpv4addr= gconf.getparref< hostaddresslist_t >(gistconf_localaddrv4); hostaddresslist_t& ntlpv6addr= gconf.getparref< hostaddresslist_t >(gistconf_localaddrv6); // check whether all addresses are really pure IPv4 if (ntlpv4addr.empty() == false) { hostaddresslist_t::iterator it= ntlpv4addr.begin(); while (it != ntlpv4addr.end()) { if ( !it->is_ipv4() ) { WLog("main", "Detected non IPv4 address, removing " << *it ); it= ntlpv4addr.erase(it); } else it++; } // end while } // check whether all addresses are really pure IPv6 if (ntlpv6addr.empty() == false) { hostaddresslist_t::iterator it= ntlpv6addr.begin(); while (it != ntlpv6addr.end()) { if ( !it->is_ipv6() ) { WLog("main", "Detected non-IPv6 address, removing " << *it ); it= ntlpv6addr.erase(it); } else it++; } // end while } // this will set default values NTLPStarterParam ntlppar; AddressList *addresses = new AddressList(); if (ntlpv4addr.size() == 0 && ntlpv6addr.size() == 0) { addresses->add_host_prop(NULL, AddressList::ConfiguredAddr_P); } if (!ntlpv4addr.empty()) { hostaddresslist_t::iterator it= ntlpv4addr.begin(); while (it != ntlpv4addr.end()) { netaddress na(*it); na.set_pref_len(32); addresses->add_property(na, AddressList::ConfiguredAddr_P); it++; } // end while } if (!ntlpv6addr.empty()) { hostaddresslist_t::iterator it= ntlpv6addr.begin(); while (it != ntlpv6addr.end()) { netaddress na(*it); na.set_pref_len(128); addresses->add_property(na, AddressList::ConfiguredAddr_P); it++; } // end while } // set specified IP addresses ntlppar.addresses = addresses; // fill the parameters from configfile or command line // (parameters given by command line will override these) if (config[gconf.parname(gistconf_udpport)].empty() == false) gconf.setpar(gistconf_udpport, (uint16) StringToInt(config[gconf.parname(gistconf_udpport)])); if (config[gconf.parname(gistconf_tcpport)].empty() == false) gconf.setpar(gistconf_tcpport, (uint16) StringToInt(config[gconf.parname(gistconf_tcpport)])); if (config[gconf.parname(gistconf_sctpport)].empty() == false) gconf.setpar(gistconf_sctpport, (uint16) StringToInt(config[gconf.parname(gistconf_sctpport)])); if (config[gconf.parname(gistconf_tlsport)].empty() == false) gconf.setpar(gistconf_tlsport, (uint16) StringToInt(config[gconf.parname(gistconf_tlsport)])); if (config[gconf.parname(gistconf_retrylimit)].empty() == false) gconf.setpar(gistconf_retrylimit, (uint32) StringToInt(config[ gconf.parname(gistconf_retrylimit)])); if (config[gconf.parname(gistconf_retryperiod)].empty() == false) gconf.setpar(gistconf_retryperiod, (uint32) StringToInt(config[ gconf.parname(gistconf_retryperiod)])); if (config[gconf.parname(gistconf_retryfactor)].empty() == false) gconf.setpar(gistconf_retryfactor, StringToDouble(config[ gconf.parname(gistconf_retryfactor)])); if (config[gconf.parname(gistconf_rs_validity_time)].empty() == false) gconf.setpar(gistconf_rs_validity_time, (uint32) StringToInt(config[ gconf.parname(gistconf_rs_validity_time)])); if (config[gconf.parname(gistconf_refresh_limit)].empty() == false) gconf.setpar(gistconf_refresh_limit, (uint32) StringToInt(config[ gconf.parname(gistconf_refresh_limit)])); if (config[gconf.parname(gistconf_ma_hold_time)].empty() == false) gconf.setpar(gistconf_ma_hold_time, (uint32) StringToInt(config[ gconf.parname(gistconf_ma_hold_time)])); if (config[gconf.parname(gistconf_secrets_refreshtime)].empty() == false) gconf.setpar(gistconf_secrets_refreshtime, (uint32) StringToInt(config[ gconf.parname(gistconf_secrets_refreshtime)])); if (config[gconf.parname(gistconf_secrets_count)].empty() == false) gconf.setpar(gistconf_secrets_count, (uint32) StringToInt(config[ gconf.parname(gistconf_secrets_count)])); if (config[gconf.parname(gistconf_secrets_length)].empty() == false) gconf.setpar(gistconf_secrets_length, (uint16) StringToInt(config[ gconf.parname(gistconf_secrets_length)])); if (config[gconf.parname(gistconf_delayedstate)].empty() == false) gconf.setpar(gistconf_delayedstate, StringToBool(config[ gconf.parname(gistconf_delayedstate)])); if (config[gconf.parname(gistconf_senddatainquery)].empty() == false) gconf.setpar(gistconf_senddatainquery, StringToBool(config[ gconf.parname(gistconf_senddatainquery)])); if (config[gconf.parname(gistconf_confirmrequired)].empty() == false) gconf.setpar(gistconf_confirmrequired, StringToBool(config[ gconf.parname(gistconf_confirmrequired)])); if (config[gconf.parname(gistconf_reqhelloecho)].empty() == false) gconf.setpar(gistconf_reqhelloecho, StringToBool(config[ gconf.parname(gistconf_reqhelloecho)])); if (config[gconf.parname(gistconf_advertise_sctp)].empty() == false) gconf.setpar(gistconf_advertise_sctp, StringToBool(config[ gconf.parname(gistconf_advertise_sctp)])); if (config[gconf.parname(gistconf_verbose_error_responses)].empty() == false) gconf.setpar(gistconf_verbose_error_responses, StringToBool(config[ gconf.parname(gistconf_verbose_error_responses)])); if (config[gconf.parname(gistconf_debug_tp)].empty() == false) gconf.setpar(gistconf_debug_tp, StringToBool(config[ gconf.parname(gistconf_debug_tp)])); #ifdef USE_FLOWINFO // Create a flowinfoservice thread FlowinfoParam fiparam; ThreadStarter<Flowinfo, FlowinfoParam> fithread(1, fiparam); fithread.start_processing(); // record the flowinfoservice thread in the ntlp_param ntlppar.fi_service = fithread.get_thread_object(); #endif // give the parameters to NTLP Starter ThreadStarter<NTLPStarter,NTLPStarterParam> ntlpthread(1,ntlppar); global_ntlpthread_p= ntlpthread.get_thread_object(); // NTLP Starter will start all the remaining modules/threads init_signals(); ntlpthread.start_processing(); sleep(2); if (startapimsgchecker) { FastQueue* apimsgrecv_fq= new FastQueue("apimsgchecker",true); QueueManager::instance()->register_queue(apimsgrecv_fq, message::qaddr_api_1); pthread_create(&apimsgreceivethread,NULL,apimsgchecker,NULL); } DLog("ntlp", "Starting GISTConsole"); GISTConsoleParam gistcon_par(getpid(), message::qaddr_api_2); ThreadStarter<GISTConsole, GISTConsoleParam> GISTconsole_thread(1, gistcon_par); GISTconsole_thread.start_processing(); while(!stopped) { sleep(2); } // stop TPchecker Log(EVENT_LOG, LOG_NORMAL, "ntlp", "Stopping apimsgchecker thread"); done = true; while (running) { sleep(1); } // end while not done GISTconsole_thread.stop_processing(); GISTconsole_thread.wait_until_stopped(); if (startapimsgchecker) { QueueManager::instance()->unregister_queue(message::qaddr_api_1); } // stop threads Log(EVENT_LOG, LOG_NORMAL, "ntlp", "Stopping GIST instance"); ntlpthread.stop_processing(); restore_signals(); } // end test
const IpAddress& NetworkInterfaceImpl::get_address(AddressList::size_type address_index) const { if (address_index < m_address_list.size()) { return std::get<NetworkInterface::IP_ADDRESS>(m_address_list[address_index]); } throw NetException("IpAddress of NetworkInterface not found"); }
void connect(::zmq::socket_t& socket, const AddressList& address_list) { typedef typename AddressList::const_iterator iter_t; for (iter_t it = address_list.begin(); it != address_list.end(); ++it) socket.connect(it->c_str()); }