FairMQ  1.4.33
C++ Message Queuing Library and Framework
Network.h
1 /********************************************************************************
2  * Copyright (C) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 
9 #ifndef FAIR_MQ_TOOLS_NETWORK_H
10 #define FAIR_MQ_TOOLS_NETWORK_H
11 
12 #include <map>
13 #include <string>
14 #include <stdexcept>
15 
16 // forward declarations
17 namespace boost
18 {
19 namespace asio
20 {
21 
22 class io_context;
23 using io_service = class io_context;
24 
25 } // namespace asio
26 } // namespace boost
27 
28 namespace fair::mq::tools
29 {
30 
31 struct DefaultRouteDetectionError : std::runtime_error { using std::runtime_error::runtime_error; };
32 
33 // returns a map with network interface names as keys and their IP addresses as values
34 std::map<std::string, std::string> getHostIPs();
35 
36 // get IP address of a given interface name
37 std::string getInterfaceIP(const std::string& interface);
38 
39 // get name of the default route interface
40 std::string getDefaultRouteNetworkInterface();
41 
42 std::string getIpFromHostname(const std::string& hostname);
43 
44 std::string getIpFromHostname(const std::string& hostname, boost::asio::io_service& ios);
45 
46 } // namespace fair::mq::tools
47 
48 #endif /* FAIR_MQ_TOOLS_NETWORK_H */
fair::mq::tools::DefaultRouteDetectionError
Definition: Network.h:31

privacy