Sending Interest
diff --git a/README.md b/README.md
old mode 100644
new mode 100755
diff --git a/nlsr.c b/nlsr.c
index caf57ec..57f0d1d 100644
--- a/nlsr.c
+++ b/nlsr.c
@@ -441,6 +441,8 @@
nlsr->sched = ccn_schedule_create(nlsr, &ndn_rtr_ticker);
+ nlsr->event_send_lsdb_interest = ccn_schedule_event(nlsr->sched, 60000000, &send_lsdb_interest, NULL, 0);
+
while(1)
{
ccn_schedule_run(nlsr->sched);
diff --git a/nlsr.h b/nlsr.h
index d9cc410..d2274ee 100644
--- a/nlsr.h
+++ b/nlsr.h
@@ -26,6 +26,7 @@
struct ccn_closure in_content;
struct ccn_schedule *sched;
struct ccn_scheduled_event *event;
+ struct ccn_scheduled_event *event_send_lsdb_interest;
struct hashtb *adl;
struct hashtb *npl;
diff --git a/nlsr_ndn.c b/nlsr_ndn.c
index c265fc3..e24e1d2 100644
--- a/nlsr_ndn.c
+++ b/nlsr_ndn.c
@@ -39,7 +39,7 @@
printf("%s\n",ccn_charbuf_as_string(c));
ccn_charbuf_destroy(&c);
- //process_incoming_interest(selfp, info);
+ process_incoming_interest(selfp, info);
/*
struct ccn_charbuf *data=ccn_charbuf_create();
@@ -110,4 +110,103 @@
return CCN_UPCALL_RESULT_OK;
}
-/* --- */
+void
+process_incoming_interest(struct ccn_closure *selfp, struct ccn_upcall_info *info)
+{
+ printf("process_incoming_interest called \n");
+
+
+ struct ccn_charbuf*c;
+ c=ccn_charbuf_create();
+ ccn_uri_append(c,info->interest_ccnb,info->pi->offset[CCN_PI_E_Name]-info->pi->offset[CCN_PI_B_Name],0);
+ printf("%s\n",ccn_charbuf_as_string(c));
+ ccn_charbuf_destroy(&c);
+
+ const unsigned char *comp_ptr1;
+ size_t comp_size;
+ int res,i;
+ int nlsr_position=0;
+ int name_comps=(int)info->interest_comps->n;
+
+ for(i=0;i<name_comps;i++)
+ {
+ res=ccn_name_comp_strcmp(info->interest_ccnb,info->interest_comps,i,"nlsr");
+ if( res == 0)
+ {
+ nlsr_position=res;
+ break;
+ }
+ }
+
+ res=ccn_name_comp_get(info->interest_ccnb, info->interest_comps,nlsr_position+1,&comp_ptr1, &comp_size);
+
+
+ printf("Det= %s \n",comp_ptr1);
+
+ if(!strcmp((char *)comp_ptr1,"lsdb"))
+ {
+ //send_hello_response_content(selfp,info);
+ }
+ else if(!strcmp((char *)comp_ptr1,"lsa"))
+ {
+ //process_iHaveUpdate_incoming_interest(selfp,info);
+ }
+ else if(!strcmp((char *)comp_ptr1,"lsaupdate"))
+ {
+ //process_sendlsdb_incoming_interest(selfp,info);
+ }
+
+}
+
+int
+send_lsdb_interest(struct ccn_schedule *sched, void *clienth,
+ struct ccn_scheduled_event *ev, int flags)
+{
+
+ struct ccn_charbuf *name;
+ long int rnum;
+ char rnumstr[20];
+ char lsdb[5];
+
+ int res,i;
+ int adl_element;
+
+ rnum=random();
+ memset(&rnumstr,0,20);
+ sprintf(rnumstr,"%ld",rnum);
+ memset(&lsdb,0,5);
+ sprintf(lsdb,"lsdb");
+
+ 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("Sending interest for name prefix:%s/%s/%s\n",nbr->neighbor->name,lsdb,rnumstr);
+ name=ccn_charbuf_create();
+ res=ccn_name_from_uri(name,nbr->neighbor->name);
+ ccn_name_append_str(name,lsdb);
+ ccn_name_append_str(name,rnumstr);
+
+ res=ccn_express_interest(nlsr->ccn,name,&(nlsr->in_content),NULL);
+ if ( res >= 0 )
+ printf("Interest sending Successfull .... \n");
+ ccn_charbuf_destroy(&name);
+
+ hashtb_next(e);
+ }
+
+ hashtb_end(e);
+
+ nlsr->event_send_lsdb_interest = ccn_schedule_event(nlsr->sched, 60000000, &send_lsdb_interest, NULL, 0);
+
+ return 0;
+
+}
+
diff --git a/nlsr_ndn.h b/nlsr_ndn.h
index 4400bbb..24e1cd1 100644
--- a/nlsr_ndn.h
+++ b/nlsr_ndn.h
@@ -1,7 +1,10 @@
#ifndef _NLSR_NDN_H_
#define _NLSR_NDN_H_
+int send_lsdb_interest(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags);
+
enum ccn_upcall_res incoming_interest(struct ccn_closure *selfp, enum ccn_upcall_kind kind, struct ccn_upcall_info *info);
+void process_incoming_interest(struct ccn_closure *selfp, struct ccn_upcall_info *info);
enum ccn_upcall_res incoming_content(struct ccn_closure* selfp, enum ccn_upcall_kind kind, struct ccn_upcall_info* info);