#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <unistd.h>
#include <getopt.h>
#include <sys/time.h>
#include <assert.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif


#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 "nlsr.h"
#include "nlsr_ndn.h"
#include "nlsr_lsdb.h"
#include "utility.h"
#include "nlsr_npl.h"
#include "nlsr_adl.h"
#include "nlsr_route.h"
#include "nlsr_npt.h"
#include "nlsr_sync.h"

/**
* LSDB version is updated to last updated timestamp
*/

void
set_new_lsdb_version(void)
{
	
	//char *time_stamp=get_current_timestamp_micro_v2();
	free(nlsr->lsdb->lsdb_version);
	nlsr->lsdb->lsdb_version=get_current_timestamp_micro_v2();
	//nlsr->lsdb->lsdb_version=(char *)calloc(strlen(time_stamp)+1,sizeof(char));
	//memcpy(nlsr->lsdb->lsdb_version,time_stamp,strlen(time_stamp)+1);
	//free(time_stamp);
}

/**
* Make key for storing Name LSA in Name LSDB
*/

void 
make_name_lsa_key(char *key, char *orig_router, int ls_type, long int ls_id)
{
	
	char lst[2];
	memset(lst,0,2);
	sprintf(lst,"%d",ls_type);	

	char lsid[10];
	memset(lsid,0,10);
	sprintf(lsid,"%ld",ls_id);
	
	memcpy(key,orig_router,strlen(orig_router));
	memcpy(key+strlen(key),"/",1);
	memcpy(key+strlen(key),lst,strlen(lst));
	memcpy(key+strlen(key),"/",1);
	memcpy(key+strlen(key),lsid,strlen(lsid));
	key[strlen(key)]='\0';	

	if ( nlsr->debugging )
		printf("name LSA Key: %s\n", key);
}


/**
* Make content name prefix for Name LSA to store in repo
*/

void 
make_name_lsa_prefix_for_repo(char *key, char *orig_router, int ls_type, 
							long int ls_id,char *orig_time,char *slice_prefix)
{
	sprintf(key,"%s%s/lsType.%d/lsId.%ld/%s",slice_prefix, orig_router, ls_type,
															 ls_id, orig_time);
	key[strlen(key)]='\0';
	if ( nlsr->debugging )
		printf("Name LSA prefix for repo content: %s\n",key);
}

/**
* Make content name prefix for Adj LSA to store in repo
*/

void 
make_adj_lsa_prefix_for_repo(char *key, char *orig_router, int ls_type, 
											char *orig_time,char *slice_prefix)
{
		
	sprintf(key,"%s%s/lsType.%d/%s",slice_prefix,orig_router,ls_type, orig_time );	
	key[strlen(key)]='\0';
	if ( nlsr->debugging )
		printf("Name LSA prefix for repo content:%s\n",key);	
}

/**
* Make content name prefix for Cor LSA to store in repo
*/

void 
make_cor_lsa_prefix_for_repo(char *key, char *orig_router, int ls_type, 
											char *orig_time,char *slice_prefix)
{
		
	sprintf(key,"%s%s/lsType.%d/%s",slice_prefix,orig_router,ls_type, orig_time );	
	key[strlen(key)]='\0';
	if ( nlsr->debugging )
		printf("Cor LSA prefix for repo content:%s\n",key);	
}

/**
* Build name lsa for all name prefixes in Name Prefix List (NPL). Intsall Name
* LSA in Name LSDB for router itself.
*/

void
destroy_name_lsa_component(struct nlsa * name_lsa)
{
	if ( name_lsa->header->orig_router->name )
		free(name_lsa->header->orig_router->name);
	if ( name_lsa->header->orig_router )
		free(name_lsa->header->orig_router);
	if ( name_lsa->header->orig_time )
		free(name_lsa->header->orig_time);
	if ( name_lsa->header ) 
		free(name_lsa->header);

	if ( name_lsa->name_prefix->name )
		free(name_lsa->name_prefix->name);
	if ( name_lsa->name_prefix )
		free(name_lsa->name_prefix);
}

void
destroy_name_lsa(struct nlsa * name_lsa)
{
	destroy_name_lsa_component(name_lsa);
	if ( name_lsa )
		free(name_lsa);
}

void
destroy_adj_lsa_component(struct alsa * adj_lsa)
{
	if ( adj_lsa->header->orig_router->name )
		free(adj_lsa->header->orig_router->name);
	if ( adj_lsa->header->orig_router )
		free(adj_lsa->header->orig_router);
	if ( adj_lsa->header->orig_time )
		free(adj_lsa->header->orig_time);
	if ( adj_lsa->header ) 
		free(adj_lsa->header);

	if ( adj_lsa->body )
		free(adj_lsa->body);
}

void 
destroy_adj_lsa(struct alsa * adj_lsa)
{
	
	destroy_adj_lsa_component(adj_lsa);
	if ( adj_lsa )
		free(adj_lsa);
}

void
destroy_cor_lsa_component(struct clsa * cor_lsa)
{
	if ( cor_lsa->header->orig_router->name )
		free(cor_lsa->header->orig_router->name);
	if ( cor_lsa->header->orig_router )
		free(cor_lsa->header->orig_router);
	if ( cor_lsa->header->orig_time )
		free(cor_lsa->header->orig_time);
	if ( cor_lsa->header ) 
		free(cor_lsa->header);
}

void 
destroy_cor_lsa(struct clsa * cor_lsa)
{
	
	destroy_cor_lsa_component(cor_lsa);
	if ( cor_lsa )
		free(cor_lsa);
}



void 
build_and_install_name_lsas(void)
{
	if ( nlsr->debugging )
		printf("build_and_install_name_lsas called \n");
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"build_and_install_name_lsas called\n");

	int i, npl_element;
	struct name_prefix_list_entry *npe;

	struct hashtb_enumerator ee;
    	struct hashtb_enumerator *e = &ee;
    	
    	hashtb_start(nlsr->npl, e);
	npl_element=hashtb_n(nlsr->npl);

	for(i=0;i<npl_element;i++)
	{
		npe=e->data;
		struct nlsa *name_lsa=(struct nlsa *)malloc(sizeof( struct nlsa ));
		build_name_lsa(name_lsa,npe->np);
		
		install_name_lsa(name_lsa);
		update_nlsa_id_for_name_in_npl(npe->np,name_lsa->header->ls_id);
		destroy_name_lsa(name_lsa);
		hashtb_next(e);		
	}

	hashtb_end(e);	
	
	print_name_prefix_from_npl();

}

/**
* Build and Install one Name LSA Use ful for API
*/

void 
build_and_install_single_name_lsa(struct name_prefix *np)
{
	if ( nlsr->debugging )
		printf("build_and_install_single_name_lsa called \n");
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"build_and_install_single_name_lsa called\n");
	
	struct nlsa *name_lsa=(struct nlsa *)malloc(sizeof( struct nlsa ));
	build_name_lsa(name_lsa,np);
		
	install_name_lsa(name_lsa);
	update_nlsa_id_for_name_in_npl(np,name_lsa->header->ls_id);
	destroy_name_lsa(name_lsa);
	print_name_prefix_from_npl();

}

void 
build_name_lsa(struct nlsa *name_lsa, struct name_prefix *np)
{
	name_lsa->header=(struct nlsa_header *)malloc(sizeof(struct nlsa_header ));
	name_lsa->header->ls_type=LS_TYPE_NAME;
	
	char *time_stamp=get_current_timestamp_micro_v2();
	name_lsa->header->orig_time=(char *)malloc(strlen(time_stamp)+1); //free 
	memset(name_lsa->header->orig_time,0,strlen(time_stamp)+1);
	memcpy(name_lsa->header->orig_time,time_stamp,strlen(time_stamp)+1);
	
	free(time_stamp);

	name_lsa->header->ls_id=++nlsr->nlsa_id;
	name_lsa->header->orig_router=(struct name_prefix *)calloc(1,sizeof(struct name_prefix ));
	name_lsa->header->orig_router->name=(char *)calloc(strlen(nlsr->router_name)+1,sizeof(char));
	memcpy(name_lsa->header->orig_router->name,nlsr->router_name,strlen(nlsr->router_name)+1);
	name_lsa->header->orig_router->length=strlen(nlsr->router_name)+1;
	name_lsa->header->isValid=1;

	
	name_lsa->name_prefix=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
	name_lsa->name_prefix->name=(char *)calloc(np->length,sizeof(char));
	memcpy(name_lsa->name_prefix->name,np->name,np->length);
	name_lsa->name_prefix->length=np->length;

}

