* Handle an incoming packets by sending it to the correct function. * @param p the received packet * @param client_addr the sender of the packet */
| 157 | * @param client_addr the sender of the packet |
| 158 | */ |
| 159 | void NetworkUDPSocketHandler::HandleUDPPacket(Packet &p, NetworkAddress &client_addr) |
| 160 | { |
| 161 | PacketUDPType type; |
| 162 | |
| 163 | /* New packet == new client, which has not quit yet */ |
| 164 | this->Reopen(); |
| 165 | |
| 166 | type = (PacketUDPType)p.Recv_uint8(); |
| 167 | |
| 168 | switch (this->HasClientQuit() ? PACKET_UDP_END : type) { |
| 169 | case PACKET_UDP_CLIENT_FIND_SERVER: this->Receive_CLIENT_FIND_SERVER(p, client_addr); break; |
| 170 | case PACKET_UDP_SERVER_RESPONSE: this->Receive_SERVER_RESPONSE(p, client_addr); break; |
| 171 | |
| 172 | default: |
| 173 | if (this->HasClientQuit()) { |
| 174 | Debug(net, 0, "[udp] Received invalid packet type {} from {}", type, client_addr.GetAddressAsString()); |
| 175 | } else { |
| 176 | Debug(net, 0, "[udp] Received illegal packet from {}", client_addr.GetAddressAsString()); |
| 177 | } |
| 178 | break; |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * Helper for logging receiving invalid packets. |
no test coverage detected