/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
 * Copyright (c) 2014  University of Memphis,
 *                     Regents of the University of California
 *
 * This file is part of NLSR (Named-data Link State Routing).
 * See AUTHORS.md for complete list of NLSR authors and contributors.
 *
 * NLSR is free software: you can redistribute it and/or modify it under the terms
 * of the GNU General Public License as published by the Free Software Foundation,
 * either version 3 of the License, or (at your option) any later version.
 *
 * NLSR 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>
 *
 **/
#ifndef NLSR_SYNC_LOGIC_HANDLER_HPP
#define NLSR_SYNC_LOGIC_HANDLER_HPP

#include <ndn-cxx/face.hpp>
#include <ndn-cxx/security/validator-null.hpp>
#include <nsync/sync-socket.h>

#include <iostream>
#include <unistd.h>
#include <boost/cstdint.hpp>

class InterestManager;

namespace nlsr {

class ConfParameter;
class Lsdb;
class SequencingManager;
class SyncUpdate;

class SyncLogicHandler
{
public:
  SyncLogicHandler(ndn::Face& face, Lsdb& lsdb, ConfParameter& conf)
    : m_validator(new ndn::ValidatorNull())
    , m_syncFace(face)
    , m_lsdb(lsdb)
    , m_confParam(conf)
  {
  }

  void
  createSyncSocket();

  void
  onNsyncUpdate(const std::vector<Sync::MissingDataInfo>& v, Sync::SyncSocket* socket);

  void
  onNsyncRemoval(const std::string& prefix);

  void
  publishRoutingUpdate(SequencingManager& manager, const ndn::Name& updatePrefix);

  void
  setSyncPrefix(const std::string& sp)
  {
    m_syncPrefix.clear();
    m_syncPrefix.set(sp);
  }

private:
  void
  processUpdateFromSync(const SyncUpdate& updateName);

  bool
  isLsaNew(const ndn::Name& originRouter, const std::string& lsaType, uint64_t seqNo);

  void
  expressInterestForLsa(const SyncUpdate& updateName, std::string lsaType, uint64_t seqNo);

  void
  publishSyncUpdate(const ndn::Name& updatePrefix, uint64_t seqNo);

private:
  ndn::shared_ptr<ndn::ValidatorNull> m_validator;
  ndn::Face& m_syncFace;
  ndn::shared_ptr<Sync::SyncSocket> m_syncSocket;
  ndn::Name m_syncPrefix;

  Lsdb& m_lsdb;
  ConfParameter& m_confParam;

  static const std::string NLSR_COMPONENT;
  static const std::string LSA_COMPONENT;
  static const std::string NAME_COMPONENT;
  static const std::string ADJACENCY_COMPONENT;
  static const std::string COORDINATE_COMPONENT;

};

} //namespace nlsr

#endif //NLSR_SYNC_LOGIC_HANDLER_HPP
