Update
diff --git a/nlsr.c b/nlsr.c
index 6b55078..b3d38e9 100644
--- a/nlsr.c
+++ b/nlsr.c
@@ -311,8 +311,7 @@
hashtb_end(e);
- hashtb_destroy(&nlsr->lsdb->adj_lsdb);
- hashtb_destroy(&nlsr->lsdb->name_lsdb);
+
hashtb_destroy(&nlsr->adl);
hashtb_destroy(&nlsr->npl);
ccn_schedule_destroy(&nlsr->sched);
@@ -338,7 +337,8 @@
nlsr->in_content.p = &incoming_content;
nlsr->lsdb=(struct linkStateDatabase *)malloc(sizeof(struct linkStateDatabase *));
- nlsr->lsdb->version=0;
+ 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);
diff --git a/nlsr.h b/nlsr.h
index c491089..11635fc 100644
--- a/nlsr.h
+++ b/nlsr.h
@@ -15,13 +15,13 @@
struct name_prefix *neighbor;
int face;
int status;
- long int last_lsdb_version;
+ char *last_lsdb_version;
struct hashtb *lsa_update_queue;
};
struct linkStateDatabase
{
- long int version;
+ char *version;
struct hashtb *adj_lsdb;
struct hashtb *name_lsdb;
};
diff --git a/nlsr_adl.c b/nlsr_adl.c
index 63d9a63..94ccb42 100644
--- a/nlsr_adl.c
+++ b/nlsr_adl.c
@@ -42,11 +42,13 @@
hnbr->neighbor=(struct name_prefix *)malloc(sizeof(struct name_prefix *));
hnbr->neighbor->name=(char *)malloc(nbr->neighbor->length);
memcpy(hnbr->neighbor->name,nbr->neighbor->name,nbr->neighbor->length);
+ hnbr->last_lsdb_version=(char *)malloc(15);
hnbr->neighbor->length=nbr->neighbor->length;
hnbr->face=nbr->face;
hnbr->status=nbr->status;
- hnbr->last_lsdb_version=0;
+ memcpy(hnbr->last_lsdb_version,"00000000000000",14);
+ memcpy(hnbr->last_lsdb_version+strlen(hnbr->last_lsdb_version),"\0",1);
struct hashtb_param param_luq = {0};
hnbr->lsa_update_queue=hashtb_create(200, ¶m_luq);
@@ -74,7 +76,7 @@
for(i=0;i<adl_element;i++)
{
nbr=e->data;
- printf("Neighbor: %s Length: %d Face: %d Status: %d LSDB Version: %ld \n",nbr->neighbor->name,nbr->neighbor->length,nbr->face, nbr->status, nbr->last_lsdb_version);
+ printf("Neighbor: %s Length: %d Face: %d Status: %d LSDB Version: %s \n",nbr->neighbor->name,nbr->neighbor->length,nbr->face, nbr->status, nbr->last_lsdb_version);
hashtb_next(e);
}
@@ -97,7 +99,7 @@
hashtb_start(nlsr->adl, e);
res = hashtb_seek(e, nbr->buf, nbr->length, 0);
- //assert( res == HT_OLD_ENTRY);
+ assert( res == HT_OLD_ENTRY);
nnbr=e->data;
nnbr->status=status;
@@ -107,7 +109,7 @@
void
-update_adjacent_lsdb_version_to_adl(struct ccn_charbuf *nbr, long int version)
+update_adjacent_lsdb_version_to_adl(struct ccn_charbuf *nbr, char *version)
{
printf("update_adjacent_status_to_adl called \n");
@@ -120,10 +122,10 @@
hashtb_start(nlsr->adl, e);
res = hashtb_seek(e, nbr->buf, nbr->length, 0);
- //assert( res == HT_OLD_ENTRY);
+ assert( res == HT_OLD_ENTRY);
nnbr=e->data;
- nnbr->last_lsdb_version=version;
-
+ memcpy(nnbr->last_lsdb_version,version,strlen(version)+1);
+
hashtb_end(e);
}
diff --git a/nlsr_adl.h b/nlsr_adl.h
index cd25524..1803a14 100644
--- a/nlsr_adl.h
+++ b/nlsr_adl.h
@@ -4,6 +4,6 @@
void add_adjacent_to_adl(struct ndn_neighbor *nbr);
void print_adjacent_from_adl(void);
void update_adjacent_status_to_adl(struct ccn_charbuf *nbr, int status);
-void update_adjacent_lsdb_version_to_adl(struct ccn_charbuf *nbr, long int version);
+void update_adjacent_lsdb_version_to_adl(struct ccn_charbuf *nbr, char *version);
#endif
diff --git a/nlsr_ndn.c b/nlsr_ndn.c
index e336e23..ab43697 100644
--- a/nlsr_ndn.c
+++ b/nlsr_ndn.c
@@ -256,6 +256,7 @@
for(i=0;i<nlsr_position;i++)
{
res=ccn_name_comp_get(info->interest_ccnb, info->interest_comps,i,&comp_ptr1, &comp_size);
+ //printf("%s \n",comp_ptr1);
ccn_charbuf_append_string(nbr,"/");
ccn_charbuf_append_string(nbr,(const char *)comp_ptr1);
}
@@ -352,20 +353,17 @@
/* Now comp points to the start of your potential number, and size is its length */
}
- int db_version=atoi((char *)comp);
- int dbcmp=db_version- nlsr->lsdb->version;
-
- //int dbcmp=strncmp(nlsr->lsdb->version,(char *)comp,16);
+ int dbcmp=strncmp(nlsr->lsdb->version,(char *)comp,16);
- //printf (" dbcmp = %d \n",dbcmp);
+ printf (" dbcmp = %d \n",dbcmp);
if(dbcmp > 0)
{
- printf("Has Updated database (Older: %s New: %ld)\n",comp,nlsr->lsdb->version);
+ printf("Has Updated database (Older: %s New: %s)\n",comp,nlsr->lsdb->version);
}
else
{
- printf("Data base is not updated than the older one (Older: %s New: %ld)\n",comp,nlsr->lsdb->version);
+ printf("Data base is not updated than the older one (Older: %s New: %s)\n",comp,nlsr->lsdb->version);
printf("Sending NACK Content back.....\n");
struct ccn_charbuf *data=ccn_charbuf_create();
@@ -432,12 +430,12 @@
for(i=0;i<adl_element;i++)
{
nbr=e->data;
- //printf("Sending interest for name prefix:%s/%s/%s\n",nbr->neighbor->name,nlsr_str,lsdb_str);
+ printf("Sending interest for name prefix:%s/%s/%s/%s\n",nbr->neighbor->name,nlsr_str,lsdb_str,rnumstr);
name=ccn_charbuf_create();
res=ccn_name_from_uri(name,nbr->neighbor->name);
ccn_name_append_str(name,nlsr_str);
ccn_name_append_str(name,lsdb_str);
- printf("Sending interest for name prefix:%s\n",ccn_name_as_string(name));
+ ccn_name_append_str(name,rnumstr);
/* adding Exclusion filter */
@@ -455,8 +453,7 @@
ccnb_tagged_putf(templ, CCN_DTAG_Any, "");
ccn_charbuf_reset(c);
//ccn_charbuf_putf(c, "%u", (unsigned)mynumber);
- //ccn_charbuf_putf(c, "%s", nbr->last_lsdb_version);
- ccn_charbuf_putf(c, "%ld", nbr->last_lsdb_version);
+ ccn_charbuf_putf(c, "%s", nbr->last_lsdb_version);
ccnb_append_tagged_blob(templ, CCN_DTAG_Component, c->buf, c->length);
ccn_charbuf_append_closer(templ); /* </Exclude> */
ccn_charbuf_append_closer(templ); /* </Interest> */