void 
install_name_lsa(struct nlsa *name_lsa)
{

	char lst[2];
	memset(lst,0,2);
	sprintf(lst,"%d",name_lsa->header->ls_type);	

	char lsid[10];
	memset(lsid,0,10);
	sprintf(lsid,"%ld",name_lsa->header->ls_id);
		
	char *key=(char *)malloc(strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1);
	memset(key,0,strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1);
	make_name_lsa_key(key, name_lsa->header->orig_router->name,name_lsa->header->ls_type,name_lsa->header->ls_id);

	if ( nlsr->debugging )
		printf("Key:%s Length:%d\n",key,(int)strlen(key));
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Key:%s Length:%d\n",key,(int)strlen(key));	
		
	struct nlsa *new_name_lsa;

	struct hashtb_enumerator ee;
    	struct hashtb_enumerator *e = &ee; 	
    	int res;

   	hashtb_start(nlsr->lsdb->name_lsdb, e);
    	res = hashtb_seek(e, key, strlen(key), 0);

	if(res == HT_NEW_ENTRY )
		{
		
			if ( name_lsa->header->isValid == 1 )
			{
			if ( nlsr->debugging )
				printf("New Name LSA... Adding to LSDB\n");
			if ( nlsr->detailed_logging )
				writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Name LSA... Adding to LSDB\n");


			new_name_lsa = e->data;
	
			
			new_name_lsa->header=(struct nlsa_header *)malloc(sizeof(struct nlsa_header ));
			new_name_lsa->header->ls_type=name_lsa->header->ls_type;

			new_name_lsa->header->orig_time=(char *)malloc(strlen(name_lsa->header->orig_time)+1);
			memset(new_name_lsa->header->orig_time,0,strlen(name_lsa->header->orig_time)+1);
			memcpy(new_name_lsa->header->orig_time,name_lsa->header->orig_time,strlen(name_lsa->header->orig_time)+1);

			new_name_lsa->header->ls_id=name_lsa->header->ls_id;
			new_name_lsa->header->orig_router=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
			new_name_lsa->header->orig_router->name=(char *)malloc(name_lsa->header->orig_router->length);
			memcpy(new_name_lsa->header->orig_router->name,name_lsa->header->orig_router->name,name_lsa->header->orig_router->length);
			new_name_lsa->header->orig_router->length=name_lsa->header->orig_router->length;
			new_name_lsa->header->isValid=name_lsa->header->isValid;

	
			new_name_lsa->name_prefix=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
			new_name_lsa->name_prefix->name=(char *)malloc(name_lsa->name_prefix->length);
			memcpy(new_name_lsa->name_prefix->name,name_lsa->name_prefix->name,name_lsa->name_prefix->length);
			new_name_lsa->name_prefix->length=name_lsa->name_prefix->length;
			

			if ( nlsr->debugging )
			{
				printf("New Name LSA Added....\n");	
				printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
			}
			if ( nlsr->detailed_logging )
			{
				writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Name LSA Added....\n");	
				writeLogg(__FILE__,__FUNCTION__,__LINE__,"Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
			}

			set_new_lsdb_version();	

			if ( nlsr->debugging )
				printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
			if ( nlsr->detailed_logging )
				writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);	

			
			int num_next_hop=get_number_of_next_hop(new_name_lsa->header->orig_router->name);
			if ( num_next_hop < 0 )
			{
				int check=add_npt_entry(new_name_lsa->header->orig_router->name,new_name_lsa->name_prefix->name,NO_NEXT_HOP,NULL,NULL);
				if ( check == HT_NEW_ENTRY )
				{
					if ( nlsr->debugging )
						printf("Added in npt \n");
					if ( nlsr->detailed_logging )
						writeLogg(__FILE__,__FUNCTION__,__LINE__,"Added in npt \n");
				}
			}
			else 
			{
				int *faces=malloc(num_next_hop*sizeof(int));
				int *route_costs=malloc(num_next_hop*sizeof(int));			
				int next_hop=get_next_hop(new_name_lsa->header->orig_router->name,faces,route_costs);
				if ( nlsr->debugging )
				{
					printf("Printing from install_name_lsa \n");
					int j;
					for(j=0;j<num_next_hop;j++)
						printf("Face: %d Route Cost: %d \n",faces[j],route_costs[j]);
				}
				if ( nlsr->detailed_logging )
				{
					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Printing from install_name_lsa \n");
					int j;
					for(j=0;j<num_next_hop;j++)
						writeLogg(__FILE__,__FUNCTION__,__LINE__,"Face: %d Route Cost: %d \n",faces[j],route_costs[j]);
				}
				int check=add_npt_entry(new_name_lsa->header->orig_router->name,new_name_lsa->name_prefix->name,next_hop,faces,route_costs);
				if ( check == HT_NEW_ENTRY )
				{
					if ( nlsr->debugging )
						printf("Added in npt \n");
					if ( nlsr->detailed_logging )
						writeLogg(__FILE__,__FUNCTION__,__LINE__,"Added in npt \n");
				}
				free(faces);
				free(route_costs);

			}
			
			writeLogg(__FILE__,__FUNCTION__,__LINE__," Name-LSA\n");
			writeLogg(__FILE__,__FUNCTION__,__LINE__," Adding name lsa\n");
			write_log_for_name_lsa(new_name_lsa);
			writeLogg(__FILE__,__FUNCTION__,__LINE__," name_lsa_end\n");
		
			//free(time_stamp);
			}
			else 
			{
				hashtb_delete(e);
			}

		}
		else if(res == HT_OLD_ENTRY)
		{
			new_name_lsa=e->data;
			if(strcmp(name_lsa->header->orig_time,new_name_lsa->header->orig_time)<0)
			{
				if ( nlsr->debugging )
					printf("Older Adj LSA. Discarded... \n");
				if ( nlsr->detailed_logging )
					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Older Adj LSA. Discarded...\n");
			}
			else if( strcmp(name_lsa->header->orig_time,new_name_lsa->header->orig_time) == 0 )
			{
				if ( nlsr->debugging )
					printf("Duplicate Adj LSA. Discarded... \n");
				if ( nlsr->detailed_logging )
					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Duplicate Adj LSA. Discarded...\n");
			}
			else 
			{
				if ( name_lsa->header->isValid == 0 )
				{
					// have to call to delete npt table entry
					delete_npt_entry_by_router_and_name_prefix(new_name_lsa->header->orig_router->name,new_name_lsa->name_prefix->name);
				
					if ( strcmp(name_lsa->header->orig_router->name,nlsr->router_name)!= 0)
					{
						writeLogg(__FILE__,__FUNCTION__,__LINE__," Name-LSA\n");
						writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting name lsa\n");
						write_log_for_name_lsa(new_name_lsa);
						writeLogg(__FILE__,__FUNCTION__,__LINE__," name_lsa_end\n");
						
						hashtb_delete(e);
						if ( nlsr->debugging )
							printf("isValid bit not set for Router %s so LSA Deleted from LSDB\n",name_lsa->header->orig_router->name);
						if ( nlsr->detailed_logging )
							writeLogg(__FILE__,__FUNCTION__,__LINE__,"isValid bit not set for Router %s so LSA Deleted from LSDB\n",name_lsa->header->orig_router->name);
					}
					else 
					{
						new_name_lsa->header->isValid=name_lsa->header->isValid;
						free(new_name_lsa->header->orig_time);
						new_name_lsa->header->orig_time=(char *)malloc(strlen(name_lsa->header->orig_time)+1);
						memset(new_name_lsa->header->orig_time,0,strlen(name_lsa->header->orig_time)+1);
						memcpy(new_name_lsa->header->orig_time,name_lsa->header->orig_time,strlen(name_lsa->header->orig_time)+1);
					}
					if ( nlsr->debugging )
						printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
					if ( nlsr->detailed_logging )
						writeLogg(__FILE__,__FUNCTION__,__LINE__,"Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
					set_new_lsdb_version();	
					if ( nlsr->debugging )
						printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
					if ( nlsr->detailed_logging )
						writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
				}
				else
				{
					int is_npt_update=0;
					if ( strcmp(new_name_lsa->name_prefix->name,name_lsa->name_prefix->name) != 0 )
					{
						is_npt_update=1;
						delete_npt_entry_by_router_and_name_prefix(new_name_lsa->header->orig_router->name,new_name_lsa->name_prefix->name);
					}

					// copying LSA content with header
					writeLogg(__FILE__,__FUNCTION__,__LINE__," Name-LSA\n");
					writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting name lsa\n");
					write_log_for_name_lsa(new_name_lsa);
					writeLogg(__FILE__,__FUNCTION__,__LINE__," name_lsa_end\n");					


					free(new_name_lsa->header->orig_time);
					new_name_lsa->header->orig_time=(char *)malloc(strlen(name_lsa->header->orig_time)+1);
					memset(new_name_lsa->header->orig_time,0,strlen(name_lsa->header->orig_time)+1);
					memcpy(new_name_lsa->header->orig_time,name_lsa->header->orig_time,strlen(name_lsa->header->orig_time));
				
					new_name_lsa->header->isValid=name_lsa->header->isValid;

					free(new_name_lsa->name_prefix->name);
					free(new_name_lsa->name_prefix);
					new_name_lsa->name_prefix=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
					new_name_lsa->name_prefix->name=(char *)malloc(name_lsa->name_prefix->length);
					memcpy(new_name_lsa->name_prefix->name,name_lsa->name_prefix->name,name_lsa->name_prefix->length);
					new_name_lsa->name_prefix->length=name_lsa->name_prefix->length;


					writeLogg(__FILE__,__FUNCTION__,__LINE__," Name-LSA\n");
					writeLogg(__FILE__,__FUNCTION__,__LINE__," Adding name lsa\n");
					write_log_for_name_lsa(new_name_lsa);
					writeLogg(__FILE__,__FUNCTION__,__LINE__," name_lsa_end\n");

					if ( nlsr->debugging )
						printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
					if ( nlsr->detailed_logging )
						writeLogg(__FILE__,__FUNCTION__,__LINE__,"Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);

					set_new_lsdb_version();	

					if ( nlsr->debugging )
						printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
					if ( nlsr->detailed_logging )
						writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);


					if( is_npt_update == 1 )
					{
						//struct hashtb *face_list;
						int num_next_hop=get_number_of_next_hop(new_name_lsa->header->orig_router->name);
						if ( num_next_hop < 0 )
						{
							
							int check=add_npt_entry(new_name_lsa->header->orig_router->name,new_name_lsa->name_prefix->name,NO_NEXT_HOP,NULL,NULL);
							if ( check == HT_NEW_ENTRY )
							{
								if ( nlsr->debugging )
									printf("Added in npt \n");
								if ( nlsr->detailed_logging )
									writeLogg(__FILE__,__FUNCTION__,__LINE__,"Added in npt \n");
							}
						}
						else 
						{
							int *faces=malloc(num_next_hop*sizeof(int));
							int *route_costs=malloc(num_next_hop*sizeof(int));			
							int next_hop=get_next_hop(new_name_lsa->header->orig_router->name,faces,route_costs);
							
							if ( nlsr->debugging )
							{
								printf("Printing from install_name_lsa \n");
								int j;
								for(j=0;j<num_next_hop;j++)
								printf("Face: %d Route Cost: %d \n",faces[j],route_costs[j]);
							}
							if ( nlsr->detailed_logging )
							{
								writeLogg(__FILE__,__FUNCTION__,__LINE__,"Printing from install_name_lsa \n");
								int j;
								for(j=0;j<num_next_hop;j++)
									writeLogg(__FILE__,__FUNCTION__,__LINE__,"Face: %d Route Cost: %d \n",faces[j],route_costs[j]);
							}

							
							int check=add_npt_entry(new_name_lsa->header->orig_router->name,new_name_lsa->name_prefix->name,next_hop,faces,route_costs);
							if ( check == HT_NEW_ENTRY )
							{
								if ( nlsr->debugging )
									printf("Added in npt \n");
								if ( nlsr->detailed_logging )
									writeLogg(__FILE__,__FUNCTION__,__LINE__,"Added in npt \n");
							}
							free(faces);
							free(route_costs);
							
						}
						
					}
				}
			}
		
		}

    		hashtb_end(e);

		free(key);
}

void 
write_log_for_name_lsa(struct nlsa *name_lsa)
{
	
	writeLogg(__FILE__,__FUNCTION__,__LINE__,"-----------Name LSA Content---------------\n");
	writeLogg(__FILE__,__FUNCTION__,__LINE__,"	Origination Router: %s\n",name_lsa->header->orig_router->name);
	writeLogg(__FILE__,__FUNCTION__,__LINE__,"	Origination Router Length:	%d\n",name_lsa->header->orig_router->length);
	writeLogg(__FILE__,__FUNCTION__,__LINE__,"	LS Type:	%d\n",name_lsa->header->ls_type);
	writeLogg(__FILE__,__FUNCTION__,__LINE__,"	LS Id:	%ld\n",name_lsa->header->ls_id);
	writeLogg(__FILE__,__FUNCTION__,__LINE__,"	Origination Time:	%s\n",name_lsa->header->orig_time);
	writeLogg(__FILE__,__FUNCTION__,__LINE__,"	Is Valid:	%d\n",name_lsa->header->isValid);
	writeLogg(__FILE__,__FUNCTION__,__LINE__,"	LSA Data			\n");
	writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Name Prefix: %s\n",name_lsa->name_prefix->name);
	writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Name Prefix Length:	%d\n",name_lsa->name_prefix->length);
	writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");	
}

void 
print_name_lsa(struct nlsa *name_lsa)
{

	if ( nlsr->debugging )
	{
		printf("-----------Name LSA Content---------------\n");
		printf("	Origination Router       :	%s\n",name_lsa->header->orig_router->name);
		printf("	Origination Router Length:	%d\n",name_lsa->header->orig_router->length);
		printf("	LS Type			 :	%d\n",name_lsa->header->ls_type);
		printf("	LS Id			 :	%ld\n",name_lsa->header->ls_id);
		printf("	Origination Time	 :	%s\n",name_lsa->header->orig_time);
		printf("	Is Valid 		 :	%d\n",name_lsa->header->isValid);
		printf("	LSA Data			\n");
		printf("		Name Prefix:	 	:	%s\n",name_lsa->name_prefix->name);
		printf("		Name Prefix Length	:	%d\n",name_lsa->name_prefix->length);

		printf("\n");	
	}
}

void
print_name_lsdb(void)
{
	if ( nlsr->debugging )
		printf("print_name_lsdb called \n");	
	int i, name_lsdb_element;
	struct nlsa *name_lsa;

	struct hashtb_enumerator ee;
    	struct hashtb_enumerator *e = &ee;
    	
    	hashtb_start(nlsr->lsdb->name_lsdb, e);
	name_lsdb_element=hashtb_n(nlsr->lsdb->name_lsdb);

	for(i=0;i<name_lsdb_element;i++)
	{
		if ( nlsr->debugging )
			printf("-----------Name LSA (%d)---------------\n",i+1);
		name_lsa=e->data;
		print_name_lsa(name_lsa);	
		hashtb_next(e);		
	}

	hashtb_end(e);

	if ( nlsr->debugging )
		printf("\n");
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");
}


void
build_and_install_others_name_lsa(char *orig_router,int ls_type,long int ls_id,char *orig_time, int isValid,char *np)
{
	if ( nlsr->debugging )
		printf("build_and_install_others_name_lsa called \n");
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"build_and_install_others_name_lsa called \n");

	struct nlsa *name_lsa=(struct nlsa *)malloc(sizeof( struct nlsa ));
	build_others_name_lsa(name_lsa,orig_router,ls_type,ls_id,orig_time, isValid,np);
	print_name_lsa(name_lsa);
	install_name_lsa(name_lsa);
	print_name_lsdb();
	print_npt();
	
	destroy_name_lsa(name_lsa);
	
}

