OpenTTD Source  1.11.2
tcp_content.h
Go to the documentation of this file.
1 /*
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/>.
6  */
7 
12 #ifndef NETWORK_CORE_TCP_CONTENT_H
13 #define NETWORK_CORE_TCP_CONTENT_H
14 
15 #include "os_abstraction.h"
16 #include "tcp.h"
17 #include "packet.h"
18 #include "../../debug.h"
19 #include "tcp_content_type.h"
20 
23 protected:
25  void Close() override;
26 
28 
36  virtual bool Receive_CLIENT_INFO_LIST(Packet *p);
37 
45  virtual bool Receive_CLIENT_INFO_ID(Packet *p);
46 
59  virtual bool Receive_CLIENT_INFO_EXTID(Packet *p);
60 
74  virtual bool Receive_CLIENT_INFO_EXTID_MD5(Packet *p);
75 
92  virtual bool Receive_SERVER_INFO(Packet *p);
93 
101  virtual bool Receive_CLIENT_CONTENT(Packet *p);
102 
113  virtual bool Receive_SERVER_CONTENT(Packet *p);
114 
115  bool HandlePacket(Packet *p);
116 public:
122  NetworkContentSocketHandler(SOCKET s = INVALID_SOCKET, const NetworkAddress &address = NetworkAddress()) :
124  client_addr(address)
125  {
126  }
127 
129  virtual ~NetworkContentSocketHandler() { this->Close(); }
130 
131  bool ReceivePackets();
132 };
133 
134 #ifndef OPENTTD_MSU
136 #endif /* OPENTTD_MSU */
137 
138 #endif /* NETWORK_CORE_TCP_CONTENT_H */
NetworkContentSocketHandler
Base socket handler for all Content TCP sockets.
Definition: tcp_content.h:22
NetworkContentSocketHandler::Receive_SERVER_CONTENT
virtual bool Receive_SERVER_CONTENT(Packet *p)
Server sending list of content info: uint32 unique id uint32 file size (0 == does not exist) string f...
Definition: tcp_content.cpp:237
NetworkContentSocketHandler::ReceivePackets
bool ReceivePackets()
Receive a packet at TCP level.
Definition: tcp_content.cpp:186
NetworkContentSocketHandler::Receive_CLIENT_INFO_EXTID_MD5
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 ...
Definition: tcp_content.cpp:234
ContentType
ContentType
The values in the enum are important; they are used as database 'keys'.
Definition: tcp_content_type.h:16
PacketContentType
PacketContentType
Enum with all types of TCP content packets.
Definition: tcp_content_type.h:32
NetworkContentSocketHandler::Receive_CLIENT_INFO_EXTID
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,...
Definition: tcp_content.cpp:233
NetworkContentSocketHandler::client_addr
NetworkAddress client_addr
The address we're connected to.
Definition: tcp_content.h:24
NetworkContentSocketHandler::~NetworkContentSocketHandler
virtual ~NetworkContentSocketHandler()
On destructing of this class, the socket needs to be closed.
Definition: tcp_content.h:129
tcp_content_type.h
Packet
Internal entity of a packet.
Definition: packet.h:40
NetworkContentSocketHandler::ReceiveInvalidPacket
bool ReceiveInvalidPacket(PacketContentType type)
Helper for logging receiving invalid packets.
Definition: tcp_content.cpp:225
NetworkAddress
Wrapper for (un)resolved network addresses; there's no reason to transform a numeric IP to a string a...
Definition: address.h:29
NetworkContentSocketHandler::Receive_CLIENT_CONTENT
virtual bool Receive_CLIENT_CONTENT(Packet *p)
Client requesting the actual content: uint16 count of unique ids uint32 unique id (count times)
Definition: tcp_content.cpp:236
packet.h
NetworkContentSocketHandler::Receive_CLIENT_INFO_LIST
virtual bool Receive_CLIENT_INFO_LIST(Packet *p)
Client requesting a list of content info: byte type uint32 openttd version.
Definition: tcp_content.cpp:231
NetworkContentSocketHandler::Receive_CLIENT_INFO_ID
virtual bool Receive_CLIENT_INFO_ID(Packet *p)
Client requesting a list of content info: uint16 count of ids uint32 id (count times)
Definition: tcp_content.cpp:232
tcp.h
NetworkContentSocketHandler::NetworkContentSocketHandler
NetworkContentSocketHandler(SOCKET s=INVALID_SOCKET, const NetworkAddress &address=NetworkAddress())
Create a new cs socket handler for a given cs.
Definition: tcp_content.h:122
Subdirectory
Subdirectory
The different kinds of subdirectories OpenTTD uses.
Definition: fileio_type.h:108
os_abstraction.h
GetContentInfoSubDir
Subdirectory GetContentInfoSubDir(ContentType type)
Helper to get the subdirectory a ContentInfo is located in.
Definition: tcp_content.cpp:245
NetworkContentSocketHandler::HandlePacket
bool HandlePacket(Packet *p)
Handle the given packet, i.e.
Definition: tcp_content.cpp:159
NetworkContentSocketHandler::Close
void Close() override
Really close the socket.
Definition: tcp_content.cpp:144
NetworkContentSocketHandler::Receive_SERVER_INFO
virtual bool Receive_SERVER_INFO(Packet *p)
Server sending list of content info: byte type (invalid ID == does not exist) uint32 id uint32 file_s...
Definition: tcp_content.cpp:235
NetworkTCPSocketHandler
Base socket handler for all TCP sockets.
Definition: tcp.h:29