Configuration Command, Commenting, and Trailing / removal added
diff --git a/macbook.conf b/macbook.conf
index dfc274e..0e61f98 100644
--- a/macbook.conf
+++ b/macbook.conf
@@ -1,8 +1,13 @@
-router-name /ndn/memphis.edu/netlab/macbook
-ccnneighbor /ndn/memphis.edu/dunhall/castor face9
-ccnneighbor /ndn/memphis.edu/joneshall/mira face11
+#----configuration file for macbook----------
+#
+router-name /ndn/memphis.edu/netlab/macbook/
+ccnneighbor /ndn/memphis.edu/dunhall/castor face14
+ccnneighbor /ndn/memphis.edu/joneshall/mira/ face11
ccnname /ndn/memphis.edu/patterson
-ccnname /ndn/memphis.edu/houston
+ccnname /ndn/memphis.edu/houston/
+#------lsdb-synch-interval-----
lsdb-synch-interval 350
interest-retry 4
interest-resend-time 5
+lsa-refresh-time 600
+router-dead-interval 900
diff --git a/nlsr.c b/nlsr.c
index 477b202..fc5320d 100644
--- a/nlsr.c
+++ b/nlsr.c
@@ -139,6 +139,10 @@
return;
}
+ if ( rtr_name[strlen(rtr_name)-1] == '/' )
+ {
+ rtr_name[strlen(rtr_name)-1]='\0';
+ }
struct name_prefix *nbr=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
nbr->name=(char *)malloc(strlen(rtr_name)+1);
memset(nbr->name,0,strlen(rtr_name)+1);
@@ -172,6 +176,9 @@
printf("Name Prefix: %s \n",name);
+ if ( name[strlen(name)-1] == '/' )
+ name[strlen(name)-1]='\0';
+
struct name_prefix *np=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
np->name=(char *)malloc(strlen(name)+1);
memset(np->name,0,strlen(name)+1);
@@ -205,6 +212,9 @@
}
+ if ( rtr_name[strlen(rtr_name)-1] == '/' )
+ rtr_name[strlen(rtr_name)-1]='\0';
+
nlsr->router_name=(char *)malloc(strlen(rtr_name)+1);
memset(nlsr->router_name,0,strlen(rtr_name)+1);
memcpy(nlsr->router_name,rtr_name,strlen(rtr_name)+1);
@@ -297,6 +307,61 @@
}
+void
+process_command_lsa_refresh_time(char *command)
+{
+ if(command==NULL)
+ {
+ printf(" Wrong Command Format ( lsa-refresh-time 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 ( lsa-refresh-time secs)\n");
+ return;
+ }
+
+ seconds=atoi(secs);
+ if ( seconds >= 240 && seconds <= 3600 )
+ {
+ nlsr->lsa_refresh_time=seconds;
+ }
+
+}
+
+void
+process_command_router_dead_interval(char *command)
+{
+ if(command==NULL)
+ {
+ printf(" Wrong Command Format ( router-dead-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 ( router-dead-interval secs)\n");
+ return;
+ }
+
+ seconds=atoi(secs);
+ if ( seconds >= 360 && seconds <= 5400 )
+ {
+ nlsr->router_dead_interval=seconds;
+ }
+
+}
void
process_conf_command(char *command)
@@ -334,7 +399,15 @@
{
process_command_interest_resend_time(remainder);
}
- else
+ else if(!strcmp(cmd_type,"lsa-refresh-time") )
+ {
+ process_command_lsa_refresh_time(remainder);
+ }
+ else if(!strcmp(cmd_type,"router-dead-interval") )
+ {
+ process_command_router_dead_interval(remainder);
+ }
+ else
{
printf("Wrong configuration Command %s \n",cmd_type);
}
@@ -361,7 +434,8 @@
len=strlen(buf);
if(buf[len-1] == '\n')
buf[len-1]='\0';
- process_conf_command(buf);
+ if ( buf[0] != '#' && buf[0] != '!')
+ process_conf_command(buf);
}
fclose(cfg);
diff --git a/nlsr.h b/nlsr.h
index 941e357..719e91a 100644
--- a/nlsr.h
+++ b/nlsr.h
@@ -7,8 +7,8 @@
#define INTEREST_RESEND_TIME 15
#define NLSR_LOCKED 1
#define NLSR_UNLOCKED 0
-#define LSA_REFRESH_TIME 600
-#define ROUTER_DEAD_INTERVAL 900
+#define LSA_REFRESH_TIME 1800
+#define ROUTER_DEAD_INTERVAL 3600
#define LINK_METRIC 10
diff --git a/nlsr_lsdb.c b/nlsr_lsdb.c
index 49b033f..0a88b5e 100644
--- a/nlsr_lsdb.c
+++ b/nlsr_lsdb.c
@@ -204,6 +204,9 @@
printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
int next_hop=get_next_hop(new_name_lsa->header->orig_router->name);
+
+ //printf("Next hop: %d \n",next_hop);
+
if ( next_hop == NO_NEXT_HOP )
{
int check=add_npt_entry(new_name_lsa->header->orig_router->name,new_name_lsa->name_prefix->name,NO_FACE);
@@ -1427,7 +1430,6 @@
memset(key,0,adj_lsa->header->orig_router->length+2);
make_adj_lsa_key(key,adj_lsa);
printf("Adjacent LSA key: %s \n",key);
-
nlsr->event = ccn_schedule_event(nlsr->sched, 10, &delete_adj_lsa, (void *)key, 0);
}
}
diff --git a/todo.txt b/todo.txt
new file mode 100644
index 0000000..77fccea
--- /dev/null
+++ b/todo.txt
@@ -0,0 +1,9 @@
+To Do:
+
+1. Add commenting facility in .conf file -- done, commenting character # or !
+2. Adding configuration command of lsa-refresh-time and router-dead-interval --- done
+3. Adding trailing "/" remover from the commands if has any -- done
+4. Multi Path Route Calculation
+5. Writing Log so that need minimal change to status page script
+6. Adding a fib entry for origination router itself
+6. Providing api to add/delete link/name prefix