2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
9 * @file tcp_stun.h Basic functions to receive and send TCP packets to/from the STUN server.
12 #ifndef NETWORK_CORE_TCP_STUN_H
13 #define NETWORK_CORE_TCP_STUN_H
15 #include "os_abstraction.h"
19 /** Enum with all types of TCP STUN packets. The order MUST not be changed. **/
20 enum PacketStunType
: uint8_t {
21 PACKET_STUN_SERCLI_STUN
, ///< Send a STUN request to the STUN server.
22 PACKET_STUN_END
, ///< Must ALWAYS be on the end of this list!! (period)
25 /** Base socket handler for all STUN TCP sockets. */
26 class NetworkStunSocketHandler
: public NetworkTCPSocketHandler
{
28 bool ReceiveInvalidPacket(PacketStunType type
);
31 * Send a STUN request to the STUN server letting the Game Coordinator know
32 * what our actually public IP:port is.
34 * uint8_t Game Coordinator protocol version.
35 * string Token to track the current STUN request.
36 * uint8_t Which interface number this is (for example, IPv4 or IPv6).
37 * The Game Coordinator relays this number back in later packets.
39 * @param p The packet that was just received.
40 * @return True upon success, otherwise false.
42 virtual bool Receive_SERCLI_STUN(Packet
&p
);
46 * Create a new cs socket handler for a given cs.
47 * @param s the socket we are connected with.
48 * @param address IP etc. of the client.
50 NetworkStunSocketHandler(SOCKET s
= INVALID_SOCKET
) : NetworkTCPSocketHandler(s
) {}
53 #endif /* NETWORK_CORE_TCP_STUN_H */