#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <assert.h>
#include <sys/types.h>
#include <signal.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>

#include <ccn/ccn.h>
#include <ccn/uri.h>
#include <ccn/keystore.h>
#include <ccn/signing.h>
#include <ccn/schedule.h>
#include <ccn/hashtb.h>
#include <ccn/sync.h>
#include <ccn/seqwriter.h>

#include "nlsr.h"
#include "nlsr_sync.h"
#include "nlsr_lsdb.h"
#include "utility.h"


	char *
hex_string(unsigned char *s, size_t l)
{
	const char *hex_digits = "0123456789abcdef";
	char *r;
	int i;
	r = calloc(1, 1 + 2 * l);
	for (i = 0; i < l; i++) {
		r[2*i] = hex_digits[(s[i]>>4) & 0xf];
		r[1+2*i] = hex_digits[s[i] & 0xf];
	}
	return(r);
}

	int
sync_cb(struct ccns_name_closure *nc,
		struct ccn_charbuf *lhash,
		struct ccn_charbuf *rhash,
		struct ccn_charbuf *name)
{
	int res;
	/*char *hexL;
	  char *hexR;
	  struct ccn_charbuf *uri = ccn_charbuf_create();
	  if (lhash == NULL || lhash->length == 0) {
	  hexL = strdup("none");
	  } else
	  hexL = hex_string(lhash->buf, lhash->length);
	  if (rhash == NULL || rhash->length == 0) {
	  hexR = strdup("none");
	  } else
	  hexR = hex_string(rhash->buf, rhash->length);
	  if (name != NULL)
	  ccn_uri_append(uri, name->buf, name->length, 1);
	  else
	  ccn_charbuf_append_string(uri, "(null)");

	  if ( nlsr->debugging )
	  printf("Response from sync in the name: %s \n",ccn_charbuf_as_string(uri));	

	  fflush(stdout);
	  free(hexL);
	  free(hexR);
	  ccn_charbuf_destroy(&uri);
	 */

	//--Doing our thing from here
	//struct ccn_indexbuf cid={0};

	//struct ccn_indexbuf *components=&cid;
	struct ccn_indexbuf *components=ccn_indexbuf_create();
	res=ccn_name_split (name, components);
	if ( res < 0 )
		return 0;
	//ccn_name_chop(name,components,-3);
	//process_content_from_sync(name,components);

	struct ccn_charbuf *content_name = ccn_charbuf_create();
	ccn_name_init(content_name);
	if (components->n < 2)
		return 0;
	res = ccn_name_append_components(content_name, name->buf, components->buf[0]
			, components->buf[components->n - 1]);

	if ( res < 0)
		return 0;


	// debugging purpose
	struct ccn_charbuf *temp=ccn_charbuf_create();
	ccn_uri_append(temp, content_name->buf, content_name->length, 0);
	if ( nlsr->debugging )
		printf("Name before chopping: %s \n",ccn_charbuf_as_string(temp));
	ccn_charbuf_destroy(&temp);

	//struct ccn_indexbuf cid1={0};
	//struct ccn_indexbuf *components1=&cid1;
	struct ccn_indexbuf *components1=ccn_indexbuf_create();
	res=ccn_name_split (content_name, components1);
	if ( res < 0)
		return 0;		

	if ( nlsr->debugging )
	{
		printf("Number of components in name = %d \n",res);
		printf("Number of components in name as indexbuf->n = %d \n",
				(int)components1->n);
	}
	ccn_name_chop(content_name,components1,-3);
	if ( nlsr->debugging )
		printf("Number of components in name as indexbuf->n after chopping= %d \n"
				,(int)components1->n);	

	//debugging purpose
	struct ccn_charbuf *temp1=ccn_charbuf_create();
	ccn_uri_append(temp1, content_name->buf, content_name->length, 0);
	if ( nlsr->debugging )
		printf("Name after chopping: %s \n",ccn_charbuf_as_string(temp1));
	ccn_charbuf_destroy(&temp1);

	process_content_from_sync(content_name,components1);
	ccn_charbuf_destroy(&content_name);
	ccn_indexbuf_destroy(&components);
	ccn_indexbuf_destroy(&components1);

	return(0);
}



	void 
