xbmc
NetworkPosix.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 CNetworkPosix;
17 
19 {
20 public:
22  std::string interfaceName,
23  char interfaceMacAddrRaw[6]);
24  virtual ~CNetworkInterfacePosix() override = default;
25 
26  bool IsEnabled() const override;
27  bool IsConnected() const override;
28  std::string GetCurrentIPAddress() const override;
29  std::string GetCurrentNetmask() const override;
30 
31  std::string GetMacAddress() const override;
32  void GetMacAddressRaw(char rawMac[6]) const override;
33 
34 protected:
35  std::string m_interfaceName;
36  CNetworkPosix* m_network;
37 
38 private:
39  std::string m_interfaceMacAdr;
40  char m_interfaceMacAddrRaw[6];
41 };
42 
44 {
45 public:
46  virtual ~CNetworkPosix() override;
47 
48  std::vector<CNetworkInterface*>& GetInterfaceList() override;
49  CNetworkInterface* GetFirstConnectedInterface() override;
50 
51  int GetSocket() { return m_sock; }
52 
53 protected:
54  CNetworkPosix();
55  std::vector<CNetworkInterface*> m_interfaces;
56 
57 private:
58  virtual void GetMacAddress(const std::string& interfaceName, char macAddrRaw[6]) = 0;
59  virtual void queryInterfaceList() = 0;
60  int m_sock;
61 };
Definition: Network.h:18
Definition: Network.h:40
Definition: NetworkPosix.h:18
Definition: NetworkPosix.h:43