void
build_others_name_lsa(struct nlsa *name_lsa, char *orig_router,int ls_type,long int ls_id,char *orig_time, int isValid,char *np)
{
	if ( nlsr->debugging )
		printf("build_others_name_lsa called\n");
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"build_others_name_lsa called \n");

	name_lsa->header=(struct nlsa_header *)calloc(1,sizeof(struct nlsa_header ));
	name_lsa->header->ls_type=LS_TYPE_NAME;

	name_lsa->header->orig_time=(char *)calloc(strlen(orig_time)+1,sizeof(char));
	memcpy(name_lsa->header->orig_time,orig_time,strlen(orig_time)+1);

	name_lsa->header->ls_id=ls_id;
	name_lsa->header->orig_router=(struct name_prefix *)calloc(1,sizeof(struct name_prefix ));
	name_lsa->header->orig_router->name=(char *)calloc(strlen(orig_router)+1,sizeof(char));
	memcpy(name_lsa->header->orig_router->name,orig_router,strlen(orig_router)+1);
	name_lsa->header->orig_router->length=strlen(orig_router)+1;
	name_lsa->header->isValid=isValid;

	name_lsa->name_prefix=(struct name_prefix *)calloc(1,sizeof(struct name_prefix ));
	name_lsa->name_prefix->name=(char *)calloc(strlen(np)+1,sizeof(char));
	memcpy(name_lsa->name_prefix->name,np,strlen(np)+1);
	name_lsa->name_prefix->length=strlen(np)+1;
}


void 
make_cor_lsa_key(char *key,struct clsa *cor_lsa)
{
	memcpy(key+strlen(key),cor_lsa->header->orig_router->name,cor_lsa->header->orig_router->length);
	memcpy(key+strlen(key),"/",1);
	char ls_type[2];
	sprintf(ls_type,"%d",cor_lsa->header->ls_type);
	memcpy(key+strlen(key),ls_type,strlen(ls_type));
	key[strlen(key)]='\0';
}


void 
make_adj_lsa_key(char *key,struct alsa *adj_lsa)
{
	memcpy(key+strlen(key),adj_lsa->header->orig_router->name,adj_lsa->header->orig_router->length);
	memcpy(key+strlen(key),"/",1);
	char ls_type[2];
	sprintf(ls_type,"%d",adj_lsa->header->ls_type);
	memcpy(key+strlen(key),ls_type,strlen(ls_type));
	key[strlen(key)]='\0';
}

int
build_and_install_adj_lsa(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
{
	if(flags == CCN_SCHEDULE_CANCEL)
	{
 	 	return -1;
	}

	nlsr_lock();

	if ( nlsr->debugging )
		printf("build_and_install_adj_lsa called \n");
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"build_and_install_adj_lsa called \n");
	
	if ( nlsr->debugging )
		printf("adj_build_flag = %d \n",nlsr->adj_build_flag);
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"adj_build_flag = %d \n",nlsr->adj_build_flag);

	if(nlsr->adj_build_flag > 0)
	{
		if ( nlsr->debugging )
			printf("is_adj_lsa_build = %d \n",is_adj_lsa_build());
		if ( nlsr->detailed_logging )
			writeLogg(__FILE__,__FUNCTION__,__LINE__,"is_adj_lsa_build = %d \n",is_adj_lsa_build());

		if ( is_adj_lsa_build()> 0)
		{
			struct alsa *adj_lsa=(struct alsa *)malloc(sizeof( struct alsa ));
			build_adj_lsa(adj_lsa);
			install_adj_lsa(adj_lsa);

			char lst[2];
			memset(lst,0,2);
			sprintf(lst,"%d",LS_TYPE_ADJ);			

			char *repo_key=(char *)calloc(strlen(nlsr->slice_prefix)+strlen(adj_lsa->header->orig_time)+strlen(adj_lsa->header->orig_router->name) + strlen(lst) + 5+15,sizeof(char));
				make_adj_lsa_prefix_for_repo(repo_key, adj_lsa->header->orig_router->name,LS_TYPE_ADJ,adj_lsa->header->orig_time,nlsr->slice_prefix);
		
			if ( nlsr->debugging )
				printf("Adj LSA Repo Key: %s \n",repo_key);

			char *key=(char *)calloc(adj_lsa->header->orig_router->length+5,sizeof(char));
			make_adj_lsa_key(key,adj_lsa);
			if ( nlsr->debugging )
				printf("Adj LSA: %s \n",key);

			struct name_prefix *lsaid=(struct name_prefix *)calloc(1,sizeof(struct name_prefix));
			lsaid->name=(char *)calloc(strlen(key)+1,sizeof(char));
			memcpy(lsaid->name,key,strlen(key)+1);
			lsaid->length=strlen(key)+1;

		
			write_adj_lsa_to_repo(repo_key, lsaid);

			free(key);
			free(repo_key);
			free(lsaid->name);
			free(lsaid);

			destroy_adj_lsa(adj_lsa);

			nlsr->adj_build_flag=0;	
			print_adj_lsdb();		
		}
		else
		{
			if ( nlsr->debugging )
				printf("Can not build adj LSA now\n");
			if ( nlsr->detailed_logging )
				writeLogg(__FILE__,__FUNCTION__,__LINE__,"Can not build adj LSA now\n");
		}
	}
	nlsr->is_build_adj_lsa_sheduled=0;

	nlsr_unlock();

	return 0;
}


void
build_adj_lsa(struct alsa * adj_lsa)
{
	if ( nlsr->debugging )
		printf("build_adj_lsa called \n");
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"build_adj_lsa called  \n");

	int no_link=no_active_nbr();
	
	adj_lsa->header=(struct alsa_header *)malloc(sizeof(struct alsa_header ));
	adj_lsa->header->orig_router=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
	adj_lsa->header->orig_router->name=(char *)malloc(strlen(nlsr->router_name)+1);
	memset(adj_lsa->header->orig_router->name,0,strlen(nlsr->router_name)+1);
	memcpy(adj_lsa->header->orig_router->name,nlsr->router_name,strlen(nlsr->router_name)+1);
	adj_lsa->header->orig_router->length=strlen(nlsr->router_name)+1;

	adj_lsa->header->ls_type=(unsigned)LS_TYPE_ADJ;	


	char *time_stamp=get_current_timestamp_micro_v2();
	adj_lsa->header->orig_time=(char *)malloc(strlen(time_stamp)+1); 
	memset(adj_lsa->header->orig_time,0,strlen(time_stamp)+1);
	memcpy(adj_lsa->header->orig_time,time_stamp,strlen(time_stamp)+1);	
	free(time_stamp);

	adj_lsa->no_link=no_link;


	struct ccn_charbuf *c=ccn_charbuf_create();
	get_active_nbr_adj_data(c);
	char *data=ccn_charbuf_as_string(c);

	adj_lsa->body=(char *)calloc(strlen(data)+1,sizeof(char));
	//memset(adj_lsa->body,0,strlen(data)+1);
	memcpy(adj_lsa->body,(char *)data,strlen(data)+1);
	data[strlen(data)]='\0';
	ccn_charbuf_destroy(&c);

	nlsr->adj_build_count++;


}


