Added checks on all printf statements (which did not already have it) to only print if debugging mode is enabled
diff --git a/nlsr-sync-0.0/nlsr_lsdb.c b/nlsr-sync-0.0/nlsr_lsdb.c
index 51133cd..87f2b9e 100755
--- a/nlsr-sync-0.0/nlsr_lsdb.c
+++ b/nlsr-sync-0.0/nlsr_lsdb.c
@@ -61,7 +61,9 @@
memcpy(key+strlen(key),lst,strlen(lst));
memcpy(key+strlen(key),"/",1);
memcpy(key+strlen(key),lsid,strlen(lsid));
- printf("%s\n", key);
+
+ if ( nlsr->debugging )
+ printf("%s\n", key);
}
@@ -69,7 +71,9 @@
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/%d/%ld/%s%s",slice_prefix, ls_type, ls_id, orig_time, orig_router);
- printf("%s\n",key);
+
+ if ( nlsr->debugging )
+ printf("%s\n",key);
}
void
@@ -77,7 +81,9 @@
{
sprintf(key,"%s/%d/%s%s",slice_prefix,ls_type, orig_time, orig_router);
- printf("Key:%s\n",key);
+
+ if ( nlsr->debugging )
+ printf("Key:%s\n",key);
}
void
@@ -1023,12 +1029,13 @@
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 ( 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++)
{
@@ -1567,7 +1574,9 @@
make_name_lsa_key(key, np->name,ls_type,ls_id);
- printf("Key:%s Length:%d\n",key,(int)strlen(key));
+
+ if ( nlsr->debugging )
+ printf("Key:%s Length:%d\n",key,(int)strlen(key));
struct nlsa *nlsa;
@@ -2111,14 +2120,17 @@
make_name_lsa_key(key, name_lsa->header->orig_router->name,name_lsa->header->ls_type,name_lsa->header->ls_id);
- printf("Name LSA Key: %s \n",key);
+
+ if ( nlsr->debugging )
+ printf("Name LSA Key: %s \n",key);
char *repo_key=(char *)malloc(strlen(slice_prefix)+1+strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1+strlen(name_lsa->header->orig_time)+1);
memset(repo_key,0,strlen(slice_prefix)+1+strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1+strlen(name_lsa->header->orig_time)+1);
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);
- printf("Name LSA Repo Key: %s \n",repo_key);
+ if ( nlsr->debugging )
+ printf("Name LSA Repo Key: %s \n",repo_key);
struct name_prefix *lsaid=(struct name_prefix *)malloc(sizeof(struct name_prefix));
lsaid->name=(char *)malloc(strlen(key)+1);
diff --git a/nlsr-sync-0.0/nlsr_route.c b/nlsr-sync-0.0/nlsr_route.c
index 8537b2e..25b99dc 100755
--- a/nlsr-sync-0.0/nlsr_route.c
+++ b/nlsr-sync-0.0/nlsr_route.c
@@ -277,7 +277,9 @@
{
if (parent[dest] != EMPTY_PARENT )
print_path(parent,parent[dest]);
- printf(" %ld",dest);
+
+ if ( nlsr->debugging )
+ printf(" %ld",dest);
}
int
diff --git a/nlsr-sync-0.0/nlsr_sync.c b/nlsr-sync-0.0/nlsr_sync.c
index 313b1b9..34ef71a 100644
--- a/nlsr-sync-0.0/nlsr_sync.c
+++ b/nlsr-sync-0.0/nlsr_sync.c
@@ -65,7 +65,9 @@
ccn_uri_append(uri, name->buf, name->length, 1);
else
ccn_charbuf_append_string(uri, "(null)");
- printf("%s %s %s\n", ccn_charbuf_as_string(uri), hexL, hexR);
+
+ if ( nlsr->debugging )
+ printf("%s %s %s\n", ccn_charbuf_as_string(uri), hexL, hexR);
fflush(stdout);
free(hexL);
free(hexR);
@@ -427,7 +429,8 @@
int is_new_name_lsa=check_is_new_name_lsa(orig_router->name,(char *)lst,(char *)lsid,(char *)origtime);
if ( is_new_name_lsa == 1 )
{
- printf("New NAME LSA.....\n");
+ if ( nlsr->debugging )
+ printf("New NAME LSA.....\n");
//content_data=get_content_by_content_name(ccn_charbuf_as_string(uri));
get_content_by_content_name(ccn_charbuf_as_string(uri), &content_data);
printf("Content Data: %s \n",content_data);
@@ -435,22 +438,28 @@
}
else
{
- printf("Name LSA / Newer Name LSA already xists in LSDB\n");
+ if ( nlsr->debugging )
+ printf("Name LSA / Newer Name LSA already xists in LSDB\n");
//content_data=get_content_by_content_name(ccn_charbuf_as_string(uri));
get_content_by_content_name(ccn_charbuf_as_string(uri), &content_data);
- printf("Content Data: %s \n",content_data);
+
+ if ( nlsr->debugging )
+ printf("Content Data: %s \n",content_data);
}
}
else
{
- printf("Lsa is older than Router LSA refresh time/ Dead Interval\n");
+ if ( nlsr->debugging )
+ printf("Lsa is older than Router LSA refresh time/ Dead Interval\n");
}
}
else if(ls_type == LS_TYPE_ADJ)
{
res=ccn_name_comp_get(content_name->buf, components,lsa_position+2,&origtime, &comp_size);
get_name_part(orig_router,content_name,components,2);
- printf("Orig Time: %s\nOrig Router: %s\n",origtime,orig_router->name);
+
+ if ( nlsr->debugging )
+ printf("Orig Time: %s\nOrig Router: %s\n",origtime,orig_router->name);
int lsa_life_time=get_time_diff(time_stamp,(char *)origtime);
@@ -461,23 +470,28 @@
int is_new_adj_lsa=check_is_new_adj_lsa(orig_router->name,(char *)lst,(char *)origtime);
if ( is_new_adj_lsa == 1 )
{
- printf("New Adj LSA.....\n");
+ if ( nlsr->debugging )
+ printf("New Adj LSA.....\n");
//content_data=get_content_by_content_name(ccn_charbuf_as_string(uri));
get_content_by_content_name(ccn_charbuf_as_string(uri), &content_data);
- printf("Content Data: %s \n",content_data);
+
+ if ( nlsr->debugging )
+ printf("Content Data: %s \n",content_data);
process_incoming_sync_content_lsa(content_data);
}
else
{
-
- printf("Adj LSA / Newer Adj LSA already exists in LSDB\n");
+ if ( nlsr->debugging )
+ printf("Adj LSA / Newer Adj LSA already exists in LSDB\n");
get_content_by_content_name(ccn_charbuf_as_string(uri), &content_data);
- printf("Content Data: %s \n",content_data);
+ if ( nlsr->debugging )
+ printf("Content Data: %s \n",content_data);
}
}
else
{
- printf("Lsa is older than Router LSA refresh time/ Dead Interval\n");
+ if ( nlsr->debugging )
+ printf("Lsa is older than Router LSA refresh time/ Dead Interval\n");
}
}