get_name_part(struct name_prefix *name_part,struct ccn_charbuf * interest_ccnb, 
		struct ccn_indexbuf *interest_comps, int offset)
{



	int i;
	int lsa_position=0;
	int len=0;


	struct ccn_indexbuf cid={0};
	struct ccn_indexbuf *components=&cid;
	struct ccn_charbuf *name=ccn_charbuf_create();
	ccn_name_from_uri(name,nlsr->slice_prefix);
	ccn_name_split (name, components);
	lsa_position=components->n-2;

	ccn_charbuf_destroy(&name);


	const unsigned char *comp_ptr1;
	size_t comp_size;
	for(i=lsa_position+1+offset;i<interest_comps->n-1;i++)
	{
		ccn_name_comp_get(interest_ccnb->buf, interest_comps,i,&comp_ptr1, 
				&comp_size);
		len+=1;
		len+=(int)comp_size;	
	}
	len++;

	char *neighbor=(char *)malloc(len);
	memset(neighbor,0,len);

	for(i=lsa_position+1+offset; i<interest_comps->n-1;i++)
	{
		ccn_name_comp_get(interest_ccnb->buf, interest_comps,i,&comp_ptr1, 
				&comp_size);
		memcpy(neighbor+strlen(neighbor),"/",1);
		memcpy(neighbor+strlen(neighbor),(char *)comp_ptr1,
				strlen((char *)comp_ptr1));

	}

	name_part->name=(char *)malloc(strlen(neighbor)+1);
	memset(name_part->name,0,strlen(neighbor)+1);
	memcpy(name_part->name,neighbor,strlen(neighbor)+1);
	name_part->length=strlen(neighbor)+1;

	// Add 01/31/2013
	free(neighbor);
}





	void 
get_content_by_content_name(char *content_name, unsigned char **content_data)
{

	struct ccn_charbuf *name = NULL;
	struct ccn_charbuf *templ = NULL;
	struct ccn_charbuf *resultbuf = NULL;
	struct ccn_parsed_ContentObject pcobuf = { 0 };
	int res;
	int allow_stale = 0;
	int content_only = 1;
	int scope = -1;
	const unsigned char *ptr; 
	size_t length;
	int resolve_version = CCN_V_HIGHEST;
	int timeout_ms = 3000;
	const unsigned lifetime_default = CCN_INTEREST_LIFETIME_SEC << 12;
	unsigned lifetime_l12 = lifetime_default;
	int get_flags = 0;

	name = ccn_charbuf_create();
	res = ccn_name_from_uri(name,content_name);
	if (res < 0) {
		fprintf(stderr, "Bad ccn URI: %s\n", content_name);
		exit(1);
	}

	if (allow_stale || lifetime_l12 != lifetime_default || scope != -1) {
		templ = ccn_charbuf_create();
		ccn_charbuf_append_tt(templ, CCN_DTAG_Interest, CCN_DTAG);
		ccn_charbuf_append_tt(templ, CCN_DTAG_Name, CCN_DTAG);
		ccn_charbuf_append_closer(templ); /* </Name> */
		if (allow_stale) {
			ccn_charbuf_append_tt(templ, CCN_DTAG_AnswerOriginKind, CCN_DTAG);
			ccnb_append_number(templ,
					CCN_AOK_DEFAULT | CCN_AOK_STALE);
			ccn_charbuf_append_closer(templ); /* </AnswerOriginKind> */
		}
		if (scope != -1) {
			ccnb_tagged_putf(templ, CCN_DTAG_Scope, "%d", scope);
		}
		if (lifetime_l12 != lifetime_default) {
			/*
			 * Choose the interest lifetime so there are at least 3
			 * expressions (in the unsatisfied case).
			 */
			unsigned char buf[3] = { 0 };
			int i;
			for (i = sizeof(buf) - 1; i >= 0; i--, lifetime_l12 >>= 8)
				buf[i] = lifetime_l12 & 0xff;
			ccnb_append_tagged_blob(templ, CCN_DTAG_InterestLifetime, buf, 
					sizeof(buf));
		}
		ccn_charbuf_append_closer(templ); /* </Interest> */
	}
	resultbuf = ccn_charbuf_create();
	if (resolve_version != 0) {
		res = ccn_resolve_version(nlsr->ccn, name, resolve_version, 500);
		if (res >= 0) {
			ccn_uri_append(resultbuf, name->buf, name->length, 1);
			resultbuf->length = 0;
		}
	}
	res = ccn_get(nlsr->ccn, name, templ, timeout_ms, resultbuf, &pcobuf, NULL, 
			get_flags);
	if (res >= 0) {
		ptr = resultbuf->buf;
		length = resultbuf->length;
		if (content_only){
			ccn_content_get_value(ptr, length, &pcobuf, &ptr, &length);
			*content_data = (unsigned char *) calloc(length, sizeof(char *));
			memcpy (*content_data, ptr, length);
		}
	}
	ccn_charbuf_destroy(&resultbuf);
	ccn_charbuf_destroy(&templ);
	ccn_charbuf_destroy(&name);   
}

	void 
