void tst_QMailMessagePart::removeHeaderField() { QString addr1("*****@*****.**"); QString addr2("*****@*****.**"); QMailMessage m; QCOMPARE(m.headerFieldText("Resent-From"), QString()); QCOMPARE(m.headerField("Resent-From"), QMailMessageHeaderField()); QCOMPARE(m.headerFieldsText("Resent-From"), QStringList()); QCOMPARE(m.headerFields("Resent-From"), QList<QMailMessageHeaderField>()); m.appendHeaderField("Resent-From", addr1); m.appendHeaderField("Resent-From", addr2); QCOMPARE(m.headerFieldText("Resent-From"), addr1); QCOMPARE(m.headerField("Resent-From").content(), addr1.toLatin1()); QCOMPARE(m.headerFieldsText("Resent-From"), (QStringList() << addr1 << addr2)); QCOMPARE(m.headerFields("Resent-From"), ( QList<QMailMessageHeaderField>() << QMailMessageHeaderField("Resent-From", addr1.toLatin1()) << QMailMessageHeaderField("Resent-From", addr2.toLatin1()) ) ); m.removeHeaderField("X-Unused-Header"); QCOMPARE(m.headerFieldText("Resent-From"), addr1); QCOMPARE(m.headerField("Resent-From").content(), addr1.toLatin1()); QCOMPARE(m.headerFieldsText("Resent-From"), (QStringList() << addr1 << addr2)); QCOMPARE(m.headerFields("Resent-From"), ( QList<QMailMessageHeaderField>() << QMailMessageHeaderField("Resent-From", addr1.toLatin1()) << QMailMessageHeaderField("Resent-From", addr2.toLatin1()) ) ); m.removeHeaderField("Resent-From"); QCOMPARE(m.headerFieldText("Resent-From"), QString()); QCOMPARE(m.headerField("Resent-From"), QMailMessageHeaderField()); QCOMPARE(m.headerFieldsText("Resent-From"), QStringList()); QCOMPARE(m.headerFields("Resent-From"), QList<QMailMessageHeaderField>()); }
BOOLEAN Disasoc(Signal_t *signal) { FrmDesc_t *pfrmDesc; Frame_t *rdu; MacAddr_t Sta; ReasonCode Rsn; U8 vapId = 0; ZDEBUG("Disasoc"); pfrmDesc = signal->frmInfo.frmDesc; rdu = pfrmDesc->mpdu; memcpy((U8 *)&Sta, (U8 *)(addr2(rdu)), 6); Rsn = (ReasonCode)(reason(rdu)); if(memcmp(addr1(rdu), (U8*)&mBssId, 6)){ //Not for this BSSID freeFdesc(pfrmDesc); return TRUE; } UpdateStaStatus(&Sta, STATION_STATE_DIS_ASOC, vapId); freeFdesc(pfrmDesc); //here to handle disassoc ind. pdot11Obj->StatusNotify(STA_DISASSOCIATED, (U8 *)&Sta); return TRUE; }
Dot11Data::Dot11Data(const address_type &dst_hw_addr, const address_type &src_hw_addr) : Dot11(dst_hw_addr) { type(Dot11::DATA); memset(&_ext_header, 0, sizeof(_ext_header)); addr2(src_hw_addr); }
bool SocketFd::Connect(const SocketAddress& addr) { CheckValidity_(); SocketAddress addr2(addr); if (addr2.IsUnresolved()) { if(!addr2.Resolve()) { base_throw(IOException, "Cannot resolve address"); } } sockaddr_in saddr; addr2.ToSockAddr(&saddr); return ::connect(fd_, reinterpret_cast<sockaddr*>(&saddr), sizeof(saddr)) == 0; }
void tst_QMailMessagePart::setHeaderField() { QString addr1("*****@*****.**"); QString addr2("*****@*****.**"); QString ownHdr("hello"); QMailMessage m; m.setHeaderField("To", addr2); QCOMPARE(m.headerFieldText("to"), addr2); QCOMPARE(m.headerField("to").content(), addr2.toLatin1()); // Ensure overwrite m.setHeaderField("To", addr1); m.setHeaderField("X-My-Own-Header", ownHdr); QCOMPARE(m.headerFieldText("to"), addr1); QCOMPARE(m.headerField("to").content(), addr1.toLatin1()); QCOMPARE(m.headerFieldText("X-My-Own-Header"), ownHdr); QCOMPARE(m.headerField("X-My-Own-Header").content(), ownHdr.toLatin1()); QCOMPARE(m.to(), (QList<QMailAddress>() << QMailAddress(addr1))); QCOMPARE(m.recipients(), (QList<QMailAddress>() << QMailAddress(addr1))); QMailMessageMetaData mtdata = *static_cast<QMailMessageMetaData*>(&m); QCOMPARE(mtdata.recipients(), (QList<QMailAddress>() << QMailAddress(addr1))); m.setHeaderField("Cc", addr2); QCOMPARE(m.recipients(), (QList<QMailAddress>() << QMailAddress(addr1) << QMailAddress(addr2))); mtdata = *static_cast<QMailMessageMetaData*>(&m); QCOMPARE(mtdata.recipients(), (QList<QMailAddress>() << QMailAddress(addr1) << QMailAddress(addr2))); QCOMPARE(m.cc(), (QList<QMailAddress>() << QMailAddress(addr2))); QString addr3("*****@*****.**"); m.setHeaderField("Bcc", addr3); QCOMPARE(m.recipients(), (QList<QMailAddress>() << QMailAddress(addr1) << QMailAddress(addr2) << QMailAddress(addr3))); mtdata = *static_cast<QMailMessageMetaData*>(&m); QCOMPARE(mtdata.recipients(), (QList<QMailAddress>() << QMailAddress(addr1) << QMailAddress(addr2) << QMailAddress(addr3))); QCOMPARE(m.bcc(), (QList<QMailAddress>() << QMailAddress(addr3))); QString rfc822 = m.toRfc2822(); QMailMessage m2 = QMailMessage::fromRfc2822(rfc822.toLatin1()); QCOMPARE(m2.headerFieldText("to"), addr1); QCOMPARE(m2.headerField("to").content(), addr1.toLatin1()); QCOMPARE(m2.headerFieldText("X-My-Own-Header"), ownHdr); QCOMPARE(m2.headerField("X-My-Own-Header").content(), ownHdr.toLatin1()); QCOMPARE(m2.to(), (QList<QMailAddress>() << QMailAddress(addr1))); m2.setTo(QList<QMailAddress>() << QMailAddress(addr2)); QCOMPARE(m2.headerFieldText("to"), addr2); QCOMPARE(m2.headerField("to").content(), addr2.toLatin1()); QCOMPARE(m2.to(), (QList<QMailAddress>() << QMailAddress(addr2))); }
int main(int argc, char **argv) { struct in_addr localhost; localhost.s_addr = htonl(0x7f000001); msrp::Ipv4Address addr1("192.168.0.12:5060"); msrp::Ipv4Address addr2("192.168.0.20",1234); msrp::Ipv4Address addr3(localhost,2); std::ostringstream buf; std::cout << addr1 << std::endl; buf << addr1; if (buf.str() != "192.168.0.12:5060") { std::cerr << "Failed at line " << __LINE__ << std::endl; exit (-1); } buf.str(""); std::cout << addr2 << std::endl; buf << addr2; if (buf.str() != "192.168.0.20:1234") { std::cerr << "Failed at line " << __LINE__ << std::endl; exit (-1); } buf.str(""); std::cout << addr3 << std::endl; buf << addr3; if (buf.str() != "127.0.0.1:2") { std::cerr << "Failed at line " << __LINE__ << std::endl; exit (-1); } buf.str(""); assert(addr1.getAddressType() == msrp::Address::IPV4); assert(addr2.getAddressType() == msrp::Address::IPV4); assert(addr3.getAddressType() == msrp::Address::IPV4); assert(addr1.getPort() == 5060); assert(addr2.getPort() == 1234); assert(addr3.getPort() == 2); return 0; }
//Encode UNSAF message with two attributes void UT_CNATFWUNSAFMessage::TestEncode3L() { const TUint8 KExpectedResult[] = { 0, 1, //UNSAF message type: Binding Request 0, 24, //Message length 0x21, 0x12, 0xa4, 0x42, //Magic cookie 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, //TransactionID //RESPONSE-ADDRESS attribute 0, 2, //type 0, 8, //length of value element 0, //undefined 1, //family 0xab, 0xcd, //port 5, 6, 7, 8, //address //MAPPED-ADDRESS attribute 0, 1, //type 0, 8, //length of value element 0, //undefined 1, //family 0x12, 0x34, //port 0x50, 0x40, 0xff, 0xaa //address }; TInetAddr addr(INET_ADDR(5,6,7,8), 0xabcd); CNATFWUNSAFAttribute* attr = CNATFWUNSAFResponseAddressAttribute::NewLC(addr); iMsg->AddAttributeL(attr); CleanupStack::Pop(attr); attr = NULL; TInetAddr addr2(0x5040ffaa, 0x1234); attr = CNATFWUNSAFMappedAddressAttribute::NewLC(addr2); iMsg->AddAttributeL(attr); CleanupStack::Pop(attr); CBufBase* msg = iMsg->EncodeL(); CleanupStack::PushL(msg); EUNIT_ASSERT(CNATFWUNSAFMessage::EHeaderSize + 24 == msg->Size()); CompareEncodedUNSAFMessageL(KExpectedResult, *msg); CleanupStack::PopAndDestroy(msg); }
BOOLEAN ProbeReq(Signal_t *signal) { FrmDesc_t *pfrmDesc; Frame_t *rdu; MacAddr_t sta; Element rSsid; Element *pWPA = NULL; U8 vapId = 0; ZDEBUG("ProbeReq"); pfrmDesc = signal->frmInfo.frmDesc; rdu = pfrmDesc->mpdu; if (!getElem(rdu, EID_SSID, &rSsid)) goto release; if (mHiddenSSID){ //discard broadcast ssid if (eLen(&rSsid) == 0){ goto release; } } memcpy((U8*)&sta, (U8*)addr2(rdu), 6); if (eLen(&rSsid) == 0){ //WPA if (mDynKeyMode == DYN_KEY_TKIP) pWPA = &mWPAIe; mkProbeRspFrm(pfrmDesc, &sta, mBeaconPeriod, mCap, &dot11DesiredSsid, &mBrates, &mPhpm, NULL, (Element *)pWPA, vapId); return sendMgtFrame(signal, pfrmDesc); } else{ if (memcmp(&rSsid, &dot11DesiredSsid, eLen(&dot11DesiredSsid)+2) == 0){ //WPA if (mDynKeyMode == DYN_KEY_TKIP) pWPA = &mWPAIe; mkProbeRspFrm(pfrmDesc, &sta, mBeaconPeriod, mCap, &dot11DesiredSsid, &mBrates, &mPhpm, NULL, (Element *)pWPA, vapId); return sendMgtFrame(signal, pfrmDesc); } } release: ZDEBUG("goto release"); freeFdesc(pfrmDesc); return TRUE; }
/** * This routine was taken from the benchmark manager, to create Dataobjects in code. * It is used for the self test. Depending on compile options, benchmark manager * may not be included, so the relevant code is copied here to be always available. * * @see BenchmarkManager::createDataObject * */ DataObjectRef CacheStrategyUtility::createDataObject(unsigned int numAttr) { char name[128]; char value[128]; unsigned int r; unsigned char macaddr[6]; macaddr[0] = (unsigned char) RANDOM_INT(255); macaddr[1] = (unsigned char) RANDOM_INT(255); macaddr[2] = (unsigned char) RANDOM_INT(255); macaddr[3] = (unsigned char) RANDOM_INT(255); macaddr[4] = (unsigned char) RANDOM_INT(255); macaddr[5] = (unsigned char) RANDOM_INT(255); unsigned char macaddr2[6]; macaddr2[0] = (unsigned char) RANDOM_INT(255); macaddr2[1] = (unsigned char) RANDOM_INT(255); macaddr2[2] = (unsigned char) RANDOM_INT(255); macaddr2[3] = (unsigned char) RANDOM_INT(255); macaddr2[4] = (unsigned char) RANDOM_INT(255); macaddr2[5] = (unsigned char) RANDOM_INT(255); EthernetAddress addr(macaddr); EthernetAddress addr2(macaddr2); InterfaceRef localIface = Interface::create<EthernetInterface>(macaddr, "eth", addr, 0); InterfaceRef remoteIface = Interface::create<EthernetInterface>(macaddr2, "eth2", addr2, 0); DataObjectRef dObj = DataObject::create(NULL, 0, localIface, remoteIface); for (unsigned int i = 0; i < numAttr; i++) { int tries = 0; do { r = RANDOM_INT(32000); sprintf(name, "name"); sprintf(value, "value %d", r); if (tries++ > 10) { HAGGLE_ERR("WARNING: Cannot generate unique attributes in data object... check attribute pool size!\n"); break; } } while (dObj->getAttribute(name, value)); dObj->addAttribute(name, value, 1); //r); } return dObj; }
enum TVerdict CEsockTest19_9::easyTestStepL() { TInetAddr addr, addrOut; TBuf<39> buf; // getting the IP address // set an IPv6 address const TIp6Addr KInet6Addr19_3 = {{{0xff,0xff,0,0,0,0,0,0,0,0,0,0,0x1,0x78,0,0x1}}}; addr.SetAddress(KInet6Addr19_3); // get the address - check the return value is 0 TESTL(addr.Address()==0); // set up an IPv4 compatible address TInetAddr addr2(INET_ADDR(140, 179, 229, 12), 23); addr2.ConvertToV4Compat(); // check conversion addr2.OutputWithScope(buf); TESTL(buf==_L("::140.179.229.12")); // get the address - check it is returned as an IPv4 address addrOut.SetAddress(addr2.Address()); addrOut.OutputWithScope(buf); TESTL(buf==_L("140.179.229.12")); // set up an IPv4 mapped address TInetAddr addr3(INET_ADDR(140, 179, 193, 121), 24); addr3.ConvertToV4Mapped(); // check conversion addr3.OutputWithScope(buf); TESTL(buf==_L("140.179.193.121")); // get the address - check it is returned as an IPv4 address addrOut.SetAddress(addr3.Address()); addrOut.OutputWithScope(buf); TESTL(buf==_L("140.179.193.121")); return EPass; }
BOOLEAN Re_AsocReq(Signal_t *signal) { FrmDesc_t *pfrmDesc; Frame_t *rdu; MacAddr_t Sta; U16 aid = 0; StatusCode asStatus; U8 lsInterval; Element WPA; Element asSsid; Element asRates; //Element extRates; U16 cap; U8 ZydasMode = 0; int i; U8 tmpMaxRate = 0x02; U8 MaxRate; U16 notifyStatus = STA_ASOC_REQ; U16 notifyStatus1 = STA_ASSOCIATED; TypeSubtype type = ST_ASOC_RSP; U8 Preamble = 0; U8 HigestBasicRate = 0; U8 vapId = 0; U8 Len; BOOLEAN bErpSta = FALSE; ZDEBUG("Re_AsocReq"); pfrmDesc = signal->frmInfo.frmDesc; rdu = pfrmDesc->mpdu; lsInterval = listenInt(pfrmDesc->mpdu); //FPRINT_V("lsInterval", lsInterval); cap = cap(pfrmDesc->mpdu); memcpy((U8 *)&Sta, (U8 *)addr2(rdu), 6); if ((isGroup(addr2(rdu))) || (!getElem(rdu, EID_SSID, &asSsid)) || (!getElem(rdu, EID_SUPRATES, &asRates))){ freeFdesc(pfrmDesc); return TRUE; } if ((eLen(&asSsid) != eLen(&dot11DesiredSsid) || memcmp(&asSsid, &dot11DesiredSsid, eLen(&dot11DesiredSsid)+2) != 0)){ freeFdesc(pfrmDesc); return TRUE; } //chaeck capability if (cap & CAP_SHORT_PREAMBLE) Preamble = 1; else Preamble = 0; // Privacy not match if (cap & CAP_PRIVACY){ if (!mPrivacyInvoked){ freeFdesc(pfrmDesc); return TRUE; } } else { if (mPrivacyInvoked){ freeFdesc(pfrmDesc); return TRUE; } } Len = eLen(&asRates); for (i=0; i<Len; i++){ if ( (asRates.buf[2+i] & 0x7f) > tmpMaxRate ){ tmpMaxRate = (asRates.buf[2+i] & 0x7f); if (asRates.buf[2+i] & 0x80) HigestBasicRate = asRates.buf[2+i]; } if (((asRates.buf[2+i] & 0x7f) == 0x21) && (!(cap & CAP_PBCC_ENABLE))){ //Zydas 16.5M void *reg = pdot11Obj->reg; ZydasMode = 1; mZyDasModeClient = TRUE; //FPRINT("ZydasMode"); } } MaxRate = RateConvert((tmpMaxRate & 0x7f), cap); if (signal->id == SIG_REASSOC_REQ) notifyStatus = STA_REASOC_REQ; if (!pdot11Obj->StatusNotify(notifyStatus, (U8 *)&Sta)){ //Accept it if (mDynKeyMode == DYN_KEY_TKIP){ if (getElem(rdu, EID_WPA, &WPA)){ //zd1205_OctetDump("AssocRequest = ", asRdu->body, asRdu->bodyLen); //zd1205_OctetDump("AssocRequest WPA_IE = ", &WPA.buf[2], WPA.buf[1]); if (pdot11Obj->AssocRequest((U8 *)&Sta, rdu->body, rdu->bodyLen)){ //reject asStatus = SC_UNSPEC_FAILURE; goto check_failed; //we need reason code here } } else{ asStatus = SC_UNSPEC_FAILURE; goto wpa_check_failed; } } wpa_check_ok: if (!UpdateStaStatus(&Sta, STATION_STATE_ASOC, vapId)){ asStatus = SC_AP_FULL; } else{ AssocInfoUpdate(&Sta, MaxRate, lsInterval, ZydasMode, Preamble, bErpSta, vapId); aid = AIdLookup(&Sta); asStatus = SC_SUCCESSFUL; if (signal->id == SIG_REASSOC_REQ) notifyStatus1 = STA_REASSOCIATED; pdot11Obj->StatusNotify(notifyStatus1, (U8 *)&Sta); } } else{ wpa_check_failed: asStatus = SC_UNSPEC_FAILURE; } aid |= 0xC000; if (aid != 0xC000){ #ifdef B500_DEBUG FPRINT_V("Aid", aid); FPRINT_V("MaxRate", MaxRate); #endif } check_failed: if (signal->id == SIG_REASSOC_REQ) type = ST_REASOC_RSP; mkRe_AsocRspFrm(pfrmDesc, type, &Sta, mCap, asStatus, aid, &mBrates, NULL, vapId); sendMgtFrame(signal, pfrmDesc); return FALSE; }
void test() { namespace ip = std::net::ip; try { std::error_code ec; // address_v6 constructors. ip::address_v6 addr1; const ip::address_v6::bytes_type const_bytes_value = { { 0 } }; ip::address_v6 addr2(const_bytes_value); // address_v6 functions. unsigned long scope_id = addr1.scope_id(); addr1.scope_id(scope_id); bool b = addr1.is_unspecified(); (void)b; b = addr1.is_loopback(); (void)b; b = addr1.is_multicast(); (void)b; b = addr1.is_link_local(); (void)b; b = addr1.is_site_local(); (void)b; b = addr1.is_v4_mapped(); (void)b; b = addr1.is_v4_compatible(); (void)b; b = addr1.is_multicast_node_local(); (void)b; b = addr1.is_multicast_link_local(); (void)b; b = addr1.is_multicast_site_local(); (void)b; b = addr1.is_multicast_org_local(); (void)b; b = addr1.is_multicast_global(); (void)b; ip::address_v6::bytes_type bytes_value = addr1.to_bytes(); (void)bytes_value; std::string string_value = addr1.to_string(); string_value = addr1.to_string(ec); ip::address_v4 addr3 = addr1.to_v4(); // address_v6 static functions. addr1 = ip::address_v6::from_string("0::0"); addr1 = ip::address_v6::from_string("0::0", ec); addr1 = ip::address_v6::from_string(string_value); addr1 = ip::address_v6::from_string(string_value, ec); addr1 = ip::address_v6::any(); addr1 = ip::address_v6::loopback(); addr1 = ip::address_v6::v4_mapped(addr3); addr1 = ip::address_v6::v4_compatible(addr3); // address_v6 comparisons. b = (addr1 == addr2); (void)b; b = (addr1 != addr2); (void)b; b = (addr1 < addr2); (void)b; b = (addr1 > addr2); (void)b; b = (addr1 <= addr2); (void)b; b = (addr1 >= addr2); (void)b; // address_v6 I/O. std::ostringstream os; os << addr1; std::wostringstream wos; wos << addr1; } catch (std::exception&) { } }
// --------------------------------------------------------------------------- // CStunTurnTests::TestSetSendingStatusTCPL // --------------------------------------------------------------------------- // void CStunTurnTests::TestSetSendingStatusTCPL() { TInetAddr inetAddr; TBuf<40> buffer; CTestClient* client = CTestClient::NewLC( this ); // testserver to wrapper CTestServer* server = CTestServer::NewLC( this ); TInetAddr addr( KInetAddrAny, KTestServerPort ); // stop scheduler when server timer runs out server->OpenL( addr, KTimeoutTime ); iNotificationIsOn = EFalse; TInetAddr testServerAddr; client->ResolveLocalAddrL( testServerAddr, iTestIapId ); testServerAddr.SetPort( KTestServerPort ); iWrapper->SetIncomingAddrL( testServerAddr ); iIfStub.StartActiveSchedulerL( KRunningTime ); iNotificationIsOn = ETrue; // testserver to natfw CTestServer* server2 = CTestServer::NewLC( this ); TInetAddr addr2( KInetAddrAny, KTestServer2Port ); server2->OpenL( addr2, KTimeoutTime ); TInetAddr destination; client->ResolveLocalAddrL( destination, iTestIapId ); destination.SetPort( KTestServer2Port ); destination.Output( buffer ); RDebug::Print( _L( "CStunTurnTests::TestSetSendingStatusTCPL; ADDR: %S PORT: %d" ), &buffer, destination.Port() ); // set sending status active RDebug::Print( _L( "\nTEST CASE: Set Sending Status Active" ) ); iNat.SetSendingStateL( iIfStub.LocalCandidateL(), EStreamingStateActive, destination ); iIfStub.StartActiveSchedulerL( KRunningTime ); server2->Cancel(); // set sending status passive RDebug::Print( _L( "\nTEST CASE: Set Sending Status Passive" ) ); iNat.SetSendingStateL( iIfStub.LocalCandidateL(), EStreamingStatePassive, destination ); iIfStub.StartActiveSchedulerL( KRunningTime ); CleanupStack::PopAndDestroy( server2 ); CleanupStack::PopAndDestroy( server ); CleanupStack::PopAndDestroy( client ); }
void test() { namespace ip = std::experimental::net::ip; try { std::error_code ec; std::string string_value; // address constructors. ip::address addr1; const ip::address_v4 const_addr_v4; ip::address addr2(const_addr_v4); const ip::address_v6 const_addr_v6; ip::address addr3(const_addr_v6); ip::address addr4("127.0.0.1"); ip::address addr5("127.0.0.1", ec); ip::address addr6(string_value); ip::address addr7(string_value, ec); // address functions. bool b = addr1.is_v4(); (void)b; b = addr1.is_v6(); (void)b; b = addr1.is_loopback(); (void)b; b = addr1.is_unspecified(); (void)b; b = addr1.is_multicast(); (void)b; ip::address_v4 addr_v4_value = ip::address_cast<ip::address_v4>(addr1); (void)addr_v4_value; ip::address_v6 addr_v6_value = ip::address_cast<ip::address_v6>(addr1); (void)addr_v6_value; string_value = addr1.to_string(); string_value = addr1.to_string(ec); // address comparisons. b = (addr1 == addr2); (void)b; b = (addr1 != addr2); (void)b; b = (addr1 < addr2); (void)b; b = (addr1 > addr2); (void)b; b = (addr1 <= addr2); (void)b; b = (addr1 >= addr2); (void)b; // address creation functions. addr1 = ip::make_address("127.0.0.1"); addr1 = ip::make_address("127.0.0.1", ec); addr1 = ip::make_address(string_value); addr1 = ip::make_address(string_value, ec); // address I/O. std::ostringstream os; os << addr1; std::wostringstream wos; wos << addr1; } catch (std::exception&) { } }
TVerdict CresolvertpcollisionorlooplStep::doTestStepL() { SetTestStepResult(EFail); CRtpCollisionMng *collMgr = NULL; CRtpSourceEntry *entry = NULL; INFO_PRINTF1(_L("CresolvertpcollisionorlooplStep::doStepL()")); /* Normal Call */ TRAPD(res,collMgr = CRtpCollisionMng::NewL(iRtpController,iSSRC1,iCname1)); if(KErrNone != res) { INFO_PRINTF1(_L("CresolvertpcollisionorlooplStep::doStepL() (iRtpController,iSSRC1,iCname1) Failed")); return TestStepResult(); } entry = collMgr->FindEntry(iSSRC1); /* Set the RTP and RTCP Source address */ TInetAddr addrLocal(iLocalIpAddr,iPort1); entry->SetRtpSourceAddr(addrLocal); addrLocal.SetPort(iPort1 + 1); entry->SetRtcpSourceAddr(addrLocal); //A dummy SSRC is given and a New Source is Created */ TRAP(res,entry = collMgr->CreateNewSourceL(iSSRC2)); if(res != KErrNone) { /* Failed .. Return */ INFO_PRINTF1(_L("CresolvertpcollisionorlooplStep::doStepL() - Failed")); delete collMgr; return TestStepResult(); } /* Set the RTP and RTCP Source address */ TInetAddr addr(iIpAddr1,iPort1); entry->SetRtpSourceAddr(addr); addr.SetPort(iPort1+1); entry->SetRtcpSourceAddr(addr); //A dummy SSRC is given and a New Source is Created */ TRAP(res,entry = collMgr->CreateNewSourceL(iSSRC3)); if(res != KErrNone) { /* Failed .. Return */ INFO_PRINTF1(_L("CresolvertpcollisionorlooplStep::doStepL() - Failed")); delete collMgr; return TestStepResult(); } /* Set the RTP and RTCP Source address */ TInetAddr addr2(iIpAddr2,iPort2); entry->SetRtpSourceAddr(addr2); addr2.SetPort(iPort2+1); entry->SetRtcpSourceAddr(addr2); /* Now check a Normal recv from BABE2 */ entry = collMgr->FindEntry(iSSRC2); if(collMgr->IsCollisionOrLoopback(entry,addr,ERtcp)) { /* This was not a Collision and was flagged as a Collision.*/ INFO_PRINTF1(_L("CresolvertpcollisionorlooplStep::doStepL() - Failed-Normal Rec Flagged as Collision")); delete collMgr; return TestStepResult(); } entry = collMgr->FindEntry(iSSRC2); /* Simulating a Collision. Make a Dummy IP Address */ TInetAddr addr3(iIpAddr3,iPort1); if(!collMgr->IsCollisionOrLoopback(entry,addr3,ERtp)) { /* This was a Collision and was flagged as not a Collision.*/ INFO_PRINTF1(_L("CresolvertpcollisionorlooplStep::doStepL() - Failed - Collision Not Detected")); delete collMgr; return TestStepResult(); } entry = collMgr->FindEntry(iSSRC2); /* Simulating a Collision. Make a Dummy IP Address */ TInetAddr addr_rtcp(iIpAddr3,iPort1+1); if(!collMgr->IsCollisionOrLoopback(entry,addr_rtcp,ERtcp)) { /* This was a Collision and was flagged as not a Collision.*/ INFO_PRINTF1(_L("CresolvertpcollisionorlooplStep::doStepL() - Failed - Collision Not Detected")); delete collMgr; return TestStepResult(); } /* Calling Resolve Collision */ if(collMgr->ResolveRtpCollisionOrLoopL(iSSRC2,addr3,ERtp)) { INFO_PRINTF1(_L("CresolvertpcollisionorlooplStep::doStepL() - Failed - Collision TRUE for processing :(")); delete collMgr; return TestStepResult(); } /* Calling Resolve Collision ..Our Address Given*/ if(!collMgr->ResolveRtpCollisionOrLoopL(iSSRC1,addr3,ERtp)) { INFO_PRINTF1(_L("CresolvertpcollisionorlooplStep::doStepL() - Failed - Local Collision FALSE for processing :(")); delete collMgr; return TestStepResult(); } if(collMgr->GetLocalEntry()->SRC() == iSSRC1) { INFO_PRINTF1(_L("CresolvertpcollisionorlooplStep::doStepL() - Failed - Local SSRC not Changed :(")); delete collMgr; return TestStepResult(); } TInt changedSSRC = collMgr->GetLocalEntry()->SRC(); /* Calling Resolve Collision ..Our Address Given*/ if(!collMgr->ResolveRtpCollisionOrLoopL(collMgr->GetLocalEntry()->SRC(),addr3,ERtp|KIsAlreadySending)) { INFO_PRINTF1(_L("CresolvertpcollisionorlooplStep::doStepL() - Failed - Local Collision FALSE for processing :(")); delete collMgr; return TestStepResult(); } if(collMgr->GetLocalEntry()->SRC() == changedSSRC) { INFO_PRINTF1(_L("CresolvertpcollisionorlooplStep::doStepL() - Failed - Local SSRC not Changed :(")); delete collMgr; return TestStepResult(); } /* Try a Loop Test .. Now */ /* Calling Resolve Collision ..Give the new SSRC and Old Addresss */ if(collMgr->ResolveRtpCollisionOrLoopL(collMgr->GetLocalEntry()->SRC(),addr3,ERtp)) { INFO_PRINTF1(_L("CresolvertpcollisionorlooplStep::doStepL() - Failed - Loop Detection 1 :(")); delete collMgr; return TestStepResult(); } if(collMgr->ResolveRtpCollisionOrLoopL(collMgr->GetLocalEntry()->SRC(),addr3,ERtp|KIsAlreadySending)) { INFO_PRINTF1(_L("CresolvertpcollisionorlooplStep::doStepL() - Failed - Loop Detection 2 :(")); delete collMgr; return TestStepResult(); } /* Calling again */ /* Calling Resolve Collision ..Give the new SSRC and Old Addresss */ if(collMgr->ResolveRtpCollisionOrLoopL(collMgr->GetLocalEntry()->SRC(),addr3,ERtp|KIsAlreadySending)) { INFO_PRINTF1(_L("CresolvertpcollisionorlooplStep::doStepL() - Failed - Loop Detection 3 :(")); delete collMgr; return TestStepResult(); } /* Calling Resolve Collision ..Give the new SSRC and Old Addresss */ if(collMgr->ResolveRtpCollisionOrLoopL(collMgr->GetLocalEntry()->SRC(),addr3,ERtp)) { INFO_PRINTF1(_L("CresolvertpcollisionorlooplStep::doStepL() - Failed - Loop Detection 4 :(")); delete collMgr; return TestStepResult(); } if(collMgr->ResolveRtpCollisionOrLoopL(collMgr->GetLocalEntry()->SRC(),addr3,ERtcp)) { INFO_PRINTF1(_L("CresolvertpcollisionorlooplStep::doStepL() - Failed - Loop Detection 5 :(")); delete collMgr; return TestStepResult(); } /* We have received only one RTP from the colliding Source. What if we receive an RTCP from a Different source With the same SSRC ? */ /*This condition tickles an old issue. So lets keep it that way */ #if 0 TInetAddr addr4(iIpAddr4,iPort4); entry = collMgr->FindEntry(iSSRC1); if(!collMgr->IsCollisionOrLoopback(entry,addr4,ERtcp)) { INFO_PRINTF1(_L("CresolvertpcollisionorlooplStep::doStepL() - Failed - Incorrect Collision Detection")); delete collMgr; return TestStepResult(); } /* Now receiving an RTCP from the same Source.. See it that is not flagged as a Collision */ addr3.SetPort(iPort1+1); entry = collMgr->FindEntry(iSSRC1); if(collMgr->IsCollisionOrLoopback(entry,addr3,ERtcp)) { INFO_PRINTF1(_L("CresolvertpcollisionorlooplStep::doStepL() - Failed - Incorrect Collision Dectection")); delete collMgr; return TestStepResult(); } #endif SetTestStepResult(EPass); delete collMgr; return TestStepResult(); }