#include <ndn-cpp-dev/face.hpp>
#include <ndn-cpp-dev/security/key-chain.hpp>
#include <ndn-cpp-dev/util/scheduler.hpp>

#include <cstdlib>

#include "nlsr.hpp"
#include "nlsr_conf_param.hpp"
#include "nlsr_conf_processor.hpp"
#include "nlsr_lsdb.hpp"


using namespace ndn;
using namespace std;

void
nlsr::nlsrRegistrationFailed(const ptr_lib::shared_ptr<const Name>&)
{
  cerr << "ERROR: Failed to register prefix in local hub's daemon" << endl;
  getNlsrFace().shutdown();
}


void
nlsr::setInterestFilterNlsr(const string& name)
{
  getNlsrFace().setInterestFilter(name,
                        func_lib::bind(&interestManager::processInterest, &im, 
                        boost::ref(*this), _1, _2),
                        func_lib::bind(&nlsr::nlsrRegistrationFailed, this, _1));
}


void
nlsr::startEventLoop()
{
	getNlsrFace().processEvents();
}

int 
nlsr::usage(const string& progname)
{

        cout << "Usage: " << progname << " [OPTIONS...]"<<endl;
        cout << "   NDN routing...." << endl;
        cout << "       -d, --daemon        Run in daemon mode" << endl;
        cout << "       -f, --config_file   Specify configuration file name" <<endl;
        cout << "       -p, --api_port      port where api client will connect" <<endl;
        cout << "       -h, --help          Display this help message" << endl;

        exit(EXIT_FAILURE);
}

int 
main(){

	nlsr nlsr;
	nlsr.setConfFileName("nlsr.conf");
	ConfFileProcessor cfp(nlsr.getConfFileName());
	cfp.processConfFile(nlsr);
	nlsr.getConfParameter().buildRouterPrefix();

	nlsr.getLsdb().buildAndInstallOwnNameLsa(nlsr);
	nlsr.getLsdb().buildAndInstallOwnCorLsa(nlsr);
	
	
/* debugging purpose start */
	cout <<	nlsr.getConfParameter();
	nlsr.getAdl().printAdl();
	nlsr.getNpl().printNpl();
	nlsr.getLsdb().printNameLsdb();
	nlsr.getLsdb().printCorLsdb();
/* debugging purpose end */
	nlsr.setInterestFilterNlsr(nlsr.getConfParameter().getRouterPrefix());
	nlsr.getIm().scheduleInfoInterest(nlsr,1);

	
	

	try{
		nlsr.startEventLoop();
	}catch(std::exception &e) {
    		std::cerr << "ERROR: " << e.what() << std::endl;
	}

	return 0;
}
