Skip to content

Commit

Permalink
[ios/networking] - Implemented Darwin_embedded specific network imple…
Browse files Browse the repository at this point in the history
…menation

Removes darwin_embedded network implementation from standard posix network implementation
Handles all CNetworkBase overloads specific to darwin_embedded platforms.
As of ios11, it is not possible to retrieve interface MAC addresses, or to retrieve info
from the devices ARP table. WOL/WakeOnAccess features are not possible without these.
MAC address access was actually deprecated in ios7.
  • Loading branch information
fuzzard committed Oct 7, 2019
1 parent 0b56084 commit 44e493a
Show file tree
Hide file tree
Showing 10 changed files with 744 additions and 69 deletions.
4 changes: 2 additions & 2 deletions cmake/scripts/darwin_embedded/ArchSetup.cmake
Expand Up @@ -12,7 +12,7 @@ else()
list(APPEND ARCH_DEFINES -DTARGET_DARWIN_IOS)
endif()
set(SYSTEM_DEFINES -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
-D__STDC_CONSTANT_MACROS -DHAS_LINUX_NETWORK -DHAS_ZEROCONF)
-D__STDC_CONSTANT_MACROS -DHAS_IOS_NETWORK -DHAS_ZEROCONF)
set(PLATFORM_DIR platform/darwin)
set(PLATFORMDEFS_DIR platform/posix)
set(CMAKE_SYSTEM_NAME Darwin)
Expand All @@ -38,7 +38,7 @@ list(APPEND DEPLIBS "-framework CoreFoundation" "-framework CoreVideo"
"-framework CFNetwork" "-framework CoreGraphics"
"-framework Foundation" "-framework UIKit"
"-framework CoreMedia" "-framework AVFoundation"
"-framework VideoToolbox")
"-framework VideoToolbox" "-lresolv")

set(ENABLE_OPTICAL OFF CACHE BOOL "" FORCE)

Expand Down
2 changes: 1 addition & 1 deletion cmake/treedata/darwin_embedded/subdirs.txt
Expand Up @@ -2,9 +2,9 @@ xbmc/input/touch input/touch
xbmc/input/touch/generic input/touch/generic
xbmc/platform/darwin platform/darwin
xbmc/platform/darwin/ios-common platform/ios-common
xbmc/platform/darwin/ios-common/network platform/ios-common/network
xbmc/platform/darwin/ios-common/storage platform/ios-common/storage
xbmc/platform/darwin/network platform/darwin/network
xbmc/platform/posix posix
xbmc/platform/posix/filesystem platform/posix/filesystem
xbmc/platform/posix/network platform/posix/network
xbmc/platform/posix/utils platform/posix/utils
2 changes: 2 additions & 0 deletions xbmc/network/Network.h
Expand Up @@ -120,6 +120,8 @@ class CNetworkBase
#include "platform/win32/network/NetworkWin32.h"
#elif defined(HAS_WIN10_NETWORK)
#include "platform/win10/network/NetworkWin10.h"
#elif defined(HAS_IOS_NETWORK)
#include "platform/darwin/ios-common/network/NetworkIOS.h"
#else
using CNetwork = CNetworkBase;
#endif
Expand Down
6 changes: 6 additions & 0 deletions xbmc/platform/darwin/ios-common/network/CMakeLists.txt
@@ -0,0 +1,6 @@
set(SOURCES NetworkIOS.mm)

set(HEADERS NetworkIOS.h
route.h)

core_add_library(platform_ios_network)
68 changes: 68 additions & 0 deletions xbmc/platform/darwin/ios-common/network/NetworkIOS.h
@@ -0,0 +1,68 @@
/*
* Copyright (C) 2005-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/

#pragma once

#include "network/Network.h"

#include <string>
#include <vector>

class CNetworkIOS;

class CNetworkInterfaceIOS : public CNetworkInterface
{
public:
CNetworkInterfaceIOS(CNetworkIOS* network, std::string interfaceName);
~CNetworkInterfaceIOS() override;

bool IsEnabled() const override;
bool IsConnected() const override;

std::string GetMacAddress() const override;
void GetMacAddressRaw(char rawMac[6]) const override;

bool GetHostMacAddress(unsigned long host, std::string& mac) const override;

std::string GetCurrentIPAddress() const override;
std::string GetCurrentNetmask() const override;
std::string GetCurrentDefaultGateway() const override;

std::string GetInterfaceName() const;

private:
std::string m_interfaceName;
CNetworkIOS* m_network;
};

class CNetworkIOS : public CNetworkBase
{
public:
CNetworkIOS();
~CNetworkIOS() override;

// Return the list of interfaces
std::vector<CNetworkInterface*>& GetInterfaceList() override;
CNetworkInterface* GetFirstConnectedInterface() override;

// Ping remote host
bool PingHost(unsigned long host, unsigned int timeout_ms = 2000) override;

// Get/set the nameserver(s)
std::vector<std::string> GetNameServers() override;

friend class CNetworkInterfaceIOS;

private:
int GetSocket() { return m_sock; }
void queryInterfaceList();
std::vector<CNetworkInterfaceIOS*> m_interfaces;
int m_sock;
};

using CNetwork = CNetworkIOS;

0 comments on commit 44e493a

Please sign in to comment.