/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2013 University of California, Los Angeles
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation;
 *
 * This program 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 this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
 *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
 */

#ifndef NDNX_TUNNEL_H
#define NDNX_TUNNEL_H

#include "ndnx-wrapper.h"

#define _OVERRIDE
#ifdef __GNUC__
#if __GNUC_MAJOR >= 4 && __GNUC_MINOR__ >= 7
  #undef _OVERRIDE
  #define _OVERRIDE override
#endif // __GNUC__ version
#endif // __GNUC__

// Eventually, Sync::NdnxWrapper should be moved to this namespace.
// It has nothing to do with Sync.
namespace Ndnx
{

class NdnxTunnel : public NdnxWrapper
{
public:
  typedef std::multimap<Name, InterestCallback> RegisteredInterestTable;
  typedef std::multimap<Name, InterestCallback>::iterator RitIter;


  NdnxTunnel();
  virtual ~NdnxTunnel();

  // name is topology-independent
  virtual int
  publishData(const Name &name, const unsigned char *buf, size_t len, int freshness) _OVERRIDE;

  int
  publishContentObject(const Name &name, const Bytes &contentObject, int freshness);

  virtual int
  sendInterest (const Name &interest, const Closure &closure, const Selectors &selectors = Selectors());


  // prefix is topology-independent
  virtual int
  setInterestFilter(const Name &prefix, const InterestCallback &interestCallback) _OVERRIDE;

  // prefix is topology-independent
  // this clears all entries with key equal to prefix
  virtual void
  clearInterestFilter(const Name &prefix) _OVERRIDE;

  // subclass should provide translation service from topology-independent name
  // to routable name
  virtual Name
  queryRoutableName(const Name &name) = 0;

  // subclass should implement the function to store ContentObject with topoloy-independent
  // name to the permanent storage; default does nothing
  virtual void
  storeContentObject(const Name &name, const Bytes &content) {}

  // should be called  when connect to a different network
  void
  refreshLocalPrefix();

  static bool
  isPrefix(const Name &prefix, const Name &name);

  void
  handleTunneledInterest(const Name &tunneldInterest);

  void
  handleTunneledData(const Name &name, const Bytes &tunneledData, const Closure::DataCallback &originalDataCallback);

private:
  NdnxTunnel(const NdnxTunnel &other) {}

protected:
  // need a way to update local prefix, perhaps using macports trick, but eventually we need something more portable
  Name m_localPrefix;
  RegisteredInterestTable m_rit;
  Lock m_ritLock;
};

class TunnelClosure : public Closure
{
public:
  TunnelClosure(const DataCallback &dataCallback, NdnxTunnel &tunnel,
                const Name &originalInterest, const TimeoutCallback &timeoutCallback = TimeoutCallback());

  TunnelClosure(const Closure &closure, NdnxTunnel &tunnel, const Name &originalInterest);

  virtual void
  runDataCallback(const Name &name, const Bytes &content) _OVERRIDE;

  virtual TimeoutCallbackReturnValue
  runTimeoutCallback(const Name &interest) _OVERRIDE;

  virtual Closure *
  dup() const;

private:
  NdnxTunnel &m_tunnel;
  Name m_originalInterest;
};

};

#endif