void
install_adj_lsa(struct alsa * adj_lsa)
{

	if ( nlsr->debugging )
		printf("install_adj_lsa called \n");
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"install_adj_lsa called  \n");
	



		char *key=(char *)calloc(adj_lsa->header->orig_router->length+4,sizeof(char));
		make_adj_lsa_key(key,adj_lsa);

		struct alsa *new_adj_lsa;//=(struct alsa*)malloc(sizeof(struct alsa ));

		struct hashtb_enumerator ee;
    		struct hashtb_enumerator *e = &ee; 	
    		int res;

   		hashtb_start(nlsr->lsdb->adj_lsdb, e);
    		res = hashtb_seek(e, key, strlen(key), 0);



		if(res == HT_NEW_ENTRY)
		{
			if ( adj_lsa->no_link > 0)
			{
				if ( nlsr->debugging )
					printf("New ADJ LSA... Adding to LSDB\n");
				if ( nlsr->detailed_logging )
					writeLogg(__FILE__,__FUNCTION__,__LINE__,"New ADJ LSA... Adding to LSDB\n");
				new_adj_lsa = e->data;

				new_adj_lsa->header=(struct alsa_header *)calloc(1,sizeof(struct alsa_header ));
				new_adj_lsa->header->ls_type=adj_lsa->header->ls_type;
				new_adj_lsa->header->orig_time=(char *)calloc(strlen(adj_lsa->header->orig_time)+1,sizeof(char));
				memcpy(new_adj_lsa->header->orig_time,adj_lsa->header->orig_time,strlen(adj_lsa->header->orig_time)+1);		

				new_adj_lsa->header->orig_router=(struct name_prefix *)calloc(1,sizeof(struct name_prefix ));
				new_adj_lsa->header->orig_router->name=(char *)calloc(adj_lsa->header->orig_router->length,sizeof(char));
				memcpy(new_adj_lsa->header->orig_router->name,adj_lsa->header->orig_router->name,adj_lsa->header->orig_router->length);
				new_adj_lsa->header->orig_router->length=adj_lsa->header->orig_router->length;

				new_adj_lsa->no_link=adj_lsa->no_link;
		
				new_adj_lsa->body=(char *)calloc(strlen(adj_lsa->body)+1,sizeof(char));
				//memset(new_adj_lsa->body,0,strlen(adj_lsa->body)+1);
				memcpy(new_adj_lsa->body,adj_lsa->body,strlen(adj_lsa->body)+1);
			
				add_next_hop_router(new_adj_lsa->header->orig_router->name);
				add_next_hop_from_lsa_adj_body(new_adj_lsa->body,new_adj_lsa->no_link);

				writeLogg(__FILE__,__FUNCTION__,__LINE__," Adj-LSA\n");
				writeLogg(__FILE__,__FUNCTION__,__LINE__," Adding adj lsa\n");
				write_log_for_adj_lsa(new_adj_lsa);
				writeLogg(__FILE__,__FUNCTION__,__LINE__," adj_lsa_end\n");
			}
			else 
			{
				hashtb_delete(e);
			}

			if ( nlsr->debugging )
				printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
			if ( nlsr->detailed_logging )
				writeLogg(__FILE__,__FUNCTION__,__LINE__,"Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);

			set_new_lsdb_version();	

			if ( nlsr->debugging )
				printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
			if ( nlsr->detailed_logging )
				writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);

		}
		else if(res == HT_OLD_ENTRY)
		{
			new_adj_lsa = e->data;
			if(strcmp(adj_lsa->header->orig_time,new_adj_lsa->header->orig_time)<=0)
			{
				if ( nlsr->debugging )
					printf("Older/Duplicate Adj LSA. Discarded...\n");
				if ( nlsr->detailed_logging )
					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Older/Duplicate Adj LSA. Discarded...\n");
			}
			else
			{

				if ( adj_lsa->no_link > 0)
				{				
					writeLogg(__FILE__,__FUNCTION__,__LINE__," Adj-LSA\n");
					writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting adj lsa\n");
					write_log_for_adj_lsa(new_adj_lsa);
					writeLogg(__FILE__,__FUNCTION__,__LINE__," adj_lsa_end\n");

					free(new_adj_lsa->header->orig_time);
					new_adj_lsa->header->orig_time=(char *)calloc(strlen(adj_lsa->header->orig_time)+1,sizeof(char));
					memcpy(new_adj_lsa->header->orig_time,adj_lsa->header->orig_time,strlen(adj_lsa->header->orig_time)+1);

					new_adj_lsa->no_link=adj_lsa->no_link;
				
					new_adj_lsa->body=(char *)calloc(strlen(adj_lsa->body)+1,sizeof(char));
					//memset(new_adj_lsa->body,0,strlen(adj_lsa->body)+1);
					memcpy(new_adj_lsa->body,adj_lsa->body,strlen(adj_lsa->body)+1);

					add_next_hop_from_lsa_adj_body(new_adj_lsa->body,new_adj_lsa->no_link);

					writeLogg(__FILE__,__FUNCTION__,__LINE__," Adj-LSA\n");
					writeLogg(__FILE__,__FUNCTION__,__LINE__," Adding adj lsa\n");
					write_log_for_adj_lsa(new_adj_lsa);
					writeLogg(__FILE__,__FUNCTION__,__LINE__," adj_lsa_end\n");
				}
				else
				{
					writeLogg(__FILE__,__FUNCTION__,__LINE__," Adj-LSA\n");
					writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting adj lsa\n");
					write_log_for_adj_lsa(new_adj_lsa);
					writeLogg(__FILE__,__FUNCTION__,__LINE__," adj_lsa_end\n");
					
					hashtb_delete(e);
				}
				
				if ( nlsr->debugging )
					printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
				if ( nlsr->detailed_logging )
					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);

				set_new_lsdb_version();	

				if ( nlsr->debugging )
					printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
				if ( nlsr->detailed_logging )
					writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
			}
	
		}
	    	hashtb_end(e);

		if ( !nlsr->is_route_calculation_scheduled )
		{
			nlsr->event_calculate_route = ccn_schedule_event(nlsr->sched, 1000000, &route_calculate, NULL, 0);
			nlsr->is_route_calculation_scheduled=1;
		}


	free(key);

	//free(time_stamp);
}

void 
write_log_for_adj_lsa_body(const char *body, int no_link)
{
	int i=0;
	char *lsa_data=(char *)calloc(strlen(body)+1,sizeof(char));
	//memset(	lsa_data,0,strlen(body)+1);
	memcpy(lsa_data,body,strlen(body)+1);
	char *sep="|";
	char *rem;
	char *rtr_id;
	char *length;
	//char *face;
	char *metric;

	if(no_link >0 )
	{
		rtr_id=strtok_r(lsa_data,sep,&rem);
		length=strtok_r(NULL,sep,&rem);
		//face=strtok_r(NULL,sep,&rem);
		metric=strtok_r(NULL,sep,&rem);

		writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Link %d	 	\n",i+1);
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Adjacent Router: %s	\n",rtr_id);
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Adjacent Router Length: %s	\n",length);
		//writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Connecting Face: %s	\n",face);
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Metric: %s	\n",metric);


		for(i=1;i<no_link;i++)
		{
			rtr_id=strtok_r(NULL,sep,&rem);
			length=strtok_r(NULL,sep,&rem);
			//face=strtok_r(NULL,sep,&rem);
			metric=strtok_r(NULL,sep,&rem);
			writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Link %d	 	\n",i+1);
			writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Adjacent Router: %s	\n",rtr_id);
			writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Adjacent Router Length: %s	\n",length);
			//writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Connecting Face: %s	\n",face);
			writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Metric: %s	\n",metric);

		}
	}

	if(lsa_data)
		free(lsa_data);
}


void
write_log_for_adj_lsa(struct alsa * adj_lsa)
{
	writeLogg(__FILE__,__FUNCTION__,__LINE__,"-----------Adj LSA Content---------------\n");
	writeLogg(__FILE__,__FUNCTION__,__LINE__,"	Origination Router: %s\n",adj_lsa->header->orig_router->name);
	writeLogg(__FILE__,__FUNCTION__,__LINE__,"	Origination Router Length: %d\n",adj_lsa->header->orig_router->length);
	writeLogg(__FILE__,__FUNCTION__,__LINE__,"	LS Type:	%d\n",adj_lsa->header->ls_type);
	writeLogg(__FILE__,__FUNCTION__,__LINE__,"	Origination Time: %s\n",adj_lsa->header->orig_time);
	writeLogg(__FILE__,__FUNCTION__,__LINE__,"	Lsa Data:\n");
	writeLogg(__FILE__,__FUNCTION__,__LINE__,"		No of Link: %d\n",adj_lsa->no_link);

	write_log_for_adj_lsa_body(adj_lsa->body,adj_lsa->no_link);
	
	writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");

}

void 
print_adj_lsa_body(const char *body, int no_link)
{
	int i=0;
	char *lsa_data=(char *)calloc(strlen(body)+1,sizeof(char));
	//memset(	lsa_data,0,strlen(body)+1);
	memcpy(lsa_data,body,strlen(body)+1);
	char *sep="|";
	char *rem;
	char *rtr_id;
	char *length;
	//char *face;
	char *metric;

	if(no_link >0 )
	{
		rtr_id=strtok_r(lsa_data,sep,&rem);
		length=strtok_r(NULL,sep,&rem);
		//face=strtok_r(NULL,sep,&rem);
		metric=strtok_r(NULL,sep,&rem);

		if ( nlsr->debugging ) {
			printf("		Link %d	 	\n",i+1);
			printf("		Neighbor		 : %s	\n",rtr_id);
			printf("		Neighbor Length		 : %s	\n",length);
			//printf("		Connecting Face		 : %s	\n",face);
			printf("		Metric			 : %s	\n",metric);
		}

		for(i=1;i<no_link;i++)
		{
			rtr_id=strtok_r(NULL,sep,&rem);
			length=strtok_r(NULL,sep,&rem);
			//face=strtok_r(NULL,sep,&rem);
			metric=strtok_r(NULL,sep,&rem);
			printf("		Link %d	 	\n",i+1);
			printf("		Neighbor		 : %s	\n",rtr_id);
			printf("		Neighbor Length		 : %s	\n",length);
			//printf("		Connecting Face		 : %s	\n",face);
			printf("		Metric			 : %s	\n",metric);

		}
	}

	if( lsa_data )
		free(lsa_data);
}

void
print_adj_lsa(struct alsa * adj_lsa)
{
	if ( nlsr->debugging )
	{
		printf("-----------ADJ LSA Content---------------\n");
		printf("	Origination Router       :	%s\n",adj_lsa->header->orig_router->name);
		printf("	Origination Router Length:	%d\n",adj_lsa->header->orig_router->length);
		printf("	LS Type			 :	%d\n",adj_lsa->header->ls_type);
		printf("	Origination Time	 :	%s\n",adj_lsa->header->orig_time);
		printf("	Lsa Data:\n");
		printf("		No of Link	: %d\n",adj_lsa->no_link);

		print_adj_lsa_body(adj_lsa->body,adj_lsa->no_link);
		printf("\n");
	}

}

void
print_adj_lsdb(void)
{
	if ( nlsr->debugging )
		printf("print_name_lsdb called \n");	
	int i, adj_lsdb_element;
	struct alsa *adj_lsa;

	struct hashtb_enumerator ee;
    	struct hashtb_enumerator *e = &ee;
    	
    	hashtb_start(nlsr->lsdb->adj_lsdb, e);
	adj_lsdb_element=hashtb_n(nlsr->lsdb->adj_lsdb);

	for(i=0;i<adj_lsdb_element;i++)
	{
		if ( nlsr->debugging )
			printf("-----------Adj LSA (%d)---------------\n",i+1);
		adj_lsa=e->data;
		print_adj_lsa(adj_lsa);	
		hashtb_next(e);		
	}

	hashtb_end(e);

	if ( nlsr->debugging )
		printf("\n");
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");
}

void 
build_and_install_others_adj_lsa(char *orig_router,int ls_type,char *orig_time, int no_link,char *data)
{
	if ( nlsr->debugging )
		printf("build_and_install_others_adj_lsa called \n");	
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"build_and_install_others_adj_lsa called \n");
	struct alsa *adj_lsa=(struct alsa *)malloc(sizeof( struct alsa ));
	build_others_adj_lsa(adj_lsa,orig_router,ls_type,orig_time,no_link,data);
	install_adj_lsa(adj_lsa);
	
	destroy_adj_lsa(adj_lsa);

	print_adj_lsdb();

}


