Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame^] | 1 | #include "aos/common/network/team_number.h" |
| 2 | |
| 3 | #include <netinet/in.h> |
| 4 | |
| 5 | #include "aos/common/once.h" |
| 6 | #include "aos/atom_code/configuration.h" |
| 7 | |
| 8 | namespace aos { |
| 9 | namespace network { |
| 10 | namespace { |
| 11 | |
| 12 | uint16_t *DoGetTeamNumber() { |
| 13 | const in_addr &address = configuration::GetOwnIPAddress(); |
| 14 | static uint16_t r = address.s_addr >> 8; |
| 15 | return &r; |
| 16 | } |
| 17 | |
| 18 | } // namespace |
| 19 | |
| 20 | uint16_t GetTeamNumber() { |
| 21 | static Once<uint16_t> once(DoGetTeamNumber); |
| 22 | return *once.Get(); |
| 23 | } |
| 24 | |
| 25 | } // namespace network |
| 26 | } // namespace aos |