update versioning
diff --git a/nlsr.c b/nlsr.c
index 49bda4a..0fa0084 100644
--- a/nlsr.c
+++ b/nlsr.c
@@ -157,10 +157,13 @@
}
struct ndn_neighbor *nbr=(struct ndn_neighbor *)malloc(sizeof(struct ndn_neighbor*));
- nbr->neighbor=(struct name_prefix *)malloc(sizeof(struct name_prefix *));
- nbr->neighbor->name=(char *)malloc(strlen(rtr_name)+1);
- memcpy(nbr->neighbor->name,rtr_name,strlen(rtr_name)+1);
- nbr->neighbor->length=strlen(rtr_name);
+ //nbr->neighbor=(struct name_prefix *)malloc(sizeof(struct name_prefix *));
+ //nbr->neighbor->name=(char *)malloc(strlen(rtr_name)+1);
+ //memcpy(nbr->neighbor->name,rtr_name,strlen(rtr_name)+1);
+ //nbr->neighbor->length=strlen(rtr_name);
+ nbr->neighbor=ccn_charbuf_create();
+ //ccn_name_from_uri(nbr->neighbor,rtr_name);
+ ccn_charbuf_append_string(nbr->neighbor,rtr_name);
nbr->face=face_id;
nbr->status=0;
@@ -169,7 +172,8 @@
add_adjacent_to_adl(nbr);
print_adjacent_from_adl();
- free(nbr->neighbor->name);
+ //free(nbr->neighbor->name);
+ ccn_charbuf_destroy(&nbr->neighbor);
free(nbr->neighbor);
free(nbr);
diff --git a/nlsr.h b/nlsr.h
index c491089..803e6b8 100644
--- a/nlsr.h
+++ b/nlsr.h
@@ -12,7 +12,8 @@
struct ndn_neighbor
{
- struct name_prefix *neighbor;
+ //struct name_prefix *neighbor;
+ struct ccn_charbuf *neighbor;
int face;
int status;
long int last_lsdb_version;
diff --git a/nlsr_adl.c b/nlsr_adl.c
index f208caf..c55efe4 100644
--- a/nlsr_adl.c
+++ b/nlsr_adl.c
@@ -26,7 +26,7 @@
add_adjacent_to_adl(struct ndn_neighbor *nbr)
{
printf("\nadd_adjacent_to_adl called\n");
- printf("Neighbor: %s Length: %d Face: %d Status: %d\n",nbr->neighbor->name,nbr->neighbor->length,nbr->face, nbr->status);
+ printf("Neighbor: %s Length: %d Face: %d Status: %d\n",ccn_charbuf_as_string(nbr->neighbor),(int)nbr->neighbor->length,nbr->face, nbr->status);
struct ndn_neighbor *hnbr=(struct ndn_neighbor *)malloc(sizeof(struct ndn_neighbor*));
@@ -35,20 +35,23 @@
int res;
hashtb_start(nlsr->adl, e);
- res = hashtb_seek(e, nbr->neighbor->name , nbr->neighbor->length, 0);
+ res = hashtb_seek(e, nbr->neighbor->buf , nbr->neighbor->length, 0);
if(res == HT_NEW_ENTRY )
{
hnbr = e->data;
-
- 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->neighbor->name[nbr->neighbor->length]='\0';
+ hnbr->neighbor=ccn_charbuf_create();
+ //res=ccn_name_from_uri(hnbr->neighbor,ccn_charbuf_as_string(nbr->neighbor));
+ ccn_charbuf_append_string(hnbr->neighbor,ccn_charbuf_as_string(nbr->neighbor));
+
+ //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->neighbor->name[nbr->neighbor->length]='\0';
//hnbr->last_lsdb_version=(char *)malloc(15);
+ //hnbr->neighbor->length=nbr->neighbor->length;
- hnbr->neighbor->length=nbr->neighbor->length;
hnbr->face=nbr->face;
hnbr->status=nbr->status;
//memcpy(hnbr->last_lsdb_version,"00000000000000",14);
@@ -82,7 +85,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: %ld \n",ccn_charbuf_as_string(nbr->neighbor),(int)nbr->neighbor->length,nbr->face, nbr->status, nbr->last_lsdb_version);
hashtb_next(e);
}
diff --git a/nlsr_ndn.c b/nlsr_ndn.c
index 224294b..eaa0ba0 100644
--- a/nlsr_ndn.c
+++ b/nlsr_ndn.c
@@ -436,9 +436,9 @@
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\n",ccn_charbuf_as_string(nbr->neighbor),nlsr_str,lsdb_str);
name=ccn_charbuf_create();
- res=ccn_name_from_uri(name,nbr->neighbor->name);
+ res=ccn_name_from_uri(name,ccn_charbuf_as_string(nbr->neighbor));
ccn_name_append_str(name,nlsr_str);
ccn_name_append_str(name,lsdb_str);
//ccn_name_append_str(name,rnumstr);
@@ -459,7 +459,8 @@
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, "%s", nbr->last_lsdb_version);
+ ccn_charbuf_putf(c, "%u", (unsigned)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> */