Tuning
diff --git a/nlsr-sync-0.0/nlsr.c b/nlsr-sync-0.0/nlsr.c
index 6faf6cc..d25fb9d 100755
--- a/nlsr-sync-0.0/nlsr.c
+++ b/nlsr-sync-0.0/nlsr.c
@@ -1216,8 +1216,13 @@
init_api_server(ccn_fd);
- create_sync_slice(nlsr->topo_prefix, nlsr->slice_prefix);
-
+ res=create_sync_slice(nlsr->topo_prefix, nlsr->slice_prefix);
+ if(res<0)
+ {
+ fprintf(stderr, "Can not create slice for prefix %s\n",nlsr->slice_prefix);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__,"Can not create slice for prefix %s\n",nlsr->slice_prefix);
+ ON_ERROR_DESTROY(res);
+ }
struct ccn_charbuf *router_prefix;
router_prefix=ccn_charbuf_create();
res=ccn_name_from_uri(router_prefix,nlsr->router_name);
diff --git a/nlsr-sync-0.0/nlsr_lsdb.c b/nlsr-sync-0.0/nlsr_lsdb.c
index 87f2b9e..70c6111 100755
--- a/nlsr-sync-0.0/nlsr_lsdb.c
+++ b/nlsr-sync-0.0/nlsr_lsdb.c
@@ -63,7 +63,7 @@
memcpy(key+strlen(key),lsid,strlen(lsid));
if ( nlsr->debugging )
- printf("%s\n", key);
+ printf("name LSA Key: %s\n", key);
}
@@ -73,7 +73,7 @@
sprintf(key,"%s/%d/%ld/%s%s",slice_prefix, ls_type, ls_id, orig_time, orig_router);
if ( nlsr->debugging )
- printf("%s\n",key);
+ printf("Name LSA prefix for repo content: %s\n",key);
}
void
@@ -83,7 +83,7 @@
sprintf(key,"%s/%d/%s%s",slice_prefix,ls_type, orig_time, orig_router);
if ( nlsr->debugging )
- printf("Key:%s\n",key);
+ printf("Name LSA prefix for repo content:%s\n",key);
}
void
@@ -191,9 +191,6 @@
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);
-
- //printf("time difference: %ld \n",lsa_life_time);
char lst[2];
@@ -1424,8 +1421,7 @@
if( res == HT_OLD_ENTRY )
{
name_lsa=e->data;
- //printf("NAME LSA found\n");
-
+
if ( nlsr->debugging )
printf("NAME LSA found \n");
if ( nlsr->detailed_logging )
@@ -1504,7 +1500,6 @@
if( res == HT_OLD_ENTRY )
{
adj_lsa=e->data;
- //printf("Adj LSA found\n");
if ( nlsr->debugging )
printf("Adj LSA found \n");
@@ -1518,15 +1513,15 @@
memset(temp_length,0,20);
sprintf(temp_length,"%d",adj_lsa->header->orig_router->length);
ccn_charbuf_append_string(lsa_data,temp_length);
- free(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);
- free(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,"|");
@@ -1535,8 +1530,8 @@
memset(temp_nl,0,20);
sprintf(temp_nl,"%d",adj_lsa->no_link);
ccn_charbuf_append_string(lsa_data,temp_nl);
- free(temp_nl);
ccn_charbuf_append_string(lsa_data,"|");
+ free(temp_nl);
ccn_charbuf_append_string(lsa_data,adj_lsa->body);
diff --git a/nlsr-sync-0.0/nlsr_sync.c b/nlsr-sync-0.0/nlsr_sync.c
index 2a77331..094180f 100644
--- a/nlsr-sync-0.0/nlsr_sync.c
+++ b/nlsr-sync-0.0/nlsr_sync.c
@@ -66,8 +66,12 @@
else
ccn_charbuf_append_string(uri, "(null)");
+ //if ( nlsr->debugging )
+ //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);
+ printf("Response from sync in the name: %s \n",ccn_charbuf_as_string(uri));
+
fflush(stdout);
free(hexL);
free(hexR);
@@ -83,6 +87,7 @@
process_content_from_sync(name,components);
+
return(0);
@@ -320,8 +325,6 @@
if ( nlsr->debugging )
printf("LSA Data \n");
- //if ( nlsr->detailed_logging )
- // writeLogg(__FILE__,__FUNCTION__,__LINE__,"LSA Data\n");
if( strlen((char *)content_data ) > 0 )
{
@@ -563,7 +566,7 @@
return(templ);
}
-void
+int
write_data_to_repo(char *data, char *name_prefix)
{
if ( nlsr->debugging )
@@ -587,14 +590,16 @@
res = ccn_name_from_uri(name, name_prefix);
if (res < 0) {
fprintf(stderr, "bad CCN URI: %s\n",name_prefix);
- exit(1);
+ //exit(1);
+ return -1;
}
w = ccn_seqw_create(nlsr->ccn, name);
if (w == NULL) {
fprintf(stderr, "ccn_seqw_create failed\n");
- exit(1);
+ //exit(1);
+ return -1;
}
ccn_seqw_set_block_limits(w, blocksize, blocksize);
if (freshness > -1)
@@ -610,7 +615,8 @@
ccn_charbuf_destroy(&name_v);
if (res < 0) {
fprintf(stderr, "No response from repository\n");
- exit(1);
+ //exit(1);
+ return -1;
}
}
@@ -634,6 +640,8 @@
ccn_seqw_close(w);
//ccn_run(nlsr->ccn, 1);
ccn_charbuf_destroy(&name);
+
+ return 0;
}
@@ -651,7 +659,8 @@
if (prefix == NULL || topo == NULL || clause == NULL ||
slice_name == NULL || slice_uri == NULL) {
fprintf(stderr, "Unable to allocate required memory.\n");
- exit(1);
+ //exit(1);
+ return -1;
}
diff --git a/nlsr-sync-0.0/nlsr_sync.h b/nlsr-sync-0.0/nlsr_sync.h
index ef9d342..68fc767 100644
--- a/nlsr-sync-0.0/nlsr_sync.h
+++ b/nlsr-sync-0.0/nlsr_sync.h
@@ -2,7 +2,7 @@
#define _NLSR_SYNC_H_
void sync_monitor(char *topo_prefix, char *slice_prefix);
-void write_data_to_repo(char *data,char *name_prefix);
+int write_data_to_repo(char *data,char *name_prefix);
int create_sync_slice(char *topo_prefix, char *slice_prefix);
void get_host_name_from_command_string(struct name_prefix *name_part,char *nbr_name_uri, int offset);
void process_content_from_sync(struct ccn_charbuf *content_name, struct ccn_indexbuf *components);