diff options
author | rubidium <rubidium@openttd.org> | 2010-10-17 17:31:03 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-10-17 17:31:03 +0000 |
commit | 33ed4ddbfbdcd269c7234ea6093acc21e7a63e7c (patch) | |
tree | 528f610d0ebafba248bd2c9ebf962990afa30676 /src/network/network_admin.h | |
parent | 12a7e2fde0b53f8d3042f3ee248522e921b80d72 (diff) | |
download | openttd-33ed4ddbfbdcd269c7234ea6093acc21e7a63e7c.tar.xz |
(svn r20963) -Add: stubs for a remote administration connection
Diffstat (limited to 'src/network/network_admin.h')
-rw-r--r-- | src/network/network_admin.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/network/network_admin.h b/src/network/network_admin.h new file mode 100644 index 000000000..ffa37ed44 --- /dev/null +++ b/src/network/network_admin.h @@ -0,0 +1,62 @@ +/* $Id$ */ + +/* + * This file is part of OpenTTD. + * 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. + * 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. + * 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/>. + */ + +/** @file network_admin.h Server part of the admin network protocol. */ + +#ifndef NETWORK_ADMIN_H +#define NETWORK_ADMIN_H + +#ifdef ENABLE_NETWORK + +#include "network_internal.h" +#include "core/tcp_listen.h" +#include "core/tcp_admin.h" + +class ServerNetworkAdminSocketHandler; +typedef Pool<ServerNetworkAdminSocketHandler, AdminIndex, 2, MAX_ADMINS> NetworkAdminSocketPool; +extern NetworkAdminSocketPool _networkadminsocket_pool; + +/** Class for handling the server side of the game connection. */ +class ServerNetworkAdminSocketHandler : public NetworkAdminSocketPool::PoolItem<&_networkadminsocket_pool>, public NetworkAdminSocketHandler, public TCPListenHandler<ServerNetworkAdminSocketHandler, ADMIN_PACKET_SERVER_FULL, ADMIN_PACKET_SERVER_BANNED> { +protected: + DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_ADMIN_JOIN); + DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_ADMIN_QUIT); + + NetworkRecvStatus SendProtocol(); +public: + NetworkAddress address; ///< Address of the admin. + + ServerNetworkAdminSocketHandler(SOCKET s); + ~ServerNetworkAdminSocketHandler(); + + NetworkRecvStatus SendError(NetworkErrorCode error); + NetworkRecvStatus SendWelcome(); + NetworkRecvStatus SendNewGame(); + NetworkRecvStatus SendShutdown(); + + static void Send(); + static void AcceptConnection(SOCKET s, const NetworkAddress &address); + static bool AllowConnection(); + static void WelcomeAll(); + + /** + * Get the name used by the listener. + * @return the name to show in debug logs and the like. + */ + static const char *GetName() + { + return "admin"; + } +}; + +#define FOR_ALL_ADMIN_SOCKETS_FROM(var, start) FOR_ALL_ITEMS_FROM(ServerNetworkAdminSocketHandler, adminsocket_index, var, start) +#define FOR_ALL_ADMIN_SOCKETS(var) FOR_ALL_ADMIN_SOCKETS_FROM(var, 0) + +#endif /* ENABLE_NETWORK */ +#endif /* NETWORK_ADMIN_H */ |