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

Method ProcessPacket

src/ClientTCPSocket.cpp:239–970  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237
238
239bool CClientTCPSocket::ProcessPacket(const uint8_t* buffer, uint32 size, uint8 opcode)
240{
241 #ifdef __PACKET_RECV_DUMP__
242 //printf("Rec: OPCODE %x \n",opcode);
243 DumpMem(buffer, size);
244 #endif
245 if (!m_client && opcode != OP_HELLO) {
246 throw wxString("Asks for something without saying hello");
247 } else if (m_client && opcode != OP_HELLO && opcode != OP_HELLOANSWER) {
248 m_client->CheckHandshakeFinished();
249 }
250
251 switch(opcode) {
252 case OP_HELLOANSWER: { // 0.43b
253 AddDebugLogLineN(logRemoteClient, "Remote Client: OP_HELLOANSWER from " + m_client->GetFullIP());
254 theStats::AddDownOverheadOther(size);
255 m_client->ProcessHelloAnswer(buffer, size);
256
257 // start secure identification, if
258 // - we have received OP_EMULEINFO and OP_HELLOANSWER (old eMule)
259 // - we have received eMule-OP_HELLOANSWER (new eMule)
260 if (m_client->GetInfoPacketsReceived() == IP_BOTH) {
261 m_client->InfoPacketsReceived();
262 }
263
264 // Socket might die because of sending in InfoPacketsReceived, so check
265 if (m_client) {
266 m_client->ConnectionEstablished();
267 }
268
269 // Socket might die on ConnectionEstablished somehow. Check it.
270 if (m_client) {
271 Notify_SharedCtrlRefreshClient( m_client->ECID() , AVAILABLE_SOURCE);
272 }
273
274 break;
275 }
276 case OP_HELLO: { // 0.43b
277
278 theStats::AddDownOverheadOther(size);
279 bool bNewClient = !m_client;
280 if (bNewClient) {
281 // create new client to save standard information
282 m_client = new CUpDownClient(this);
283 }
284
285 // Do not move up!
286 AddDebugLogLineN(logRemoteClient, "Remote Client: OP_HELLO from " + m_client->GetFullIP() );
287
288 bool bIsMuleHello = false;
289
290 try{
291 bIsMuleHello = m_client->ProcessHelloPacket(buffer, size);
292 } catch(...) {
293 if (bNewClient && m_client) {
294 // Don't let CUpDownClient::Disconnected be processed for a client which is not in the list of clients.
295 m_client->Safe_Delete();
296 m_client = NULL;

Callers

nothing calls this directly

Calls 15

DumpMemFunction · 0.85
IsLowIDFunction · 0.85
Uint32toStringIPFunction · 0.85
CFormatClass · 0.85
ProcessHelloAnswerMethod · 0.80
InfoPacketsReceivedMethod · 0.80
ECIDMethod · 0.80
ProcessHelloPacketMethod · 0.80
AttachToAlreadyKnownMethod · 0.80
SetCommentDirtyMethod · 0.80

Tested by

no test coverage detected