void 
build_others_adj_lsa(struct alsa *adj_lsa,char *orig_router,int ls_type,char *orig_time,int no_link,char *data)
{
	if ( nlsr->debugging )
		printf("build_others_adj_lsa called  \n");	
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"build_others_adj_lsa called  \n");

	/*Filling Up Header Data */
	adj_lsa->header=(struct alsa_header *)calloc(1,sizeof(struct alsa_header ));
	adj_lsa->header->orig_router=(struct name_prefix *)calloc(1,sizeof(struct name_prefix ));
	adj_lsa->header->orig_router->name=(char *)calloc(strlen(orig_router)+1,sizeof(char));
	memcpy(adj_lsa->header->orig_router->name,orig_router,strlen(orig_router)+1);

	adj_lsa->header->orig_router->length=strlen(orig_router)+1;


	adj_lsa->header->ls_type=(unsigned)LS_TYPE_ADJ;	

	adj_lsa->header->orig_time=(char *)calloc(strlen(orig_time)+1,sizeof(char));
	memcpy(adj_lsa->header->orig_time,orig_time,strlen(orig_time)+1);

	adj_lsa->no_link=no_link;

	adj_lsa->body=(char *)calloc(strlen(data)+1,sizeof(char));
	memcpy(adj_lsa->body,(char *)data,strlen(data)+1);

}


long int
get_name_lsdb_num_element(void)
{
	long int num_element;


	struct hashtb_enumerator ee;
    	struct hashtb_enumerator *e = &ee;
    	
    	hashtb_start(nlsr->lsdb->name_lsdb, e);
	num_element=hashtb_n(nlsr->lsdb->name_lsdb);
	hashtb_end(e);

	return num_element; 
}

long int
get_adj_lsdb_num_element(void)
{
	long int num_element;


	struct hashtb_enumerator ee;
    	struct hashtb_enumerator *e = &ee;
    	
    	hashtb_start(nlsr->lsdb->adj_lsdb, e);
	num_element=hashtb_n(nlsr->lsdb->adj_lsdb);
	hashtb_end(e);

	return num_element; 
}


int 
check_is_new_name_lsa(char *orig_router,char *lst,char *lsid,char *orig_time)
{
	int ret=0;
	struct ccn_charbuf *key=ccn_charbuf_create();
	ccn_charbuf_append_string(key,orig_router);
	ccn_charbuf_append_string(key,"/");
	ccn_charbuf_append_string(key,lst);
	ccn_charbuf_append_string(key,"/");
	ccn_charbuf_append_string(key,lsid);

	int res;
	struct nlsa *name_lsa;

	struct hashtb_enumerator ee;
    	struct hashtb_enumerator *e = &ee;

	hashtb_start(nlsr->lsdb->name_lsdb, e);
	res = hashtb_seek(e, ccn_charbuf_as_string(key), key->length, 0);

	if( res == HT_NEW_ENTRY )
	{
		hashtb_delete(e);
		ret=1;

	}
	else if(res == HT_OLD_ENTRY)
	{
		name_lsa=e->data;
		if( strcmp ( orig_time , name_lsa->header->orig_time ) > 0 )
		{
			ret=1;
		}
	}

	hashtb_end(e);

	ccn_charbuf_destroy(&key);
	
	return ret;
}

int 
check_is_new_adj_lsa(char *orig_router,char *lst,char *orig_time)
{
	int ret=0;
	struct ccn_charbuf *key=ccn_charbuf_create();
	ccn_charbuf_append_string(key,orig_router);
	ccn_charbuf_append_string(key,"/");
	ccn_charbuf_append_string(key,lst);

	int res;
	struct alsa *adj_lsa;

	struct hashtb_enumerator ee;
    	struct hashtb_enumerator *e = &ee;

	hashtb_start(nlsr->lsdb->adj_lsdb, e);
	res = hashtb_seek(e, ccn_charbuf_as_string(key), key->length, 0);

	if( res == HT_NEW_ENTRY )
	{
		hashtb_delete(e);
		ret=1;

	}
	else if(res == HT_OLD_ENTRY)
	{
		adj_lsa=e->data;
		if( strcmp ( orig_time , adj_lsa->header->orig_time ) > 0 )
		{
			ret=1;
		}
	}

	hashtb_end(e);
	
	ccn_charbuf_destroy(&key);

	return ret;
}

int 
check_is_new_cor_lsa(char *orig_router,char *lst,char *orig_time)
{
	int ret=0;
	struct ccn_charbuf *key=ccn_charbuf_create();
	ccn_charbuf_append_string(key,orig_router);
	ccn_charbuf_append_string(key,"/");
	ccn_charbuf_append_string(key,lst);

	int res;
	struct clsa *cor_lsa;

	struct hashtb_enumerator ee;
    	struct hashtb_enumerator *e = &ee;

	hashtb_start(nlsr->lsdb->cor_lsdb, e);
	res = hashtb_seek(e, ccn_charbuf_as_string(key), key->length, 0);

	if( res == HT_NEW_ENTRY )
	{
		hashtb_delete(e);
		ret=1;

	}
	else if(res == HT_OLD_ENTRY)
	{
		cor_lsa=e->data;
		if( strcmp ( orig_time , cor_lsa->header->orig_time ) > 0 )
		{
			ret=1;
		}
	}

	hashtb_end(e);
	
	ccn_charbuf_destroy(&key);

	return ret;
}

void 
get_name_lsa_data(struct ccn_charbuf *lsa_data, struct name_prefix *lsaId)
{
	if ( nlsr->debugging )
		printf("get_name_lsa_data called  \n");	
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_name_lsa_data called  \n");

	struct nlsa *name_lsa;//=(struct nlsa*)malloc(sizeof(struct nlsa ));

	struct hashtb_enumerator ee;
    	struct hashtb_enumerator *e = &ee; 	
    	int res;

   	hashtb_start(nlsr->lsdb->name_lsdb, e);
    	res = hashtb_seek(e, lsaId->name, lsaId->length-1, 0);

	if( res == HT_OLD_ENTRY )
	{
		name_lsa=e->data;
		
		if ( nlsr->debugging )
			printf("NAME LSA found  \n");	
		if ( nlsr->detailed_logging )
			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Name LSA found  \n");

		ccn_charbuf_append_string(lsa_data,name_lsa->header->orig_router->name);
		ccn_charbuf_append_string(lsa_data,"|");

		char *temp_length=(char *)malloc(20);
		memset(temp_length,0,20);
		sprintf(temp_length,"%d",name_lsa->header->orig_router->length);
		ccn_charbuf_append_string(lsa_data,temp_length);
		free(temp_length);
		ccn_charbuf_append_string(lsa_data,"|");

		char *temp_ltype=(char *)malloc(20);
		memset(temp_ltype,0,20);
		sprintf(temp_ltype,"%d",name_lsa->header->ls_type);
		ccn_charbuf_append_string(lsa_data,temp_ltype);
		free(temp_ltype);
		ccn_charbuf_append_string(lsa_data,"|");

		char *temp_lsid=(char *)malloc(20);
		memset(temp_lsid,0,20);
		sprintf(temp_lsid,"%ld",name_lsa->header->ls_id);
		ccn_charbuf_append_string(lsa_data,temp_lsid);
		free(temp_lsid);
		ccn_charbuf_append_string(lsa_data,"|");

		ccn_charbuf_append_string(lsa_data,name_lsa->header->orig_time);
		ccn_charbuf_append_string(lsa_data,"|");

		char *temp_valid=(char *)malloc(20);
		memset(temp_valid,0,20);
		sprintf(temp_valid,"%d",name_lsa->header->isValid);
		ccn_charbuf_append_string(lsa_data,temp_valid);
		free(temp_valid);
		ccn_charbuf_append_string(lsa_data,"|");

		ccn_charbuf_append_string(lsa_data,name_lsa->name_prefix->name);
		ccn_charbuf_append_string(lsa_data,"|");

		char *temp_npl=(char *)malloc(20);
		memset(temp_npl,0,20);
		sprintf(temp_npl,"%d",name_lsa->name_prefix->length);
		ccn_charbuf_append_string(lsa_data,temp_npl);
		free(temp_npl);
		ccn_charbuf_append_string(lsa_data,"|");

	}
	else if(res == HT_NEW_ENTRY)
	{
		hashtb_delete(e);
	}

	hashtb_end(e);
}

void 
get_adj_lsa_data(struct ccn_charbuf *lsa_data,struct name_prefix *lsaId)
{
	if ( nlsr->debugging )
		printf("get_adj_lsa_data called  \n");	
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_adj_lsa_data called  \n");

	struct alsa *adj_lsa=(struct alsa*)malloc(sizeof(struct alsa ));

	struct hashtb_enumerator ee;
    	struct hashtb_enumerator *e = &ee; 	
    	int res;

   	hashtb_start(nlsr->lsdb->adj_lsdb, e);
    	res = hashtb_seek(e, lsaId->name, lsaId->length-1, 0);

	if( res == HT_OLD_ENTRY )
	{
		adj_lsa=e->data;

		if ( nlsr->debugging )
			printf("Adj LSA found  \n");	
		if ( nlsr->detailed_logging )
			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Adj LSA found  \n");

		ccn_charbuf_append_string(lsa_data,adj_lsa->header->orig_router->name);
		ccn_charbuf_append_string(lsa_data,"|");

		char *temp_length=(char *)malloc(20);
		memset(temp_length,0,20);
		sprintf(temp_length,"%d",adj_lsa->header->orig_router->length);
		ccn_charbuf_append_string(lsa_data,temp_length);
		ccn_charbuf_append_string(lsa_data,"|");
		free(temp_length);

		char *temp_ltype=(char *)malloc(20);
		memset(temp_ltype,0,20);
		sprintf(temp_ltype,"%d",adj_lsa->header->ls_type);
		ccn_charbuf_append_string(lsa_data,temp_ltype);
		ccn_charbuf_append_string(lsa_data,"|");
		free(temp_ltype);

		ccn_charbuf_append_string(lsa_data,adj_lsa->header->orig_time);
		ccn_charbuf_append_string(lsa_data,"|");

		char *temp_nl=(char *)malloc(20);
		memset(temp_nl,0,20);
		sprintf(temp_nl,"%d",adj_lsa->no_link);
		ccn_charbuf_append_string(lsa_data,temp_nl);
		ccn_charbuf_append_string(lsa_data,"|");
		free(temp_nl);

		ccn_charbuf_append_string(lsa_data,adj_lsa->body);


	}
	else if(res == HT_NEW_ENTRY)
	{
		hashtb_delete(e);
	}

	hashtb_end(e);
}

