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

Method PacketReceived

src/ClientTCPSocket.cpp:1914–2005  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1912
1913
1914bool CClientTCPSocket::PacketReceived(CPacket* packet)
1915{
1916 // 0.42e
1917 bool bResult = false;
1918 uint32 uRawSize = packet->GetPacketSize();
1919
1920 AddDebugLogLineN( logRemoteClient,
1921 CFormat("Packet with protocol %x, opcode %x, size %u received from %s")
1922 % packet->GetProtocol()
1923 % packet->GetOpCode()
1924 % packet->GetPacketSize()
1925 % ( m_client ? m_client->GetFullIP() : "Unknown Client" )
1926 );
1927
1928 wxString exception;
1929
1930 try {
1931 bool process = true;
1932
1933 if ((packet->GetProtocol() == OP_PACKEDPROT) ||
1934 (packet->GetProtocol() == OP_ED2KV2PACKEDPROT)) {
1935
1936 if (!packet->UnPackPacket()) {
1937 AddDebugLogLineN(logZLib, "Failed to decompress client TCP packet.");
1938 bResult = false;
1939 process = false;
1940 } else {
1941 AddDebugLogLineN(logRemoteClient, CFormat("Packet unpacked, new protocol %x, opcode %x, size %u")
1942 % packet->GetProtocol() % packet->GetOpCode() % packet->GetPacketSize());
1943 }
1944 }
1945
1946 if (process) {
1947 switch (packet->GetProtocol()) {
1948 case OP_EDONKEYPROT:
1949 bResult = ProcessPacket(packet->GetDataBuffer(),uRawSize,packet->GetOpCode());
1950 break;
1951 case OP_EMULEPROT:
1952 bResult = ProcessExtPacket(packet->GetDataBuffer(), packet->GetPacketSize(), packet->GetOpCode());
1953 break;
1954 case OP_ED2KV2HEADER:
1955 bResult = ProcessED2Kv2Packet(packet->GetDataBuffer(), packet->GetPacketSize(), packet->GetOpCode());
1956 break;
1957 case OP_ED2KV2PACKEDPROT:
1958 case OP_PACKEDPROT:
1959 // Packed inside packed?
1960 wxFAIL;
1961 break;
1962 default: {
1963 theStats::AddDownOverheadOther(uRawSize);
1964 if (m_client) {
1965 m_client->SetDownloadState(DS_ERROR);
1966 }
1967 Disconnect("Unknown protocol");
1968 bResult = false;
1969 }
1970 }
1971 }

Callers

nothing calls this directly

Calls 12

CFormatClass · 0.85
GetPacketSizeMethod · 0.80
GetProtocolMethod · 0.80
UnPackPacketMethod · 0.80
GetDataBufferMethod · 0.80
SetDownloadStateMethod · 0.80
whatMethod · 0.80
GetClientFullInfoMethod · 0.80
wxStringClass · 0.70
GetOpCodeMethod · 0.45
GetFullIPMethod · 0.45
IsEmptyMethod · 0.45

Tested by

no test coverage detected