Configurable Detailed Logging, Debugging Added
diff --git a/nlsr.c b/nlsr.c
index 32edf4e..e1a49c2 100644
--- a/nlsr.c
+++ b/nlsr.c
@@ -113,7 +113,7 @@
process_id = fork();
if (process_id < 0)
{
- printf("fork failed!\n");
+ printf("Daemonization failed!\n");
ON_ERROR_DESTROY(process_id);
}
if (process_id > 0)
@@ -450,6 +450,56 @@
}
void
+process_command_detailed_log(char *command)
+{
+ if(command==NULL)
+ {
+ printf(" Wrong Command Format ( detailed-log on/off )\n");
+ return;
+ }
+ char *rem;
+ const char *sep=" \t\n";
+ char *on_off;
+
+ on_off=strtok_r(command,sep,&rem);
+ if(on_off==NULL)
+ {
+ printf(" Wrong Command Format ( detailed-log on/off )\n");
+ return;
+ }
+
+ if ( strcmp(on_off,"ON") == 0 || strcmp(on_off,"on") == 0)
+ {
+ nlsr->detailed_logging=1;
+ }
+}
+
+void
+process_command_debug(char *command)
+{
+ if(command==NULL)
+ {
+ printf(" Wrong Command Format ( debug on/off )\n");
+ return;
+ }
+ char *rem;
+ const char *sep=" \t\n";
+ char *on_off;
+
+ on_off=strtok_r(command,sep,&rem);
+ if(on_off==NULL)
+ {
+ printf(" Wrong Command Format ( debug on/off )\n");
+ return;
+ }
+
+ if ( strcmp(on_off,"ON") == 0 || strcmp(on_off,"on") == 0 )
+ {
+ nlsr->debugging=1;
+ }
+}
+
+void
process_conf_command(char *command)
{
const char *separators=" \t\n";
@@ -501,6 +551,14 @@
{
process_command_logdir(remainder);
}
+ else if(!strcmp(cmd_type,"detailed-log") )
+ {
+ process_command_detailed_log(remainder);
+ }
+ else if(!strcmp(cmd_type,"debug") )
+ {
+ process_command_debug(remainder);
+ }
else
{
printf("Wrong configuration Command %s \n",cmd_type);
@@ -540,8 +598,10 @@
void
nlsr_destroy( void )
{
-
- printf("Freeing Allocated Memory....\n");
+ if ( nlsr->debugging )
+ {
+ 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();
@@ -583,8 +643,10 @@
free(nlsr->lsdb);
free(nlsr->router_name);
free(nlsr);
-
- printf("Finished freeing allocated memory\n");
+ if ( nlsr->debugging )
+ {
+ printf("Finished freeing allocated memory\n");
+ }
writeLogg(__FILE__,__FUNCTION__,__LINE__,"Finished freeing allocated memory\n");
}
@@ -650,6 +712,9 @@
nlsr->is_send_lsdb_interest_scheduled=0;
nlsr->is_route_calculation_scheduled=0;
+ nlsr->detailed_logging=0;
+ nlsr->debugging=0;
+
nlsr->lsdb_synch_interval = LSDB_SYNCH_INTERVAL;
nlsr->interest_retry = INTEREST_RETRY;
nlsr->interest_resend_time = INTEREST_RESEND_TIME;
@@ -728,9 +793,11 @@
}
ccn_charbuf_destroy(&router_prefix);
- printf("Router Name : %s\n",nlsr->router_name);
+ if ( nlsr->debugging )
+ 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);
+ if ( nlsr->debugging )
+ 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();
diff --git a/nlsr.h b/nlsr.h
index a914880..f113d52 100644
--- a/nlsr.h
+++ b/nlsr.h
@@ -79,6 +79,8 @@
long int router_dead_interval;
long int multi_path_face_num;
char *logDir;
+ int detailed_logging;
+ int debugging;
int semaphor;
diff --git a/nlsr_adl.c b/nlsr_adl.c
index 913e0c0..1c30be8 100644
--- a/nlsr_adl.c
+++ b/nlsr_adl.c
@@ -75,31 +75,59 @@
void
print_adjacent(struct ndn_neighbor *nbr)
{
- printf("print_adjacent called\n");
- printf("--------Neighbor---------------------------\n");
- printf(" Neighbor: %s \n",nbr->neighbor->name);
- printf(" Length : %d \n",nbr->neighbor->length);
- printf(" Face : %d \n",nbr->face);
- printf(" Metric : %d \n",nbr->metric);
- printf(" Status : %d \n",nbr->status);
- printf(" LSDB Version: %s \n",nbr->last_lsdb_version);
- printf(" Info Version: %s \n",nbr->last_info_version);
- printf(" Info Interest Timed Out : %d \n",nbr->info_interest_timed_out);
- printf(" LSDB Interest Timed Out : %d \n",nbr->lsdb_interest_timed_out);
- printf(" LSDB Synch Interval : %ld \n",nbr->lsdb_synch_interval);
- printf(" LSDB Random Time comp : %d \n",nbr->lsdb_random_time_component);
- printf(" Las Time LSDB Requested: %ld \n",nbr->last_lsdb_requested);
- printf(" IS_lsdb_send_interest_scheduled : %d \n",nbr->is_lsdb_send_interest_scheduled);
+ if ( nlsr->debugging )
+ {
+ printf("print_adjacent called\n");
+ printf("--------Neighbor---------------------------\n");
+ printf(" Neighbor: %s \n",nbr->neighbor->name);
+ printf(" Length : %d \n",nbr->neighbor->length);
+ printf(" Face : %d \n",nbr->face);
+ printf(" Metric : %d \n",nbr->metric);
+ printf(" Status : %d \n",nbr->status);
+ printf(" LSDB Version: %s \n",nbr->last_lsdb_version);
+ printf(" Info Version: %s \n",nbr->last_info_version);
+ printf(" Info Interest Timed Out : %d \n",nbr->info_interest_timed_out);
+ printf(" LSDB Interest Timed Out : %d \n",nbr->lsdb_interest_timed_out);
+ printf(" LSDB Synch Interval : %ld \n",nbr->lsdb_synch_interval);
+ printf(" LSDB Random Time comp : %d \n",nbr->lsdb_random_time_component);
+ printf(" Las Time LSDB Requested: %ld \n",nbr->last_lsdb_requested);
+ printf(" IS_lsdb_send_interest_scheduled : %d \n",nbr->is_lsdb_send_interest_scheduled);
- printf("\n");
+ printf("\n");
+ }
+
+ if ( nlsr->detailed_logging )
+ {
+
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"print_adjacent called\n");
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"--------Neighbor---------------------------\n");
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," Neighbor: %s \n",nbr->neighbor->name);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," Length : %d \n",nbr->neighbor->length);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," Face : %d \n",nbr->face);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," Metric : %d \n",nbr->metric);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," Status : %d \n",nbr->status);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," LSDB Version: %s \n",nbr->last_lsdb_version);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," Info Version: %s \n",nbr->last_info_version);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," Info Interest Timed Out : %d \n",nbr->info_interest_timed_out);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," LSDB Interest Timed Out : %d \n",nbr->lsdb_interest_timed_out);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," LSDB Synch Interval : %ld \n",nbr->lsdb_synch_interval);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," LSDB Random Time comp : %d \n",nbr->lsdb_random_time_component);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," Las Time LSDB Requested: %ld \n",nbr->last_lsdb_requested);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," IS_lsdb_send_interest_scheduled : %d \n",nbr->is_lsdb_send_interest_scheduled);
+
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");
+ }
}
void
print_adjacent_from_adl(void)
{
-
- printf("print_adjacent_from_adl called \n");
+ if ( nlsr->debugging )
+ printf("print_adjacent_from_adl called \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"print_adjacent_from_adl called \n");
+
int i, adl_element;
struct ndn_neighbor *nbr;
@@ -123,7 +151,11 @@
int
get_adjacent_status(struct name_prefix *nbr)
{
- printf("get_adjacent_status called \n");
+
+ if ( nlsr->debugging )
+ printf("get_adjacent_status called \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_adjacent_status called \n");
int res;
int status=-1;
@@ -154,7 +186,12 @@
int
get_timed_out_number(struct name_prefix *nbr)
{
- printf("get_timed_out_number called \n");
+
+ if ( nlsr->debugging )
+ printf("get_timed_out_number called \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_timed_out_number called \n");
+
int res,ret=-1;
struct ndn_neighbor *nnbr;
@@ -183,7 +220,11 @@
int
get_lsdb_interest_timed_out_number(struct name_prefix *nbr)
{
- printf("get_timed_out_number called \n");
+
+ if ( nlsr->debugging )
+ printf("get_lsdb_interest_timed_out_number called \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_lsdb_interest_timed_out_number called \n");
int res,ret=-1;
struct ndn_neighbor *nnbr;
@@ -212,7 +253,10 @@
void
update_adjacent_timed_out_to_adl(struct name_prefix *nbr, int increment)
{
- printf("update_adjacent_timed_out_to_adl called \n");
+ if ( nlsr->debugging )
+ printf("update_adjacent_timed_out_to_adl called \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"update_adjacent_timed_out_to_adl called \n");
int res;
struct ndn_neighbor *nnbr;
@@ -239,7 +283,11 @@
void
update_adjacent_timed_out_zero_to_adl(struct name_prefix *nbr)
{
- printf("update_adjacent_timed_out_zero_to_adl called \n");
+ if ( nlsr->debugging )
+ printf("update_adjacent_timed_out_zero_to_adl called \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"update_adjacent_timed_out_zero_to_adl called \n");
+
int time_out_number=get_timed_out_number(nbr);
update_adjacent_timed_out_to_adl(nbr,-time_out_number);
@@ -249,7 +297,10 @@
void
update_lsdb_interest_timed_out_to_adl(struct name_prefix *nbr, int increment)
{
- printf("update_lsdb_interest_timed_out_to_adl called \n");
+ if ( nlsr->debugging )
+ printf("update_lsdb_interest_timed_out_to_adl called\n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"update_lsdb_interest_timed_out_to_adl called \n");
int res;
struct ndn_neighbor *nnbr;
@@ -282,7 +333,11 @@
void
update_lsdb_interest_timed_out_zero_to_adl(struct name_prefix *nbr)
{
- printf("update_adjacent_timed_out_zero_to_adl called \n");
+ if ( nlsr->debugging )
+ printf("update_adjacent_timed_out_zero_to_adl called\n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"update_adjacent_timed_out_zero_to_adl called\n");
+
int time_out_number=get_lsdb_interest_timed_out_number(nbr);
update_lsdb_interest_timed_out_to_adl(nbr,-time_out_number);
@@ -291,7 +346,10 @@
void
update_adjacent_status_to_adl(struct name_prefix *nbr, int status)
{
- printf("update_adjacent_status_to_adl called \n");
+ if ( nlsr->debugging )
+ printf("update_adjacent_status_to_adl called\n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"update_adjacent_status_to_adl called \n");
int res;
struct ndn_neighbor *nnbr;
@@ -323,7 +381,10 @@
void
update_lsdb_synch_interval_to_adl(struct name_prefix *nbr, long int interval)
{
- printf("uupdate_lsdb_synch_interval_to_adl called \n");
+ if ( nlsr->debugging )
+ printf("update_lsdb_synch_interval_to_adl called\n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"update_lsdb_synch_interval_to_adl called \n");
int res;
struct ndn_neighbor *nnbr;
@@ -467,7 +528,10 @@
long int
get_nbr_time_diff_lsdb_req(char *nbr)
{
- printf("get_nbr_time_diff_lsdb_req called \n");
+ if ( nlsr->debugging )
+ printf("get_nbr_time_diff_lsdb_req called\n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_nbr_time_diff_lsdb_req called\n");
long int time_diff=get_lsdb_synch_interval(nbr)+1;
int res;
@@ -501,7 +565,10 @@
long int
get_nbr_last_lsdb_requested(char *nbr)
{
- printf("get_timed_out_number called \n");
+ if ( nlsr->debugging )
+ printf("get_timed_out_number called\n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_timed_out_number called\n");
long int last_lsdb_requested=0;
@@ -533,7 +600,10 @@
int
get_nbr_random_time_component(char *nbr)
{
- printf("get_timed_out_number called \n");
+ if ( nlsr->debugging )
+ printf("get_nbr_random_time_component called\n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_nbr_random_time_component called\n");
int time=0;
@@ -564,7 +634,10 @@
long int
get_lsdb_synch_interval(char *nbr)
{
- printf("get_lsdb_synch_interval called \n");
+ if ( nlsr->debugging )
+ printf("get_lsdb_synch_interval called \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_lsdb_synch_interval called \n");
long int lsdb_synch_interval=300;
@@ -597,7 +670,10 @@
char *
get_nbr_lsdb_version(char *nbr)
{
- printf("get_timed_out_number called \n");
+ if ( nlsr->debugging )
+ printf("get_nbr_lsdb_version called \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_nbr_lsdb_version called \n");
char *version=NULL;
@@ -630,7 +706,10 @@
void
update_adjacent_last_lsdb_requested_to_adl(char *nbr, long int timestamp)
{
- printf("update_adjacent_last_lsdb_requested_to_adl called \n");
+ if ( nlsr->debugging )
+ printf("update_adjacent_last_lsdb_requested_to_adl called \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"update_adjacent_last_lsdb_requested_to_adl called \n");
int res;
struct ndn_neighbor *nnbr;
@@ -658,7 +737,11 @@
void
set_is_lsdb_send_interest_scheduled_to_zero(char *nbr)
{
- printf("set_is_lsdb_send_interest_scheduled_to_zero called \n");
+ if ( nlsr->debugging )
+ printf("set_is_lsdb_send_interest_scheduled_to_zero called \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"set_is_lsdb_send_interest_scheduled_to_zero called\n");
+
int res;
struct ndn_neighbor *nnbr;
@@ -685,7 +768,10 @@
void
update_adjacent_lsdb_version_to_adl(struct name_prefix *nbr, char *version)
{
- printf("update_adjacent_timed_out_to_adl called \n");
+ if ( nlsr->debugging )
+ printf("update_adjacent_timed_out_to_adl called \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"update_adjacent_timed_out_to_adl called\n");
int res;
struct ndn_neighbor *nnbr;
@@ -718,6 +804,12 @@
{
printf("update_adjacent_last_lsdb_requested_to_adl called \n");
+ if ( nlsr->debugging )
+ printf("update_adjacent_last_lsdb_requested_to_adl called \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"update_adjacent_last_lsdb_requested_to_adl called\n");
+
+
int res;
struct ndn_neighbor *nnbr;
diff --git a/nlsr_lsdb.c b/nlsr_lsdb.c
index 41fe7e8..5b30e70 100644
--- a/nlsr_lsdb.c
+++ b/nlsr_lsdb.c
@@ -48,7 +48,7 @@
{
- printf("Orig Router: %s LS Type: %d LS Id: %ld\n",orig_router,ls_type,ls_id);
+ //printf("Orig Router: %s LS Type: %d LS Id: %ld\n",orig_router,ls_type,ls_id);
char lst[2];
memset(lst,0,2);
@@ -71,7 +71,10 @@
void
build_and_install_name_lsas(void)
{
- printf("build_and_install_name_lsas called \n");
+ 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 *np;
@@ -141,9 +144,9 @@
char *time_stamp=(char *)malloc(20);
memset(time_stamp,0,20);
get_current_timestamp_micro(time_stamp);
- long int lsa_life_time=get_time_diff(time_stamp,name_lsa->header->orig_time);
+ //long int lsa_life_time=get_time_diff(time_stamp,name_lsa->header->orig_time);
- printf("time difference: %ld \n",lsa_life_time);
+ //printf("time difference: %ld \n",lsa_life_time);
char lst[2];
@@ -174,7 +177,12 @@
if(res == HT_NEW_ENTRY )
{
- printf("New Name LSA... Adding to LSDB\n");
+ 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 )); //free
@@ -197,10 +205,21 @@
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;
- printf("New Name LSA Added....\n");
- printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
+ 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();
- printf("New Version Number of LSDB: %s \n",nlsr->lsdb->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);
@@ -209,7 +228,10 @@
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 )
{
- printf("Added in npt \n");
+ if ( nlsr->debugging )
+ printf("Added in npt \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Added in npt \n");
}
}
else
@@ -217,14 +239,27 @@
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);
- 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->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 )
{
- printf("Added in npt \n");
+ 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);
@@ -244,11 +279,17 @@
new_name_lsa=e->data;
if(strcmp(name_lsa->header->orig_time,new_name_lsa->header->orig_time)<0)
{
- printf("Older Adj LSA. Discarded...\n");
+ 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 )
{
- printf("Duplicate Adj LSA. Discarded...\n");
+ if ( nlsr->debugging )
+ printf("Duplicate Adj LSA. Discarded... \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Duplicate Adj LSA. Discarded...\n");
}
else
{
@@ -265,7 +306,10 @@
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);
+ 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
{
@@ -275,9 +319,15 @@
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);
}
- printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
+ 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();
- printf("New Version Number of LSDB: %s \n",nlsr->lsdb->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
{
@@ -315,9 +365,18 @@
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);
+ 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();
- printf("New Version Number of LSDB: %s \n",nlsr->lsdb->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 )
{
@@ -329,7 +388,10 @@
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 )
{
- printf("Added in npt \n");
+ if ( nlsr->debugging )
+ printf("Added in npt \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Added in npt \n");
}
}
else
@@ -337,15 +399,31 @@
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);
- printf("Printing from install_name_lsa \n");
- int j;
- for(j=0;j<num_next_hop;j++)
+
+ 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 )
{
- printf("Added in npt \n");
+ //printf("Added in npt \n");
+ 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);
@@ -383,25 +461,29 @@
void
print_name_lsa(struct nlsa *name_lsa)
{
-
- 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");
+ 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)
{
- printf("print_name_lsdb called \n");
+ if ( nlsr->debugging )
+ printf("print_name_lsdb called \n");
int i, name_lsdb_element;
struct nlsa *name_lsa;
@@ -413,7 +495,8 @@
for(i=0;i<name_lsdb_element;i++)
{
- printf("-----------Name LSA (%d)---------------\n",i+1);
+ if ( nlsr->debugging )
+ printf("-----------Name LSA (%d)---------------\n",i+1);
name_lsa=e->data;
print_name_lsa(name_lsa);
hashtb_next(e);
@@ -428,7 +511,10 @@
void
build_and_install_others_name_lsa(char *orig_router,int ls_type,long int ls_id,char *orig_time, int isValid,char *np)
{
- printf("build_and_install_others_name_lsa called \n");
+ 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);
@@ -449,7 +535,10 @@
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)
{
- printf("build_others_name_lsa called \n");
+ 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 *)malloc(sizeof(struct nlsa_header ));
name_lsa->header->ls_type=LS_TYPE_NAME;
@@ -497,13 +586,23 @@
nlsr_lock();
- printf("build_and_install_adj_lsa called \n");
-
- printf("adj_build_flag = %d \n",nlsr->adj_build_flag);
+ 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)
{
- printf("is_adj_lsa_build = %d \n",is_adj_lsa_build());
+ 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 ));
@@ -521,7 +620,10 @@
}
else
{
- printf("Can not build adj LSA now\n");
+ 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;
@@ -535,10 +637,14 @@
void
build_adj_lsa(struct alsa * adj_lsa)
{
- printf("build_adj_lsa called \n");
+ 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();
- printf("Number of link in Adjacent LSA: %d\n",no_link);
+
+ //printf("Number of link in Adjacent LSA: %d\n",no_link);
/*Filling Up Header Data */
adj_lsa->header=(struct alsa_header *)malloc(sizeof(struct alsa_header ));
@@ -591,21 +697,25 @@
void
install_adj_lsa(struct alsa * adj_lsa)
{
- printf("install_adj_lsa called \n");
+ if ( nlsr->debugging )
+ printf("install_adj_lsa called \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"install_adj_lsa called \n");
+
char *time_stamp=(char *)malloc(20);
memset(time_stamp,0,20);
get_current_timestamp_micro(time_stamp);
- long int lsa_life_time=get_time_diff(time_stamp,adj_lsa->header->orig_time);
+ //long int lsa_life_time=get_time_diff(time_stamp,adj_lsa->header->orig_time);
- printf("time difference: %ld \n",lsa_life_time);
+ //printf("time difference: %ld \n",lsa_life_time);
char *key=(char *)malloc(adj_lsa->header->orig_router->length+2+2);
memset(key,0,adj_lsa->header->orig_router->length+2);
make_adj_lsa_key(key,adj_lsa);
- printf("Adjacent LSA key: %s \n",key);
+ //printf("Adjacent LSA key: %s \n",key);
struct alsa *new_adj_lsa=(struct alsa*)malloc(sizeof(struct alsa ));
@@ -654,16 +764,28 @@
hashtb_delete(e);
}
- printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
+ 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();
- printf("New Version Number of LSDB: %s \n",nlsr->lsdb->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)
{
- printf("Older/Duplicate Adj LSA. Discarded...\n");
+ 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
{
@@ -703,9 +825,18 @@
hashtb_delete(e);
}
- printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
+
+ 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();
- printf("New Version Number of LSDB: %s \n",nlsr->lsdb->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);
}
}
@@ -836,23 +967,27 @@
void
print_adj_lsa(struct alsa * adj_lsa)
{
- 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);
+ 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");
+ print_adj_lsa_body(adj_lsa->body,adj_lsa->no_link);
+ printf("\n");
+ }
}
void
print_adj_lsdb(void)
{
- printf("print_name_lsdb called \n");
+ if ( nlsr->debugging )
+ printf("print_name_lsdb called \n");
int i, adj_lsdb_element;
struct alsa *adj_lsa;
@@ -864,7 +999,8 @@
for(i=0;i<adj_lsdb_element;i++)
{
- printf("-----------Adj LSA (%d)---------------\n",i+1);
+ if ( nlsr->debugging )
+ printf("-----------Adj LSA (%d)---------------\n",i+1);
adj_lsa=e->data;
print_adj_lsa(adj_lsa);
hashtb_next(e);
@@ -878,7 +1014,10 @@
void
build_and_install_others_adj_lsa(char *orig_router,int ls_type,char *orig_time, int no_link,char *data)
{
- printf("build_and_install_others_adj_lsa called \n");
+ 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);
//print_adj_lsa(adj_lsa);
@@ -900,7 +1039,11 @@
void
build_others_adj_lsa(struct alsa *adj_lsa,char *orig_router,int ls_type,char *orig_time,int no_link,char *data)
{
- printf("build_others_adj_lsa called \n");
+ //printf("build_others_adj_lsa called \n");
+ 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 *)malloc(sizeof(struct alsa_header ));
@@ -962,7 +1105,12 @@
void
get_name_lsdb_summary(struct ccn_charbuf *name_lsdb_data)
{
- printf("get_name_lsdb_summary called \n");
+ //printf("get_name_lsdb_summary called \n");
+ if ( nlsr->debugging )
+ printf("get_name_lsdb_summary called \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_name_lsdb_summary called \n");
+
int i, name_lsdb_element;
struct nlsa *name_lsa;
@@ -1007,7 +1155,10 @@
void
get_adj_lsdb_summary(struct ccn_charbuf *adj_lsdb_data)
{
- printf("get_adj_lsdb_summary called \n");
+ if ( nlsr->debugging )
+ printf("get_adj_lsdb_summary called \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_adj_lsdb_summary called \n");
int i, adj_lsdb_element;
struct alsa *adj_lsa;
@@ -1161,7 +1312,11 @@
void
get_name_lsa_data(struct ccn_charbuf *lsa_data, struct name_prefix *lsaId)
{
- printf("get_name_lsa_data called \n");
+ //printf("get_name_lsa_data called \n");
+ 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 ));
@@ -1175,7 +1330,12 @@
if( res == HT_OLD_ENTRY )
{
name_lsa=e->data;
- printf("NAME LSA found\n");
+ //printf("NAME LSA found\n");
+
+ 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,"|");
@@ -1233,7 +1393,10 @@
void
get_adj_lsa_data(struct ccn_charbuf *lsa_data,struct name_prefix *lsaId)
{
- printf("get_adj_lsa_data called \n");
+ 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 ));
@@ -1247,7 +1410,12 @@
if( res == HT_OLD_ENTRY )
{
adj_lsa=e->data;
- printf("NAME LSA found\n");
+ //printf("Adj LSA found\n");
+
+ 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,"|");
@@ -1291,7 +1459,12 @@
int
delete_name_lsa(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
{
- printf("delete_name_lsa called \n");
+ //printf("delete_name_lsa called \n");
+
+ if ( nlsr->debugging )
+ printf("delete_name_lsa called \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"delete_name_lsa called \n");
if(flags == CCN_SCHEDULE_CANCEL)
{
@@ -1302,7 +1475,10 @@
nlsr_lock();
- printf("LSA Key: %s \n",(char *)ev->evdata);
+ if ( nlsr->debugging )
+ printf("LSA Key: %s \n",(char *)ev->evdata);
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"LSA Key: %s \n",(char *)ev->evdata);
struct nlsa *nlsa;
@@ -1332,10 +1508,17 @@
}
hashtb_end(e);
-
- printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
+ 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();
- printf("New Version Number of LSDB: %s \n",nlsr->lsdb->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();
@@ -1347,7 +1530,12 @@
int
delete_adj_lsa(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
{
- printf("delete_adj_lsa called \n");
+ //printf("delete_adj_lsa called \n");
+
+ if ( nlsr->debugging )
+ printf("delete_adj_lsa called \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"delete_adj_lsa called \n");
if(flags == CCN_SCHEDULE_CANCEL)
{
@@ -1355,7 +1543,12 @@
}
nlsr_lock();
- printf("LSA Key: %s \n",(char *)ev->evdata);
+ //printf("LSA Key: %s \n",(char *)ev->evdata);
+
+ if ( nlsr->debugging )
+ printf("LSA Key: %s \n",(char *)ev->evdata);
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"LSA Key: %s \n",(char *)ev->evdata);
struct alsa *alsa;
struct hashtb_enumerator ee;
@@ -1381,9 +1574,18 @@
}
hashtb_end(e);
- printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
+ 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();
- printf("New Version Number of LSDB: %s \n",nlsr->lsdb->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)
{
@@ -1401,7 +1603,12 @@
void
refresh_name_lsdb(void)
{
- printf("refresh_name_lsdb called \n");
+ //printf("refresh_name_lsdb called \n");
+
+ if ( nlsr->debugging )
+ printf("refresh_name_lsdb called \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"refresh_name_lsdb called \n");
//int lsa_change_count=0;
@@ -1425,7 +1632,10 @@
name_lsa=e->data;
lsa_life_time=get_time_diff(time_stamp,name_lsa->header->orig_time);
- printf("LSA Life Time: %ld \n",lsa_life_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)
{
@@ -1433,7 +1643,10 @@
{
if ( name_lsa->header->isValid == NAME_LSA_VALID )
{
- printf("Own Name LSA need to be refrshed\n");
+ 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");
@@ -1473,14 +1686,24 @@
make_name_lsa_key(key, name_lsa->header->orig_router->name,name_lsa->header->ls_type,name_lsa->header->ls_id);
- printf("Key:%s Length:%d\n",key,(int)strlen(key));
+ //printf("Key:%s Length:%d\n",key,(int)strlen(key));
nlsr->event = ccn_schedule_event(nlsr->sched, 10, &delete_name_lsa, (void *)key, 0);
}
- printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
+ 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();
- printf("New Version Number of LSDB: %s \n",nlsr->lsdb->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();
//lsa_change_count++;
@@ -1490,7 +1713,10 @@
{
if ( lsa_life_time > nlsr->router_dead_interval )
{
- printf("Others Name LSA need to be deleted\n");
+ 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");
char lst[2];
memset(lst,0,2);
@@ -1506,7 +1732,7 @@
make_name_lsa_key(key, name_lsa->header->orig_router->name,name_lsa->header->ls_type,name_lsa->header->ls_id);
- printf("Key:%s Length:%d\n",key,(int)strlen(key));
+ //printf("Key:%s Length:%d\n",key,(int)strlen(key));
nlsr->event = ccn_schedule_event(nlsr->sched, 10, &delete_name_lsa, (void *)key, 0);
//lsa_change_count++;
@@ -1526,8 +1752,12 @@
void
refresh_adj_lsdb(void)
{
- printf("refresh_adj_lsdb called \n");
+ //printf("refresh_adj_lsdb called \n");
+ 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=(char *)malloc(20);
memset(time_stamp,0,20);
@@ -1549,13 +1779,22 @@
adj_lsa=e->data;
lsa_life_time=get_time_diff(time_stamp,adj_lsa->header->orig_time);
- printf("LSA Life Time: %ld \n",lsa_life_time);
+ //printf("LSA Life Time: %ld \n",lsa_life_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 )
{
- printf("Own Adj LSA need to be refrshed\n");
+ //printf("Own Adj LSA need to be refrshed\n");
+ 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");
@@ -1578,9 +1817,17 @@
write_log_for_adj_lsa(adj_lsa);
writeLogg(__FILE__,__FUNCTION__,__LINE__," adj_lsa_end\n");
- printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
+ 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();
- printf("New Version Number of LSDB: %s \n",nlsr->lsdb->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();
}
@@ -1589,12 +1836,17 @@
{
if ( lsa_life_time > nlsr->router_dead_interval )
{
- printf("Others Adj LSA need to be deleted\n");
+ //printf("Others Adj LSA need to be deleted\n");
+
+ 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");
char *key=(char *)malloc(adj_lsa->header->orig_router->length+2+2);
memset(key,0,adj_lsa->header->orig_router->length+2);
make_adj_lsa_key(key,adj_lsa);
- printf("Adjacent LSA key: %s \n",key);
+ //printf("Adjacent LSA key: %s \n",key);
nlsr->event = ccn_schedule_event(nlsr->sched, 10, &delete_adj_lsa, (void *)key, 0);
}
}
@@ -1619,7 +1871,12 @@
nlsr_lock();
- printf("refresh_lsdb called \n");
+ //printf("refresh_lsdb called \n");
+
+ 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();
diff --git a/nlsr_ndn.c b/nlsr_ndn.c
index 475e4b4..82e8df8 100644
--- a/nlsr_ndn.c
+++ b/nlsr_ndn.c
@@ -45,8 +45,11 @@
void
get_nbr(struct name_prefix *nbr,struct ccn_closure *selfp, struct ccn_upcall_info *info)
{
+ if ( nlsr->debugging )
+ printf("get_nbr called\n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_nbr called\n");
- printf("get_nbr called\n");
int res,i;
int nlsr_position=0;
int name_comps=(int)info->interest_comps->n;
@@ -88,7 +91,11 @@
memcpy(nbr->name,neighbor,strlen(neighbor)+1);
nbr->length=strlen(neighbor)+1;
- printf("Neighbor: %s Length: %d\n",nbr->name,nbr->length);
+ if ( nlsr->debugging )
+ printf("Neighbor: %s Length: %d\n",nbr->name,nbr->length);
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Neighbor: %s Length: %d\n",nbr->name,nbr->length);
+
}
@@ -97,7 +104,13 @@
get_lsa_identifier(struct name_prefix *lsaId,struct ccn_closure *selfp, struct ccn_upcall_info *info, int offset)
{
- printf("get_lsa_identifier called\n");
+ //printf("get_lsa_identifier called\n");
+
+ if ( nlsr->debugging )
+ printf("get_lsa_identifier called\n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_lsa_identifier called\n");
+
int res,i;
int nlsr_position=0;
int name_comps=(int)info->interest_comps->n;
@@ -140,7 +153,12 @@
memcpy(lsaId->name,neighbor,strlen(neighbor)+1);
lsaId->length=strlen(neighbor)+1;
- printf("LSA Identifier: %s Length: %d\n",lsaId->name,lsaId->length-1);
+ if ( nlsr->debugging )
+ printf("LSA Identifier: %s Length: %d\n",lsaId->name,lsaId->length-1);
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"LSA Identifier: %s Length: %d\n",lsaId->name,lsaId->length-1);
+
+ //printf("LSA Identifier: %s Length: %d\n",lsaId->name,lsaId->length-1);
}
@@ -200,11 +218,20 @@
break;
case CCN_UPCALL_INTEREST:
// printing the name prefix for which it received interest
- printf("Interest Received for name: ");
+ if ( nlsr->debugging )
+ printf("Interest Received for name: ");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Interest Received for name: ");
+
struct ccn_charbuf*c;
c=ccn_charbuf_create();
ccn_uri_append(c,info->interest_ccnb,info->pi->offset[CCN_PI_E_Name],0);
- printf("%s\n",ccn_charbuf_as_string(c));
+
+ if ( nlsr->debugging )
+ printf("%s\n",ccn_charbuf_as_string(c));
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"%s\n",ccn_charbuf_as_string(c));
+
ccn_charbuf_destroy(&c);
process_incoming_interest(selfp, info);
@@ -225,7 +252,11 @@
void
process_incoming_interest(struct ccn_closure *selfp, struct ccn_upcall_info *info)
{
- printf("process_incoming_interest called \n");
+ if ( nlsr->debugging )
+ printf("process_incoming_interest called \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"process_incoming_interest called \n");
+
const unsigned char *comp_ptr1;
size_t comp_size;
int res,i;
@@ -244,7 +275,7 @@
res=ccn_name_comp_get(info->interest_ccnb, info->interest_comps,nlsr_position+1,&comp_ptr1, &comp_size);
- printf("Det= %s \n",comp_ptr1);
+ //printf("Det= %s \n",comp_ptr1);
if(!strcmp((char *)comp_ptr1,"info"))
{
@@ -263,9 +294,18 @@
void
process_incoming_interest_info(struct ccn_closure *selfp, struct ccn_upcall_info *info)
{
- printf("process_incoming_interest_info called \n");
+ if ( nlsr->debugging )
+ {
+ printf("process_incoming_interest_info called \n");
+ printf("Sending Info Content back.....\n");
+ }
+ if ( nlsr->detailed_logging )
+ {
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"process_incoming_interest_info called \n");
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Sending Info Content back.....\n");
+ }
+
- printf("Sending Info Content back.....\n");
int res;
struct ccn_charbuf *data=ccn_charbuf_create();
struct ccn_charbuf *name=ccn_charbuf_create();
@@ -287,18 +327,33 @@
res= ccn_sign_content(nlsr->ccn, data, name, &sp, raw_data,strlen(raw_data));
if(res >= 0)
- printf("Signing Content is successful \n");
+ {
+ if ( nlsr->debugging )
+ printf("Signing info Content is successful \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Signing info Content is successful \n");
+ }
res=ccn_put(nlsr->ccn,data->buf,data->length);
if(res >= 0)
- printf("Sending Info Content is successful \n");
-
- printf("Info Content sending done....\n");
+ {
+ if ( nlsr->debugging )
+ printf("Sending Info Content is successful \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Sending info Content is successful \n");
+ }
+
struct name_prefix *nbr=(struct name_prefix * )malloc(sizeof(struct name_prefix *));
get_lsa_identifier(nbr,selfp,info,-1);
- printf("Neighbor : %s Length : %d Status : %d\n",nbr->name,nbr->length,get_adjacent_status(nbr));
+
+ if ( nlsr->debugging )
+ printf("Neighbor : %s Length : %d Status : %d\n",nbr->name,nbr->length,get_adjacent_status(nbr));
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Neighbor : %s Length : %d Status : %d\n",nbr->name,nbr->length,get_adjacent_status(nbr));
+
+ //printf("Neighbor : %s Length : %d Status : %d\n",nbr->name,nbr->length,get_adjacent_status(nbr));
if( get_adjacent_status(nbr) == 0 && get_timed_out_number(nbr)>=nlsr->interest_retry )
@@ -321,7 +376,13 @@
void
process_incoming_interest_lsdb(struct ccn_closure *selfp, struct ccn_upcall_info *info)
{
- printf("process_incoming_interest_lsdb called \n");
+ //printf("process_incoming_interest_lsdb called \n");
+
+ if ( nlsr->debugging )
+ printf("process_incoming_interest_lsdb called \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"process_incoming_interest_lsdb called \n");
+
int l,res;
const unsigned char *exclbase;
@@ -355,15 +416,26 @@
}
if (comp != NULL)
{
- printf("LSDB Version in Exclusion Filter is %s\n",comp);
- printf("LSDB Version of own NLSR is: %s \n",nlsr->lsdb->lsdb_version);
+ if ( nlsr->debugging )
+ {
+ printf("LSDB Version in Exclusion Filter is %s\n",comp);
+ printf("LSDB Version of own NLSR is: %s \n",nlsr->lsdb->lsdb_version);
+ }
+ if ( nlsr->detailed_logging )
+ {
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"LSDB Version in Exclusion Filter is %s\n",comp);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"LSDB Version of own NLSR is: %s \n",nlsr->lsdb->lsdb_version);
+ }
dbcmp=strcmp(nlsr->lsdb->lsdb_version,(char *)comp);
}
/* Now comp points to the start of your potential number, and size is its length */
}
else
{
- printf("LSDB Version in Exclusion Filter is: None Added\n");
+ if ( nlsr->debugging )
+ printf("LSDB Version in Exclusion Filter is: None Added\n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"LSDB Version in Exclusion Filter is: None Added\n");
dbcmp=1;
}
@@ -383,9 +455,16 @@
if(dbcmp>0)
{
- printf("Has Updated Database than Neighbor\n");
- printf("Sending LSDB Summary of Updated LSDB Content...\n");
-
+ if ( nlsr->debugging )
+ {
+ printf("Has Updated Database than Neighbor\n");
+ printf("Sending LSDB Summary of Updated LSDB Content...\n");
+ }
+ if ( nlsr->detailed_logging )
+ {
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Has Updated Database than Neighbor\n");
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Sending LSDB Summary of Updated LSDB Content...\n");
+ }
ccn_name_append_str(name,nlsr->lsdb->lsdb_version);
struct ccn_charbuf *lsdb_data=ccn_charbuf_create();
@@ -403,29 +482,59 @@
{
res= ccn_sign_content(nlsr->ccn, data, name, &sp, raw_data , strlen(raw_data));
}
+
if(res >= 0)
- printf("Signing LSDB Summary of Updated LSDB Content is successful \n");
+ {
+ if ( nlsr->debugging )
+ printf("Signing LSDB Summary of Updated LSDB Content is successful \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Signing LSDB Summary of Updated LSDB Content is successful \n");
+ }
res=ccn_put(nlsr->ccn,data->buf,data->length);
if(res >= 0)
- printf("Sending LSDB Summary of Updated LSDB Content is successful \n");
+ {
+ if ( nlsr->debugging )
+ printf("Sending LSDB Summary of Updated LSDB Content is successful \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Sending LSDB Summary of Updated LSDB Content is successful \n");
+ }
ccn_charbuf_destroy(&lsdb_data);
}
else
{
- printf("Does not have Updated Database than Neighbor\n");
-
- printf("Sending NACK Content.....\n");
+ if ( nlsr->debugging )
+ {
+ printf("Does not have Updated Database than Neighbor\n");
+ printf("Sending NACK Content.....\n");
+ }
+ if ( nlsr->detailed_logging )
+ {
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Does not have Updated Database than Neighbor\n");
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Sending NACK Content.....\n");
+ }
+
res= ccn_sign_content(nlsr->ccn, data, name, &sp, "NACK", strlen("NACK"));
+
if(res >= 0)
- printf("Signing NACK Content is successful \n");
+ {
+ if ( nlsr->debugging )
+ printf("Signing NACK Content is successful \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Signing NACK Content is successful \n");
+ }
res=ccn_put(nlsr->ccn,data->buf,data->length);
if(res >= 0)
- printf("Sending NACK Content is successful \n");
+ {
+ if ( nlsr->debugging )
+ printf("Sending NACK Content is successful \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Sending NACK Content is successful \n");
+ }
}
@@ -441,26 +550,35 @@
void
process_incoming_interest_lsa(struct ccn_closure *selfp, struct ccn_upcall_info *info)
{
- printf("process_incoming_interest_lsa called \n");
+ if ( nlsr->debugging )
+ printf("process_incoming_interest_lsa called \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"process_incoming_interest_lsa called \n");
int res;
struct name_prefix *lsaId=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
get_lsa_identifier(lsaId,selfp,info,0);
- printf("LSA Identifier: %s Length: %d\n",lsaId->name,lsaId->length);
+ //printf("LSA Identifier: %s Length: %d\n",lsaId->name,lsaId->length);
int ls_type=get_ls_type(selfp, info);
struct ccn_charbuf *lsa_data=ccn_charbuf_create();
if ( ls_type == LS_TYPE_NAME )
{
- printf("Interest Received for NAME LSA\n");
+ if ( nlsr->debugging )
+ printf("Interest Received for NAME LSA \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Interest Received for NAME LSA \n");
get_name_lsa_data(lsa_data,lsaId);
}
else if ( ls_type == LS_TYPE_ADJ )
{
- printf("Interest Received for ADJ LSA\n");
+ if ( nlsr->debugging )
+ printf("Interest Received for ADJ LSA \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Interest Received for ADJ LSA \n");
get_adj_lsa_data(lsa_data,lsaId);
}
@@ -483,12 +601,24 @@
ccn_charbuf_append_closer(sp.template_ccnb);
res= ccn_sign_content(nlsr->ccn, data, name, &sp, raw_data , strlen(raw_data));
+
if(res >= 0)
- printf("Signing LSA Content is successful \n");
+ {
+ if ( nlsr->debugging )
+ printf("Signing LSA Content is successful \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Signing LSA Content is successful \n");
+ }
res=ccn_put(nlsr->ccn,data->buf,data->length);
+
if(res >= 0)
- printf("Sending LSA Content is successful \n");
+ {
+ if ( nlsr->debugging )
+ printf("Sending LSA Content is successful \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Sending LSA Content is successful \n");
+ }
@@ -513,23 +643,41 @@
case CCN_UPCALL_FINAL:
break;
case CCN_UPCALL_CONTENT:
- printf("Content Received for Name: ");
+ if ( nlsr->debugging )
+ printf("Content Received for Name: ");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Content Received for Name: ");
+
struct ccn_charbuf*c;
c=ccn_charbuf_create();
ccn_uri_append(c,info->interest_ccnb,info->pi->offset[CCN_PI_E],0);
- printf("%s\n",ccn_charbuf_as_string(c));
+ if ( nlsr->debugging )
+ printf("%s\n",ccn_charbuf_as_string(c));
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"%s\n",ccn_charbuf_as_string(c));
+
ccn_charbuf_destroy(&c);
process_incoming_content(selfp,info);
break;
case CCN_UPCALL_INTEREST_TIMED_OUT:
- printf("Interest Timed Out Received for Name: ");
+ //printf("Interest Timed Out Received for Name: ");
+ if ( nlsr->debugging )
+ printf("Interest Timed Out Received for Name: ");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Interest Timed Out Received for Name: ");
struct ccn_charbuf*ito;
ito=ccn_charbuf_create();
ccn_uri_append(ito,info->interest_ccnb,info->pi->offset[CCN_PI_E],0);
- printf("%s\n",ccn_charbuf_as_string(ito));
+
+ if ( nlsr->debugging )
+ printf("%s\n",ccn_charbuf_as_string(ito));
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"%s\n",ccn_charbuf_as_string(ito));
+
+ //printf("%s\n",ccn_charbuf_as_string(ito));
ccn_charbuf_destroy(&ito);
process_incoming_timed_out_interest(selfp,info);
@@ -537,7 +685,10 @@
break;
default:
fprintf(stderr, "Unexpected response of kind %d\n", kind);
- //return CCN_UPCALL_RESULT_ERR;
+ if ( nlsr->debugging )
+ printf("Unexpected response of kind %d\n", kind);
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Unexpected response of kind %d\n", kind);
break;
}
@@ -550,7 +701,11 @@
void
process_incoming_content(struct ccn_closure *selfp, struct ccn_upcall_info* info)
{
- printf("process_incoming_content called \n");
+ //printf("process_incoming_content called \n");
+ if ( nlsr->debugging )
+ printf("process_incoming_content called \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"process_incoming_content called \n");
const unsigned char *comp_ptr1;
size_t comp_size;
@@ -570,7 +725,7 @@
res=ccn_name_comp_get(info->interest_ccnb, info->interest_comps,nlsr_position+1,&comp_ptr1, &comp_size);
- printf("Det= %s \n",comp_ptr1);
+ //printf("Det= %s \n",comp_ptr1);
if(!strcmp((char *)comp_ptr1,"info"))
{
@@ -591,12 +746,19 @@
void
process_incoming_content_info(struct ccn_closure *selfp, struct ccn_upcall_info* info)
{
- printf("process_incoming_content_info called \n");
+ //printf("process_incoming_content_info called \n");
+ if ( nlsr->debugging )
+ printf("process_incoming_content_info called \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"process_incoming_content_info called \n");
struct name_prefix *nbr=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
get_nbr(nbr,selfp,info);
- printf("Info Content Received For Neighbor: %s Length:%d\n",nbr->name,nbr->length);
+ if ( nlsr->debugging )
+ printf("Info Content Received For Neighbor: %s Length:%d\n",nbr->name,nbr->length);
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Info Content Received For Neighbor: %s Length:%d\n",nbr->name,nbr->length);
const unsigned char *ptr;
@@ -617,13 +779,19 @@
if(!nlsr->is_build_adj_lsa_sheduled)
{
- printf("Scheduling Build and Install Adj LSA...\n");
+ if ( nlsr->debugging )
+ printf("Scheduling Build and Install Adj LSA...\n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Scheduling Build and Install Adj LSA...\n");
nlsr->event_build_adj_lsa = ccn_schedule_event(nlsr->sched, 100000, &build_and_install_adj_lsa, NULL, 0);
nlsr->is_build_adj_lsa_sheduled=1;
}
else
{
- printf("Build and Install Adj LSA already scheduled\n");
+ if ( nlsr->debugging )
+ printf("Build and Install Adj LSA already scheduled\n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Build and Install Adj LSA already scheduled\n");
}
@@ -636,7 +804,10 @@
void
process_incoming_content_lsdb(struct ccn_closure *selfp, struct ccn_upcall_info* info)
{
- printf("process_incoming_content_lsdb called \n");
+ if ( nlsr->debugging )
+ printf("process_incoming_content_lsdb called \n");
+ if ( nlsr->detailed_logging )
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"process_incoming_content_lsdb called \n");
const unsigned char *ptr;
size_t length;