OpenTTD Source
20241121-master-g67a0fccfad
|
Base socket handler for all Content TCP sockets. More...
#include <tcp_content.h>
Public Member Functions | |
NetworkContentSocketHandler (SOCKET s=INVALID_SOCKET) | |
Create a new cs socket handler for a given cs. More... | |
virtual | ~NetworkContentSocketHandler () |
On destructing of this class, the socket needs to be closed. | |
bool | ReceivePackets () |
Receive a packet at TCP level. More... | |
Public Member Functions inherited from NetworkTCPSocketHandler | |
bool | IsConnected () const |
Whether this socket is currently bound to a socket. More... | |
virtual NetworkRecvStatus | CloseConnection (bool error=true) |
This will put this socket handler in a close state. More... | |
void | CloseSocket () |
Close the actual socket of the connection. More... | |
virtual void | SendPacket (std::unique_ptr< Packet > &&packet) |
This function puts the packet in the send-queue and it is send as soon as possible. More... | |
SendPacketsState | SendPackets (bool closing_down=false) |
Sends all the buffered packets out for this client. More... | |
virtual std::unique_ptr< Packet > | ReceivePacket () |
Receives a packet for the given client. More... | |
bool | CanSendReceive () |
Check whether this socket can send or receive something. More... | |
bool | HasSendQueue () |
Whether there is something pending in the send queue. More... | |
NetworkTCPSocketHandler (SOCKET s=INVALID_SOCKET) | |
Construct a socket handler for a TCP connection. More... | |
Public Member Functions inherited from NetworkSocketHandler | |
NetworkSocketHandler () | |
Create a new unbound socket. | |
virtual | ~NetworkSocketHandler ()=default |
Close the socket when destructing the socket handler. | |
void | MarkClosed () |
Mark the connection as closed. More... | |
bool | HasClientQuit () const |
Whether the current client connected to the socket has quit. More... | |
void | Reopen () |
Reopen the socket so we can send/receive stuff again. | |
Protected Member Functions | |
bool | ReceiveInvalidPacket (PacketContentType type) |
Helper for logging receiving invalid packets. More... | |
virtual bool | Receive_CLIENT_INFO_LIST (Packet &p) |
Client requesting a list of content info: uint8_t type uint32_t openttd version (or 0xFFFFFFFF if using a list) Only if the above value is 0xFFFFFFFF: uint8_t count string branch-name ("vanilla" for upstream OpenTTD) string release version (like "12.0") More... | |
virtual bool | Receive_CLIENT_INFO_ID (Packet &p) |
Client requesting a list of content info: uint16_t count of ids uint32_t id (count times) More... | |
virtual bool | Receive_CLIENT_INFO_EXTID (Packet &p) |
Client requesting a list of content info based on an external 'unique' id; GRF ID for NewGRFS, shortname and for base graphics and AIs. More... | |
virtual bool | Receive_CLIENT_INFO_EXTID_MD5 (Packet &p) |
Client requesting a list of content info based on an external 'unique' id; GRF ID + MD5 checksum for NewGRFS, shortname and xor-ed MD5 checksums for base graphics and AIs. More... | |
virtual bool | Receive_SERVER_INFO (Packet &p) |
Server sending list of content info: uint8_t type (invalid ID == does not exist) uint32_t id uint32_t file_size string name (max 32 characters) string version (max 16 characters) uint32_t unique id uint8_t md5sum (16 bytes) uint8_t dependency count uint32_t unique id of dependency (dependency count times) uint8_t tag count string tag (max 32 characters for tag count times) More... | |
virtual bool | Receive_CLIENT_CONTENT (Packet &p) |
Client requesting the actual content: uint16_t count of unique ids uint32_t unique id (count times) More... | |
virtual bool | Receive_SERVER_CONTENT (Packet &p) |
Server sending list of content info: uint32_t unique id uint32_t file size (0 == does not exist) string file name (max 48 characters) After this initial packet, packets with the actual data are send using the same packet type. More... | |
bool | HandlePacket (Packet &p) |
Handle the given packet, i.e. More... | |
Additional Inherited Members | |
Data Fields inherited from NetworkTCPSocketHandler | |
SOCKET | sock |
The socket currently connected to. | |
bool | writable |
Can we write to this socket? | |
Protected Attributes inherited from NetworkSocketHandler | |
std::unique_ptr< class NetworkEncryptionHandler > | receive_encryption_handler |
The handler for decrypting received packets. | |
std::unique_ptr< class NetworkEncryptionHandler > | send_encryption_handler |
The handler for encrypting sent packets. | |
Base socket handler for all Content TCP sockets.
Definition at line 22 of file tcp_content.h.
|
inline |
Create a new cs socket handler for a given cs.
s | the socket we are connected with |
address | IP etc. of the client |
Definition at line 123 of file tcp_content.h.
|
protected |
Handle the given packet, i.e.
pass it to the right parser receive command.
p | the packet to handle |
Definition at line 101 of file tcp_content.cpp.
References Debug, NetworkSocketHandler::HasClientQuit(), PACKET_CONTENT_CLIENT_CONTENT, PACKET_CONTENT_CLIENT_INFO_EXTID, PACKET_CONTENT_CLIENT_INFO_EXTID_MD5, PACKET_CONTENT_CLIENT_INFO_ID, PACKET_CONTENT_CLIENT_INFO_LIST, PACKET_CONTENT_END, PACKET_CONTENT_SERVER_CONTENT, PACKET_CONTENT_SERVER_INFO, Receive_CLIENT_CONTENT(), Receive_CLIENT_INFO_EXTID(), Receive_CLIENT_INFO_EXTID_MD5(), Receive_CLIENT_INFO_ID(), Receive_CLIENT_INFO_LIST(), Receive_SERVER_CONTENT(), Receive_SERVER_INFO(), and Packet::Recv_uint8().
Referenced by ReceivePackets().
|
protectedvirtual |
Client requesting the actual content: uint16_t count of unique ids uint32_t unique id (count times)
p | The packet that was just received. |
Definition at line 177 of file tcp_content.cpp.
References PACKET_CONTENT_CLIENT_CONTENT, and ReceiveInvalidPacket().
Referenced by HandlePacket().
|
protectedvirtual |
Client requesting a list of content info based on an external 'unique' id; GRF ID for NewGRFS, shortname and for base graphics and AIs.
Scenarios and AI libraries are not supported uint8_t count of requests for each request: uint8_t type unique id (uint32_t)
p | The packet that was just received. |
Definition at line 174 of file tcp_content.cpp.
References PACKET_CONTENT_CLIENT_INFO_EXTID, and ReceiveInvalidPacket().
Referenced by HandlePacket().
|
protectedvirtual |
Client requesting a list of content info based on an external 'unique' id; GRF ID + MD5 checksum for NewGRFS, shortname and xor-ed MD5 checksums for base graphics and AIs.
Scenarios and AI libraries are not supported uint8_t count of requests for each request: uint8_t type unique id (uint32_t) md5 (16 bytes)
p | The packet that was just received. |
Definition at line 175 of file tcp_content.cpp.
References PACKET_CONTENT_CLIENT_INFO_EXTID_MD5, and ReceiveInvalidPacket().
Referenced by HandlePacket().
|
protectedvirtual |
Client requesting a list of content info: uint16_t count of ids uint32_t id (count times)
p | The packet that was just received. |
Definition at line 173 of file tcp_content.cpp.
References PACKET_CONTENT_CLIENT_INFO_ID, and ReceiveInvalidPacket().
Referenced by HandlePacket().
|
protectedvirtual |
Client requesting a list of content info: uint8_t type uint32_t openttd version (or 0xFFFFFFFF if using a list) Only if the above value is 0xFFFFFFFF: uint8_t count string branch-name ("vanilla" for upstream OpenTTD) string release version (like "12.0")
p | The packet that was just received. |
Definition at line 172 of file tcp_content.cpp.
References PACKET_CONTENT_CLIENT_INFO_LIST, and ReceiveInvalidPacket().
Referenced by HandlePacket().
|
protectedvirtual |
Server sending list of content info: uint32_t unique id uint32_t file size (0 == does not exist) string file name (max 48 characters) After this initial packet, packets with the actual data are send using the same packet type.
p | The packet that was just received. |
Reimplemented in ClientNetworkContentSocketHandler.
Definition at line 178 of file tcp_content.cpp.
References PACKET_CONTENT_SERVER_CONTENT, and ReceiveInvalidPacket().
Referenced by HandlePacket().
|
protectedvirtual |
Server sending list of content info: uint8_t type (invalid ID == does not exist) uint32_t id uint32_t file_size string name (max 32 characters) string version (max 16 characters) uint32_t unique id uint8_t md5sum (16 bytes) uint8_t dependency count uint32_t unique id of dependency (dependency count times) uint8_t tag count string tag (max 32 characters for tag count times)
p | The packet that was just received. |
Reimplemented in ClientNetworkContentSocketHandler.
Definition at line 176 of file tcp_content.cpp.
References PACKET_CONTENT_SERVER_INFO, and ReceiveInvalidPacket().
Referenced by HandlePacket().
|
protected |
Helper for logging receiving invalid packets.
type | The received packet type. |
Definition at line 166 of file tcp_content.cpp.
References Debug.
Referenced by Receive_CLIENT_CONTENT(), Receive_CLIENT_INFO_EXTID(), Receive_CLIENT_INFO_EXTID_MD5(), Receive_CLIENT_INFO_ID(), Receive_CLIENT_INFO_LIST(), Receive_SERVER_CONTENT(), and Receive_SERVER_INFO().
bool NetworkContentSocketHandler::ReceivePackets | ( | ) |
Receive a packet at TCP level.
Definition at line 128 of file tcp_content.cpp.
References HandlePacket(), and NetworkTCPSocketHandler::ReceivePacket().
Referenced by ClientNetworkContentSocketHandler::SendReceive().