void
make_name_lsa_invalid(struct name_prefix *np,int ls_type, long int ls_id)
{

	if ( nlsr->debugging )
		printf("make_name_lsa_invalid called  \n");	
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"make_name_lsa_invalid called  \n");


	char lst[2];
	memset(lst,0,2);
	sprintf(lst,"%d",ls_type);	

	char lsid[10];
	memset(lsid,0,10);
	sprintf(lsid,"%ld",ls_id);
	
	
	char *key=(char *)malloc(strlen(np->name)+1+strlen(lst)+1+strlen(lsid)+1);
	memset(key,0,strlen(np->name)+1+strlen(lst)+1+strlen(lsid)+1);


	make_name_lsa_key(key, np->name,ls_type,ls_id);	
	
	if ( nlsr->debugging )
		printf("Key:%s Length:%d\n",key,(int)strlen(key));

	struct nlsa *nlsa;

	struct hashtb_enumerator ee;
    	struct hashtb_enumerator *e = &ee;
	 	
    	int res;

   	hashtb_start(nlsr->lsdb->name_lsdb, e);
    	res = hashtb_seek(e, key,strlen(key) , 0);

	if( res == HT_OLD_ENTRY )
	{
		nlsa=e->data;
	
		nlsa->header->isValid=0;

		writeLogg(__FILE__,__FUNCTION__,__LINE__," Name-LSA\n");
		writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting name lsa\n");
		write_log_for_name_lsa(nlsa);
		writeLogg(__FILE__,__FUNCTION__,__LINE__," name_lsa_end\n");

		hashtb_delete(e);
	}
	else if( res == HT_NEW_ENTRY )
	{
		hashtb_delete(e);
	}
	hashtb_end(e);
	
	if ( nlsr->debugging )
		printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);

	set_new_lsdb_version();	

	if ( nlsr->debugging )
		printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);

}


int
delete_name_lsa(char *orig_router, char *name_prefix)
{
	
	if ( nlsr->debugging )
		printf("delete_name_lsa called  \n");	
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"delete_name_lsa called  \n");

		delete_npt_entry_by_router_and_name_prefix(orig_router, name_prefix);
	
	
	if ( nlsr->debugging )
		printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);

	set_new_lsdb_version();	

	if ( nlsr->debugging )
		printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
	

	return 0;
}


int delete_adj_lsa()
{
	
	if ( nlsr->debugging )
		printf("delete_adj_lsa called  \n");	
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"delete_adj_lsa called  \n");

	if ( nlsr->debugging )
		printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);

	set_new_lsdb_version();	

	if ( nlsr->debugging )
		printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);


	if ( !nlsr->is_route_calculation_scheduled)
	{
		nlsr->event_calculate_route = ccn_schedule_event(nlsr->sched, 1000000, &route_calculate, NULL, 0);
		nlsr->is_route_calculation_scheduled=1;
	}

	return 0;
}

void
refresh_name_lsdb(void)
{
	if ( nlsr->debugging )
		printf("refresh_name_lsdb called  \n");	
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"refresh_name_lsdb called  \n");

	char *time_stamp=get_current_timestamp_micro_v2();
	
	long int lsa_life_time;
		
	int i, name_lsdb_element;
	struct nlsa *name_lsa;

	struct hashtb_enumerator ee;
    	struct hashtb_enumerator *e = &ee;
    	
    	hashtb_start(nlsr->lsdb->name_lsdb, e);
	name_lsdb_element=hashtb_n(nlsr->lsdb->name_lsdb);

	for(i=0;i<name_lsdb_element;i++)
	{
		name_lsa=e->data;

		lsa_life_time=get_time_diff(time_stamp,name_lsa->header->orig_time);
		if ( nlsr->debugging )
			printf("LSA Life Time: %ld \n",lsa_life_time);	
		if ( nlsr->detailed_logging )
			writeLogg(__FILE__,__FUNCTION__,__LINE__,"LSA Life Time: %ld \n",lsa_life_time);
		
		if ( strcmp(name_lsa->header->orig_router->name,nlsr->router_name) == 0)
		{
			if ( lsa_life_time > nlsr->lsa_refresh_time )
			{
				if ( name_lsa->header->isValid == NAME_LSA_VALID )					
				{
					if ( nlsr->debugging )
						printf("Own Name LSA need to be refrshed\n");
					if ( nlsr->detailed_logging )
						writeLogg(__FILE__,__FUNCTION__,__LINE__,"Own Name LSA need to be refrshed\n");

					writeLogg(__FILE__,__FUNCTION__,__LINE__," Name-LSA\n");
					writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting name lsa\n");
					write_log_for_name_lsa(name_lsa);
					writeLogg(__FILE__,__FUNCTION__,__LINE__," name_lsa_end\n");
					
					char *current_time_stamp=get_current_timestamp_micro_v2();

					free(name_lsa->header->orig_time);
					name_lsa->header->orig_time=(char *)calloc(strlen(current_time_stamp)+1,sizeof(char));
					memcpy(name_lsa->header->orig_time,current_time_stamp,strlen(current_time_stamp)+1);

					writeLogg(__FILE__,__FUNCTION__,__LINE__," Name-LSA\n");
					writeLogg(__FILE__,__FUNCTION__,__LINE__," Adding name lsa\n");
					write_log_for_name_lsa(name_lsa);
					writeLogg(__FILE__,__FUNCTION__,__LINE__," name_lsa_end\n");
	
					free(current_time_stamp);
					
					hashtb_next(e);
				}
				else 
				{	
					delete_name_lsa(name_lsa->header->orig_router->name, name_lsa->name_prefix->name);
					writeLogg(__FILE__,__FUNCTION__,__LINE__," Name-LSA\n");
					writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting name lsa\n");
					write_log_for_name_lsa(name_lsa);
					writeLogg(__FILE__,__FUNCTION__,__LINE__," name_lsa_end\n");

					destroy_name_lsa_component(name_lsa);

					hashtb_delete(e);
					i++;
				}

				if ( nlsr->debugging )
					printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
				if ( nlsr->detailed_logging )
					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);

				set_new_lsdb_version();	

				if ( nlsr->debugging )
					printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
				if ( nlsr->detailed_logging )
					writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);

							

				print_name_lsdb();
			}
			else 
			{
				hashtb_next(e);
			}	
		}
		else 
		{
			if ( lsa_life_time > nlsr->router_dead_interval )
			{
				if ( nlsr->debugging )
				 	printf("Others Name LSA need to be deleted\n");
				if ( nlsr->detailed_logging )
					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Others Name LSA need to be deleted\n");

				delete_name_lsa(name_lsa->header->orig_router->name, name_lsa->name_prefix->name);
				writeLogg(__FILE__,__FUNCTION__,__LINE__," Name-LSA\n");
				writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting name lsa\n");
				write_log_for_name_lsa(name_lsa);
				writeLogg(__FILE__,__FUNCTION__,__LINE__," name_lsa_end\n");

				destroy_name_lsa_component(name_lsa);
				hashtb_delete(e);
				i++;
			}
			else 
			{
				hashtb_next(e);
			}
		}
	}

	hashtb_end(e);
	
	free(time_stamp);

	
}

void
refresh_adj_lsdb(void)
{

	if ( nlsr->debugging )
		printf("refresh_adj_lsdb called  \n");	
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"refresh_adj_lsdb called  \n");
	
	char *time_stamp=get_current_timestamp_micro_v2();

	long int lsa_life_time;
		
	int i, adj_lsdb_element;
	struct alsa *adj_lsa;

	struct hashtb_enumerator ee;
    	struct hashtb_enumerator *e = &ee;
    	
    	hashtb_start(nlsr->lsdb->adj_lsdb, e);
	adj_lsdb_element=hashtb_n(nlsr->lsdb->adj_lsdb);

	for(i=0;i<adj_lsdb_element;i++)
	{
		adj_lsa=e->data;

		lsa_life_time=get_time_diff(time_stamp,adj_lsa->header->orig_time);	

		if ( nlsr->debugging )
			printf("LSA Life Time: %ld \n",lsa_life_time);	
		if ( nlsr->detailed_logging )
			writeLogg(__FILE__,__FUNCTION__,__LINE__,"LSA Life Time: %ld \n",lsa_life_time);		

		if ( strcmp(adj_lsa->header->orig_router->name,nlsr->router_name) == 0)
		{
			if ( lsa_life_time > nlsr->lsa_refresh_time )
			{
				if ( nlsr->debugging )
					printf("Own Adj LSA need to be refrshed\n");
				if ( nlsr->detailed_logging )
					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Own Adj LSA need to be refrshed\n");

				writeLogg(__FILE__,__FUNCTION__,__LINE__," Adj-LSA\n");
				writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting adj lsa\n");
				write_log_for_adj_lsa(adj_lsa);
				writeLogg(__FILE__,__FUNCTION__,__LINE__," adj_lsa_end\n");

				char *current_time_stamp=get_current_timestamp_micro_v2();

				free(adj_lsa->header->orig_time);
				adj_lsa->header->orig_time=(char *)calloc(strlen(current_time_stamp)+1,sizeof(char));
				memcpy(adj_lsa->header->orig_time,current_time_stamp,strlen(current_time_stamp)+1);
	
				free(current_time_stamp);

				writeLogg(__FILE__,__FUNCTION__,__LINE__," Adj-LSA\n");
				writeLogg(__FILE__,__FUNCTION__,__LINE__," Adding adj lsa\n");
				write_log_for_adj_lsa(adj_lsa);
				writeLogg(__FILE__,__FUNCTION__,__LINE__," adj_lsa_end\n");

				if ( nlsr->debugging )
					printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
				if ( nlsr->detailed_logging )
					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);

				set_new_lsdb_version();	

				if ( nlsr->debugging )
					printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
				if ( nlsr->detailed_logging )
					writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);

				print_adj_lsdb();
				
				
			}	
			
			hashtb_next(e);
		}
		else 
		{
			if ( lsa_life_time > nlsr->router_dead_interval )
			{

				if ( nlsr->debugging )
				 	printf("Others Adj LSA need to be deleted\n");
				if ( nlsr->detailed_logging )
					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Others Adj LSA need to be deleted\n");
				writeLogg(__FILE__,__FUNCTION__,__LINE__," Adj-LSA\n");
				writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting adj lsa\n");
				write_log_for_adj_lsa(adj_lsa);
				writeLogg(__FILE__,__FUNCTION__,__LINE__," adj_lsa_end\n");
				delete_adj_lsa();

				destroy_adj_lsa_component(adj_lsa);
				hashtb_delete(e);
				i++;
				
			}
			else
			{
				hashtb_next(e);
			}
		}
	
	}

	hashtb_end(e);
	
	free(time_stamp);
}