process_incoming_sync_content_lsa( unsigned char *content_data)
{


	if ( nlsr->debugging )
		printf("process_incoming_sync_content_lsa called \n");	

	char *sep="|";
	char *rem;
	char *orig_router;
	char *orl;
	int orig_router_length;
	char *lst;
	int ls_type;
	char *lsid;
	long int ls_id;
	char *isvld;
	int isValid;
	char *num_link;
	int no_link;
	char *np;
	char *np_length;
	int name_length;
	char *data;
	char *orig_time;


	if ( nlsr->debugging )
		printf("LSA Data \n");

	if( strlen((char *)content_data ) > 0 )
	{

		orig_router=strtok_r((char *)content_data,sep,&rem);
		orl=strtok_r(NULL,sep,&rem);
		orig_router_length=atoi(orl);

		if ( nlsr->debugging )
		{
			printf("	Orig Router Name  : %s\n",orig_router);
			printf("	Orig Router Length: %d\n",orig_router_length);
		}

		lst=strtok_r(NULL,sep,&rem);		
		ls_type=atoi(lst);

		if ( nlsr->debugging )
			printf("	LS Type  : %d\n",ls_type);

		if ( ls_type == LS_TYPE_NAME )
		{
			lsid=strtok_r(NULL,sep,&rem);
			ls_id=atoi(lsid);
			orig_time=strtok_r(NULL,sep,&rem);
			isvld=strtok_r(NULL,sep,&rem);
			isValid=atoi(isvld);
			np=strtok_r(NULL,sep,&rem);
			np_length=strtok_r(NULL,sep,&rem);
			name_length=atoi(np_length);
			if ( nlsr->debugging )
			{
				printf("	LS ID  : %ld\n",ls_id);
				printf("	isValid  : %d\n",isValid);
				printf("	Name Prefix : %s\n",np);
				printf("	Orig Time   : %s\n",orig_time);
				printf("	Name Prefix length: %d\n",name_length);
			}

			build_and_install_others_name_lsa(orig_router,ls_type,ls_id,orig_time,isValid,np);

			print_name_lsdb();

		}
		else if ( ls_type == LS_TYPE_ADJ )
		{
			orig_time=strtok_r(NULL,sep,&rem);
			num_link=strtok_r(NULL,sep,&rem);
			no_link=atoi(num_link);
			data=rem;

			if ( nlsr->debugging )
			{
				printf("	Orig Time   : %s\n",orig_time);
				printf("	No Link  : %d\n",no_link);
				printf("	Data  : %s\n",data);
			}
			build_and_install_others_adj_lsa(orig_router,ls_type,orig_time,no_link,data);
		}
		else if ( ls_type == LS_TYPE_COR )
		{
			orig_time=strtok_r(NULL,sep,&rem);
			char *cor_r=strtok_r(NULL,sep,&rem);
			char *cor_theta=strtok_r(NULL,sep,&rem);

			double r, theta;
			r=strtof(cor_r,NULL);
			theta=strtof(cor_theta,NULL);

			if ( nlsr->debugging )
			{
				printf("	Orig Time   : %s\n",orig_time);
				printf("	Cor R	    : %f\n",r);
				printf("	Cor Theta   : %f\n",theta);
			}
			build_and_install_others_cor_lsa(orig_router,ls_type,orig_time, (double)r, (double)theta);	
		}

	}
}

	void
