/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
 * Copyright (c) 2013-2017 Regents of the University of California.
 *
 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
 *
 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
 * terms of the GNU Lesser General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later version.
 *
 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
 *
 * You should have received copies of the GNU General Public License and GNU Lesser
 * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
 * <http://www.gnu.org/licenses/>.
 *
 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
 */

#ifndef NDN_NET_NETWORK_MONITOR_IMPL_OSX_HPP
#define NDN_NET_NETWORK_MONITOR_IMPL_OSX_HPP

#include "ndn-cxx-config.hpp"
#include "../network-monitor.hpp"

#ifndef NDN_CXX_HAVE_OSX_FRAMEWORKS
#error "This file should not be compiled ..."
#endif

#include "../../util/cf-releaser-osx.hpp"
#include "../../util/scheduler.hpp"
#include "../../util/scheduler-scoped-event-id.hpp"

#include <CoreFoundation/CoreFoundation.h>
#include <SystemConfiguration/SystemConfiguration.h>

#include <boost/asio/ip/udp.hpp>

namespace ndn {
namespace net {

class NetworkMonitorImplOsx : public NetworkMonitorImpl
{
public:
  using Error = NetworkMonitor::Error;

  NetworkMonitorImplOsx(boost::asio::io_service& io);

  ~NetworkMonitorImplOsx();

  uint32_t
  getCapabilities() const final
  {
    return NetworkMonitor::CAP_ENUM |
           NetworkMonitor::CAP_IF_ADD_REMOVE |
           NetworkMonitor::CAP_STATE_CHANGE |
           NetworkMonitor::CAP_ADDR_ADD_REMOVE;
  }

  shared_ptr<const NetworkInterface>
  getNetworkInterface(const std::string& ifname) const final;

  std::vector<shared_ptr<const NetworkInterface>>
  listNetworkInterfaces() const final;

  static void
  afterNotificationCenterEvent(CFNotificationCenterRef center,
                               void* observer,
                               CFStringRef name,
                               const void* object,
                               CFDictionaryRef userInfo);

private:
  void
  scheduleCfLoop();

  void
  pollCfLoop();

  void
  addNewInterface(const std::string& ifName);

  void
  enumerateInterfaces();

  std::set<std::string>
  getInterfaceNames();

  InterfaceState
  getInterfaceState(const std::string& ifName);

  void
  updateInterfaceInfo(NetworkInterface& netif);

  size_t
  getInterfaceMtu(const std::string& ifName);

  static void
  onConfigChanged(SCDynamicStoreRef store, CFArrayRef changedKeys, void* context);

  void
  onConfigChanged(CFArrayRef changedKeys);

private:
  std::map<std::string, shared_ptr<NetworkInterface>> m_interfaces; ///< ifname => interface

  util::Scheduler m_scheduler;
  util::scheduler::ScopedEventId m_cfLoopEvent;

  SCDynamicStoreContext m_context;
  util::CFReleaser<SCDynamicStoreRef> m_scStore;
  util::CFReleaser<CFRunLoopSourceRef> m_loopSource;

  boost::asio::ip::udp::socket m_nullUdpSocket;
};

} // namespace net
} // namespace ndn

#endif // NDN_NET_NETWORK_MONITOR_IMPL_OSX_HPP
