bool ReplicatedConfig::Init() { Endpoint endpoint; nodeID = Config::GetIntValue("paxos.nodeID", 0); numNodes = Config::GetListNum("paxos.endpoints"); if (numNodes == 0) { endpoint.Set("0.0.0.0:10000"); endpoints[0] = endpoint; nodeID = 0; } else { if (nodeID < 0 || nodeID >= numNodes) STOP_FAIL("Configuration error, " "check your paxos.nodeID and paxos.endpoints entry" ,0); for (unsigned i = 0; i < numNodes; i++) { endpoint.Set(Config::GetListValue("paxos.endpoints", i, NULL), true); endpoints[i] = endpoint; } } if (strcmp("replicated", Config::GetValue("mode", "")) == 0) InitRestartCounter(); return true; }
int MediaSession::AudioMixerPortAttachToEndpoint(int mixerId,int portId,int endpointId) { //Get mixer AudioMixers::iterator it = audioMixers.find(mixerId); //If not found if (it==audioMixers.end()) //Exit return Error("AudioMixerResource not found\n"); //Get it AudioMixerResource* audioMixer = it->second; //Get endpoint Endpoints::iterator itEnd = endpoints.find(endpointId); //If not found if (itEnd==endpoints.end()) //Exit return Error("Endpoint not found\n"); //Get it Endpoint* endpoint = itEnd->second; //Log endpoint tag name Log("-AudioMixerPortAttachToEndpoint [%ls]\n",endpoint->GetName().c_str()); //Attach return audioMixer->Attach(portId,endpoint->GetJoinable(MediaFrame::Audio)); }
void SaslConnection::close() { Endpoint client = peer(); Connection::close(); if ( !u || logged || !client.valid() || client.protocol() == Endpoint::Unix ) return; logged = true; Query * q = new Query( "insert into connections " "(username,address,port,mechanism,authfailures," "syntaxerrors,started_at,ended_at,userid) " "values ($1,$2,$3,$4,$5,$6," "$7::interval + 'epoch'::timestamptz," "$8::interval + 'epoch'::timestamptz,$9)", 0 ); q->bind( 1, u->login() ); q->bind( 2, client.address() ); q->bind( 3, client.port() ); q->bind( 4, m ); q->bind( 5, af ); q->bind( 6, sf ); q->bind( 7, s ); q->bind( 8, (uint)time( 0 ) ); q->bind( 9, u->id() ); q->execute(); }
NMErr NMAcceptConnection( NMEndpointRef inEndpoint, void *inCookie, NMEndpointCallbackFunction *inCallback, void *inContext) { DEBUG_ENTRY_EXIT("NMAcceptConnection"); NMErr status = kNMNoError; NMIPEndpointPriv *epRef; Endpoint *ep; NMIPEndpointPriv *newEPRef; op_vassert_return((inEndpoint != NULL),"Endpoint is NIL!",kNMParameterErr); op_vassert_return((inCookie != NULL),"Cookie is NIL!",kNMParameterErr); op_vassert_return((inCallback != NULL),"Callback function is NIL!",kNMParameterErr); epRef = (NMIPEndpointPriv *) inEndpoint; ep = epRef->ep; op_vassert_return((ep != NULL),"Private endpoint is NIL!",kNMParameterErr); op_vassert_return((epRef->id == kModuleID),"Endpoint id is not mine!",kNMParameterErr); // First, we need to create a new endpoint that will be returned to the user status = MakeNewIPEndpointPriv(NULL, inCallback, inContext, ep->mMode, ep->mNetSprocketMode, &newEPRef); if( !status ) status = ep->AcceptConnection(newEPRef->ep, inCookie); // Hands off the new connection async return (status); }
int MediaSession::EndpointAttachToEndpoint(int endpointId,int sourceId,MediaFrame::Type media) { //Get endpoint Endpoints::iterator it = endpoints.find(endpointId); //If not found if (it==endpoints.end()) //Exit return Error("Endpoint not found\n"); //Get it Endpoint* endpoint = it->second; //Log endpoint tag name Log("-EndpointAttachToEndpoint [%ls]\n",endpoint->GetName().c_str()); //Get source endpoint it = endpoints.find(sourceId); //If not found if (it==endpoints.end()) //Exit return Error("Endpoint not found\n"); //Get it Endpoint* source = it->second; //Attach return endpoint->Attach(media,source->GetJoinable(media)); }
NMErr NMReceive( NMEndpointRef inEndpoint, void *ioData, NMUInt32 *ioSize, NMFlags *outFlags) { DEBUG_ENTRY_EXIT("NMReceive"); NMErr status = kNMNoError; NMIPEndpointPriv *epRef; Endpoint *ep; op_vassert_return((inEndpoint != NULL),"Endpoint is NIL!",kNMParameterErr); op_vassert_return((ioData != NULL),"Data pointer is NULL!",kNMParameterErr); op_vassert_return((ioSize != NULL),"Data size pointer is NULL!",kNMParameterErr); op_vassert_return((outFlags != NULL),"Flags pointer is NULL!",kNMParameterErr); op_vassert_return((*ioSize >= 1),"Data size < 1!",kNMParameterErr); epRef = (NMIPEndpointPriv *) inEndpoint; ep = epRef->ep; op_vassert_return((ep != NULL),"Private endpoint is NIL!",kNMParameterErr); op_vassert_return((epRef->id == kModuleID),"Endpoint id is not mine!",kNMParameterErr); status = ep->Receive(ioData, ioSize, outFlags); return (status); }
int main() { int ret = 0; Endpoint ep; try { ep.libCreate(); mainProg3(ep); ret = PJ_SUCCESS; } catch (Error & err) { std::cout << "Exception: " << err.info() << std::endl; ret = 1; } try { ep.libDestroy(); } catch(Error &err) { std::cout << "Exception: " << err.info() << std::endl; ret = 1; } if (ret == PJ_SUCCESS) { std::cout << "Success" << std::endl; } else { std::cout << "Error Found" << std::endl; } return ret; }
int MediaSession::RecorderAttachToEndpoint(int recorderId,int endpointId,MediaFrame::Type media) { //Get Player Recorders::iterator it = recorders.find(recorderId); //If not found if (it==recorders.end()) //Exit return Error("Recorder not found\n"); //Get it Recorder* recorder = it->second; //Get source endpoint Endpoints::iterator itEndpoints = endpoints.find(endpointId); //If not found if (itEndpoints==endpoints.end()) //Exit return Error("Endpoint not found\n"); //Get it Endpoint* source = itEndpoints->second; //Attach return recorder->Attach(media,source->GetJoinable(media)); }
int MediaSession::EndpointDelete(int endpointId) { //Get Player Endpoints::iterator it = endpoints.find(endpointId); //If not found if (it==endpoints.end()) //Exit return Error("Endpoint not found\n"); //Get it Endpoint* endpoint = it->second; //Log endpoint tag name Log("-EndpointDelete [%ls]\n",endpoint->GetName().c_str()); //Remove from list endpoints.erase(it); //End it endpoint->End(); //Relete endpoint delete(endpoint); return 1; }
int Connection::connect( const Endpoint &e ) { if ( !e.valid() ) return -1; if ( !valid() ) { init( socket( e.protocol() ) ); if ( !valid() ) return -1; } int n = ::connect( d->fd, e.sockaddr(), e.sockaddrSize() ); d->pending = false; setState( Connecting ); if ( n == 0 || ( n < 0 && errno == EINPROGRESS ) ) { if ( n == 0 ) { d->event = Connect; d->pending = true; } n = 1; } else { d->event = Error; d->pending = true; n = -1; } return n; }
int MediaSession::VideoTranscoderAttachToEndpoint(int videoTranscoderId,int endpointId) { //Get mixer VideoTranscoders::iterator it = videoTranscoders.find(videoTranscoderId); //If not found if (it==videoTranscoders.end()) //Exit return Error("VideoTranscoder not found [%d]\n",videoTranscoderId); //Get it VideoTranscoder* videoTranscoder = it->second; //Get endpoint Endpoints::iterator itEnd = endpoints.find(endpointId); //If not found if (itEnd==endpoints.end()) //Exit return Error("Endpoint not found [%d]\n",endpointId); //Get it Endpoint* endpoint = itEnd->second; //Log endpoint tag name Log("-VideoTranscoderAttachToEndpoint [transcoder:%ls,endpoint:%ls]\n",videoTranscoder->GetName().c_str(),endpoint->GetName().c_str()); //Attach return videoTranscoder->Attach(endpoint->GetJoinable(MediaFrame::Video)); }
Network::msg_l3_status_t BaseRFApplication::sendPropertyReport(univmsg_l7_any_t* msg, bool cmd_mc_last, uint8_t clusterID, uint8_t endpointID) { MW_LOG_DEBUG_TRACE(MW_LOG_BASERF); //6.a.1) GET: create empty endpoint_value_t and call getProperty Endpoint::endpoint_value_t value; value.len = BASERF_MESSAGE_PAYLOAD_MAXLEN - BASERF_MESSAGE_PAYLOAD_HEADERLEN - 2;//12 uint8_t maxLen = value.len;//12 value.pvalue = &msg->data[2];//reusing the allocated buffer with a proper offset Endpoint* endpoint = m_device->getCluster(clusterID)->getEndpoint(endpointID); endpoint->getProperty(&value); int result = ERROR_INVALID_DATA; MW_LOG_DEBUG_TRACE(MW_LOG_BASERF) << PSTR("Endpoint value len: ") << value.len; if ( value.len > 0 && value.len <= maxLen ) { //prepare the message structure msg->msg_header.cmd_id = BASERF_CMD_PROPERTY_REP; msg->msg_header.cmd_mc = cmd_mc_last ? false : true; msg->msg_header.dataLen = value.len + 2;//extra bytes in the header msg->data[0] = clusterID; msg->data[1] = endpointID; result = sendMessage(msg); } else { MW_LOG_WARNING(MW_LOG_BASERF, "No report sent! Invalid data for C:E=%d:%d", clusterID, endpointID); } MW_LOG_DEBUG_TRACE(MW_LOG_BASERF) << PSTR("result=") << result; return result; }
void udp_server_task(void const *argument) { DigitalOut indicator(LED1); UDPSocket server; server.bind(ECHO_SERVER_PORT); // printf("[udp_server_task] Start\r\n"); Endpoint client; char buffer[BUFFER_SIZE] = { 0 }; while (true) { //printf("[udp_server_task] Wait for packet...\r\n"); int n = server.receiveFrom(client, buffer, sizeof(buffer)); if (n > 0) { //printf("[udp_server_task] Received packet from: %s\r\n", client.get_address()); const int buffer_string_end_index = n >= BUFFER_SIZE ? BUFFER_SIZE - 1 : n; buffer[buffer_string_end_index] = '\0'; //printf("[udp_server_task] Server received: %s\r\n", buffer); if (host_port == 0) { strcpy(host_address, client.get_address()); host_port = ECHO_SERVER_PORT + 1; //printf("[udp_server_task] Set host address and port: %s:%d\r\n", host_address, host_port); } // Dispatch data to client for sending to test HOST cli_serv_mutex.lock(); // LOCK // Push to datagram queue datagram_queue.push_front(std::string(buffer)); max_queue_len = datagram_queue.size() > max_queue_len ? datagram_queue.size() : max_queue_len; received_packets++; cli_serv_mutex.unlock(); // LOCK indicator = !indicator; } } }
void BroadcastReceiver::operator() (timeval *pTimeout) throw (FatalError) { // only one thread allowed per instance if(0 == std::atomic_fetch_add(&mNumInstances, 1)) try { size_t numRemotes = mIpTable.size(); timeval endTime, now; gettimeofday(&endTime, NULL); timeval_add(&endTime, pTimeout); do { const Endpoint remote = GetNextRemote(pTimeout); if(remote.IsValid()) { numRemotes++; } gettimeofday(&now, NULL); } while(mIsRunning && timeval_sub(&endTime, &now, pTimeout)); } catch(FatalError& e) { std::atomic_fetch_sub(&mNumInstances, 1); throw(e); } std::atomic_fetch_sub(&mNumInstances, 1); }
std::unique_ptr<fs::LocalHandle> Arbiter::getLocalHandle( const std::string path, const Endpoint& tempEndpoint) const { std::unique_ptr<fs::LocalHandle> localHandle; if (isRemote(path)) { if (tempEndpoint.isRemote()) { throw ArbiterError("Temporary endpoint must be local."); } std::string name(path); std::replace(name.begin(), name.end(), '/', '-'); std::replace(name.begin(), name.end(), '\\', '-'); std::replace(name.begin(), name.end(), ':', '_'); tempEndpoint.put(name, getBinary(path)); localHandle.reset( new fs::LocalHandle(tempEndpoint.root() + name, true)); } else { localHandle.reset( new fs::LocalHandle(fs::expandTilde(stripType(path)), false)); } return localHandle; }
int MediaSession::EndpointAttachToPlayer(int endpointId,int playerId,MediaFrame::Type media) { //Get endpoint Endpoints::iterator it = endpoints.find(endpointId); //If not found if (it==endpoints.end()) //Exit return Error("Endpoint not found\n"); //Get it Endpoint* endpoint = it->second; //Log endpoint tag name Log("-EndpointAttachToPlayer [%ls]\n",endpoint->GetName().c_str()); //Get Player Players::iterator itPlayer = players.find(playerId); //If not found if (itPlayer==players.end()) //Exit return Error("Player not found\n"); //Get it Player* player = itPlayer->second; //Attach return endpoint->Attach(media,player->GetJoinable(media)); }
void SuiteEndpoint::Test() { // Test bad DNS look ups Endpoint ep; TEST_THROWS(ep.SetAddress(Brn("baddomainname.linn.co.uk")), NetworkError); TEST_THROWS(Endpoint ep2(1234, Brn("baddomainname.linn.co.uk")); (void)ep2, NetworkError); }
int MediaSession::EndpointAttachToVideoMixerPort(int endpointId,int mixerId,int portId) { //Get endpoint Endpoints::iterator it = endpoints.find(endpointId); //If not found if (it==endpoints.end()) //Exit return Error("Endpoint not found\n"); //Get it Endpoint* endpoint = it->second; //Log endpoint tag name Log("-EndpointAttachToVideoMixerPort [%ls]\n",endpoint->GetName().c_str()); //Get Player VideoMixers::iterator itMixer = videoMixers.find(mixerId); //If not found if (itMixer==videoMixers.end()) //Exit return Error("VideoMixerResource not found\n"); //Get it VideoMixerResource* videoMixer = itMixer->second; //And attach return endpoint->Attach(MediaFrame::Video,videoMixer->GetJoinable(portId)); }
/** * Walks the source DDR bus passed in out to the ending unit, and then * creates the DDRSystemBus object that contains information about the whole path */ void walkDDRBus(DDRBus* i_sourceBus, endpointType i_type, MemMcs * i_mcs) { DDRBus* bus = i_sourceBus; Endpoint* source = (i_type == SOURCE) ? &i_sourceBus->source() : &i_sourceBus->endpoint(); Endpoint* endpoint = (i_type == SOURCE) ? &i_sourceBus->endpoint() : &i_sourceBus->source(); endpointType type = (i_type == SOURCE) ? ENDPOINT : SOURCE; bool done = false; //only need to walk busses if there's more than 1 segment if (endpoint->unit().empty()) { do { bus = mrwGetNextBus<DDRBus>(bus, type); if (!bus) break; if (type == SOURCE) done = !bus->source().unit().empty(); else done = !bus->endpoint().unit().empty(); } while (!done); } if (!bus) { ostringstream msg; msg << "Couldn't complete a DDR bus that started at " << i_sourceBus->plug()->path() << "/" << i_sourceBus->source().id() << "/" << i_sourceBus->source().unit(); mrwError(msg.str()); return; } //the midpoint of the system bus - the source of the DDR/end of the DMI. //The ID of i_sourceBus->source() is the centaur instance //The unit of i_sourceBus->source is the DDR unit MemMba* mba = new MemMba(i_sourceBus->plug(), *source); //the destination of the system bus, the DIMM MemDram* dram = new MemDram(bus->plug(), (type == SOURCE) ? bus->source() : bus->endpoint()); if (mrwLogger::getDebugMode()) { string m = "Found DDR endpoint " + mrwUnitPath(dram->plug(), dram->dramEndpoint()); mrwLogger::debug(m); } //the whole system bus MemSystemBus* systemBus = new MemSystemBus(i_mcs, mba, dram); g_systemBusList.push_back(systemBus); }
int MediaSession::EndpointAttachToVideoTranscoder(int endpointId,int videoTranscoderId) { //Get endpoint Endpoints::iterator it = endpoints.find(endpointId); //If not found if (it==endpoints.end()) //Exit return Error("Endpoint not found [%d]\n",endpointId); //Get it Endpoint* endpoint = it->second; //Get Video transcoder VideoTranscoders::iterator itTranscoder = videoTranscoders.find(videoTranscoderId); //If not found if (itTranscoder==videoTranscoders.end()) //Exit return Error("VideoTranscoder not found[%d]\n",videoTranscoderId); //Get it VideoTranscoder* videoTranscoder = itTranscoder->second; //Log endpoint tag name Log("-EndpointAttachToVideoTranscoder [endpoint:%ls,transcoder:%ls]\n",endpoint->GetName().c_str(),videoTranscoder->GetName().c_str()); //And attach return endpoint->Attach(MediaFrame::Video,videoTranscoder); }
NMSInt32 NMSend( NMEndpointRef inEndpoint, void *inData, NMUInt32 inSize, NMFlags inFlags) { DEBUG_ENTRY_EXIT("NMSend"); NMSInt32 rv; NMIPEndpointPriv *epRef; Endpoint *ep; NMErr status = kNMNoError; op_vassert_return((inEndpoint != NULL),"Endpoint is NIL!",kNMParameterErr); op_vassert_return((inData != NULL),"Data pointer is NULL!",kNMParameterErr); op_vassert_return((inSize > 0),"Data size < 1!",kNMParameterErr); epRef = (NMIPEndpointPriv *) inEndpoint; ep = epRef->ep; op_vassert_return((ep != NULL),"Private endpoint is NIL!",kNMParameterErr); op_vassert_return((epRef->id == kModuleID),"Endpoint id is not mine!",kNMParameterErr); // Send returns the number of bytes actually sent, or an error rv = ep->Send(inData, inSize, inFlags); return (rv); }
void resolve_no_block( implementation_type & impl, NetName const & name, error_code & ec) { Endpoint svc; svc_cache_.find(name, svc, ec); if (ec) { impl->ec = ec; impl->state = ResolveTask::finished; return; } // 可能service只有一种 impl->name = name; impl->name.protocol((NetName::ProtocolEnum)svc.protocol()); impl->endpoints.clear(); impl->ec.clear(); bool found = host_cache_.find(impl->name, impl->endpoints); if (found) { for (size_t i = 0; i < impl->endpoints.size(); ++i) { impl->endpoints[i].port(svc.port()); } } else { ec = boost::asio::error::would_block; } #ifndef FRAMEWORK_NETWORK_WITH_SERVICE_CACHE impl->name.svc(format(svc.port())); #endif impl->state = ResolveTask::waiting; tasks_.push_back(impl); if (tasks_.size() == 1 && tasks2_.empty()) { sync_data_->cond.notify_one(); } }
bool P3ReplicationGroup::prebindDataToReplica(OverlayPeerInfoPtr& replica) { ACE_GUARD_RETURN(ACE_SYNCH_RECURSIVE_MUTEX, mon, m_lock, false); ACE_Connector<FTDataClientHandler, ACE_SOCK_Connector> connector; Endpoint endpoint; replica->getFTDataSAPInfo()->getFirstEndpoint(endpoint); ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3ReplicationGroup::prebindDataToReplica - SAP=%s\n"), endpoint.toString().c_str())); ThreadPerConnection *tpc = new ThreadPerConnection(); //ACE_Strong_Bound_Ptr<ThreadPerConnection, ACE_Recursive_Thread_Mutex>* tpcPrt = new // ACE_Strong_Bound_Ptr<ThreadPerConnection, ACE_Recursive_Thread_Mutex > (tpc); ExecutionModelPtr* tpcPrt = new ExecutionModelPtr(tpc); FTDataClientHandler* ftDataClient = new FTDataClientHandler(this, replica->getUUID(), replica->getFID(), this->getGroupUUID(), false, false, tpcPrt, 0, 0, 0); CPUReservation* reserve = 0; CPUQoS* cpuQoS = new CPUPriorityQoS(CPUQoS::SCHEDULE_RT_DEFAULT, CPUQoS::MAX_RT_PRIO); if (this->m_ft->getQoSManager() != 0) { reserve = m_ft->getQoSManager()->createCPUReservation("HRT", cpuQoS); } tpc->bind(ftDataClient); tpc->open(reserve, cpuQoS); //tpc->bind(ftDataClient); connector.reactor(tpc->getResources()->getReactor()); if (connector.connect(ftDataClient, endpoint.getAddr()) == -1) { ACE_ERROR((LM_ERROR, ACE_TEXT("(%T)%@\n"), ACE_TEXT("(%T)ERROR: P3ReplicationGroup::prebindDataToReplica - connect failed:"))); ftDataClient->close(); delete ftDataClient; return false; } else { if (m_debugP3ReplicationGroup) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3ReplicationGroup::prebindDataToReplica - Connect Data to Replica - OK! UUID=%s\n"), replica->getUUID()->toString().c_str())); } } ftDataClient->preBindSession(); if (m_clientDataManager.add(ftDataClient) == -1) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3ReplicationGroup::prebindDataToReplica - failed to add to group UUID=%s\n"), replica->getUUID()->toString().c_str())); return false; } if (ftDataClient->asynchronous(true, false) == -1) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3ReplicationGroup::prebindDataToReplica - failed to add to async UUID=%s\n"), replica->getUUID()->toString().c_str())); ftDataClient->close(); return false; } ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3ReplicationGroup::prebindDataToReplica - OK! UUID=%s\n"), replica->getUUID()->toString().c_str())); return true; }
void OpenHome::Os::NetworkConnect(THandle aHandle, const Endpoint& aEndpoint, TUint aTimeoutMs) { int32_t err = OsNetworkConnect(aHandle, aEndpoint.Address(), aEndpoint.Port(), aTimeoutMs); if (err != 0) { LOG2F(kNetwork, kError, "Os::NetworkConnect H = %d, RETURN VALUE = %d\n", aHandle, err); THROW(NetworkError); } }
void mainProg() throw(Error) { Endpoint ep; // Create library ep.libCreate(); string json_str; { JsonDocument jdoc; AccountConfig accCfg; accCfg.idUri = "\"Just Test\" <sip:[email protected]>"; accCfg.regConfig.registrarUri = "sip:pjsip.org"; SipHeader h; h.hName = "X-Header"; h.hValue = "User header"; accCfg.regConfig.headers.push_back(h); accCfg.sipConfig.proxies.push_back("<sip:sip.pjsip.org;transport=tcp>"); accCfg.sipConfig.proxies.push_back("<sip:sip.pjsip.org;transport=tls>"); accCfg.mediaConfig.transportConfig.tlsConfig.ciphers.push_back(1); accCfg.mediaConfig.transportConfig.tlsConfig.ciphers.push_back(2); accCfg.mediaConfig.transportConfig.tlsConfig.ciphers.push_back(3); AuthCredInfo aci; aci.scheme = "digest"; aci.username = "******"; aci.data = "passwd"; aci.realm = "*"; accCfg.sipConfig.authCreds.push_back(aci); jdoc.writeObject(accCfg); json_str = jdoc.saveString(); std::cout << "Original:" << std::endl; std::cout << json_str << std::endl << std::endl; } { JsonDocument rdoc; rdoc.loadString(json_str); AccountConfig accCfg; rdoc.readObject(accCfg); JsonDocument wdoc; wdoc.writeObject(accCfg); json_str = wdoc.saveString(); std::cout << "Parsed:" << std::endl; std::cout << json_str << std::endl << std::endl; } ep.libDestroy(); }
void testEndpoint () { testcase ("Endpoint"); { std::pair <Endpoint, bool> result ( Endpoint::from_string_checked ("1.2.3.4")); expect (result.second); if (expect (result.first.address().is_v4 ())) { expect (result.first.address().to_v4() == AddressV4 (1, 2, 3, 4)); expect (result.first.port() == 0); expect (to_string (result.first) == "1.2.3.4"); } } { std::pair <Endpoint, bool> result ( Endpoint::from_string_checked ("1.2.3.4:5")); expect (result.second); if (expect (result.first.address().is_v4 ())) { expect (result.first.address().to_v4() == AddressV4 (1, 2, 3, 4)); expect (result.first.port() == 5); expect (to_string (result.first) == "1.2.3.4:5"); } } Endpoint ep; ep = Endpoint (AddressV4 (127,0,0,1), 80); expect (! is_unspecified (ep)); expect (! is_public (ep)); expect ( is_private (ep)); expect (! is_multicast (ep)); expect ( is_loopback (ep)); expect (to_string (ep) == "127.0.0.1:80"); ep = Endpoint (AddressV4 (10,0,0,1)); expect (AddressV4::get_class (ep.to_v4()) == 'A'); expect (! is_unspecified (ep)); expect (! is_public (ep)); expect ( is_private (ep)); expect (! is_multicast (ep)); expect (! is_loopback (ep)); expect (to_string (ep) == "10.0.0.1"); ep = Endpoint (AddressV4 (166,78,151,147)); expect (! is_unspecified (ep)); expect ( is_public (ep)); expect (! is_private (ep)); expect (! is_multicast (ep)); expect (! is_loopback (ep)); expect (to_string (ep) == "166.78.151.147"); }
THandle Os::NetworkAccept(THandle aHandle, Endpoint& aClient) { TIpAddress clientAddress; TUint32 clientPort; THandle handle = OsNetworkAccept(aHandle, &clientAddress, &clientPort); aClient.SetAddress(clientAddress); aClient.SetPort(clientPort); return handle; }
const char* Socket::ToString(char s[ENDPOINT_STRING_SIZE]) { Endpoint endpoint; if (!GetEndpoint(endpoint)) return ""; return endpoint.ToString(s); }
void B777MCP::initialize() { CDebugLog("initialize"); EndpointListIterator iter; for(iter = m_endpoints.begin(); iter != m_endpoints.end(); iter++) { Endpoint endpoint = *iter; endpoint.sendValue(m_connection, true); } }
NMErr MakeNewIPEndpointPriv( NMConfigRef inConfig, NMEndpointCallbackFunction *inCallback, void *inContext, NMUInt32 inMode, NMBoolean inNetSprocketMode, NMIPEndpointPriv **theEP) { NMErr status = kNMNoError; Endpoint *ep = NULL; NMIPConfigPriv *config = (NMIPConfigPriv *) inConfig; NMUInt32 mode = (config == NULL) ? inMode : config->connectionMode; *theEP = new NMIPEndpointPriv; if (*theEP == NULL) { status = kNMBadStateErr; goto error; } ep = new OTIPEndpoint((NMEndpointRef) *theEP, mode); if (ep == NULL) { status = kNMBadStateErr; goto error; } // Set NetSprocket mode ep->mNetSprocketMode = (config == NULL) ? inNetSprocketMode : config->netSprocketMode; // Install the user's callback function status = ep->InstallCallback(inCallback, inContext); if (status) goto error; // Allow the endpoint to do one-time init stuff status = ep->Initialize(inConfig); if (status) goto error; (*theEP)->ep = ep; (*theEP)->id = kModuleID; error: if (status) { if( *theEP ) delete *theEP; if( ep ) delete ep; *theEP = NULL; } return status; }