Ipv4InterfaceContainer Ipv4AddressHelper::Assign (const NetDeviceContainer &c) { NS_LOG_FUNCTION_NOARGS (); Ipv4InterfaceContainer retval; for (uint32_t i = 0; i < c.GetN (); ++i) { Ptr<NetDevice> device = c.Get (i); Ptr<Node> node = device->GetNode (); NS_ASSERT_MSG (node, "Ipv4AddressHelper::Assign(): NetDevice is not not associated " "with any node -> fail"); Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> (); NS_ASSERT_MSG (ipv4, "Ipv4AddressHelper::Assign(): NetDevice is associated" " with a node without IPv4 stack installed -> fail " "(maybe need to use InternetStackHelper?)"); int32_t interface = ipv4->GetInterfaceForDevice (device); if (interface == -1) { interface = ipv4->AddInterface (device); } NS_ASSERT_MSG (interface >= 0, "Ipv4AddressHelper::Assign(): " "Interface index not found"); Ipv4InterfaceAddress ipv4Addr = Ipv4InterfaceAddress (NewAddress (), m_mask); ipv4->AddAddress (interface, ipv4Addr); ipv4->SetMetric (interface, 1); ipv4->SetUp (interface); retval.Add (ipv4, interface); } return retval; }
CRpcHelper::address_str CRpcHelper::GetOrNewAccountAddress( const label_str& label ) { #if 1 Json::Value args; args.append( label ); std::string ret = m_rpc->Send( "getaccountaddress", args ); return address_str( ret ); #else if( GetAddrList_FromLabel( label ).empty() ) { ret = NewAddress( label ); } return address_str( ret ); #endif }
Server* NewServer(AddressType type, char* host, aio4c_port_t port, int bufferSize, int nbPipes, void (*handler)(Event,Connection*,void*), void* handlerArg, void* (*dataFactory)(Connection*,void*)) { Server* server = NULL; ErrorCode code = AIO4C_ERROR_CODE_INITIALIZER; if ((server = aio4c_malloc(sizeof(Server))) == NULL) { #ifndef AIO4C_WIN32 code.error = errno; #else /* AIO4C_WIN32 */ code.source = AIO4C_ERRNO_SOURCE_SYS; #endif /* AIO4C_WIN32 */ code.size = sizeof(Server); code.type = "Server"; Raise(AIO4C_LOG_LEVEL_ERROR, AIO4C_ALLOC_ERROR_TYPE, AIO4C_ALLOC_ERROR, &code); return NULL; } server->address = NewAddress(type, host, port); server->pool = NewBufferPool(bufferSize); server->factory = NewConnectionFactory(server->pool, dataFactory, handlerArg); server->acceptor = NULL; server->thread = NULL; server->handler = handler; server->queue = NewQueue(); server->nbPipes = nbPipes; server->thread = NewThread( "server", _serverInit, _serverRun, _serverExit, (ThreadData)server); if (server->thread == NULL) { FreeAddress(&server->address); FreeBufferPool(&server->pool); FreeConnection(&server->factory); FreeQueue(&server->queue); aio4c_free(server); return NULL; } return server; }