void
refresh_cor_lsdb(void)
{

	if ( nlsr->debugging )
		printf("refresh_cor_lsdb called  \n");	
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"refresh_cor_lsdb called  \n");

	char *time_stamp=get_current_timestamp_micro_v2();

	long int lsa_life_time;
		
	int i, cor_lsdb_element;
	struct clsa *cor_lsa;

	struct hashtb_enumerator ee;
    	struct hashtb_enumerator *e = &ee;
    	
    	hashtb_start(nlsr->lsdb->cor_lsdb, e);
	cor_lsdb_element=hashtb_n(nlsr->lsdb->cor_lsdb);

	for(i=0;i<cor_lsdb_element;i++)
	{
		cor_lsa=e->data;

		lsa_life_time=get_time_diff(time_stamp,cor_lsa->header->orig_time);	

		if ( nlsr->debugging )
			printf("LSA Life Time: %ld \n",lsa_life_time);	
		if ( nlsr->detailed_logging )
			writeLogg(__FILE__,__FUNCTION__,__LINE__,"LSA Life Time: %ld \n",lsa_life_time);		

		if ( strcmp(cor_lsa->header->orig_router->name,nlsr->router_name) == 0)
		{
			if ( lsa_life_time > nlsr->lsa_refresh_time )
			{
				if ( nlsr->debugging )
					printf("Own Cor LSA need to be refrshed\n");
				if ( nlsr->detailed_logging )
					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Own Cor LSA need to be refrshed\n");

				char *current_time_stamp=get_current_timestamp_micro_v2();

				free(cor_lsa->header->orig_time);
				cor_lsa->header->orig_time=(char *)malloc(strlen(current_time_stamp)+1); //free 
				memset(cor_lsa->header->orig_time,0,strlen(current_time_stamp)+1);
				memcpy(cor_lsa->header->orig_time,current_time_stamp,strlen(current_time_stamp)+1);
	
				free(current_time_stamp);

				if ( nlsr->debugging )
					printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
				if ( nlsr->detailed_logging )
					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);

				set_new_lsdb_version();	

				if ( nlsr->debugging )
					printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
				if ( nlsr->detailed_logging )
					writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);

				print_adj_lsdb();
			}

			hashtb_next(e);		
		}
		else 
		{
			if ( lsa_life_time > nlsr->router_dead_interval )
			{

				if ( nlsr->debugging )
				 	printf("Others Adj LSA need to be deleted\n");
				if ( nlsr->detailed_logging )
					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Others Adj LSA need to be deleted\n");
								
				destroy_cor_lsa_component(cor_lsa);
				hashtb_delete(e);
				i++;
			}
			else 
			{
				hashtb_next(e);	
			}
		}

		
	
	}

	hashtb_end(e);
	
	free(time_stamp);
}

int
refresh_lsdb(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
{
	if(flags == CCN_SCHEDULE_CANCEL)
	{
 	 	return -1;
	}

	nlsr_lock();

	if ( nlsr->debugging )
		printf("refresh_lsdb called\n");
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"refresh_lsdb called\n");
	
	refresh_name_lsdb();
	refresh_adj_lsdb();

	nlsr->event = ccn_schedule_event(nlsr->sched, 60000000, &refresh_lsdb, NULL, 0);
	
	nlsr_unlock();
	return 0;
}

void
write_adj_lsa_to_repo(char *repo_content_prefix, struct name_prefix *lsa_id)
{
	if ( nlsr->debugging )
		printf("write_adj_lsa_to_repo called\n");
	if ( nlsr->debugging )
		printf("Content Prefix: %s\n",repo_content_prefix);
	
	struct ccn_charbuf *lsa_data=ccn_charbuf_create();		
	get_adj_lsa_data(lsa_data,lsa_id);
	if ( nlsr->debugging )
		printf("Adj LSA Data: %s \n",ccn_charbuf_as_string(lsa_data));

	char *data=calloc(strlen(ccn_charbuf_as_string(lsa_data))+1,sizeof(char));
	data=ccn_charbuf_as_string(lsa_data);
	data[strlen(data)]='\0';

	write_data_to_repo(data, repo_content_prefix);


	ccn_charbuf_destroy(&lsa_data);
}

void
write_name_lsa_to_repo(char *repo_content_prefix, struct name_prefix *lsa_id)
{
	if ( nlsr->debugging )
		printf("write_name_lsa_to_repo called\n");
	if ( nlsr->debugging )
		printf("Content Prefix: %s\n",repo_content_prefix);
	
	struct ccn_charbuf *lsa_data=ccn_charbuf_create();		
	get_name_lsa_data(lsa_data,lsa_id);
	
	if ( nlsr->debugging )
		printf("Name LSA Data: %s \n",ccn_charbuf_as_string(lsa_data));	

	char *data=calloc(strlen(ccn_charbuf_as_string(lsa_data))+1,sizeof(char));
	data=ccn_charbuf_as_string(lsa_data);
	data[strlen(data)]='\0';

	write_data_to_repo(data, repo_content_prefix);

	ccn_charbuf_destroy(&lsa_data);
}


void
write_name_lsdb_to_repo(char *slice_prefix)
{
	int i, name_lsdb_element;

	struct nlsa *name_lsa;
	struct hashtb_enumerator ee;
    	struct hashtb_enumerator *e = &ee;
    	
    	hashtb_start(nlsr->lsdb->name_lsdb, e);
	name_lsdb_element=hashtb_n(nlsr->lsdb->name_lsdb);

	for(i=0;i<name_lsdb_element;i++)
	{
		name_lsa=e->data;

		char lst[2];
		memset(lst,0,2);
		sprintf(lst,"%d",name_lsa->header->ls_type);	

		char lsid[10];
		memset(lsid,0,10);
		sprintf(lsid,"%ld",name_lsa->header->ls_id);
	
	
		char *key=(char *)malloc(strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1);
		memset(key,0,strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1);


		make_name_lsa_key(key, name_lsa->header->orig_router->name,name_lsa->header->ls_type,name_lsa->header->ls_id);
		
		if ( nlsr->debugging )
			printf("Name LSA Key: %s \n",key);


		char *repo_key=(char *)calloc(strlen(slice_prefix)+1+strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1+strlen(name_lsa->header->orig_time)+16,sizeof(char));	
		make_name_lsa_prefix_for_repo(repo_key, name_lsa->header->orig_router->name,name_lsa->header->ls_type,name_lsa->header->ls_id,name_lsa->header->orig_time,slice_prefix);
		
		if ( nlsr->debugging )
			printf("Name LSA Repo Key: %s \n",repo_key);

		struct name_prefix *lsaid=(struct name_prefix *)calloc(1,sizeof(struct name_prefix));
		lsaid->name=(char *)calloc(strlen(key)+1,sizeof(char));
		memcpy(lsaid->name,key,strlen(key)+1);
		lsaid->length=strlen(key)+1;

		
		write_name_lsa_to_repo(repo_key, lsaid);

		free(key);
		free(repo_key);
		free(lsaid->name);
		free(lsaid);

		hashtb_next(e);		
	}

	hashtb_end(e);
	

}

void
print_cor_lsa(struct clsa *cor_lsa)
{
	if ( nlsr->debugging )
	{
		printf("-----------Cor LSA Content---------------\n");
		printf("	Origination Router       :	%s\n",cor_lsa->header->orig_router->name);
		printf("	Origination Router Length:	%d\n",cor_lsa->header->orig_router->length);
		printf("	LS Type			 :	%d\n",cor_lsa->header->ls_type);
		printf("	Origination Time	 :	%s\n",cor_lsa->header->orig_time);
		printf("	LSA Data			\n");
		printf("		Cor R:	 	:	%f\n",cor_lsa->cor_r);
		printf("		Cor Theta	:	%f\n",cor_lsa->cor_theta);

		printf("\n");	
	}
}

void 
print_cor_lsdb()
{
	
	if ( nlsr->debugging )
		printf("print_cor_lsdb called \n");	
	
	struct hashtb_enumerator ee;
    	struct hashtb_enumerator *e = &ee;
    	
	int i=1;

	for (hashtb_start(nlsr->lsdb->cor_lsdb, e); e->key != NULL; hashtb_next(e)) 
	{
		if ( nlsr->debugging )
			printf("-----------Cor LSA (%d)---------------\n",i);	
		struct clsa *cor_lsa=e->data;
		print_cor_lsa(cor_lsa);
		i++;
  	}
	hashtb_end(e);

	if ( nlsr->debugging )
		printf("\n");
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");
}

void
install_cor_lsa(struct clsa *cor_lsa)
{
	if ( nlsr->debugging )
		printf("install_cor_lsa called \n");
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"install_cor_lsa called  \n");
	

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


	char *key=(char *)malloc(cor_lsa->header->orig_router->length+4);
	memset(key,0,cor_lsa->header->orig_router->length+4);
	make_cor_lsa_key(key,cor_lsa);

	if ( nlsr->debugging )
		printf("Cor LSA key: %s \n",key);

	struct hashtb_enumerator ee;
    	struct hashtb_enumerator *e = &ee; 	
    	int res;

   	hashtb_start(nlsr->lsdb->cor_lsdb, e);
    	res = hashtb_seek(e, key, strlen(key), 0);

	if ( res == HT_NEW_ENTRY )
	{
		if ( nlsr->debugging )
			printf("New Cor LSA... \n");
		
		struct clsa *new_cor_lsa;//=(struct clsa *)malloc(sizeof( struct clsa ));
		new_cor_lsa=e->data;
		new_cor_lsa->header=(struct alsa_header *)malloc(sizeof(struct alsa_header ));

		new_cor_lsa->header->orig_router=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
		new_cor_lsa->header->orig_router->name=(char *)malloc(strlen(cor_lsa->header->orig_router->name)+1);
		memset(new_cor_lsa->header->orig_router->name,0,strlen(cor_lsa->header->orig_router->name)+1);
		memcpy(new_cor_lsa->header->orig_router->name,cor_lsa->header->orig_router->name,strlen(cor_lsa->header->orig_router->name)+1);
		new_cor_lsa->header->orig_router->length=cor_lsa->header->orig_router->length;

		new_cor_lsa->header->orig_time=(char *)malloc(strlen(cor_lsa->header->orig_time)+1); //free 
		memset(new_cor_lsa->header->orig_time,0,strlen(cor_lsa->header->orig_time)+1);
		memcpy(new_cor_lsa->header->orig_time,cor_lsa->header->orig_time,strlen(cor_lsa->header->orig_time)+1);

		new_cor_lsa->header->ls_type=cor_lsa->header->ls_type;

		new_cor_lsa->cor_r=cor_lsa->cor_r;
		new_cor_lsa->cor_theta=cor_lsa->cor_theta;
	}
	else if ( res == HT_OLD_ENTRY )
	{	
		if ( nlsr->debugging )
			printf("Cor LSA exists (Old)... \n");
	}
	hashtb_end(e);

	free(key);

}

void 
build_cor_lsa(struct clsa *cor_lsa, double cor_r, double cor_theta)
{
	cor_lsa->header=(struct alsa_header *)malloc(sizeof(struct alsa_header ));
	cor_lsa->header->ls_type=LS_TYPE_COR;

	char *time_stamp=get_current_timestamp_micro_v2();
	cor_lsa->header->orig_time=(char *)malloc(strlen(time_stamp)+1); //free 
	memset(cor_lsa->header->orig_time,0,strlen(time_stamp)+1);
	memcpy(cor_lsa->header->orig_time,time_stamp,strlen(time_stamp)+1);
	free(time_stamp);

	cor_lsa->header->orig_router=(struct name_prefix *)calloc(1,sizeof(struct name_prefix ));
	cor_lsa->header->orig_router->name=(char *)calloc(strlen(nlsr->router_name)+1,sizeof(char));
	memset(cor_lsa->header->orig_router->name,0,strlen(nlsr->router_name)+1);
	memcpy(cor_lsa->header->orig_router->name,nlsr->router_name,strlen(nlsr->router_name)+1);
	cor_lsa->header->orig_router->length=strlen(nlsr->router_name)+1;

	cor_lsa->cor_r=cor_r;	
	cor_lsa->cor_theta=cor_theta;

}

