Updated Timing Diagram
diff --git a/NLSR_Timing_Diagram.odg b/NLSR_Timing_Diagram.odg
index 4f8c2b8..820b307 100644
--- a/NLSR_Timing_Diagram.odg
+++ b/NLSR_Timing_Diagram.odg
Binary files differ
diff --git a/nlsr.c b/nlsr.c
index 591a93a..32edf4e 100644
--- a/nlsr.c
+++ b/nlsr.c
@@ -541,7 +541,8 @@
nlsr_destroy( void )
{
- printf("Freeing Allocated Memory....\n");
+ printf("Freeing Allocated Memory....\n");
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Freeing Allocated Memory....\n");
/* Destroying all face created by nlsr in CCND */
destroy_all_face_by_nlsr();
@@ -584,6 +585,7 @@
free(nlsr);
printf("Finished freeing allocated memory\n");
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Finished freeing allocated memory\n");
}
@@ -721,12 +723,15 @@
if ( res < 0 )
{
fprintf(stderr,"Failed to register interest for router\n");
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Failed to register interest for router\n");
ON_ERROR_DESTROY(res);
}
ccn_charbuf_destroy(&router_prefix);
printf("Router Name : %s\n",nlsr->router_name);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Router Name : %s\n",nlsr->router_name);
printf("lsdb_version: %s\n",nlsr->lsdb->lsdb_version);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"lsdb_version: %s\n",nlsr->lsdb->lsdb_version);
print_name_prefix_from_npl();
print_adjacent_from_adl();
diff --git a/nlsr_lsdb.c b/nlsr_lsdb.c
index 982fef4..6f68102 100644
--- a/nlsr_lsdb.c
+++ b/nlsr_lsdb.c
@@ -198,16 +198,12 @@
new_name_lsa->name_prefix->length=name_lsa->name_prefix->length;
printf("New Name LSA Added....\n");
-
printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
set_new_lsdb_version();
printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
- //struct hashtb *face_list;
+
int num_next_hop=get_number_of_next_hop(new_name_lsa->header->orig_router->name);
-
- //printf("Next hop: %d \n",next_hop);
-
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);
@@ -235,7 +231,10 @@
}
-
+ 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);
@@ -260,6 +259,11 @@
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);
printf("isValid bit not set for Router %s so LSA Deleted from LSDB\n",name_lsa->header->orig_router->name);
}
@@ -285,6 +289,11 @@
}
// 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);
@@ -300,6 +309,12 @@
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");
+
printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
set_new_lsdb_version();
printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
@@ -348,6 +363,22 @@
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)
@@ -612,6 +643,11 @@
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
{
@@ -634,7 +670,12 @@
if ( adj_lsa->no_link > 0)
{
- new_adj_lsa = e->data;
+ //new_adj_lsa = e->data;
+
+ 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 *)malloc(strlen(adj_lsa->header->orig_time)+1);
@@ -647,9 +688,19 @@
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);
}
printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
@@ -673,6 +724,70 @@
}
void
+write_log_for_adj_lsa_body(const char *body, int no_link)
+{
+ int i=0;
+ char *lsa_data=(char *)malloc(strlen(body)+1);
+ 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__," Neighbor : %s \n",rtr_id);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," Neighbor 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__," Neighbor : %s \n",rtr_id);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," Neighbor Length : %s \n",length);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," Connecting Face : %s \n",face);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," Metric : %s \n",metric);
+
+ }
+ }
+
+ 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;
@@ -721,9 +836,6 @@
void
print_adj_lsa(struct alsa * adj_lsa)
{
-
- printf("print_adj_lsa called \n");
-
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);
@@ -733,22 +845,6 @@
printf(" No of Link : %d\n",adj_lsa->no_link);
print_adj_lsa_body(adj_lsa->body,adj_lsa->no_link);
-
-/*
- struct link *templ=adj_lsa->links;
- int i;
-
- for(i=0 ; i< adj_lsa->no_link ; i++)
- {
- printf(" Link %d \n",i+1);
- printf(" Neighbor : %s \n",templ->nbr->name);
- printf(" Neighbor Length : %d \n",templ->nbr->length);
- printf(" Connecting Face : %d \n",templ->face);
- printf(" Metric : %d \n",templ->metric);
-
- templ++;
- }
-*/
printf("\n");
}
@@ -1222,6 +1318,12 @@
{
nlsa=e->data;
delete_npt_entry_by_router_and_name_prefix(nlsa->header->orig_router->name, nlsa->name_prefix->name);
+
+ 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 )
@@ -1255,6 +1357,7 @@
printf("LSA Key: %s \n",(char *)ev->evdata);
+ struct alsa *alsa;
struct hashtb_enumerator ee;
struct hashtb_enumerator *e = ⅇ
int res;
@@ -1264,6 +1367,12 @@
if( res == HT_OLD_ENTRY )
{
+ alsa=e->data;
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," Adj-LSA\n");
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting adj lsa\n");
+ write_log_for_adj_lsa(alsa);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," adj_lsa_end\n");
+
hashtb_delete(e);
}
else if( res == HT_OLD_ENTRY )
diff --git a/nlsr_lsdb.h b/nlsr_lsdb.h
index 75f1886..9ba33b1 100644
--- a/nlsr_lsdb.h
+++ b/nlsr_lsdb.h
@@ -50,6 +50,7 @@
void build_name_lsa(struct nlsa *name_lsa, struct name_prefix *np);
void install_name_lsa(struct nlsa *name_lsa);
void print_name_lsa(struct nlsa *name_lsa);
+void write_log_for_name_lsa(struct nlsa *name_lsa);
void print_name_lsdb(void);
void build_and_install_others_name_lsa(char *orig_router,int ls_type,long int ls_id,char *orig_time, int isValid,char *np);
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);
@@ -61,6 +62,7 @@
void install_adj_lsa(struct alsa * adj_lsa);
void print_adj_lsa_body(const char *body, int no_link);
void print_adj_lsa(struct alsa * adj_lsa);
+void write_log_for_adj_lsa(struct alsa * adj_lsa);
void print_adj_lsdb(void);
void make_adj_lsa_key(char *key,struct alsa *adj_lsa);
void build_and_install_others_adj_lsa(char *orig_router,int ls_type,char *orig_time, int no_link,char *data);
diff --git a/utility.c b/utility.c
index 8326283..b136c67 100644
--- a/utility.c
+++ b/utility.c
@@ -204,7 +204,7 @@
{
struct timeval t;
gettimeofday(&t, NULL);
- fprintf(fp,"%ld.%06u - %s, %s, %d:",(long)t.tv_sec , (unsigned)t.tv_usec , source_file , function , line);
+ fprintf(fp,"%ld.%06u - %s, %s, %d :",(long)t.tv_sec , (unsigned)t.tv_usec , source_file , function , line);
va_list args;
va_start(args, format);
vfprintf(fp, format, args);