MCPcopy Create free account
hub / github.com/amule-project/amule / ProcessAICHAnswer

Method ProcessAICHAnswer

src/DownloadClient.cpp:1624–1663  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1622}
1623
1624void CUpDownClient::ProcessAICHAnswer(const uint8_t* packet, uint32 size)
1625{
1626 if (m_fAICHRequested == FALSE){
1627 throw wxString("Received unrequested AICH Packet");
1628 }
1629 m_fAICHRequested = FALSE;
1630
1631 CMemFile data(packet, size);
1632 if (size <= 16){
1633 CAICHHashSet::ClientAICHRequestFailed(this);
1634 return;
1635 }
1636
1637 CMD4Hash hash = data.ReadHash();
1638 CPartFile* pPartFile = theApp->downloadqueue->GetFileByID(hash);
1639 CAICHRequestedData request = CAICHHashSet::GetAICHReqDetails(this);
1640 uint16 nPart = data.ReadUInt16();
1641 if (pPartFile != NULL && request.m_pPartFile == pPartFile && request.m_pClient.GetClient() == this && nPart == request.m_nPart){
1642 CAICHHash ahMasterHash(&data);
1643 if ( (pPartFile->GetAICHHashset()->GetStatus() == AICH_TRUSTED || pPartFile->GetAICHHashset()->GetStatus() == AICH_VERIFIED)
1644 && ahMasterHash == pPartFile->GetAICHHashset()->GetMasterHash())
1645 {
1646 if(pPartFile->GetAICHHashset()->ReadRecoveryData(request.m_nPart*PARTSIZE, &data)){
1647 // finally all checks passed, everything seems to be fine
1648 AddDebugLogLineN(logAICHTransfer, "AICH Packet Answer: Succeeded to read and validate received recoverydata");
1649 CAICHHashSet::RemoveClientAICHRequest(this);
1650 pPartFile->AICHRecoveryDataAvailable(request.m_nPart);
1651 return;
1652 } else {
1653 AddDebugLogLineN(logAICHTransfer, "AICH Packet Answer: Succeeded to read and validate received recoverydata");
1654 }
1655 } else {
1656 AddDebugLogLineN( logAICHTransfer, "AICH Packet Answer: Masterhash differs from packethash or hashset has no trusted Masterhash" );
1657 }
1658 } else {
1659 AddDebugLogLineN( logAICHTransfer, "AICH Packet Answer: requested values differ from values in packet" );
1660 }
1661
1662 CAICHHashSet::ClientAICHRequestFailed(this);
1663}
1664
1665
1666void CUpDownClient::ProcessAICHRequest(const uint8_t* packet, uint32 size)

Callers 1

ProcessExtPacketMethod · 0.80

Calls 9

ReadUInt16Method · 0.80
GetAICHHashsetMethod · 0.80
ReadRecoveryDataMethod · 0.80
wxStringClass · 0.70
ReadHashMethod · 0.45
GetFileByIDMethod · 0.45
GetClientMethod · 0.45
GetStatusMethod · 0.45

Tested by

no test coverage detected