process_content_from_sync(struct ccn_charbuf *content_name, struct ccn_indexbuf *components)
{
	size_t comp_size;
	char *lst;
	char *lsid;
	const unsigned char *second_last_comp;
	const unsigned char *third_last_comp;
	const unsigned char *origtime;
	char *sep=".";
	char *rem;
	char *second_comp_type;

	int ls_type;
	long int ls_id=0;

	unsigned char *content_data = NULL;

	char *time_stamp=(char *)malloc(20);
	memset(time_stamp,0,20);
	get_current_timestamp_micro(time_stamp);

	struct ccn_charbuf *uri = ccn_charbuf_create();
	ccn_uri_append(uri, content_name->buf, content_name->length, 0);	

	struct name_prefix *orig_router=(struct name_prefix *)malloc(sizeof(struct name_prefix));



	ccn_name_comp_get(content_name->buf, components,components->n-1-2,&second_last_comp, &comp_size);
	if (nlsr->debugging)
		printf("2nd Last Component: %s \n",second_last_comp);

	second_comp_type=strtok_r((char *)second_last_comp,sep,&rem);		
	if ( strcmp( second_comp_type, "lsId" ) == 0 )
	{	
		lsid=rem;
		ls_id=atoi(rem);
		ccn_name_comp_get(content_name->buf, components,components->n-2-2,&third_last_comp, &comp_size);
		lst=strtok_r((char *)third_last_comp,sep,&rem);
		lst=rem;
		ls_type=atoi(lst);
		ccn_name_comp_get(content_name->buf, components,components->n-2,&origtime, &comp_size);
		ccn_name_chop(content_name,components,-3);
		get_name_part(orig_router,content_name,components,0);

		if ( nlsr->debugging )
			printf("Orig Router: %s Ls Type: %d Ls id: %ld Orig Time: %s\n",orig_router->name,ls_type,ls_id,origtime);

		int lsa_life_time=get_time_diff(time_stamp,(char *)origtime);

		if ( (strcmp(orig_router->name,nlsr->router_name) == 0 && lsa_life_time < nlsr->lsa_refresh_time) 
				|| (strcmp(orig_router->name,nlsr->router_name) != 0 && lsa_life_time < nlsr->router_dead_interval) )
		{
			int is_new_name_lsa=check_is_new_name_lsa(orig_router->name,(char *)lst,(char *)lsid,(char *)origtime);
			if ( is_new_name_lsa == 1 )
			{
				if ( nlsr->debugging )
					printf("New NAME LSA.....\n");	
				get_content_by_content_name(ccn_charbuf_as_string(uri), &content_data);
				if ( nlsr->debugging )
					printf("Content Data: %s \n",content_data);
				process_incoming_sync_content_lsa(content_data);
			}
			else 
			{
				if ( nlsr->debugging )
					printf("Name LSA / Newer Name LSA already xists in LSDB\n");
				get_content_by_content_name(ccn_charbuf_as_string(uri), &content_data);

				if ( nlsr->debugging )
					printf("Content Data: %s \n",content_data);
			}
		}
		else 
		{
			if ( nlsr->debugging )
				printf("Lsa is older than Router LSA refresh time/ Dead Interval\n");
		}
	}
	else
	{
		ls_type=atoi(rem);
		lst=rem;
		if(ls_type == LS_TYPE_ADJ)
		{
			ccn_name_comp_get(content_name->buf, components,components->n-2,&origtime, &comp_size);
			ccn_name_chop(content_name,components,-2);
			get_name_part(orig_router,content_name,components,0);

			if ( nlsr->debugging )
				printf("Orig Router: %s Ls Type: %d Orig Time: %s\n",orig_router->name,ls_type,origtime);		

			int lsa_life_time=get_time_diff(time_stamp,(char *)origtime);
			if ( (strcmp(orig_router->name,nlsr->router_name) == 0 && lsa_life_time < nlsr->lsa_refresh_time) || (strcmp(orig_router->name,nlsr->router_name) != 0 && lsa_life_time < nlsr->router_dead_interval) )	
			{
				int is_new_adj_lsa=check_is_new_adj_lsa(orig_router->name,(char *)lst,(char *)origtime);
				if ( is_new_adj_lsa == 1 )
				{
					if ( nlsr->debugging )
						printf("New Adj LSA.....\n");	
					get_content_by_content_name(ccn_charbuf_as_string(uri), &content_data);

					if ( nlsr->debugging )
						printf("Content Data: %s \n",content_data);
					process_incoming_sync_content_lsa(content_data);			
				}
				else
				{
					if ( nlsr->debugging )
						printf("Adj LSA / Newer Adj LSA already exists in LSDB\n");
					get_content_by_content_name(ccn_charbuf_as_string(uri), &content_data);
					if ( nlsr->debugging )
						printf("Content Data: %s \n",content_data);
				}
			}
			else 
			{
				if ( nlsr->debugging )
					printf("Lsa is older than Router LSA refresh time/ Dead Interval\n");
			}
		}
		else if(ls_type == LS_TYPE_COR)
		{
			ccn_name_comp_get(content_name->buf, components,components->n-2,&origtime, &comp_size);
			ccn_name_chop(content_name,components,-2);
			get_name_part(orig_router,content_name,components,0);

			if ( nlsr->debugging )
				printf("Orig Router: %s Ls Type: %d Orig Time: %s\n",orig_router->name,ls_type,origtime);

			int lsa_life_time=get_time_diff(time_stamp,(char *)origtime);
			if ( (strcmp(orig_router->name,nlsr->router_name) == 0 && lsa_life_time < nlsr->lsa_refresh_time) || (strcmp(orig_router->name,nlsr->router_name) != 0 && lsa_life_time < nlsr->router_dead_interval) )	
			{
				int is_new_cor_lsa=check_is_new_cor_lsa(orig_router->name,(char *)lst,(char *)origtime);
				if ( is_new_cor_lsa == 1 )
				{
					if ( nlsr->debugging )
						printf("New Cor LSA.....\n");	
					get_content_by_content_name(ccn_charbuf_as_string(uri), &content_data);

					if ( nlsr->debugging )
						printf("Content Data: %s \n",content_data);
					process_incoming_sync_content_lsa(content_data);			
				}
				else
				{
					if ( nlsr->debugging )
						printf("Cor LSA / Newer Cor LSA already exists in LSDB\n");
					get_content_by_content_name(ccn_charbuf_as_string(uri), &content_data);
					if ( nlsr->debugging )
						printf("Content Data: %s \n",content_data);
				}
			}
			else 
			{	
				if ( nlsr->debugging )
					printf("Lsa is older than Router LSA refresh time/ Dead Interval\n");
			}

		}
	}

	free(orig_router);
	ccn_charbuf_destroy(&uri);
	//01/31/2013	
	free(time_stamp);
}

	int
