5 * Copyright (C) 2005-2008 Team XBMC
8 * This Program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
13 * This Program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with XBMC; see the file COPYING. If not, write to
20 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21 * http://www.gnu.org/copyleft/gpl.html
26 #include "StdString.h"
28 enum EncMode
{ ENC_NONE
= 0, ENC_WEP
= 1, ENC_WPA
= 2, ENC_WPA2
= 3 };
29 enum NetworkAssignment
{ NETWORK_DASH
= 0, NETWORK_DHCP
= 1, NETWORK_STATIC
= 2, NETWORK_DISABLED
= 3 };
31 class NetworkAccessPoint
34 NetworkAccessPoint(CStdString
& essId
, int quality
, EncMode encryption
)
38 m_encryptionMode
= encryption
;
41 CStdString
getEssId() { return m_essId
; }
42 int getQuality() { return m_quality
; }
43 EncMode
getEncryptionMode() { return m_encryptionMode
; }
48 EncMode m_encryptionMode
;
51 class CNetworkInterface
54 virtual ~CNetworkInterface() {};
56 virtual CStdString
& GetName(void) = 0;
58 virtual bool IsEnabled(void) = 0;
59 virtual bool IsConnected(void) = 0;
60 virtual bool IsWireless(void) = 0;
62 virtual CStdString
GetMacAddress(void) = 0;
64 virtual CStdString
GetCurrentIPAddress() = 0;
65 virtual CStdString
GetCurrentNetmask() = 0;
66 virtual CStdString
GetCurrentDefaultGateway(void) = 0;
67 virtual CStdString
GetCurrentWirelessEssId(void) = 0;
69 // Returns the list of access points in the area
70 virtual std::vector
<NetworkAccessPoint
> GetAccessPoints(void) = 0;
72 virtual void GetSettings(NetworkAssignment
& assignment
, CStdString
& ipAddress
, CStdString
& networkMask
, CStdString
& defaultGateway
, CStdString
& essId
, CStdString
& key
, EncMode
& encryptionMode
) = 0;
73 virtual void SetSettings(NetworkAssignment
& assignment
, CStdString
& ipAddress
, CStdString
& networkMask
, CStdString
& defaultGateway
, CStdString
& essId
, CStdString
& key
, EncMode
& encryptionMode
) = 0;
90 // Return the list of interfaces
91 virtual std::vector
<CNetworkInterface
*>& GetInterfaceList(void) = 0;
92 CNetworkInterface
* GetInterfaceByName(CStdString
& name
);
94 // Return the first interface which is active
95 CNetworkInterface
* GetFirstConnectedInterface(void);
97 // Return true if there is a interface for the same network as address
98 bool HasInterfaceForIP(unsigned long address
);
100 // Return true if there's at least one defined network interface
101 bool IsAvailable(bool wait
= false);
103 // Return true if there's at least one interface which is connected
104 bool IsConnected(void);
106 // Return true if the magic packet was send
107 bool WakeOnLan(const char *mac
);
109 // Get/set the nameserver(s)
110 virtual std::vector
<CStdString
> GetNameServers(void) = 0;
111 virtual void SetNameServers(std::vector
<CStdString
> nameServers
) = 0;
113 // callback from application controlled thread to handle any setup
114 void NetworkMessage(EMESSAGE message
, int param
);
116 void StartServices();
117 void StopServices(bool bWait
);
119 static int ParseHex(char *str
, unsigned char *addr
);
121 #ifdef HAS_LINUX_NETWORK
122 #include "linux/NetworkLinux.h"
124 #include "win32/NetworkWin32.h"