void 
build_others_cor_lsa(struct clsa *cor_lsa,char *orig_router, int ls_type,char *orig_time, double cor_r, double cor_theta)
{
	cor_lsa->header=(struct alsa_header *)malloc(sizeof(struct alsa_header ));
	cor_lsa->header->ls_type=ls_type;

	cor_lsa->header->orig_time=(char *)malloc(strlen(orig_time)+1); 
	memset(cor_lsa->header->orig_time,0,strlen(orig_time)+1);
	memcpy(cor_lsa->header->orig_time,orig_time,strlen(orig_time));

	cor_lsa->header->orig_router=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
	cor_lsa->header->orig_router->name=(char *)malloc(strlen(orig_router)+1);
	memset(cor_lsa->header->orig_router->name,0,strlen(orig_router)+1);
	memcpy(cor_lsa->header->orig_router->name,orig_router,strlen(orig_router));
	cor_lsa->header->orig_router->length=strlen(orig_router)+1;

	cor_lsa->cor_r=cor_r;	
	cor_lsa->cor_theta=cor_theta;

}

void
build_and_install_others_cor_lsa(char *orig_router,int ls_type,char *orig_time, double cor_r, double cor_theta)
{
	struct clsa *cor_lsa=(struct clsa *)malloc(sizeof( struct clsa ));
	build_others_cor_lsa(cor_lsa,orig_router,ls_type, orig_time, cor_r, cor_theta);
	install_cor_lsa(cor_lsa);

	print_cor_lsdb();
	
	destroy_cor_lsa(cor_lsa);
}


void 
build_and_install_cor_lsa()
{

	

	struct clsa *cor_lsa=(struct clsa *)malloc(sizeof( struct clsa ));
	
	build_cor_lsa(cor_lsa,nlsr->cor_r,nlsr->cor_theta);
	install_cor_lsa(cor_lsa);

	write_cor_lsa_to_repo(cor_lsa);
	destroy_cor_lsa(cor_lsa);

	print_cor_lsdb();	
	
}

void 
get_cor_lsa_data(struct ccn_charbuf *lsa_data,char *cor_lsa_key)
{
	if ( nlsr->debugging )
		printf("get_cor_lsa_data called  \n");	
	if ( nlsr->detailed_logging )
		writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_adj_lsa_data called  \n");

	struct clsa *cor_lsa=(struct clsa*)malloc(sizeof(struct clsa ));

	struct hashtb_enumerator ee;
    	struct hashtb_enumerator *e = &ee; 	
    	int res;

   	hashtb_start(nlsr->lsdb->cor_lsdb, e);
    	res = hashtb_seek(e, cor_lsa_key, strlen(cor_lsa_key), 0);

	if( res == HT_OLD_ENTRY )
	{
		cor_lsa=e->data;

		if ( nlsr->debugging )
			printf("Cor LSA found  \n");	
		if ( nlsr->detailed_logging )
			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Cor LSA found  \n");

		ccn_charbuf_append_string(lsa_data,cor_lsa->header->orig_router->name);
		ccn_charbuf_append_string(lsa_data,"|");

		char *temp_length=(char *)malloc(20);
		memset(temp_length,0,20);
		sprintf(temp_length,"%d",cor_lsa->header->orig_router->length);
		ccn_charbuf_append_string(lsa_data,temp_length);
		ccn_charbuf_append_string(lsa_data,"|");
		free(temp_length);

		char *temp_ltype=(char *)malloc(20);
		memset(temp_ltype,0,20);
		sprintf(temp_ltype,"%d",cor_lsa->header->ls_type);
		ccn_charbuf_append_string(lsa_data,temp_ltype);
		ccn_charbuf_append_string(lsa_data,"|");
		free(temp_ltype);

		ccn_charbuf_append_string(lsa_data,cor_lsa->header->orig_time);
		ccn_charbuf_append_string(lsa_data,"|");

		char *cor_r=(char *)malloc(20);
		memset(cor_r,0,20);
		sprintf(cor_r,"%f",cor_lsa->cor_r);
		ccn_charbuf_append_string(lsa_data,cor_r);
		ccn_charbuf_append_string(lsa_data,"|");
		free(cor_r);

		char *cor_theta=(char *)malloc(20);
		memset(cor_theta,0,20);
		sprintf(cor_theta,"%f",cor_lsa->cor_theta);
		ccn_charbuf_append_string(lsa_data,cor_theta);
		ccn_charbuf_append_string(lsa_data,"|");
		free(cor_theta);

	}
	else if(res == HT_NEW_ENTRY)
	{
		hashtb_delete(e);
	}

	hashtb_end(e);
}

void
write_cor_lsa_to_repo(struct clsa *cor_lsa)
{
	

	if ( nlsr->debugging )
		printf("write_cor_lsa_to_repo called\n");
	
	
	char *key=(char *)calloc(cor_lsa->header->orig_router->length+4,sizeof(char));
	make_cor_lsa_key(key,cor_lsa);
	
	struct ccn_charbuf *lsa_data=ccn_charbuf_create();
	get_cor_lsa_data(lsa_data,key);

	if ( nlsr->debugging )
		printf("Cor LSA Data: %s \n",ccn_charbuf_as_string(lsa_data));	

	char *lst=(char *)malloc(20);
	memset(lst,0,20);
	sprintf(lst,"%d",cor_lsa->header->ls_type);
	char *repo_key=(char *)calloc(strlen(nlsr->slice_prefix)+strlen(cor_lsa->header->orig_time)+strlen(cor_lsa->header->orig_router->name) + strlen(lst) + 20,sizeof(char));
	make_cor_lsa_prefix_for_repo(repo_key, cor_lsa->header->orig_router->name,LS_TYPE_COR,cor_lsa->header->orig_time,nlsr->slice_prefix);
		
	if ( nlsr->debugging )
		printf("Cor LSA Repo Key: %s \n",repo_key);	

	char *data=calloc(strlen(ccn_charbuf_as_string(lsa_data))+1,sizeof(char));
	data=ccn_charbuf_as_string(lsa_data);
	data[strlen(data)]='\0';

	write_data_to_repo(data, repo_key);


	
		
	free(lst);
	free(key);
	free(repo_key);
	ccn_charbuf_destroy(&lsa_data);
}

void 
make_cor_lsa_key_by_router_name(char *key,char *router_name)
{
	memcpy(key+strlen(key),router_name,strlen(router_name));
	memcpy(key+strlen(key),"/",1);
	char ls_type[2];
	sprintf(ls_type,"%d",LS_TYPE_COR);
	memcpy(key+strlen(key),ls_type,strlen(ls_type));
	key[strlen(key)]='\0';
}


double 
get_hyperbolic_r(char *router)
{
	double ret=-1.0;
	char *cor_lsa_key=(char *)calloc(strlen(router)+4,sizeof(char));
	make_cor_lsa_key_by_router_name(cor_lsa_key,router);

	
	struct clsa *cor_lsa;
	struct hashtb_enumerator ee;
    	struct hashtb_enumerator *e = &ee; 	
    	int res;

   	hashtb_start(nlsr->lsdb->cor_lsdb, e);
    	res = hashtb_seek(e, cor_lsa_key, strlen(cor_lsa_key), 0);

	if ( res == HT_OLD_ENTRY)
	{	
		cor_lsa=e->data;
		ret=cor_lsa->cor_r;
	}
	else if(res == HT_NEW_ENTRY)
	{
		hashtb_delete(e);
	}

	hashtb_end(e);
	
	free(cor_lsa_key);
	return ret;
}

double 
get_hyperbolic_theta(char *router)
{
	double ret=-1.0;
	char *cor_lsa_key=(char *)calloc(strlen(router)+4,sizeof(char));
	make_cor_lsa_key_by_router_name(cor_lsa_key,router);

	struct clsa *cor_lsa;
	struct hashtb_enumerator ee;
    	struct hashtb_enumerator *e = &ee; 	
    	int res;

   	hashtb_start(nlsr->lsdb->cor_lsdb, e);
    	res = hashtb_seek(e, cor_lsa_key, strlen(cor_lsa_key), 0);

	if ( res == HT_OLD_ENTRY)
	{	
		cor_lsa=e->data;
		ret=cor_lsa->cor_theta;
	}
	else if(res == HT_NEW_ENTRY)
	{
		hashtb_delete(e);
	}

	hashtb_end(e);
	
	free(cor_lsa_key);
	return ret;
}


void
destroy_name_lsdb(void)
{
	int i, name_lsdb_element;
	struct nlsa *name_lsa;

	struct hashtb_enumerator ee;
    	struct hashtb_enumerator *e = &ee;
    	
    	hashtb_start(nlsr->lsdb->name_lsdb, e);
	name_lsdb_element=hashtb_n(nlsr->lsdb->name_lsdb);

	for(i=0;i<name_lsdb_element;i++)
	{
		name_lsa=e->data;
		destroy_name_lsa_component(name_lsa);	
		hashtb_next(e);		
	}

	hashtb_end(e);

	if ( nlsr->lsdb->name_lsdb )
		hashtb_destroy(&nlsr->lsdb->name_lsdb);
}

void
destroy_adj_lsdb(void)
{
	int i, adj_lsdb_element;
	struct alsa *adj_lsa;

	struct hashtb_enumerator ee;
    	struct hashtb_enumerator *e = &ee;
    	
    	hashtb_start(nlsr->lsdb->adj_lsdb, e);
	adj_lsdb_element=hashtb_n(nlsr->lsdb->adj_lsdb);

	for(i=0;i<adj_lsdb_element;i++)
	{
		adj_lsa=e->data;
		destroy_adj_lsa_component(adj_lsa);	
		hashtb_next(e);		
	}

	hashtb_end(e);
	if(nlsr->lsdb->adj_lsdb	)
		hashtb_destroy(&nlsr->lsdb->adj_lsdb);
}

void
destroy_cor_lsdb(void)
{
	int i, cor_lsdb_element;
	struct clsa *cor_lsa;

	struct hashtb_enumerator ee;
    	struct hashtb_enumerator *e = &ee;
    	
    	hashtb_start(nlsr->lsdb->cor_lsdb, e);
	cor_lsdb_element=hashtb_n(nlsr->lsdb->cor_lsdb);

	for(i=0;i<cor_lsdb_element;i++)
	{
		cor_lsa=e->data;
		destroy_cor_lsa_component(cor_lsa);	
		hashtb_next(e);		
	}

	hashtb_end(e);
	if(nlsr->lsdb->cor_lsdb	)
		hashtb_destroy(&nlsr->lsdb->cor_lsdb);
}

void
destroy_lsdb(void)
{
	destroy_name_lsdb();
	destroy_adj_lsdb();
	destroy_cor_lsdb();
	
	if ( nlsr->lsdb->lsdb_version )
		free(nlsr->lsdb->lsdb_version);
	if ( nlsr->lsdb )
		free(nlsr->lsdb);
}