sync_monitor(char *topo_prefix, char *slice_prefix)
{

	static struct ccns_name_closure nc={0};
	nlsr->closure = &nc;
	struct ccn_charbuf *prefix = ccn_charbuf_create();
	struct ccn_charbuf *roothash = NULL;
	struct ccn_charbuf *topo = ccn_charbuf_create(); 
	nlsr->slice = ccns_slice_create();
	ccn_charbuf_reset(prefix);
	ccn_charbuf_reset(topo);

	ccn_charbuf_reset(prefix);
	ccn_name_from_uri(prefix, slice_prefix);

	ccn_charbuf_reset(topo);
	ccn_name_from_uri(topo, topo_prefix);

	ccns_slice_set_topo_prefix(nlsr->slice, topo, prefix);
	nlsr->closure->callback = &sync_cb;
	nlsr->ccns = ccns_open(nlsr->ccn, nlsr->slice, nlsr->closure, roothash, NULL);

	//01/31/2013
	ccn_charbuf_destroy(&prefix);
	ccn_charbuf_destroy(&topo);
	ccn_charbuf_destroy(&roothash);
	return 0;
}

	struct ccn_charbuf *
make_template(int scope)
{
	struct ccn_charbuf *templ = NULL;
	templ = ccn_charbuf_create();
	ccn_charbuf_append_tt(templ, CCN_DTAG_Interest, CCN_DTAG);
	ccn_charbuf_append_tt(templ, CCN_DTAG_Name, CCN_DTAG);
	ccn_charbuf_append_closer(templ); /* </Name> */
	if (0 <= scope && scope <= 2)
		ccnb_tagged_putf(templ, CCN_DTAG_Scope, "%d", scope);
	ccn_charbuf_append_closer(templ); /* </Interest> */
	return(templ);
}

	int
