Key Management Update
diff --git a/nlsr.c b/nlsr.c
index 6ca3c40..c63aa9e 100644
--- a/nlsr.c
+++ b/nlsr.c
@@ -282,35 +282,6 @@
}
-/*
- void
- process_command_lsdb_synch_interval(char *command)
- {
- if(command==NULL)
- {
- printf(" Wrong Command Format ( lsdb-synch-interval secs )\n");
- return;
- }
- char *rem;
- const char *sep=" \t\n";
- char *secs;
- long int seconds;
-
- secs=strtok_r(command,sep,&rem);
- if(secs==NULL)
- {
- printf(" Wrong Command Format ( lsdb-synch-interval secs)\n");
- return;
- }
-
- seconds=atoi(secs);
- if ( seconds >= 120 && seconds <= 3600 )
- {
- nlsr->lsdb_synch_interval=seconds;
- }
-
- }
- */
void
process_command_interest_retry(char *command)
@@ -954,9 +925,9 @@
(const char *)nbr->ip_address, 9695,nlsr->tunnel_type);
update_face_to_adl_for_nbr(nbr->neighbor->name, face_id);
add_delete_ccn_face_by_face_id(nlsr->ccn,
- (const char *)nlsr->topo_prefix, OP_REG, face_id);
+ (const char *)nlsr->topo_prefix, OP_REG, face_id,(~0U) >> 1);
add_delete_ccn_face_by_face_id(nlsr->ccn,
- (const char *)nlsr->slice_prefix, OP_REG, face_id);
+ (const char *)nlsr->slice_prefix, OP_REG, face_id,(~0U) >> 1);
hashtb_next(e);
}
@@ -982,11 +953,11 @@
if ( nbr->face > 0 )
{
add_delete_ccn_face_by_face_id(nlsr->ccn,
- (const char *)nlsr->topo_prefix, OP_UNREG, nbr->face);
+ (const char *)nlsr->topo_prefix, OP_UNREG, nbr->face,(~0U) >> 1);
add_delete_ccn_face_by_face_id(nlsr->ccn,
- (const char *)nbr->neighbor->name,OP_UNREG,nbr->face);
+ (const char *)nbr->neighbor->name,OP_UNREG,nbr->face,(~0U) >> 1);
add_delete_ccn_face_by_face_id(nlsr->ccn,
- (const char *)nlsr->slice_prefix, OP_UNREG, nbr->face);
+ (const char *)nlsr->slice_prefix, OP_UNREG, nbr->face,(~0U) >> 1);
}
hashtb_next(e);
}
@@ -1078,9 +1049,9 @@
{
update_adjacent_status_to_adl(np,NBR_DOWN);
int face_id=get_next_hop_face_from_adl(np->name);
- add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)np->name, OP_UNREG, face_id);
- add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nlsr->topo_prefix, OP_UNREG, face_id);
- add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nlsr->slice_prefix, OP_UNREG, face_id);
+ add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)np->name, OP_UNREG, face_id,(~0U) >> 1);
+ add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nlsr->topo_prefix, OP_UNREG, face_id,(~0U) >> 1);
+ add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nlsr->slice_prefix, OP_UNREG, face_id,(~0U) >> 1);
delete_nbr_from_adl(np);
if(!nlsr->is_build_adj_lsa_sheduled)
{
@@ -1105,8 +1076,8 @@
printf("IP Address: %s \n",ip_addr);
int face_id=add_ccn_face(nlsr->ccn, (const char *)nbr_name->name, (const char *)ip_addr, 9695,nlsr->tunnel_type);
update_face_to_adl_for_nbr(nbr_name->name, face_id);
- add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nlsr->topo_prefix, OP_REG, face_id);
- add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nlsr->slice_prefix, OP_REG, face_id);
+ add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nlsr->topo_prefix, OP_REG, face_id,(~0U) >> 1);
+ add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nlsr->slice_prefix, OP_REG, face_id,(~0U) >> 1);
add_nbr_to_adl(np,face_id,ip_addr);
diff --git a/nlsr_face.c b/nlsr_face.c
index 708fab7..6a7e48c 100644
--- a/nlsr_face.c
+++ b/nlsr_face.c
@@ -100,7 +100,7 @@
forwarding_entry->ccnd_id_size = face_instance->ccnd_id_size;
forwarding_entry->faceid = face_instance->faceid;
forwarding_entry->flags = -1;
- forwarding_entry->lifetime = 2100;
+ forwarding_entry->lifetime = (~0U) >> 1;
prefixreg = ccn_charbuf_create();
ccnb_append_forwarding_entry(prefixreg, forwarding_entry);
diff --git a/nlsr_fib.c b/nlsr_fib.c
index 6ef81cb..a83899d 100644
--- a/nlsr_fib.c
+++ b/nlsr_fib.c
@@ -50,7 +50,9 @@
static int
register_unregister_prefix(struct ccn *h, struct ccn_charbuf *local_scope_template,
- struct ccn_charbuf *no_name, struct ccn_charbuf *name_prefix,const unsigned char *ccndid, size_t ccnd_id_size, int faceid, int operation)
+ struct ccn_charbuf *no_name, struct ccn_charbuf *name_prefix,
+ const unsigned char *ccndid, size_t ccnd_id_size, int faceid,
+ int operation, long int lifetime)
{
struct ccn_charbuf *temp = NULL;
struct ccn_charbuf *resultbuf = NULL;
@@ -72,7 +74,7 @@
forwarding_entry->ccnd_id_size =ccnd_id_size;
forwarding_entry->faceid = faceid;
forwarding_entry->flags = -1;
- forwarding_entry->lifetime = 2100;
+ forwarding_entry->lifetime = lifetime;
prefixreg = ccn_charbuf_create();
ccnb_append_forwarding_entry(prefixreg, forwarding_entry);
@@ -180,7 +182,7 @@
}
int
-add_delete_ccn_face_by_face_id(struct ccn *h, const char *uri, int operation, int faceid)
+add_delete_ccn_face_by_face_id(struct ccn *h, const char *uri, int operation, int faceid, long int lifetime)
{
if ( nlsr->debugging )
{
@@ -210,7 +212,7 @@
ON_ERROR_CLEANUP(-1);
}
- res = register_unregister_prefix(h, local_scope_template, no_name, prefix,ccndid, ccndid_size,faceid, operation);
+ res = register_unregister_prefix(h, local_scope_template, no_name, prefix,ccndid, ccndid_size,faceid, operation,lifetime);
ON_ERROR_CLEANUP(res);
diff --git a/nlsr_fib.h b/nlsr_fib.h
index ce5e6d1..544a943 100644
--- a/nlsr_fib.h
+++ b/nlsr_fib.h
@@ -6,6 +6,7 @@
#define OP_REG 0
#define OP_UNREG 1
-int add_delete_ccn_face_by_face_id(struct ccn *h, const char *uri, int operation, int faceid);
+int add_delete_ccn_face_by_face_id(struct ccn *h, const char *uri, int operation,
+ int faceid, long int lifetime);
#endif
diff --git a/nlsr_lsdb.c b/nlsr_lsdb.c
index 235f826..d08cb69 100644
--- a/nlsr_lsdb.c
+++ b/nlsr_lsdb.c
@@ -2348,10 +2348,10 @@
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
+ new_cor_lsa->header->orig_time=(char *)calloc(strlen(cor_lsa->header->orig_time)+1,sizeof(char)); //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->orig_time=get_current_timestamp_micro_v2();
+ memcpy(new_cor_lsa->header->orig_time,cor_lsa->header->orig_time,strlen(cor_lsa->header->orig_time)+1);
+ //new_cor_lsa->header->orig_time=get_current_timestamp_micro_v2();
new_cor_lsa->header->ls_type=cor_lsa->header->ls_type;
diff --git a/nlsr_npt.c b/nlsr_npt.c
index 48577cb..00728cd 100644
--- a/nlsr_npt.c
+++ b/nlsr_npt.c
@@ -250,7 +250,7 @@
if ( !( is_neighbor(nle->name) == 1 && get_next_hop_face_from_adl(nle->name) == faces[j] ) )
{
- add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, faces[j]);
+ add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, faces[j],nlsr->router_dead_interval);
}
}
@@ -284,7 +284,7 @@
printf("Adding face: Name:%s Face: %d\n",nle->name,faces[j]);
if ( nlsr->detailed_logging )
writeLogg(__FILE__,__FUNCTION__,__LINE__,"Adding face: Name:%s Face: %d\n",nle->name,faces[j]);
- add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_REG, faces[j]);
+ add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_REG, faces[j],nlsr->router_dead_interval);
}
else
{
@@ -294,7 +294,7 @@
printf("Adding face: Name:%s Face: %d\n",nle->name,faces[j]);
if ( nlsr->detailed_logging )
writeLogg(__FILE__,__FUNCTION__,__LINE__,"Adding face: Name:%s Face: %d\n",nle->name,faces[j]);
- add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_REG, faces[j]);
+ add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_REG, faces[j],nlsr->router_dead_interval);
}
}
}
@@ -394,7 +394,7 @@
printf("Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);
if ( nlsr->detailed_logging )
writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);
- add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, faces[j]);
+ add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, faces[j],nlsr->router_dead_interval);
}
else
{
@@ -404,7 +404,7 @@
printf("Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);
if ( nlsr->detailed_logging )
writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);
- add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, faces[j]);
+ add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, faces[j],nlsr->router_dead_interval);
}
}
@@ -816,7 +816,7 @@
printf("Deleting face: Name:%s Face: %d\n",nle->name,fle->next_hop_face);
if ( nlsr->detailed_logging )
writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,fle->next_hop_face);
- add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, fle->next_hop_face);
+ add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, fle->next_hop_face,nlsr->router_dead_interval);
}
@@ -847,7 +847,7 @@
printf("Deleting face: Name:%s Face: %d\n",nle->name,fle->next_hop_face);
if ( nlsr->detailed_logging )
writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,fle->next_hop_face);
- add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, fle->next_hop_face);
+ add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, fle->next_hop_face,nlsr->router_dead_interval);
}
@@ -1038,7 +1038,7 @@
printf("Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);
if ( nlsr->detailed_logging )
writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);
- add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, faces[j]);
+ add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, faces[j],nlsr->router_dead_interval);
}
else
{
@@ -1048,7 +1048,7 @@
printf("Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);
if ( nlsr->detailed_logging )
writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);
- add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, faces[j]);
+ add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, faces[j],nlsr->router_dead_interval);
}
}
}
diff --git a/nlsr_sync.c b/nlsr_sync.c
index 80b0175..4ae6c82 100644
--- a/nlsr_sync.c
+++ b/nlsr_sync.c
@@ -53,6 +53,7 @@
struct ccn_charbuf *rhash,
struct ccn_charbuf *name)
{
+ nlsr_lock();
int res;
struct ccn_charbuf *content_name;
struct ccn_indexbuf *content_comps;
@@ -113,6 +114,7 @@
ccn_indexbuf_destroy(&content_comps);
ccn_indexbuf_destroy(&name_comps);
+ nlsr_unlock();
return(0);
}
@@ -460,10 +462,8 @@
if ( nlsr->debugging )
printf("LSA Life time: %d\n",lsa_life_time);
- if ( (strcmp(orig_router->name,nlsr->router_name) == 0 &&
- lsa_life_time < nlsr->lsa_refresh_time)
- || (strcmp(orig_router->name,nlsr->router_name) != 0
- && lsa_life_time < nlsr->router_dead_interval) )
+ if ( strcmp(orig_router->name,nlsr->router_name) != 0
+ && (lsa_life_time < nlsr->router_dead_interval) )
{
int is_new_name_lsa=check_is_new_name_lsa(orig_router->name,
(char *)lst,(char *)lsid,(char *)origtime);
@@ -526,10 +526,8 @@
if ( nlsr->debugging )
printf("LSA Life time: %d\n",lsa_life_time);
- if ( (strcmp(orig_router->name,nlsr->router_name) == 0 &&
- lsa_life_time < nlsr->lsa_refresh_time) ||
- (strcmp(orig_router->name,nlsr->router_name) != 0 &&
- lsa_life_time < nlsr->router_dead_interval) )
+ if ( strcmp(orig_router->name,nlsr->router_name) != 0
+ && (lsa_life_time < nlsr->router_dead_interval) )
{
int is_new_adj_lsa = check_is_new_adj_lsa( orig_router->name,
(char *)lst, (char *)origtime);
@@ -588,10 +586,8 @@
if ( nlsr->debugging )
printf("LSA Life time: %d\n",lsa_life_time);
- if ( (strcmp(orig_router->name,nlsr->router_name) == 0 &&
- lsa_life_time < nlsr->lsa_refresh_time) ||
- (strcmp(orig_router->name,nlsr->router_name) != 0 &&
- lsa_life_time < nlsr->router_dead_interval) )
+ if ( strcmp(orig_router->name,nlsr->router_name) != 0
+ && (lsa_life_time < nlsr->router_dead_interval) )
{
int is_new_cor_lsa=check_is_new_cor_lsa( orig_router->name,
(char *)lst,(char *) origtime);
@@ -692,6 +688,8 @@
int
write_data_to_repo(char *data, char *name_prefix)
{
+
+ nlsr_lock();
if ( nlsr->debugging )
{
printf("write_data_to_repo called\n");
@@ -781,6 +779,7 @@
ccn_destroy(&temp_ccn);
ccn_charbuf_destroy(&resultbuf);
+ nlsr_unlock();
return 0;
}
int