/** * Called when the context has been activated to set our IP address and get * any other required settings from CommDB. * * @param aConfig The new context config */ void CIPv4Binder::UpdateContextConfigL(const TPacketDataConfigBase& aConfig) { OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONTEXTCONFIGL_1, "CIPv4Binder::UpdateContextConfig"); // Get our IP address from the GPRS context config. TInetAddr address; TBuf<RPacketContext::KMaxPDPAddressLength> tempAddr; const RPacketContext::TProtocolConfigOptionV2* pco; TInt rel = const_cast<TPacketDataConfigBase&>(aConfig).ExtensionId(); if (rel == TPacketDataConfigBase::KConfigGPRS) { tempAddr.Copy(static_cast<const RPacketContext::TContextConfigGPRS&>(aConfig).iPdpAddress); pco = &static_cast<const RPacketContext::TContextConfigGPRS&>(aConfig).iProtocolConfigOption; } else { ASSERT(rel == TPacketDataConfigBase::KConfigRel99Rel4 || rel == TPacketDataConfigBase::KConfigRel5); tempAddr.Copy(static_cast<const RPacketContext::TContextConfigR99_R4&>(aConfig).iPdpAddress); pco = &static_cast<const RPacketContext::TContextConfigR99_R4&>(aConfig).iProtocolConfigOption; } TInt ret = address.Input(tempAddr); // We've got our IP address! Let's save it. if (ret == KErrNone) { iSettings.iLocalAddr = address.Address(); OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONTEXTCONFIGL_2, "Got local IP address from context = %u.%u.%u.%u",iSettings.iLocalAddr >> 24, (iSettings.iLocalAddr >> 16) & 0xFF, (iSettings.iLocalAddr >> 8) & 0xFF, iSettings.iLocalAddr & 0xFF); iSettings.iDefGateway = address.Address(); OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONTEXTCONFIGL_3, "Set Default Gateway to local IP address"); }
TBool CTcpTestConsole::StartL() { TLex args(iChars); // args are separated by spaces args.SkipSpace(); TInetAddr addr; TInt size; if(!iMode) { //Get ip addr TPtrC cmdAddr = args.NextToken(); if(!args.Eos()) { if(KErrNone == addr.Input(cmdAddr)) { args.Inc(); } else { return EFalse; } } else { return EFalse; } } //Get port TInt port; if(KErrNone != args.Val(port)) { return EFalse; } addr.SetPort(port); //Get pkg size args.Inc(); if(KErrNone != args.Val(size)) { return EFalse; } iCommandMode = ECommandRunning; if (iIsTcp) { iConsole->Printf(_L("Test for TCP...\n")); iTcp = CTcpProcess::NewL(*iConsole, addr, port, size, iMode); } else { iConsole->Printf(_L("Test for UDP...\n")); iUdp = CUdpProcess::NewL(*iConsole, addr, port, size, iMode); } return ETrue; }
/** * Function that takes an IP address from user input, accesses the * Bluetooth PAN Profile table in the CommDb and updates the IpAddr * field with the supplied address. */ void CPanConnections::SetLocalIpAddrL(TUint32 addr) { iLocalIpAddr = addr; iSrcAddr.SetAddress(iLocalIpAddr); CCommsDatabase* db = CCommsDatabase::NewL(); CleanupStack::PushL(db); // Get the LAN service table CCommsDbTableView* tableView = db->OpenTableLC(TPtrC(LAN_SERVICE)); TBuf<KMaxBufferSize> tableName; TInt err = tableView->GotoFirstRecord(); if(err == KErrNone) { // Get the name of the table tableView->ReadTextL(TPtrC(COMMDB_NAME), tableName); if(tableName == TPtrC(_S("BluetoothPANProfile"))) { TInetAddr tempAddr; TBuf<KMaxBufferSize> dispBuf; tempAddr.SetAddress(iLocalIpAddr); tempAddr.Output(dispBuf); User::LeaveIfError(tableView->UpdateRecord()); tableView->WriteTextL(_L("IpAddr"), dispBuf); User::LeaveIfError(tableView->PutRecordChanges()); User::LeaveIfError(db->CommitTransaction()); } } else { User::Leave(KErrNotFound); } CleanupStack::PopAndDestroy(2);//db & tableView }
int TcpipComm::Open(CConsoleBase *cons, TDes &name, TDesC &destination, TRequestStatus &st) { int r; TInetAddr addr; TPtrC servername; int port = 0; if((r = iServ.Connect()) != KErrNone) return r; if((r = iSock.Open(iServ,KAfInet,KSockStream,KProtocolInetTcp)) != KErrNone) return r; ////////////// // Parse the destination, which is of the form ip.adress:port for(r = 0; r < destination.Length(); r++) if(destination[r] == ':') break; servername.Set(destination.Left(r)); // Wont include ':' TLex parser(destination.Mid(r+1)); parser.Val(port); addr.SetPort(port); if(addr.Input(servername) != KErrNone) // Its a real hostname, wont resolv return 1; iSock.Connect(addr, st); TPckgBuf<int> one(1); iSock.SetOpt(KSoTcpNoDelay, KSolInetTcp, one); return 0; }
//------------------------------------------------------------------------------------------------------ // testing // EHRGetByAddress // Requires alive connection. Uses Ethernet one //------------------------------------------------------------------------------------------------------ TInt CPARAM_MESS_NAMEStep::do_execute(Int2Type<EHRGetByAddress>) { TInt result; //-- 1. Create a connection. result = OpenHostResolver(); if(result != KErrNone) { //-- close connection SendReceive(EHRClose,TIpcArgs(0,0,0,iSSRes)); return result; } _LIT(KName, "127.0.0.1"); TBufC<20> aName(KName); TInetAddr addr; addr.Input(aName); TNameEntry aResult; result =SendReceive(EHRGetByAddress,TIpcArgs(&addr,&aResult,0, iSSRes)); if(result != KErrNone) return result; //-- stop connection result = SendReceive(EHRClose,TIpcArgs(0,0,0,iSSRes)); return result; }
void CSender::ConstructL() { // Connect to socket server User::LeaveIfError(iSocketServ.Connect()); User::LeaveIfError(iSocketServ.ShareAuto()); // allow other threads to use iSendSocket.Close(); User::LeaveIfError(iSendSocket.Open(iSocketServ, KAfInet, KSockStream, KProtocolInetTcp)); TRequestStatus status; // Request the Socket to connect to the destination address (implicit Connection) TInetAddr destAddr; destAddr.Input(KRemoteAddr); destAddr.SetPort(KRemotePort); iSendSocket.Connect(destAddr, status); RDEBUGPRINTLOGGER1(_L("RPS: Waiting for Send socket to connect to remote destination ...")); User::WaitForRequest(status); RDEBUGPRINTLOGGER2(_L("RPS: Wait over. Status returned: %d\n"), status.Int()); if(status != KErrNone) { RDEBUGPRINTLOGGER1(_L("RPS: Socket could not Connect!!")); User::Leave(KErrCouldNotConnect); } else { RDEBUGPRINTLOGGER1(_L("RPS: Send socket connected to remote destination ")); } }
// ----------------------------------------------------------------------------- // CUpnpHttpServer::ConnectionAcceptedL // // ----------------------------------------------------------------------------- // CUpnpTcpSession* CUpnpHttpServer::ConnectionAcceptedL( RSocket aSocket ) { LOG_FUNC_NAME; #ifdef _DEBUG TInetAddr tempAddr; aSocket.RemoteName( tempAddr ); tempAddr.ConvertToV4(); const TInt KMaxAdressLength = 20; TBuf<KMaxAdressLength> addrBuf; tempAddr.Output( addrBuf ); HBufC8* addrBuf8 = UpnpString::FromUnicodeL( addrBuf ); CleanupStack::PushL( addrBuf8 ); LOGS( "CUpnpHttpServer::ConnectionAcceptedL - Remote socket connected" ); LOGT( addrBuf8->Des() ); LOGS1("CUpnpHttpServer::ConnectionAcceptedL - Creating a new Http session. Session count: %i", iSessionList.Count()); CleanupStack::PopAndDestroy(addrBuf8); #endif //_DEBUG CUpnpHttpSession* sess = CUpnpHttpSession::NewL( aSocket, this, CUpnpHttpMessage::NewSessionIdL(), EPriorityNormal ); return sess; }
TSAHostCacheEntry::TSAHostCacheEntry(const TInetAddr& aAddress, TInt aQuality) { iPort = aAddress.Port(); iAddress = aAddress.Address(); iQuality = aQuality; }
enum TVerdict CEsockTest2_4::easyTestStepL() { TESTL(EPass == TestStepResult()); // double bind on different sockets // get IP address TInetAddr addr; TESTL(GetIpAddressFromConfig(SectionName(_L("Test_2.4")), _L("ipAddress"), addr)); // set port number to a valid value addr.SetPort(9); // socket already opened - retrieve // socket handle and bind TInt nRet = iEsockSuite->GetSocketHandle(1).Bind(addr); // bind should succeed TESTEL(nRet == KErrNone, nRet); // socket already opened - retrieve // socket handle and bind again to same address nRet = iEsockSuite->GetSocketHandle(2).Bind(addr); // second bind should fail TESTEL(nRet == KErrInUse, nRet); return EPass; }
// --------------------------------------------------------------------------- // SdpUtil::SetDefaultNetTypeAndAddrType // Sets network type and address type to their "default" values // --------------------------------------------------------------------------- // void SdpUtil::SetDefaultNetTypeAndAddrType( RStringPool aPool, const TInetAddr& aAddress, RStringF& aNetType, RStringF& aAddressType ) { // Sets network type to IN aNetType.Close(); aNetType = aPool.StringF( SdpCodecStringConstants::ENetType, SdpCodecStringConstants::Table ).Copy(); // Address type aAddressType.Close(); TBuf16 <KMaxAddressLength> output; aAddress.Output(output); //addresstype for IPv4 if((aAddress.Address() && !aAddress.IsV4Mapped()) || (!aAddress.Address() && aAddress.IsWildAddr() && output.Match(KWildAddr) == 0)) { aAddressType = aPool.StringF( SdpCodecStringConstants::EAddressTypeIP4, SdpCodecStringConstants::Table ).Copy(); } else { //addresstype for IPv4-Mapped IPv6 && IPv6 aAddressType = aPool.StringF( SdpCodecStringConstants::EAddressType, SdpCodecStringConstants::Table ).Copy(); } }
// Help function for address loading, returns // = 0, if address did not change // = 1, if address has changed // static TInt ChangedAddress(TInetAddr &aAddr, const TInetAddr &aNewAddr) { // "Normalize" new address // - convert IPv4 addresess into IPv4 mapped // - anything other then KAfInet6 will be set as None TInetAddr tmp(aNewAddr); if (tmp.Family() == KAfInet) { tmp.ConvertToV4Mapped(); tmp.SetScope(0); // [is already part of "convert" in newer insocks] } else if (tmp.Family() != KAfInet6) tmp.SetAddress(KInet6AddrNone); if (tmp.CmpAddr(aAddr) && // address and port same? tmp.FlowLabel() == aAddr.FlowLabel()) { // If the scope id in new addres is zero, then the // scope id is not part the address compare. // (this will optimize unconnected sockets where application // gives destination without scope -- eliminates unnecessary // flow connect operations. if (tmp.Scope() == aAddr.Scope() || tmp.Scope() == 0) return 0; // No Change to the previous value } // Address is being changed aAddr = tmp; return 1; }
enum TVerdict CEsockTest11_1::easyTestStepL() { // get ip address to connect to TInetAddr addr; TESTL(GetIpAddressFromConfig(_L("Test_Common"), _L("ipAddress"), addr)); // get port number to connect to TInt port; TESTL(GetIntFromConfig(_L("Test_11.1"), _L("port"), port)); // set remote address port addr.SetPort(port); // open a TCP socket RSocket sock; CleanupClosePushL(sock); TInt nRet = sock.Open(iEsockSuite->iSocketServer, KAfInet, KSockStream, KProtocolInetTcp); TESTEL(KErrNone == nRet, nRet); // connect to the remote address TRequestStatus stat; sock.Connect(addr, stat); User::WaitForRequest(stat); TESTEL(stat==KErrNone, stat.Int()); // get the remote name of the connected socket TInetAddr addr1; sock.RemoteName(addr1); // check this matches the address we connected to TESTL(addr.CmpAddr(addr1)); CleanupStack::PopAndDestroy(1, &sock); return EPass; }
TInt RWin32Socket::SendTo(const TDesC8& aSendBuffer, const TInetAddr& aAddress, TRequestStatus& aStatus) { WSP_LOG(WspLog::Printf(_L("RWin32Socket::SendTo: this: 0x%x, bytes to send: %d"), this, aSendBuffer.Length())); TPtr8 addressPtr(const_cast<TUint8*>(aAddress.Ptr()), aAddress.Length(), aAddress.MaxLength()); // Slight hack - need to send two read buffers, but the framework doesn't support this, so send the address as a write buffer. iWin32Message.Set(CWin32Socket::ESendTo, aSendBuffer, addressPtr, aStatus); return MakeRequest(iWin32Message); }
void CWin32Socket::SendTo(TWin32Message& aMessage) { __ASSERT_DEBUG((iSendMessage == NULL) && (iBytesSent == 0), Panic(EWinSockPrtCWin32SocketMultipleSendToRequests)); iSendMessage = &aMessage; WSP_LOG(WspLog::Printf(_L("CWin32Socket::SendTo: this: 0x%x, bytes to send: %d"), this, iSendMessage->ReadBuffer().Length())); TPtrC8 bufPtr(iSendMessage->ReadBuffer()); iSendBuffer.buf = reinterpret_cast<char*>(const_cast<TUint8*>(bufPtr.Ptr())); iSendBuffer.len = bufPtr.Length(); iSendOverlapped.hEvent = (void*) this; TInetAddr address; address.Copy(iSendMessage->WriteBuffer()); SOCKADDR_IN winSockAddress; ConvertAddress(address, winSockAddress); DWORD numberOfBytesSent; TInt ret = WSASendTo(iSocket, &iSendBuffer, 1, &numberOfBytesSent, 0, (LPSOCKADDR)&winSockAddress, sizeof(struct sockaddr_in), &iSendOverlapped, &SendToCompletion); if (ret == SOCKET_ERROR) { TInt err = WSAGetLastError(); if (err != WSA_IO_PENDING) { WSP_LOG(WspLog::Printf(_L("\tsocket error: %d"), err)); Complete(iSendMessage, MapWinSockError(err)); } } }
void UT_CTBCPFloorControlImpl::UT_CTBCPFloorControlImpl_ConnectionStarted2LL( ) { iPlugIn->SetIapId(KIAPID); TBuf<KBufLength> addressbuffer; TInetAddr addr; addr.Input(KAddr3); addr.Output(addressbuffer); iPlugIn->SetAddressL(addressbuffer, KPort1); iPlugIn->SetLocalPort(KPort2); iPlugIn->ConnectL( ETrue ); iPlugIn->ConnectionStarted(0); EUNIT_ASSERT(iError==0); TBuf<KBufLength> addressbuffer2; TInetAddr addr2; addr2.Input(KAddr2); addr2.Output(addressbuffer2); iPlugIn->SetAddressL(addressbuffer2, KPort1); iPlugIn->iConnection->Cancel(); iPlugIn->iConnection->iStatus = KErrNone; iPlugIn->iConnection->RunL(); FC_EUNIT_ASSERT_EQUALS( iError, KErrNone ); }
void UT_CTBCPFloorControlImpl::UT_CTBCPFloorControlImpl_CancelSendL( ) { iPlugIn->SetIapId(KIAPID); TBuf<KBufLength> addressbuffer; TInetAddr addr; addr.Input(KAddr2); addr.Output(addressbuffer); iPlugIn->SetAddressL(addressbuffer, KPort1); iPlugIn->SetLocalPort(KPort2); iPlugIn->ConnectL(ETrue); iPlugIn->iConnection->Cancel(); iPlugIn->iConnection->RunL(); EUNIT_PRINT( _L( "DigiaEunit::Socket has open and start Listen!" ) ); HBufC8* data = HBufC8::NewLC(KLength); data->Des().Copy(KHello); EUNIT_PRINT( _L( "DigiaEunit::BeforeSendToNetL" ) ); iPlugIn ->SendToNetL(data); CleanupStack::Pop( data ); iPlugIn->ConnectL(ETrue); iPlugIn->iConnection->Cancel(); iPlugIn->iConnection->RunL(); iPlugIn->CancelSend(); EUNIT_PRINT( _L( "DigiaEunit::After Cancel Send" ) ); EUNIT_ASSERT( iError==0); }
/** * Handle incoming connects */ void tcp_sock::tcp_conn_handler() { if (!ctc) { DEBUG_WARNING("conn handler: no pending socket\n"); } TInetAddr ia; struct sa peer; ctc->iSocket.RemoteName(ia); sa_set_in(&peer, ia.Address(), ia.Port()); DEBUG_INFO("conn handler: incoming connect from %J\n", &peer); ctc->blank = false; /* * Application handler might call tcp_accept(), tcp_reject() * or do nothing */ if (connh) connh(&peer, arg); if (ctc) { DEBUG_INFO("delete ctc\n"); delete ctc; ctc = NULL; } /* Create blank socket for the next incoming CONNECT */ blank_socket(); cts->Accepting(); }
int ILibSocketWrapper_joinmulticastgroup(int socketObject, long multicastAddress, long multicastInterface) { RSocket *s = (RSocket*)SocketArray[socketObject]; int RetVal; TInetAddr dst; dst.SetAddress(htonl(multicastAddress)); dst.SetPort(0); dst.ConvertToV4Mapped(); TPckgBuf<TIp6Mreq> req; req().iAddr = dst.Ip6Address(); req().iInterface = ILibSocketWrapper_GetInterfaceIndex(multicastInterface); RetVal = s->SetOpt(KSoIp6JoinGroup,KSolInetIp,req); if(RetVal==KErrNone) { return(0); } else { s->SetOpt(KSoIp6LeaveGroup,KSolInetIp,req); return(-1); } }
// --------------------------------------------------------------------------- // NSPUtil::IsUnspecifiedL // --------------------------------------------------------------------------- // TBool NSPUtil::IsUnspecifiedL( const TDesC8& aAddress, TUint aPort ) { TInetAddr addr; TRAPD( error, addr = ConvertTDesC8ToTInetAddrL( aAddress, aPort ) ); User::LeaveIfError( KErrNoMemory == error ? KErrNoMemory : KErrNone ); return ( KErrNone == error ? addr.IsUnspecified() : EFalse ); }
SilcUInt16 silc_net_get_remote_port(SilcSocket sock) { SilcSymbianSocket *s = (SilcSymbianSocket *)sock; TInetAddr addr; s->sock->RemoteName(addr); return (SilcUInt16)addr.Port(); }
SilcUInt16 silc_net_get_local_port(SilcSocket sock) { SilcSymbianSocket *s = (SilcSymbianSocket *)sock; TInetAddr addr; s->sock->LocalName(addr); return (SilcUInt16)addr.Port(); }
void UT_CTBCPFloorControlImpl::UT_CTBCPFloorControlImpl_SetAddressLL( ) { TBuf<KBufLength> addressbuffer; TInetAddr addr; addr.Input(KAddr2); addr.Output(addressbuffer); iPlugIn->SetAddressL(addressbuffer, KPort1); EUNIT_ASSERT( iPlugIn->iRemoteAddr.Address()==addr.Address()); }
int udp_sock::local_get(struct sa *local) const { TInetAddr ia; cus->iSocket.LocalName(ia); sa_set_in(local, ia.Address(), ia.Port()); return 0; }
/** * Function to print the current connections we have. */ void CPanConnections::PrintConns() { iConsole.Printf(_L("\nRemotenames : %d\n"), iRemoteNames.Count()); PrintTcpSocketConnections(); iConsole.Printf(_L("--------------------------------------------------\n")); iConsole.Printf(_L("Listening Mode: ")); iListening ? iConsole.Printf(_L("Enabled ")) : iConsole.Printf(_L("Disabled ")); if(iIapStarted) { iConsole.Printf(_L(" IAP Started")); TInt err = UpdateCurrentConnections(); if(err != KErrNone) { iConsole.Printf(_L("FAILED TO ENUMERATE CONNECTIONS. Err %d\n"), err); } else { iConsole.Printf(_L("\n------------------ CONNECTIONS -------------------\n")); iConsole.Printf(_L("Index Remote Addr\n")); for(TInt i=0;i<iActiveConnections.Count();i++) { TBuf<KMaxBufferSize> dispBuf; iActiveConnections[i].GetReadable(dispBuf); if(iActivePanConn == i) { iConsole.Printf(_L("-> ")); } else { iConsole.Printf(_L(" ")); } iConsole.Printf(_L("%d 0x%S\n"), i, &dispBuf); } } } if(iLocalIpAddr == 0) { iConsole.Printf(_L("\nNo local IP address set\n")); } else { TInetAddr tempAddr; TBuf<KMaxBufferSize> dispBuf; tempAddr.SetAddress(iLocalIpAddr); tempAddr.Output(dispBuf); iConsole.Printf(_L("\nLocal IP address: %S\n"), &dispBuf); } }
void HXSymbianTCPConnector::Connect(RSocket& socket, ULONG32 ulAddr, UINT16 nPort) { m_addr.SetAddress(ulAddr); m_addr.SetPort(nPort); iStatus = KRequestPending; socket.Connect(m_addr, iStatus); SetActive(); }
QHostAddress qt_QHostAddressFromTInetAddr(const TInetAddr& addr) { if (addr.IsV4Mapped() || addr.Family() == KAfInet) { //convert v4 host address return QHostAddress(addr.Address()); } else { //convert v6 host address return QHostAddress((quint8 *)(addr.Ip6Address().u.iAddr8)); } }
void CMSocketS::Listen() { if (m_status != IDLE) { m_pNotify->OnAccept(MERN_INITIALIZE, NULL); return; } CMNetConnMgr& mgr = CMNetConnMgr::Instance(); //网络未接入直接返回失败 if (mgr.CurrentType() == CMNetConnMgr::NONE) { // m_pNotify->OnAccept(MERN_INITIALIZE, NULL); } //构造本地侦听ip,端口 RHostResolver hostResolver; TNameEntry entry; TInetAddr aAddress; User::LeaveIfError( hostResolver.Open( mgr.SocketServer(), KAfInet, KProtocolInetTcp, mgr.Connection() )); CleanupClosePushL( hostResolver ); User::LeaveIfError(hostResolver.GetByName(TPtrC(), entry)); if (!TInetAddr::Cast(entry().iAddr).IsWildAddr()) { aAddress = TInetAddr::Cast(entry().iAddr); } CleanupStack::PopAndDestroy(); // hostResolver aAddress.SetPort(m_nPort); //开始侦听 User::LeaveIfError( m_sk.Open( mgr.SocketServer(), KAfInet, KSockStream, KProtocolInetTcp ) ); User::LeaveIfError( m_sk.Bind( aAddress ) ); User::LeaveIfError( m_sk.Listen( 1 ) ); CMSocketC* pSocketC = new CMSocketC(NULL); // pSocketC->m_status = CMSocketC::CONNECTED; // if (pSocketC == NULL || pSocketC->GetStatus() != CMSocketC::NOTCONNECTED) // { // m_pNotify->OnAccept(MERN_WRONG_PARAM, NULL); // return; // } User::LeaveIfError( pSocketC->m_sk.Open( mgr.SocketServer() ) ); m_sk.Accept( pSocketC->m_sk, iStatus ); m_status = LISTENING; m_pSocketC = pSocketC; SetActive(); }
//TODO: share this, at least QHostInfo needs to do the same thing static QHostAddress qt_QHostAddressFromTInetAddr(const TInetAddr& addr) { //TODO: do we want to call v4 mapped addresses v4 or v6 outside of this file? if (addr.IsV4Mapped() || addr.Family() == KAfInet) { //convert v4 host address return QHostAddress(addr.Address()); } else { //convert v6 host address return QHostAddress((quint8 *)(addr.Ip6Address().u.iAddr8)); } }
enum TVerdict CTestIdna04::doTestStepL() { INFO_PRINTF1(_L(" Testing GetByAddress(for an IDN) with IDN Enabled ")); INFO_PRINTF1(_L("*********************************************************")); SetTestStepResult(EFail); // By default start the test case with failure. RSocketServ pSocketServ; User::LeaveIfError(pSocketServ.Connect()); RConnection myConnection; myConnection.Open(pSocketServ, KAfInet); TRequestStatus myStatus=KErrNone; myConnection.Start(myStatus); User::WaitForRequest(myStatus); RHostResolver hr; hr.Open(pSocketServ,KAfInet,KProtocolInetUdp); TBool enableIdn = ETrue;//enabling the option of IDN support TPckgC<TBool> pckgEnable(enableIdn); TInt setOptErr = hr.SetOpt(KSoDnsEnableIdn , KSolInetDns , pckgEnable); User::LeaveIfError(setOptErr); TInetAddr inetAddr; //inetAddr.Input(_L("83.241.177.38")); // this is the IPAddress of the domain räksmörgås.josefsson.org // as of 06 Feb 2009. If this IP changes, this test case might fail // but no harm on this. //TNameEntry resultEntry; inetAddr.Input(_L("64.233.169.103")); TNameRecord asdf; TPckgBuf<TNameRecord> resultEntry(asdf); hr.GetByAddress(inetAddr,resultEntry,myStatus); User::WaitForRequest(myStatus); TInt err = myStatus.Int(); if(err == KErrNone) { INFO_PRINTF2(_L(" GetByAddress with IDN disabled returned %d"),err); SetTestStepResult(EPass); } hr.Close(); myConnection.Close(); pSocketServ.Close(); return TestStepResult(); }
int tcp_conn_peer_get(const struct tcp_conn *tc, struct sa *peer) { if (!tc || !peer) return EINVAL; TInetAddr ia; tc->ctc->iSocket.RemoteName(ia); sa_set_in(peer, ia.Address(), ia.Port()); return 0; }