blob: c38413339bb440aa47ea4a4a09150f1ed6423a6b [file] [log] [blame]
#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_npl.h"
#include "utility.h"
void
add_name_to_npl(struct name_prefix *np)
{
struct name_prefix *hnp=(struct name_prefix *)malloc(sizeof(struct name_prefix )); //free
struct hashtb_enumerator ee;
struct hashtb_enumerator *e = &ee;
int res;
hashtb_start(nlsr->npl, e);
res = hashtb_seek(e, np->name, np->length, 0);
if(res == HT_NEW_ENTRY)
{
hnp = e->data;
hnp->length=np->length;
hnp->name=(char *)malloc(np->length); //free
memcpy(hnp->name,np->name,np->length);
}
hashtb_end(e);
}
void
print_name_prefix_from_npl(void)
{
if ( nlsr->debugging )
printf("print_name_prefix_from_npl called \n");
if ( nlsr->detailed_logging )
writeLogg(__FILE__,__FUNCTION__,__LINE__,"print_name_prefix_from_npl called\n");
int i, npl_element;
struct name_prefix *np;
struct hashtb_enumerator ee;
struct hashtb_enumerator *e = &ee;
hashtb_start(nlsr->npl, e);
npl_element=hashtb_n(nlsr->npl);
for(i=0;i<npl_element;i++)
{
np=e->data;
if ( nlsr->debugging )
printf("Name Prefix: %s and Length: %d \n",np->name,np->length);
if ( nlsr->detailed_logging )
writeLogg(__FILE__,__FUNCTION__,__LINE__,"Name Prefix: %s and Length: %d \n",np->name,np->length);
hashtb_next(e);
}
hashtb_end(e);
printf("\n");
}