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