2009-08-21 22:21:05 +02:00
/*
* 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/>.
*/
2007-02-23 09:37:33 +01:00
/**
2008-06-04 13:21:36 +02:00
* @ file config . h Configuration options of the network stuff . It is used even when compiling without network support .
2007-02-23 09:37:33 +01:00
*/
2007-01-02 18:34:03 +01:00
# ifndef NETWORK_CORE_CONFIG_H
# define NETWORK_CORE_CONFIG_H
2021-07-10 22:16:03 +02:00
const char * NetworkCoordinatorConnectionString ( ) ;
2021-04-27 11:51:00 +02:00
const char * NetworkStunConnectionString ( ) ;
2021-07-10 22:16:03 +02:00
const char * NetworkContentServerConnectionString ( ) ;
2023-02-12 12:07:31 +01:00
const char * NetworkContentMirrorUriString ( ) ;
2023-04-25 19:43:45 +02:00
const char * NetworkSurveyUriString ( ) ;
2007-01-02 18:34:03 +01:00
2023-05-08 19:01:06 +02:00
static const uint16_t NETWORK_COORDINATOR_SERVER_PORT = 3976 ; ///< The default port of the Game Coordinator server (TCP)
static const uint16_t NETWORK_STUN_SERVER_PORT = 3975 ; ///< The default port of the STUN server (TCP)
static const uint16_t NETWORK_TURN_SERVER_PORT = 3974 ; ///< The default port of the TURN server (TCP)
static const uint16_t NETWORK_CONTENT_SERVER_PORT = 3978 ; ///< The default port of the content server (TCP)
static const uint16_t NETWORK_DEFAULT_PORT = 3979 ; ///< The default port of the game server (TCP & UDP)
static const uint16_t NETWORK_ADMIN_PORT = 3977 ; ///< The default port for admin network
2007-01-02 18:34:03 +01:00
2024-02-04 12:31:56 +01:00
static const size_t UDP_MTU = 1460 ; ///< Number of bytes we can pack in a single UDP packet
2023-04-25 19:43:45 +02:00
static const std : : string NETWORK_SURVEY_DETAILS_LINK = " https://survey.openttd.org/participate " ; ///< Link with more details & privacy statement of the survey.
2021-04-18 14:56:25 +02:00
/*
* Technically a TCP packet could become 64 kiB , however the high bit is kept so it becomes possible in the future
* to go to ( significantly ) larger packets if needed . This would entail a strategy such as employed for UTF - 8.
*
* Packets up to 32 KiB have the high bit not set :
* 00000000 00000000 0 bbbbbbb aaaaaaaa - > aaaaaaaa 0 bbbbbbb
* Send_uint16 ( GB ( size , 0 , 15 )
*
2023-05-08 19:01:06 +02:00
* Packets up to 1 GiB , first uint16_t has high bit set so it knows to read a
* next uint16_t for the remaining bits of the size .
2021-04-18 14:56:25 +02:00
* 00 dddddd cccccccc bbbbbbbb aaaaaaaa - > cccccccc 10 dddddd aaaaaaaa bbbbbbbb
* Send_uint16 ( GB ( size , 16 , 14 ) | 0 b10 < < 14 )
* Send_uint16 ( GB ( size , 0 , 16 ) )
*/
2024-02-04 12:31:56 +01:00
static const size_t TCP_MTU = 32767 ; ///< Number of bytes we can pack in a single TCP packet
static const size_t COMPAT_MTU = 1460 ; ///< Number of bytes we can pack in a single packet for backward compatibility
2007-01-02 18:34:03 +01:00
2024-03-16 23:59:32 +01:00
static const uint8_t NETWORK_GAME_ADMIN_VERSION = 3 ; ///< What version of the admin network do we use?
static const uint8_t NETWORK_GAME_INFO_VERSION = 7 ; ///< What version of game-info do we use?
static const uint8_t NETWORK_COORDINATOR_VERSION = 6 ; ///< What version of game-coordinator-protocol do we use?
static const uint8_t NETWORK_SURVEY_VERSION = 2 ; ///< What version of the survey do we use?
2007-01-02 18:34:03 +01:00
2021-07-03 11:04:32 +02:00
static const uint NETWORK_NAME_LENGTH = 80 ; ///< The maximum length of the server name and map name, in bytes including '\0'
static const uint NETWORK_COMPANY_NAME_LENGTH = 128 ; ///< The maximum length of the company name, in bytes including '\0'
static const uint NETWORK_HOSTNAME_LENGTH = 80 ; ///< The maximum length of the host name, in bytes including '\0'
static const uint NETWORK_HOSTNAME_PORT_LENGTH = 80 + 6 ; ///< The maximum length of the host name + port, in bytes including '\0'. The extra six is ":" + port number (with a max of 65536)
static const uint NETWORK_SERVER_ID_LENGTH = 33 ; ///< The maximum length of the network id of the servers, in bytes including '\0'
static const uint NETWORK_REVISION_LENGTH = 33 ; ///< The maximum length of the revision, in bytes including '\0'
static const uint NETWORK_PASSWORD_LENGTH = 33 ; ///< The maximum length of the password, in bytes including '\0' (must be >= NETWORK_SERVER_ID_LENGTH)
static const uint NETWORK_CLIENT_NAME_LENGTH = 25 ; ///< The maximum length of a client's name, in bytes including '\0'
static const uint NETWORK_RCONCOMMAND_LENGTH = 500 ; ///< The maximum length of a rconsole command, in bytes including '\0'
2023-09-06 13:14:12 +02:00
static const uint NETWORK_GAMESCRIPT_JSON_LENGTH = 9000 ; ///< The maximum length of a receiving gamescript json string, in bytes including '\0'.
2021-07-03 11:04:32 +02:00
static const uint NETWORK_CHAT_LENGTH = 900 ; ///< The maximum length of a chat message, in bytes including '\0'
static const uint NETWORK_CONTENT_FILENAME_LENGTH = 48 ; ///< The maximum length of a content's filename, in bytes including '\0'.
static const uint NETWORK_CONTENT_NAME_LENGTH = 32 ; ///< The maximum length of a content's name, in bytes including '\0'.
static const uint NETWORK_CONTENT_VERSION_LENGTH = 16 ; ///< The maximum length of a content's version, in bytes including '\0'.
static const uint NETWORK_CONTENT_URL_LENGTH = 96 ; ///< The maximum length of a content's url, in bytes including '\0'.
static const uint NETWORK_CONTENT_DESC_LENGTH = 512 ; ///< The maximum length of a content's description, in bytes including '\0'.
static const uint NETWORK_CONTENT_TAG_LENGTH = 32 ; ///< The maximum length of a content's tag, in bytes including '\0'.
2021-04-29 15:37:02 +02:00
static const uint NETWORK_ERROR_DETAIL_LENGTH = 100 ; ///< The maximum length of the error detail, in bytes including '\0'.
static const uint NETWORK_INVITE_CODE_LENGTH = 64 ; ///< The maximum length of the invite code, in bytes including '\0'.
static const uint NETWORK_INVITE_CODE_SECRET_LENGTH = 80 ; ///< The maximum length of the invite code secret, in bytes including '\0'.
static const uint NETWORK_TOKEN_LENGTH = 64 ; ///< The maximum length of a token, in bytes including '\0'.
2007-01-02 18:34:03 +01:00
2021-07-03 11:04:32 +02:00
static const uint NETWORK_GRF_NAME_LENGTH = 80 ; ///< Maximum length of the name of a GRF
2007-01-02 18:34:03 +01:00
2010-05-13 11:04:41 +02:00
/**
* Maximum number of GRFs that can be sent .
2021-05-09 19:07:58 +02:00
*
* This limit exists to avoid that the SERVER_INFO packet exceeding the
* maximum MTU . At the time of writing this limit is 32767 ( TCP_MTU ) .
*
* In the SERVER_INFO packet is the NetworkGameInfo struct , which is
* 142 bytes + 100 per NewGRF ( under the assumption strings are used to
* their max ) . This brings us to roughly 326 possible NewGRFs . Round it
* down so people don ' t freak out because they see a weird value , and you
* get the limit : 255.
*
* PS : in case you ever want to raise this number , please be mindful that
* " amount of NewGRFs " in NetworkGameInfo is currently an uint8 .
2010-05-13 11:04:41 +02:00
*/
2021-05-09 19:07:58 +02:00
static const uint NETWORK_MAX_GRF_COUNT = 255 ;
2010-05-13 11:04:41 +02:00
2024-03-15 22:36:58 +01:00
/**
* The maximum length of the hexadecimal encoded secret keys , in bytes including ' \0 ' .
* This is related to \ c X25519_KEY_SIZE in the network crypto internals .
*/
static const uint NETWORK_SECRET_KEY_LENGTH = 32 * 2 + 1 ;
2007-01-02 18:34:03 +01:00
# endif /* NETWORK_CORE_CONFIG_H */