Update
This commit is contained in:
1 parent
e07898659e
commit
8a5babe8d4
7 files changed
+173
-88
No files matched your search
@@ -7,7 +7,7 @@ PROGRAMS = nlsr
|
||||
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
|
||||
|
||||
@@ -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 @@ process_command_ccnneighbor(char *command)
|
||||
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 @@ print_name_prefix_from_npl(void)
|
||||
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 )
|
||||
|
||||
@@ -60,8 +60,7 @@ void add_name_prefix_to_npl(struct name_prefix *name_prefix);
|
||||
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 );
|
||||
|
||||
+131
@@ -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);
|
||||
}
|
||||
@@ -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
|
||||
+29
-14
@@ -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 @@ process_incoming_content_lsdb(struct ccn_closure* selfp, struct ccn_upcall_info*
|
||||
{
|
||||
// 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 @@ process_incoming_timed_out_interest_lsdb(struct ccn_closure* selfp, struct ccn_u
|
||||
}
|
||||
|
||||
|
||||
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 @@ process_incoming_interest_lsdb(struct ccn_closure *selfp, struct ccn_upcall_info
|
||||
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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in new issue
Block a user