Updates
diff --git a/Makefile b/Makefile
index fad396f..94d2529 100644
--- a/Makefile
+++ b/Makefile
@@ -6,8 +6,8 @@
all: $(PROGRAMS)
-nlsr: nlsr.c nlsr_ndn.c utility.c
- $(CC) $(CFLAGS) nlsr.c nlsr_adl.c nlsr_ndn.c utility.c -o nlsr $(LIBS)
+nlsr: nlsr.c nlsr_adl.c nlsr_lsdb.c nlsr_ndn.c utility.c
+ $(CC) $(CFLAGS) nlsr.c nlsr_adl.c nlsr_lsdb.c nlsr_ndn.c utility.c -o nlsr $(LIBS)
clean:
rm -f *.o
diff --git a/nlsr.c b/nlsr.c
index 6dc8fb7..b3d38e9 100644
--- a/nlsr.c
+++ b/nlsr.c
@@ -21,6 +21,7 @@
#include "nlsr_ndn.h"
#include "utility.h"
#include "nlsr_adl.h"
+#include "nlsr_lsdb.h"
struct option longopts[] =
@@ -319,15 +320,14 @@
}
-
-int
-main(int argc, char *argv[])
+void
+init_nlsr(void)
{
- int res;
- char *config_file;
- int daemon_mode;
struct hashtb_param param_adl = {0};
struct hashtb_param param_npl = {0};
+
+ struct hashtb_param param_adj_lsdb = {0};
+ struct hashtb_param param_name_lsdb = {0};
nlsr=(struct nlsr *)malloc(sizeof(struct nlsr));
@@ -340,10 +340,23 @@
nlsr->lsdb->version=(char *)malloc(16);
nlsr->lsdb->version="0000000000000000";
+ nlsr->lsdb->adj_lsdb = hashtb_create(sizeof(struct adj_lsa), ¶m_adj_lsdb);
+ nlsr->lsdb->name_lsdb = hashtb_create(sizeof(struct name_lsa), ¶m_name_lsdb);
+
nlsr->is_synch_init=1;
nlsr->nlsa_id=0;
+}
+
+int
+main(int argc, char *argv[])
+{
+ int res;
+ char *config_file;
+ int daemon_mode;
struct ccn_charbuf *router_prefix;
+
+ init_nlsr();
while ((res = getopt_long(argc, argv, "df:h", longopts, 0)) != -1)
{
diff --git a/nlsr.h b/nlsr.h
index 19c77bb..11635fc 100644
--- a/nlsr.h
+++ b/nlsr.h
@@ -22,7 +22,8 @@
struct linkStateDatabase
{
char *version;
- struct hashtb *db;
+ struct hashtb *adj_lsdb;
+ struct hashtb *name_lsdb;
};
struct nlsr
@@ -48,6 +49,7 @@
struct nlsr *nlsr;
+void init_nlsr(void);
void ndn_rtr_gettime(const struct ccn_gettime *self, struct ccn_timeval *result);
void process_command_router_name(char *command);
diff --git a/nlsr_lsdb.h b/nlsr_lsdb.h
new file mode 100644
index 0000000..21826e9
--- /dev/null
+++ b/nlsr_lsdb.h
@@ -0,0 +1,33 @@
+#ifndef _NLSR_LSDB_H_
+#define _NLSR_LSDB_H_
+
+struct link
+{
+ struct charbuf *nbr;
+ int face;
+ int metric;
+};
+
+struct adj_lsa
+{
+
+ unsigned char ls_type;
+ char orig_time[15];
+ struct charbuf *orig_router;
+ int no_link;
+
+ struct link *links;
+};
+
+struct name_lsa
+{
+ unsigned char ls_type;
+ char orig_time[15];
+ long ls_id;
+ struct charbuf *orig_router;
+ unsigned char isValid;
+
+ struct charbuf *name_prefix;
+};
+
+#endif