Update
diff --git a/Makefile b/Makefile
index 9a466bc..fad396f 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@
all: $(PROGRAMS)
nlsr: nlsr.c nlsr_ndn.c utility.c
- $(CC) $(CFLAGS) nlsr.c nlsr_ndn.c utility.c -o nlsr $(LIBS)
+ $(CC) $(CFLAGS) nlsr.c nlsr_adl.c nlsr_ndn.c utility.c -o nlsr $(LIBS)
clean:
rm -f *.o
diff --git a/nlsr.c b/nlsr.c
index ffa1900..6dc8fb7 100644
--- a/nlsr.c
+++ b/nlsr.c
@@ -20,6 +20,7 @@
#include "nlsr.h"
#include "nlsr_ndn.h"
#include "utility.h"
+#include "nlsr_adl.h"
struct option longopts[] =
@@ -158,7 +159,7 @@
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)+1;
+ nbr->neighbor->length=strlen(rtr_name);
nbr->face=face_id;
nbr->status=0;
@@ -284,68 +285,6 @@
printf("\n");
}
-void
-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);
-
- struct ndn_neighbor *hnbr=(struct ndn_neighbor *)malloc(sizeof(struct ndn_neighbor*));
-
- struct hashtb_enumerator ee;
- struct hashtb_enumerator *e = ⅇ
- int res;
-
- hashtb_start(nlsr->adl, e);
- res = hashtb_seek(e, nbr->neighbor->name , nbr->neighbor->length, 0);
-
- 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->last_lsdb_version=(char *)malloc(16);
-
- hnbr->neighbor->length=nbr->neighbor->length;
- hnbr->face=nbr->face;
- hnbr->status=nbr->status;
- hnbr->last_lsdb_version="0000000000000000";
-
- struct hashtb_param param_luq = {0};
- hnbr->lsa_update_queue=hashtb_create(200, ¶m_luq);
-
- hashtb_end(e);
-
- printf("\n");
-
-
-}
-
-void
-print_adjacent_from_adl(void)
-{
- printf("print_adjacent_from_adl called \n");
- int i, adl_element;
- struct ndn_neighbor *nbr;
-
- struct hashtb_enumerator ee;
- struct hashtb_enumerator *e = ⅇ
-
- hashtb_start(nlsr->adl, e);
- adl_element=hashtb_n(nlsr->adl);
-
- for(i=0;i<adl_element;i++)
- {
- nbr=e->data;
- 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);
- }
-
- hashtb_end(e);
-
- printf("\n");
-}
-
void
nlsr_destroy( void )
diff --git a/nlsr.h b/nlsr.h
index 9895256..19c77bb 100644
--- a/nlsr.h
+++ b/nlsr.h
@@ -60,8 +60,7 @@
void print_name_prefix_from_npl(void);
-void add_adjacent_to_adl(struct ndn_neighbor *nbr);
-void print_adjacent_from_adl(void);
+
void nlsr_destroy( void );
diff --git a/nlsr_adl.c b/nlsr_adl.c
new file mode 100644
index 0000000..94ccb42
--- /dev/null
+++ b/nlsr_adl.c
@@ -0,0 +1,131 @@
+#include<stdio.h>
+#include<string.h>
+#include<stdlib.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <sys/time.h>
+#include <assert.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <ccn/ccn.h>
+#include <ccn/uri.h>
+#include <ccn/keystore.h>
+#include <ccn/signing.h>
+#include <ccn/schedule.h>
+#include <ccn/hashtb.h>
+
+#include "nlsr.h"
+#include "nlsr_ndn.h"
+#include "utility.h"
+#include "nlsr_adl.h"
+
+void
+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);
+
+ struct ndn_neighbor *hnbr=(struct ndn_neighbor *)malloc(sizeof(struct ndn_neighbor*));
+
+ struct hashtb_enumerator ee;
+ struct hashtb_enumerator *e = ⅇ
+ int res;
+
+ hashtb_start(nlsr->adl, e);
+ res = hashtb_seek(e, nbr->neighbor->name , nbr->neighbor->length, 0);
+
+ 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->last_lsdb_version=(char *)malloc(15);
+
+ hnbr->neighbor->length=nbr->neighbor->length;
+ hnbr->face=nbr->face;
+ hnbr->status=nbr->status;
+ 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);
+
+ hashtb_end(e);
+
+ printf("\n");
+
+
+}
+
+void
+print_adjacent_from_adl(void)
+{
+ printf("print_adjacent_from_adl called \n");
+ int i, adl_element;
+ struct ndn_neighbor *nbr;
+
+ struct hashtb_enumerator ee;
+ struct hashtb_enumerator *e = ⅇ
+
+ hashtb_start(nlsr->adl, e);
+ adl_element=hashtb_n(nlsr->adl);
+
+ for(i=0;i<adl_element;i++)
+ {
+ nbr=e->data;
+ 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);
+ }
+
+ hashtb_end(e);
+
+ printf("\n");
+}
+
+void
+update_adjacent_status_to_adl(struct ccn_charbuf *nbr, int status)
+{
+ printf("update_adjacent_status_to_adl called \n");
+
+ int res;
+ struct ndn_neighbor *nnbr;
+
+ struct hashtb_enumerator ee;
+ struct hashtb_enumerator *e = ⅇ
+
+ hashtb_start(nlsr->adl, e);
+ res = hashtb_seek(e, nbr->buf, nbr->length, 0);
+
+ assert( res == HT_OLD_ENTRY);
+
+ nnbr=e->data;
+ nnbr->status=status;
+
+ hashtb_end(e);
+}
+
+
+void
+update_adjacent_lsdb_version_to_adl(struct ccn_charbuf *nbr, char *version)
+{
+ printf("update_adjacent_status_to_adl called \n");
+
+ int res;
+ struct ndn_neighbor *nnbr;
+
+ struct hashtb_enumerator ee;
+ struct hashtb_enumerator *e = ⅇ
+
+ hashtb_start(nlsr->adl, e);
+ res = hashtb_seek(e, nbr->buf, nbr->length, 0);
+
+ assert( res == HT_OLD_ENTRY);
+
+ nnbr=e->data;
+ memcpy(nnbr->last_lsdb_version,version,strlen(version)+1);
+
+ hashtb_end(e);
+}
diff --git a/nlsr_adl.h b/nlsr_adl.h
new file mode 100644
index 0000000..1803a14
--- /dev/null
+++ b/nlsr_adl.h
@@ -0,0 +1,9 @@
+#ifndef _NLSR_ADL_H_
+#define _NLSR_ADL_H_
+
+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, char *version);
+
+#endif
diff --git a/nlsr_ndn.c b/nlsr_ndn.c
index f0ee538..ab43697 100644
--- a/nlsr_ndn.c
+++ b/nlsr_ndn.c
@@ -21,6 +21,7 @@
#include "nlsr.h"
#include "nlsr_ndn.h"
#include "utility.h"
+#include "nlsr_adl.h"
enum ccn_upcall_res
incoming_interest(struct ccn_closure *selfp,
@@ -168,15 +169,16 @@
{
// Do the LSDB processing here
+ const unsigned char *comp_ptr1;
+ size_t comp_size;
+ int res;
+
+ res=ccn_name_comp_get(info->content_ccnb, info->content_comps,info->interest_comps->n-1,&comp_ptr1, &comp_size);
+ printf("Received Database Version: %s \n",(char *)comp_ptr1);
+
}
- const unsigned char *comp_ptr1;
- size_t comp_size;
- int res;
-
- res=ccn_name_comp_get(info->content_ccnb, info->content_comps,info->interest_comps->n-1,&comp_ptr1, &comp_size);
-
- printf("Database Version: %s \n",(char *)comp_ptr1);
+
}
@@ -245,13 +247,26 @@
}
- struct ccn_charbuf*c;
- c=ccn_charbuf_create();
- ccn_uri_append(c,info->interest_ccnb,info->pi->offset[CCN_PI_E_Name],0);
- printf("%s\n",ccn_charbuf_as_string(c));
- ccn_charbuf_destroy(&c);
+ struct ccn_charbuf *nbr;
+ nbr=ccn_charbuf_create();
+
-
+ const unsigned char *comp_ptr1;
+ size_t comp_size;
+ 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);
+ }
+
+ ccn_charbuf_append_string(nbr,"\0");
+ printf("Interest Timed out for Neighbor: %s\n",ccn_charbuf_as_string(nbr));
+
+ update_adjacent_status_to_adl(nbr,1);
+
+ ccn_charbuf_destroy(&nbr);
}
void
@@ -356,7 +371,7 @@
struct ccn_signing_params sp=CCN_SIGNING_PARAMS_INIT;
ccn_charbuf_append(name, info->interest_ccnb + info->pi->offset[CCN_PI_B_Name],info->pi->offset[CCN_PI_E_Name] - info->pi->offset[CCN_PI_B_Name]);
- ccn_name_append_str(name,"0000000000000001");
+ //ccn_name_append_str(name,"0000000000000001");
sp.template_ccnb=ccn_charbuf_create();
ccn_charbuf_append_tt(sp.template_ccnb,CCN_DTAG_SignedInfo, CCN_DTAG);
diff --git a/nlsr_ndn.h b/nlsr_ndn.h
index da3480c..cb249c2 100644
--- a/nlsr_ndn.h
+++ b/nlsr_ndn.h
@@ -1,14 +1,6 @@
#ifndef _NLSR_NDN_H_
#define _NLSR_NDN_H_
-struct upcalldata {
- int magic; /* 856372 */
- long *counter;
- unsigned warn;
- int flags;
- int n_excl;
- struct ccn_charbuf **excl; /* Array of n_excl items */
-};
int send_lsdb_interest(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags);