| 423 | |
| 424 | |
| 425 | std::size_t CNetworkServer::RecvConnectionInit(std::shared_ptr<CNetworkPeer> peer, const void* data, std::size_t maxlength) |
| 426 | { |
| 427 | if (maxlength < TPacketConnectionInit::size()) |
| 428 | return 0; |
| 429 | |
| 430 | if (maxlength != TPacketConnectionInit::size()) |
| 431 | { |
| 432 | NETWORK_LOG(LL_CRI, "Packet size mismatch it can be combined packet!"); |
| 433 | return TPacketConnectionInit::size(); |
| 434 | } |
| 435 | |
| 436 | auto packet = reinterpret_cast<const TPacketConnectionInit*>(data); |
| 437 | |
| 438 | // Packet sum check |
| 439 | auto pCorrectChecksum = g_nmApp->NetworkMgrInstance()->CreateChecksum(data, maxlength - (NET_CHECKSUM_LENGTH /* hash */ + NET_CHECKSUM_LENGTH /* sum */)); |
| 440 | if (pCorrectChecksum != packet->ulChecksum) |
| 441 | { |
| 442 | NETWORK_LOG(LL_CRI, "Packet checksum mismatch! Current: %p Correct: %p", packet->ulChecksum, pCorrectChecksum); |
| 443 | return TPacketConnectionInit::size(); |
| 444 | } |
| 445 | |
| 446 | switch (packet->pConnectionType) |
| 447 | { |
| 448 | case NM_CONNECTION_TYPE_SERVICE: |
| 449 | case NM_CONNECTION_TYPE_CLIENT: |
| 450 | { |
| 451 | // Register connection type of peer |
| 452 | peer->SetConnectionType(packet->pConnectionType); |
| 453 | |
| 454 | // Create & Send pre crypt dynamic key |
| 455 | peer->SendPreCryptKey(); |
| 456 | |
| 457 | } break; |
| 458 | |
| 459 | // case NM_CONNECTION_TYPE_P2P_MASTER_SERVER: |
| 460 | // case NM_CONNECTION_TYPE_GAME_SERVER: |
| 461 | // case NM_CONNECTION_TYPE_WEB_INTERFACE: |
| 462 | // { |
| 463 | // TODO_MSG; |
| 464 | // } break; |
| 465 | |
| 466 | default: |
| 467 | NETWORK_LOG(LL_ERR, "Unknown connection type: %X", packet->pConnectionType); |
| 468 | boost::system::error_code e; |
| 469 | peer->Disconnect(e); |
| 470 | break; |
| 471 | } |
| 472 | |
| 473 | NETWORK_LOG(LL_SYS, "Connection type info packet received! Type: %X", packet->pConnectionType); |
| 474 | |
| 475 | return TPacketConnectionInit::size(); |
| 476 | } |
| 477 | |
| 478 | std::size_t CNetworkServer::RecvNotificationPacket(std::shared_ptr<CNetworkPeer> peer, const void* data, std::size_t maxlength) |
| 479 | { |
nothing calls this directly
no test coverage detected