iFun Engine API  1.0.0-b2821
Great Technology for Great Games
 All Classes Files Functions Variables Typedefs Macros
hardware_info.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2015 iFunFactory Inc. All Rights Reserved.
2 //
3 // This work is confidential and proprietary to iFunFactory Inc. and
4 // must not be used, disclosed, copied, or distributed without the prior
5 // consent of iFunFactory Inc.
6 
9 #ifndef INCLUDE_FUNAPI_SYSTEM_HARDWARE_INFO_H_
10 #define INCLUDE_FUNAPI_SYSTEM_HARDWARE_INFO_H_
11 
12 #include <boost/array.hpp>
13 #include <boost/asio.hpp>
14 #include <boost/noncopyable.hpp>
16 #include <funapi/types.h>
17 
18 #include <map>
19 
20 
21 namespace fun {
22 
24 class HardwareInfo : private boost::noncopyable {
25  public:
27  struct NicInfo {
28  string name_;
29  boost::asio::ip::address address_;
30  boost::asio::ip::address netmask_;
31  boost::array<uint8_t, 6> hw_address_;
32  };
33 
34  enum FunapiProtocol {
35  kTcpPbuf = 0,
36  kTcpJson,
37  kUdpPbuf,
38  kUdpJson,
39  kHttpPbuf,
40  kHttpJson,
41  };
42 
44  typedef std::map<string, const NicInfo> NicInfoMap;
45 
46  // Protocol name to port mapping.
47  typedef std::map<FunapiProtocol, uint16_t> ProtocolPortMap;
48 
51  static const NicInfoMap &GetNicInfo();
52 
56  static boost::asio::ip::address GetExternalIp();
57 
60  static std::string GetExternalHostname();
61 
64  static ProtocolPortMap GetExternalPorts();
65 
69  DEPRECATED(static boost::asio::ip::address_v4 GetAwsPublicIpv4());
70 };
71 
72 } // namespace fun
73 
74 #endif // INCLUDE_FUNAPI_SYSTEM_HARDWARE_INFO_H_
boost::asio::ip::address netmask_
Netmask applying to the NIC.
Definition: hardware_info.h:30
static boost::asio::ip::address GetExternalIp()
Returns an external IP the server is assigned.
std::map< string, const NicInfo > NicInfoMap
NIC name to NIC information mapping.
Definition: hardware_info.h:44
static const NicInfoMap & GetNicInfo()
Returns available NICs.
DEPRECATED(static boost::asio::ip::address_v4 GetAwsPublicIpv4())
Returns a public IP if the server is on AWS.
static ProtocolPortMap GetExternalPorts()
Returns <protocol, port> tuples.
Datastructure to hold IP-capable Network Interface Card (NIC) information.
Definition: hardware_info.h:27
static std::string GetExternalHostname()
Returns an hostname or IP address for the server.
string name_
NIC name.
Definition: hardware_info.h:28
boost::asio::ip::address address_
IP address associated with the NIC.
Definition: hardware_info.h:29
Class to access hardware information.
Definition: hardware_info.h:24