Removed Face in Adj LSA and Schedule Event for deleting Items
diff --git a/nlsr.c b/nlsr.c
index 1d16b4c..07b3175 100644
--- a/nlsr.c
+++ b/nlsr.c
@@ -1125,8 +1125,11 @@
close(nlsr->nlsr_api_server_sock_fd);
ccn_schedule_destroy(&nlsr->sched);
- ccn_destroy(&nlsr->ccn);
+ ccns_close(&nlsr->ccns,NULL, NULL);
+ ccns_slice_destroy(&nlsr->slice);
+
+ ccn_destroy(&nlsr->ccn);
free(nlsr->lsdb->lsdb_version);
free(nlsr->lsdb);
free(nlsr->router_name);
@@ -1366,8 +1369,8 @@
print_adjacent_from_adl();
build_and_install_name_lsas();
- sync_monitor(nlsr->topo_prefix,nlsr->slice_prefix);
-
+ res=sync_monitor(nlsr->topo_prefix,nlsr->slice_prefix);
+ ON_ERROR_DESTROY(res);
print_name_lsdb();
if ( nlsr->cor_r != -1.0 && nlsr->cor_theta != -1.0)
diff --git a/nlsr_adl.c b/nlsr_adl.c
index 6e96d7b..ad6254d 100644
--- a/nlsr_adl.c
+++ b/nlsr_adl.c
@@ -535,12 +535,13 @@
free(temp_length);
ccn_charbuf_append_string(c,"|");
- char *temp_face=(char *)malloc(20);
+ /*char *temp_face=(char *)malloc(20);
memset(temp_face,0,20);
sprintf(temp_face,"%d",nbr->face);
ccn_charbuf_append_string(c,temp_face);
free(temp_face);
ccn_charbuf_append_string(c,"|");
+ */
char *temp_metric=(char *)malloc(20);
memset(temp_metric,0,20);
diff --git a/nlsr_lsdb.c b/nlsr_lsdb.c
index e465457..ac184da 100644
--- a/nlsr_lsdb.c
+++ b/nlsr_lsdb.c
@@ -956,13 +956,13 @@
{
rtr_id=strtok_r(lsa_data,sep,&rem);
length=strtok_r(NULL,sep,&rem);
- face=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__," Adjacent Router: %s \n",rtr_id);
writeLogg(__FILE__,__FUNCTION__,__LINE__," Adjacent Router Length: %s \n",length);
- writeLogg(__FILE__,__FUNCTION__,__LINE__," Connecting Face: %s \n",face);
+ //writeLogg(__FILE__,__FUNCTION__,__LINE__," Connecting Face: %s \n",face);
writeLogg(__FILE__,__FUNCTION__,__LINE__," Metric: %s \n",metric);
@@ -975,7 +975,7 @@
writeLogg(__FILE__,__FUNCTION__,__LINE__," Link %d \n",i+1);
writeLogg(__FILE__,__FUNCTION__,__LINE__," Adjacent Router: %s \n",rtr_id);
writeLogg(__FILE__,__FUNCTION__,__LINE__," Adjacent Router Length: %s \n",length);
- writeLogg(__FILE__,__FUNCTION__,__LINE__," Connecting Face: %s \n",face);
+ //writeLogg(__FILE__,__FUNCTION__,__LINE__," Connecting Face: %s \n",face);
writeLogg(__FILE__,__FUNCTION__,__LINE__," Metric: %s \n",metric);
}
@@ -1020,14 +1020,14 @@
{
rtr_id=strtok_r(lsa_data,sep,&rem);
length=strtok_r(NULL,sep,&rem);
- face=strtok_r(NULL,sep,&rem);
+ //face=strtok_r(NULL,sep,&rem);
metric=strtok_r(NULL,sep,&rem);
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(" Connecting Face : %s \n",face);
printf(" Metric : %s \n",metric);
}
@@ -1040,7 +1040,7 @@
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(" Connecting Face : %s \n",face);
printf(" Metric : %s \n",metric);
}
@@ -1526,15 +1526,17 @@
}
-int
-delete_name_lsa(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
+//int
+//delete_name_lsa(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
+int
+delete_name_lsa(char *orig_router, char *name_prefix)
{
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)
{
return -1;
@@ -1562,8 +1564,9 @@
if( res == HT_OLD_ENTRY )
{
nlsa=e->data;
- delete_npt_entry_by_router_and_name_prefix(nlsa->header->orig_router->name, nlsa->name_prefix->name);
-
+ */
+ delete_npt_entry_by_router_and_name_prefix(orig_router, name_prefix);
+ /*
writeLogg(__FILE__,__FUNCTION__,__LINE__," Name-LSA\n");
writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting name lsa\n");
write_log_for_name_lsa(nlsa);
@@ -1576,6 +1579,7 @@
hashtb_delete(e);
}
hashtb_end(e);
+ */
if ( nlsr->debugging )
printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
@@ -1589,19 +1593,22 @@
if ( nlsr->detailed_logging )
writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
- nlsr_unlock();
+ //nlsr_unlock();
return 0;
}
-int
-delete_adj_lsa(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
+//int
+//delete_adj_lsa(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
+int delete_adj_lsa()
{
+
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)
{
return -1;
@@ -1636,6 +1643,7 @@
hashtb_delete(e);
}
hashtb_end(e);
+ */
if ( nlsr->debugging )
printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
@@ -1656,7 +1664,7 @@
nlsr->is_route_calculation_scheduled=1;
}
- nlsr_unlock();
+ //nlsr_unlock();
return 0;
}
@@ -1726,9 +1734,11 @@
writeLogg(__FILE__,__FUNCTION__,__LINE__," name_lsa_end\n");
free(current_time_stamp);
+
+ hashtb_next(e);
}
else
- {
+ { /*
char lst[2];
memset(lst,0,2);
sprintf(lst,"%d",name_lsa->header->ls_type);
@@ -1737,7 +1747,7 @@
memset(lsid,0,10);
sprintf(lsid,"%ld",name_lsa->header->ls_id);
-
+
char *key=(char *)malloc(strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1);
memset(key,0,strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1);
@@ -1745,6 +1755,14 @@
make_name_lsa_key(key, name_lsa->header->orig_router->name,name_lsa->header->ls_type,name_lsa->header->ls_id);
nlsr->event = ccn_schedule_event(nlsr->sched, 10, &delete_name_lsa, (void *)key, 0);
+ */
+ delete_name_lsa(name_lsa->header->orig_router->name, name_lsa->name_prefix->name);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," Name-LSA\n");
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting name lsa\n");
+ write_log_for_name_lsa(name_lsa);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," name_lsa_end\n");
+ hashtb_delete(e);
+ i++;
}
if ( nlsr->debugging )
@@ -1762,6 +1780,10 @@
print_name_lsdb();
+ }
+ else
+ {
+ hashtb_next(e);
}
}
else
@@ -1773,7 +1795,7 @@
if ( nlsr->detailed_logging )
writeLogg(__FILE__,__FUNCTION__,__LINE__,"Others Name LSA need to be deleted\n");
- char lst[2];
+ /*char lst[2];
memset(lst,0,2);
sprintf(lst,"%d",name_lsa->header->ls_type);
@@ -1789,10 +1811,24 @@
make_name_lsa_key(key, name_lsa->header->orig_router->name,name_lsa->header->ls_type,name_lsa->header->ls_id);
nlsr->event = ccn_schedule_event(nlsr->sched, 10, &delete_name_lsa, (void *)key, 0);
+ */
+ delete_name_lsa(name_lsa->header->orig_router->name, name_lsa->name_prefix->name);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," Name-LSA\n");
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting name lsa\n");
+ write_log_for_name_lsa(name_lsa);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," name_lsa_end\n");
+ hashtb_delete(e);
+ i++;
+ }
+ else
+ {
+ hashtb_next(e);
}
}
-
- hashtb_next(e);
+ /*else
+ {
+ hashtb_next(e);
+ }*/
}
hashtb_end(e);
@@ -1880,7 +1916,11 @@
writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
print_adj_lsdb();
+
+
}
+
+ hashtb_next(e);
}
else
{
@@ -1891,18 +1931,32 @@
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);
nlsr->event = ccn_schedule_event(nlsr->sched, 10, &delete_adj_lsa, (void *)key, 0);
+ */
+
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," Adj-LSA\n");
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting adj lsa\n");
+ write_log_for_adj_lsa(adj_lsa);
+ writeLogg(__FILE__,__FUNCTION__,__LINE__," adj_lsa_end\n");
+ delete_adj_lsa();
+ hashtb_delete(e);
+ i++;
+
+ }
+ else
+ {
+ hashtb_next(e);
}
}
- hashtb_next(e);
+ //hashtb_next(e);
}
hashtb_end(e);
@@ -1989,7 +2043,9 @@
writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
print_adj_lsdb();
- }
+ }
+
+ hashtb_next(e);
}
else
{
@@ -2004,11 +2060,14 @@
hashtb_delete(e);
i++;
}
+ else
+ {
+ hashtb_next(e);
+ }
}
-
- hashtb_next(e);
+
}
hashtb_end(e);
diff --git a/nlsr_route.c b/nlsr_route.c
index 573fcf9..b4f70a4 100644
--- a/nlsr_route.c
+++ b/nlsr_route.c
@@ -553,14 +553,14 @@
char *rem;
char *rtr_id;
char *length;
- char *face;
+ //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);
+ //face=strtok_r(NULL,sep,&rem);
metric=strtok_r(NULL,sep,&rem);
add_map_entry(rtr_id);
@@ -569,7 +569,7 @@
{
rtr_id=strtok_r(NULL,sep,&rem);
length=strtok_r(NULL,sep,&rem);
- face=strtok_r(NULL,sep,&rem);
+ //face=strtok_r(NULL,sep,&rem);
metric=strtok_r(NULL,sep,&rem);
add_map_entry(rtr_id);
@@ -714,14 +714,14 @@
char *rem;
char *rtr_id;
char *length;
- char *face;
+ //char *face;
char *metric;
if(adj_lsa->no_link >0 )
{
rtr_id=strtok_r(lsa_data,sep,&rem);
length=strtok_r(NULL,sep,&rem);
- face=strtok_r(NULL,sep,&rem);
+ //face=strtok_r(NULL,sep,&rem);
metric=strtok_r(NULL,sep,&rem);
mapping_nbr_router=get_mapping_no(rtr_id);
@@ -731,7 +731,7 @@
{
rtr_id=strtok_r(NULL,sep,&rem);
length=strtok_r(NULL,sep,&rem);
- face=strtok_r(NULL,sep,&rem);
+ //face=strtok_r(NULL,sep,&rem);
metric=strtok_r(NULL,sep,&rem);
mapping_nbr_router=get_mapping_no(rtr_id);
@@ -961,14 +961,14 @@
char *rem;
char *rtr_id;
char *length;
- char *face;
+ //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);
+ //face=strtok_r(NULL,sep,&rem);
metric=strtok_r(NULL,sep,&rem);
@@ -978,7 +978,7 @@
{
rtr_id=strtok_r(NULL,sep,&rem);
length=strtok_r(NULL,sep,&rem);
- face=strtok_r(NULL,sep,&rem);
+ //face=strtok_r(NULL,sep,&rem);
metric=strtok_r(NULL,sep,&rem);
add_next_hop_router(rtr_id);
@@ -1115,7 +1115,7 @@
writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");
}
-
+/*
int
delete_empty_rte(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
{
@@ -1158,6 +1158,7 @@
return 0;
}
+*/
void
clear_old_routing_table(void)
@@ -1216,12 +1217,19 @@
if ( mapping_no == NO_MAPPING_NUM)
{
delete_orig_router_from_npt(rte->dest_router);
+ /*
char *router=(char *)malloc(strlen(rte->dest_router)+1);
memset(router,0,strlen(rte->dest_router)+1);
memcpy(router,rte->dest_router,strlen(rte->dest_router)+1);
nlsr->event = ccn_schedule_event(nlsr->sched, 1, &delete_empty_rte, (void *)router , 0);
+ */
+ hashtb_delete(e);
+ i++;
}
- hashtb_next(e);
+ else
+ {
+ hashtb_next(e);
+ }
}
hashtb_end(e);
diff --git a/nlsr_sync.c b/nlsr_sync.c
index 2804ee8..75c8017 100644
--- a/nlsr_sync.c
+++ b/nlsr_sync.c
@@ -626,14 +626,14 @@
}
}
- if (content_data != NULL)
- free(content_data);
+ //if (content_data != NULL)
+ //free(content_data);
ccn_charbuf_destroy(&uri);
//01/31/2013
free(time_stamp);
}
-void
+int
sync_monitor(char *topo_prefix, char *slice_prefix)
{
@@ -661,6 +661,8 @@
//01/31/2013
ccn_charbuf_destroy(&prefix);
ccn_charbuf_destroy(&topo);
+ ccn_charbuf_destroy(&roothash);
+ return 0;
}
struct ccn_charbuf *
@@ -767,6 +769,7 @@
create_sync_slice(char *topo_prefix, char *slice_prefix)
{
int res;
+ struct ccn *handle;
struct ccns_slice *slice;
struct ccn_charbuf *prefix = ccn_charbuf_create();
struct ccn_charbuf *topo = ccn_charbuf_create();
@@ -780,7 +783,13 @@
return -1;
}
-
+ handle = ccn_create();
+ res = ccn_connect(handle, NULL);
+ if (0 > res) {
+ fprintf(stderr, "Unable to connect to ccnd.\n");
+ return -1;
+ }
+
slice = ccns_slice_create();
ccn_charbuf_reset(topo);
@@ -790,10 +799,11 @@
ccns_slice_set_topo_prefix(slice, topo, prefix);
- res = ccns_write_slice(nlsr->ccn, slice, slice_name);
+ res = ccns_write_slice(handle, slice, slice_name);
//01/31/2013
ccns_slice_destroy(&slice);
+ ccn_destroy(&handle);
ccn_charbuf_destroy(&prefix);
ccn_charbuf_destroy(&topo);
ccn_charbuf_destroy(&clause);
diff --git a/nlsr_sync.h b/nlsr_sync.h
index 68fc767..d2fe9e5 100644
--- a/nlsr_sync.h
+++ b/nlsr_sync.h
@@ -1,7 +1,7 @@
#ifndef _NLSR_SYNC_H_
#define _NLSR_SYNC_H_
-void sync_monitor(char *topo_prefix, char *slice_prefix);
+int sync_monitor(char *topo_prefix, char *slice_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);