| 83 | } |
| 84 | |
| 85 | void NetInterface::processPacketReceiveEvent(NetAddress srcAddress, RawData packetData) |
| 86 | { |
| 87 | |
| 88 | U32 dataSize = packetData.size; |
| 89 | BitStream pStream(packetData.data, dataSize); |
| 90 | |
| 91 | // Determine what to do with this packet: |
| 92 | |
| 93 | if(packetData.data[0] & 0x01) // it's a protocol packet... |
| 94 | { |
| 95 | // if the LSB of the first byte is set, it's a game data packet |
| 96 | // so pass it to the appropriate connection. |
| 97 | |
| 98 | // lookup the connection in the addressTable |
| 99 | NetConnection *conn = NetConnection::lookup(&srcAddress); |
| 100 | if(conn) |
| 101 | conn->processRawPacket(&pStream); |
| 102 | } |
| 103 | else |
| 104 | { |
| 105 | // Otherwise, it's either a game info packet or a |
| 106 | // connection handshake packet. |
| 107 | |
| 108 | U8 packetType; |
| 109 | pStream.read(&packetType); |
| 110 | NetAddress *addr = &srcAddress; |
| 111 | |
| 112 | if(packetType <= GameHeartbeat || packetType == MasterServerExtendedListResponse) |
| 113 | handleInfoPacket(addr, packetType, &pStream); |
| 114 | #ifdef GGC_PLUGIN |
| 115 | else if (packetType == GGCPacket) |
| 116 | { |
| 117 | HandleGGCPacket(addr, (U8*)packetData.data, dataSize); |
| 118 | } |
| 119 | #endif |
| 120 | else |
| 121 | { |
| 122 | // check if there's a connection already: |
| 123 | switch(packetType) |
| 124 | { |
| 125 | case ConnectChallengeRequest: |
| 126 | handleConnectChallengeRequest(addr, &pStream); |
| 127 | break; |
| 128 | case ConnectRequest: |
| 129 | handleConnectRequest(addr, &pStream); |
| 130 | break; |
| 131 | case ConnectChallengeResponse: |
| 132 | handleConnectChallengeResponse(addr, &pStream); |
| 133 | break; |
| 134 | case ConnectAccept: |
| 135 | handleConnectAccept(addr, &pStream); |
| 136 | break; |
| 137 | case Disconnect: |
| 138 | handleDisconnect(addr, &pStream); |
| 139 | break; |
| 140 | case ConnectReject: |
| 141 | handleConnectReject(addr, &pStream); |
| 142 | break; |
nothing calls this directly
no test coverage detected