John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 1 | #ifndef AOS_NETWORK_TEAM_NUMBER_H_ |
| 2 | #define AOS_NETWORK_TEAM_NUMBER_H_ |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 3 | |
| 4 | #include <stdint.h> |
| 5 | |
Austin Schuh | df5591e | 2015-12-19 22:36:50 -0800 | [diff] [blame] | 6 | #include <string> |
| 7 | |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 8 | namespace aos { |
| 9 | namespace network { |
| 10 | |
| 11 | // Retrieves the current team number based off of the network address. |
| 12 | // This function will only do the complicated stuff once so it is cheap to call |
| 13 | // repeatedly. |
| 14 | uint16_t GetTeamNumber(); |
| 15 | |
Austin Schuh | 288479d | 2019-12-18 19:47:52 -0800 | [diff] [blame^] | 16 | // Returns the current hostname. |
| 17 | ::std::string GetHostname(); |
| 18 | |
Brian Silverman | de0a53a | 2014-02-10 22:27:44 -0800 | [diff] [blame] | 19 | // Overrides the team number returned from GetTeamNumber(). Must be called |
| 20 | // before GetTeamNumber() is ever called. |
| 21 | // Overriding to team 0 won't work. |
| 22 | // Intended only for tests. |
Philipp Schrader | f75a8bf | 2015-02-02 05:30:16 +0000 | [diff] [blame] | 23 | // Guaranteed to be safe to call during static initialization time. |
Brian Silverman | de0a53a | 2014-02-10 22:27:44 -0800 | [diff] [blame] | 24 | void OverrideTeamNumber(uint16_t team); |
| 25 | |
Austin Schuh | df5591e | 2015-12-19 22:36:50 -0800 | [diff] [blame] | 26 | namespace internal { |
| 27 | int ParseTeamNumber(const std::string &hostname, uint16_t *teamnumber); |
| 28 | } // namespace internal |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 29 | } // namespace network |
| 30 | } // namespace aos |
| 31 | |
John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 32 | #endif // AOS_NETWORK_TEAM_NUMBER_H_ |