xbmc
NetworkIOS.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "network/Network.h"
12 
13 #include <string>
14 #include <vector>
15 
16 class CNetworkIOS;
17 
19 {
20 public:
21  CNetworkInterfaceIOS(CNetworkIOS* network, std::string interfaceName);
22  ~CNetworkInterfaceIOS() override;
23 
24  bool IsEnabled() const override;
25  bool IsConnected() const override;
26 
27  std::string GetMacAddress() const override;
28  void GetMacAddressRaw(char rawMac[6]) const override;
29 
30  bool GetHostMacAddress(unsigned long host, std::string& mac) const override;
31 
32  std::string GetCurrentIPAddress() const override;
33  std::string GetCurrentNetmask() const override;
34  std::string GetCurrentDefaultGateway() const override;
35 
36  std::string GetInterfaceName() const;
37 
38 private:
39  std::string m_interfaceName;
40  CNetworkIOS* m_network;
41 };
42 
43 class CNetworkIOS : public CNetworkBase
44 {
45 public:
46  CNetworkIOS();
47  ~CNetworkIOS() override;
48 
49  // Return the list of interfaces
50  std::vector<CNetworkInterface*>& GetInterfaceList() override;
51  CNetworkInterface* GetFirstConnectedInterface() override;
52 
53  // Ping remote host
54  bool PingHost(unsigned long host, unsigned int timeout_ms = 2000) override;
55 
56  // Get/set the nameserver(s)
57  std::vector<std::string> GetNameServers() override;
58 
59  friend class CNetworkInterfaceIOS;
60 
61 private:
62  int GetSocket() { return m_sock; }
63  void queryInterfaceList();
64  std::vector<CNetworkInterfaceIOS*> m_interfaces;
65  int m_sock;
66 };
Definition: NetworkIOS.h:18
Definition: NetworkIOS.h:43
Definition: Network.h:18
Definition: Network.h:40
bool GetHostMacAddress(unsigned long host, std::string &mac) const override
Definition: NetworkIOS.mm:413
void GetMacAddressRaw(char rawMac[6]) const override
Definition: NetworkIOS.mm:87
std::string GetMacAddress() const override
Definition: NetworkIOS.mm:81