write_data_to_repo(char *data, char *name_prefix)
{
	if ( nlsr->debugging )
	{
		printf("write_data_to_repo called\n");
		printf("Content Name: %s \n",name_prefix);
		printf("Content Data: %s \n",data);
	}

	struct ccn *temp_ccn;
	temp_ccn=ccn_create();
	int ccn_fd=ccn_connect(temp_ccn, NULL);
	if(ccn_fd == -1)
	{
		fprintf(stderr,"Could not connect to ccnd for Data Writing\n");
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Could not connect to ccnd for Data Writing\n");
		return -1;
	}
	struct ccn_charbuf *name = NULL;
	struct ccn_seqwriter *w = NULL;
	int blocksize = 4096;
	int freshness = -1;
	int torepo = 1;
	int scope = 1;
	int res;
	size_t blockread;
	struct ccn_charbuf *templ;

	name = ccn_charbuf_create();
	res = ccn_name_from_uri(name, name_prefix);
	if (res < 0) {
		fprintf(stderr, "bad CCN URI: %s\n",name_prefix);
		return -1;
	}


	w = ccn_seqw_create(temp_ccn, name);
	if (w == NULL) {
		fprintf(stderr, "ccn_seqw_create failed\n");
		return -1;
	}
	ccn_seqw_set_block_limits(w, blocksize, blocksize);
	if (freshness > -1)
		ccn_seqw_set_freshness(w, freshness);
	if (torepo) {
		struct ccn_charbuf *name_v = ccn_charbuf_create();
		ccn_seqw_get_name(w, name_v);
		ccn_name_from_uri(name_v, "%C1.R.sw");
		ccn_name_append_nonce(name_v);
		templ = make_template(scope);
		res = ccn_get(temp_ccn, name_v, templ, 60000, NULL, NULL, NULL, 0);
		ccn_charbuf_destroy(&templ);
		ccn_charbuf_destroy(&name_v);
		if (res < 0) {
			fprintf(stderr, "No response from repository\n");
			return -1;
		}
	}




	blockread = 0;


	blockread=strlen(data);

	if (blockread > 0) {
		ccn_run(temp_ccn, 100);
		res = ccn_seqw_write(w, data, blockread);	
		while (res == -1) {
			ccn_run(temp_ccn, 100);
			res = ccn_seqw_write(w, data, blockread);
		}
	}

	ccn_seqw_close(w);
	ccn_run(temp_ccn, 100);
	ccn_charbuf_destroy(&name);
	ccn_destroy(&temp_ccn);

	return 0;
}


	int
create_sync_slice(char *topo_prefix, char *slice_prefix)
{
	int res;
	struct ccn *handle;
	struct ccns_slice *slice;
	struct ccn_charbuf *prefix = ccn_charbuf_create();
	struct ccn_charbuf *topo = ccn_charbuf_create();
	struct ccn_charbuf *clause = ccn_charbuf_create();
	struct ccn_charbuf *slice_name = ccn_charbuf_create();
	struct ccn_charbuf *slice_uri = ccn_charbuf_create();

	if (prefix == NULL || topo == NULL || clause == NULL ||
			slice_name == NULL || slice_uri == NULL) {
		fprintf(stderr, "Unable to allocate required memory.\n");
		return -1;
	}

	handle = ccn_create();
	res = ccn_connect(handle, NULL);
	if (0 > res) {
		fprintf(stderr, "Unable to connect to ccnd.\n");
		return -1;
	}    

	slice = ccns_slice_create();

	ccn_charbuf_reset(topo);
	ccn_name_from_uri(topo, topo_prefix);
	ccn_charbuf_reset(prefix);
	ccn_name_from_uri(prefix,slice_prefix );
	ccns_slice_set_topo_prefix(slice, topo, prefix);


	res = ccns_write_slice(handle, slice, slice_name);

	//01/31/2013
	ccns_slice_destroy(&slice);
	ccn_destroy(&handle);
	ccn_charbuf_destroy(&prefix);
	ccn_charbuf_destroy(&topo);
	ccn_charbuf_destroy(&clause);
	ccn_charbuf_destroy(&slice_name);
	ccn_charbuf_destroy(&slice_uri);

	return 0;
}

