enum TVerdict CEsockTest19_7::easyTestStepL() { TInetAddr addr; TBuf<39> buf; // set IP address using a prefix length // set IP address addr.PrefixMask(60); // check it has been set correctly addr.OutputWithScope(buf); TESTL(buf==_L("ffff:ffff:ffff:fff0::")); // change the IP address addr.Input(_L("1.1.1.1.1.1.1.1")); // set the IP address using a different prefisx length addr.PrefixMask(58); // check it has been set correctly addr.OutputWithScope(buf); TESTL(buf==_L("ffff:ffff:ffff:ffc0::")); return EPass; }
enum TVerdict CEsockTest19_1::easyTestStepL() { TInetAddr addr; TBuf<39> buf; // setting the IP address const TIp6Addr KInet6Addr19_1 = {{{0xff,0xfe,0,0,0,0,0,0,0,0,0,0,0,0,0x29,0xfe}}}; const TIp6Addr KInet6Addr19_2 = {{{0xff,0xf1,0,1,0,1,0,1,0,1,0,1,0,1,0x29,0xff}}}; // setting the IP address // set the address addr.SetAddress(KInet6Addr19_1); // check it has been set correctly addr.OutputWithScope(buf); TESTL(buf==_L("fffe::29fe")); // check port number initialised to 0 TESTL(addr.Port()==0); // change the address addr.SetAddress(KInet6Addr19_2); // check it has been set correctly addr.OutputWithScope(buf); TESTL(buf==_L("fff1:1:1:1:1:1:1:29ff")); // check port number is still set to 0 TESTL(addr.Port()==0); return EPass; }
enum TVerdict CEsockTest19_6::easyTestStepL() { TInetAddr addr; TBuf<39> buf; // convert to V4 // set address to IPv6 unspecified address addr.Input(_L("::")); // convert to IPv4 format addr.ConvertToV4(); addr.OutputWithScope(buf); // check address has been reformatted correctly addr.OutputWithScope(buf); TESTL(buf==_L("0.0.0.0")); // change address to IPv4 compatible address addr.Input(_L("::199.12.255.21")); // convert to IPv4 format addr.ConvertToV4(); // check address has been reformatted correctly addr.OutputWithScope(buf); TESTL(buf==_L("199.12.255.21")); // change address to IPv4 mapped address addr.Input(_L("::FFFF:149.124.223.12")); // convert to IPv4 format addr.ConvertToV4(); // check address has been reformatted correctly addr.OutputWithScope(buf); TESTL(buf==_L("149.124.223.12")); return EPass; }
// --------------------------------------------------------------------------- // Build internal address info object from internal address information. // --------------------------------------------------------------------------- // EXPORT_C void VPNAddrInfo::BuildVPNAddrInfo( const CInternalAddress* aInternalAddr, const TInetAddr& aDnsServerAddr, TVPNAddress& aVPNAddress, MIkeDebug& aDebug ) { __ASSERT_DEBUG( aInternalAddr != NULL, User::Invariant() ); aVPNAddress.iVPNIfAddr = aInternalAddr->iClientIntAddr; // // Add DNS address(es) to the virtual TVPNAddress object // TInt dnsCount = aInternalAddr->Count(); if ( dnsCount ) { aVPNAddress.iVPNIfDNS1 = *(aInternalAddr->At(0)); if ( dnsCount > 1 ) { aVPNAddress.iVPNIfDNS2 = *(aInternalAddr->At(1)); } } else { if ( aDnsServerAddr.Address() != KAFUnspec ) { #ifdef _DEBUG TBuf<39> addrBuf; aDnsServerAddr.OutputWithScope( addrBuf ); aDebug.LogWriteF(_L("DNS Server Address in IKE data %S"), &addrBuf); #endif //_DEBUG aVPNAddress.iVPNIfDNS1 = aDnsServerAddr; } else { #ifdef _DEBUG aDebug.LogWrite(_L("DNS server not defined in policy")); #endif // _DEBUG } } }
// // RunReader // void CDnsSocketWriter::RunReader(const TMsgBuf &aMsg, const TInetAddr &aFrom) { if (iRunReader) return; iRunReader = 1; #ifdef _LOG { TBuf<50> tmp; aFrom.OutputWithScope(tmp); Log::Printf(_L("CDnsSocketWriter[%u]::RunReader() read %d bytes from %S#%d"), this, (TInt)aMsg.Length(), &tmp, aFrom.Port()); } #endif if (aMsg.Length() >= TInt(sizeof(TDndHeader))) { const TDndHeader &hdr = aMsg.Header(); const TUint16 id = (TUint16)hdr.ID(); if (hdr.QR()) { // // This is a reply message, match it with // a waiting request, if any... // // Things get somewhat tricky, because almost anything // can happen inside the Reply (like DeactivateSocket, // ActivateSocketL, removal of any requests, requeing // for sent, etc... // Grab the current list into separate list. Note, that // Query or Reply callbacks are allowed to remove entries // from this temporary queue (the TDnsRequest::Cancel and // CDnsSocket::Redmove() still work correctly--they don't // care which chain the request belongs!), TRequestQueue reply(iWaitQueue); TUint mark = iDeactivateCount; TDnsRequest *rq; for (;;) { rq = reply.Remove(); if (rq == NULL) { // Didn't match any request, punt it into Query() iMaster.Query(aMsg, aFrom, iSocket); break; } iWaitQueue.AddLast(*rq); if (rq->iId == id && rq->Reply(iMaster, aMsg, aFrom)) break; } if (iDeactivateCount == mark) { // // No socket shutdown occurred, just reinsert remaining requests // while ((rq = reply.Remove()) != NULL) iWaitQueue.AddLast(*rq); } else { // // Socket was shut within Reply, all requests // should have been cancelled then... // while ((rq = reply.Remove()) != NULL) { rq->iQueueLink.SetWriter(NULL); rq->Abort(iMaster, KErrCancel); } } } else { // // Not a reply message, let the derived // class decide on how to deal with it. // iMaster.Query(aMsg, aFrom, iSocket); } } iRunReader = 0; if (iOpened ) // still open for business? { // Start a new read iReader->Activate(); } }