OpenTTD
tcp_admin.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_ADMIN_H
13 #define NETWORK_CORE_TCP_ADMIN_H
14 
15 #include "os_abstraction.h"
16 #include "tcp.h"
17 #include "../network_type.h"
18 #include "../../core/pool_type.hpp"
19 
33 
41 
62 
64 };
65 
71 };
72 
86 };
87 
97 };
99 
100 
105 
107 };
108 
111 protected:
115 
117 
127 
134 
143 
154 
165 
173 
181 
189 
196 
203 
211 
222 
238 
245 
252 
260 
268 
281 
291 
299 
308 
316 
330 
347 
356 
374 
392 
404 
413 
422 
441 
463 
471 
479 
481 public:
482  NetworkRecvStatus CloseConnection(bool error = true) override;
483 
484  NetworkAdminSocketHandler(SOCKET s);
486 
488 
494  {
495  return this->status;
496  }
497 };
498 
499 #endif /* NETWORK_CORE_TCP_ADMIN_H */
char admin_name[NETWORK_CLIENT_NAME_LENGTH]
Name of the admin.
Definition: tcp_admin.h:112
The admin would like to have console messages.
Definition: tcp_admin.h:81
The admin sends a chat message to be distributed.
Definition: tcp_admin.h:29
static const uint NETWORK_CLIENT_NAME_LENGTH
The maximum length of a client&#39;s name, in bytes including &#39;\0&#39;.
Definition: config.h:47
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
virtual NetworkRecvStatus Receive_ADMIN_POLL(Packet *p)
Poll the server for certain updates, an invalid poll (e.g.
Definition: tcp_admin.cpp:138
virtual NetworkRecvStatus Receive_ADMIN_PING(Packet *p)
Ping the server, requiring the server to reply with a pong packet.
Definition: tcp_admin.cpp:142
Internal entity of a packet.
Definition: packet.h:40
The server replies to a ping request from the admin.
Definition: tcp_admin.h:61
AdminCompanyRemoveReason
Reasons for removing a company - communicated to admins.
Definition: tcp_admin.h:101
Network stuff has many things that needs to be included and/or implemented by default.
The admin would like to have chat messages.
Definition: tcp_admin.h:80
virtual NetworkRecvStatus Receive_SERVER_PROTOCOL(Packet *p)
Inform a just joined admin about the protocol specifics: uint8 Protocol version.
Definition: tcp_admin.cpp:147
AdminStatus GetAdminStatus() const
Get the status of the admin.
Definition: tcp_admin.h:493
virtual NetworkRecvStatus Receive_SERVER_RCON(Packet *p)
Result of an rcon command: uint16 Colour as it would be used on the server or a client.
Definition: tcp_admin.cpp:165
The admin explicitly polls for a piece of information.
Definition: tcp_admin.h:28
The server gives the admin information from the GameScript in JSON.
Definition: tcp_admin.h:59
The server tells the admin its going to start a new game.
Definition: tcp_admin.h:39
The server tells the admin its shutting down.
Definition: tcp_admin.h:40
NetworkRecvStatus CloseConnection(bool error=true) override
Close the current connection; for TCP this will be mostly equivalent to Close(), but for UDP it just ...
Definition: tcp_admin.cpp:41
The server received a chat message and relays it.
Definition: tcp_admin.h:54
The server tells the admin that a new company has started.
Definition: tcp_admin.h:48
The server tells the admin its protocol version.
Definition: tcp_admin.h:37
Base socket handler for all TCP sockets.
Definition: tcp.h:27
The admin would like a list of all DoCommand names.
Definition: tcp_admin.h:82
AdminStatus
Status of an admin.
Definition: tcp_admin.h:67
The admin announces and authenticates itself to the server.
Definition: tcp_admin.h:25
The server tells the admin that a client quit.
Definition: tcp_admin.h:46
virtual NetworkRecvStatus Receive_SERVER_COMPANY_STATS(Packet *p)
Company statistics on stations and vehicles: uint8 ID of the company.
Definition: tcp_admin.cpp:163
An invalid marker for admin packets.
Definition: tcp_admin.h:63
virtual NetworkRecvStatus Receive_SERVER_DATE(Packet *p)
Send the current date of the game: uint32 Current game date.
Definition: tcp_admin.cpp:152
virtual NetworkRecvStatus Receive_SERVER_ERROR(Packet *p)
An error was caused by this admin connection (connection gets closed).
Definition: tcp_admin.cpp:146
The server tells the admin an error has occurred.
Definition: tcp_admin.h:36
Updates about the information of clients.
Definition: tcp_admin.h:76
char admin_version[NETWORK_REVISION_LENGTH]
Version string of the admin.
Definition: tcp_admin.h:113
virtual NetworkRecvStatus Receive_SERVER_SHUTDOWN(Packet *p)
Notification about the server shutting down.
Definition: tcp_admin.cpp:150
virtual NetworkRecvStatus Receive_SERVER_CLIENT_QUIT(Packet *p)
Notification about a client leaving the game.
Definition: tcp_admin.cpp:156
The admin sends a JSON string for the GameScript.
Definition: tcp_admin.h:31
NetworkRecvStatus ReceiveInvalidPacket(PacketAdminType type)
Helper for logging receiving invalid packets.
Definition: tcp_admin.cpp:129
The admin gets information about this on a daily basis.
Definition: tcp_admin.h:91
The server tells the admin what the current game date is.
Definition: tcp_admin.h:42
virtual NetworkRecvStatus Receive_SERVER_CLIENT_INFO(Packet *p)
Client information of a specific client: uint32 ID of the client.
Definition: tcp_admin.cpp:154
The admin would like to have DoCommand information.
Definition: tcp_admin.h:83
AdminUpdateFrequency
Update frequencies an admin can register.
Definition: tcp_admin.h:89
virtual NetworkRecvStatus Receive_SERVER_CLIENT_ERROR(Packet *p)
Notification about a client error (and thus the clients disconnection).
Definition: tcp_admin.cpp:157
The admin gets information about this on a monthly basis.
Definition: tcp_admin.h:93
The server gives the admin some statistics about a company.
Definition: tcp_admin.h:53
NetworkRecvStatus ReceivePackets()
Do the actual receiving of packets.
Definition: tcp_admin.cpp:113
AdminStatus status
Status of this admin.
Definition: tcp_admin.h:114
The admin can poll this.
Definition: tcp_admin.h:90
The server&#39;s reply to a remove console command.
Definition: tcp_admin.h:55
virtual NetworkRecvStatus Receive_SERVER_FULL(Packet *p)
The server is full (connection gets closed).
Definition: tcp_admin.cpp:144
Updates about the statistics of companies.
Definition: tcp_admin.h:79
The server gives the admin an information update on a client.
Definition: tcp_admin.h:45
NetworkRecvStatus HandlePacket(Packet *p)
Handle the given packet, i.e.
Definition: tcp_admin.cpp:52
virtual NetworkRecvStatus Receive_SERVER_COMPANY_UPDATE(Packet *p)
Company information of a specific company: uint8 ID of the company.
Definition: tcp_admin.cpp:160
Updates about the economy of companies.
Definition: tcp_admin.h:78
The admin is not connected nor active.
Definition: tcp_admin.h:68
The admin gets information about this on a quarterly basis.
Definition: tcp_admin.h:94
The server tells the admin it cannot accept the admin.
Definition: tcp_admin.h:34
The admin would like to have gamescript messages.
Definition: tcp_admin.h:84
virtual NetworkRecvStatus Receive_SERVER_CONSOLE(Packet *p)
Send what would be printed on the server&#39;s console also into the admin network.
Definition: tcp_admin.cpp:166
virtual NetworkRecvStatus Receive_ADMIN_CHAT(Packet *p)
Send chat as the server: uint8 Action such as NETWORK_ACTION_CHAT_CLIENT (see NetworkAction).
Definition: tcp_admin.cpp:139
NetworkRecvStatus
Status of a network client; reasons why a client has quit.
Definition: core.h:22
The server indicates that the remote console command has completed.
Definition: tcp_admin.h:60
The company is manually removed.
Definition: tcp_admin.h:102
Updates about the date of the game.
Definition: tcp_admin.h:75
virtual NetworkRecvStatus Receive_SERVER_COMPANY_REMOVE(Packet *p)
Notification about a removed company (e.g.
Definition: tcp_admin.cpp:161
virtual NetworkRecvStatus Receive_ADMIN_RCON(Packet *p)
Execute a command on the servers console: string Command to be executed.
Definition: tcp_admin.cpp:140
virtual NetworkRecvStatus Receive_ADMIN_JOIN(Packet *p)
Join the admin network: string Password the server is expecting for this network. ...
Definition: tcp_admin.cpp:135
The server tells the admin that a company was removed.
Definition: tcp_admin.h:51
The server sends out the names of the DoCommands to the admins.
Definition: tcp_admin.h:57
virtual NetworkRecvStatus Receive_ADMIN_GAMESCRIPT(Packet *p)
Send a JSON string to the current active GameScript.
Definition: tcp_admin.cpp:141
The server tells the admin that a client caused an error.
Definition: tcp_admin.h:47
virtual NetworkRecvStatus Receive_SERVER_PONG(Packet *p)
Send a ping-reply (pong) to the admin that sent us the ping packet.
Definition: tcp_admin.cpp:170
The admin tells the server that it is quitting.
Definition: tcp_admin.h:26
The server gives the admin the data that got printed to its console.
Definition: tcp_admin.h:56
virtual NetworkRecvStatus Receive_SERVER_CLIENT_UPDATE(Packet *p)
Client update details on a specific client (e.g.
Definition: tcp_admin.cpp:155
The server gives the admin an information update on a company.
Definition: tcp_admin.h:50
virtual NetworkRecvStatus Receive_SERVER_CMD_NAMES(Packet *p)
Send DoCommand names to the bot upon request only.
Definition: tcp_admin.cpp:167
virtual NetworkRecvStatus Receive_SERVER_CHAT(Packet *p)
Send chat from the game into the admin network: uint8 Action such as NETWORK_ACTION_CHAT_CLIENT (see ...
Definition: tcp_admin.cpp:164
virtual NetworkRecvStatus Receive_ADMIN_UPDATE_FREQUENCY(Packet *p)
Register updates to be sent at certain frequencies (as announced in the PROTOCOL packet): uint16 Upda...
Definition: tcp_admin.cpp:137
The company is removed due to autoclean.
Definition: tcp_admin.h:103
PacketAdminType
Enum with types of TCP packets specific to the admin network.
Definition: tcp_admin.h:24
virtual NetworkRecvStatus Receive_SERVER_COMPANY_INFO(Packet *p)
Company information on a specific company: uint8 ID of the company.
Definition: tcp_admin.cpp:159
virtual NetworkRecvStatus Receive_SERVER_COMPANY_NEW(Packet *p)
Notification of a new company: uint8 ID of the new company.
Definition: tcp_admin.cpp:158
virtual NetworkRecvStatus Receive_ADMIN_QUIT(Packet *p)
Notification to the server that this admin is quitting.
Definition: tcp_admin.cpp:136
The admin gets information about this on a yearly basis.
Definition: tcp_admin.h:95
The server tells the admin that a client has joined.
Definition: tcp_admin.h:43
virtual NetworkRecvStatus Receive_SERVER_RCON_END(Packet *p)
Notify the admin connection that the rcon command has finished.
Definition: tcp_admin.cpp:169
The admin gets information about this on a weekly basis.
Definition: tcp_admin.h:92
The admin sends a remote console command.
Definition: tcp_admin.h:30
void CDECL error(const char *s,...)
Error handling for fatal non-user errors.
Definition: openttd.cpp:112
The admin sends a ping to the server, expecting a ping-reply (PONG) packet.
Definition: tcp_admin.h:32
Must ALWAYS be on the end of this list!! (period)
Definition: tcp_admin.h:85
virtual NetworkRecvStatus Receive_SERVER_WELCOME(Packet *p)
Welcome a connected admin to the game: string Name of the Server (e.g.
Definition: tcp_admin.cpp:148
Must ALWAYS be on the end of this list!! (period)
Definition: tcp_admin.h:70
The server gives the admin information about a client.
Definition: tcp_admin.h:44
Main socket handler for admin related connections.
Definition: tcp_admin.h:110
NetworkAdminSocketHandler(SOCKET s)
Create the admin handler for the given socket.
Definition: tcp_admin.cpp:30
The server welcomes the admin to a game.
Definition: tcp_admin.h:38
The company went belly-up.
Definition: tcp_admin.h:104
The admin gets information about this when it changes.
Definition: tcp_admin.h:96
virtual NetworkRecvStatus Receive_SERVER_COMPANY_ECONOMY(Packet *p)
Economy update of a specific company: uint8 ID of the company.
Definition: tcp_admin.cpp:162
The admin is active.
Definition: tcp_admin.h:69
virtual NetworkRecvStatus Receive_SERVER_BANNED(Packet *p)
The source IP address is banned (connection gets closed).
Definition: tcp_admin.cpp:145
The server gives the admin copies of incoming command packets.
Definition: tcp_admin.h:58
virtual NetworkRecvStatus Receive_SERVER_CLIENT_JOIN(Packet *p)
Notification of a new client: uint32 ID of the new client.
Definition: tcp_admin.cpp:153
virtual NetworkRecvStatus Receive_SERVER_NEWGAME(Packet *p)
Notification about a newgame.
Definition: tcp_admin.cpp:149
Sentinel for end.
Definition: tcp_admin.h:106
Updates about the generic information of companies.
Definition: tcp_admin.h:77
The server gives the admin some economy related company information.
Definition: tcp_admin.h:52
static const uint NETWORK_REVISION_LENGTH
The maximum length of the revision, in bytes including &#39;\0&#39;.
Definition: config.h:44
Basic functions to receive and send TCP packets.
The admin tells the server the update frequency of a particular piece of information.
Definition: tcp_admin.h:27
AdminUpdateType
Update types an admin can register a frequency for.
Definition: tcp_admin.h:74
The server tells the admin it is banned.
Definition: tcp_admin.h:35
The server gives the admin information about a company.
Definition: tcp_admin.h:49
virtual NetworkRecvStatus Receive_SERVER_CMD_LOGGING(Packet *p)
Send incoming command packets to the admin network.
Definition: tcp_admin.cpp:168