blob: c38413339bb440aa47ea4a4a09150f1ed6423a6b [file] [log] [blame]
akmhoque03004e62012-09-06 01:12:28 -05001#include<stdio.h>
2#include<string.h>
3#include<stdlib.h>
4#include <unistd.h>
5#include <getopt.h>
6#include <sys/time.h>
7#include <assert.h>
8#ifdef HAVE_CONFIG_H
9#include <config.h>
10#endif
11
12
13#include <ccn/ccn.h>
14#include <ccn/uri.h>
15#include <ccn/keystore.h>
16#include <ccn/signing.h>
17#include <ccn/schedule.h>
18#include <ccn/hashtb.h>
19
20#include "nlsr.h"
21#include "nlsr_npl.h"
akmhoque1771c412012-11-09 13:06:08 -060022#include "utility.h"
akmhoque03004e62012-09-06 01:12:28 -050023
24
25void
26add_name_to_npl(struct name_prefix *np)
27{
28 struct name_prefix *hnp=(struct name_prefix *)malloc(sizeof(struct name_prefix )); //free
29
30 struct hashtb_enumerator ee;
31 struct hashtb_enumerator *e = &ee;
32 int res;
33
34 hashtb_start(nlsr->npl, e);
35 res = hashtb_seek(e, np->name, np->length, 0);
36
37 if(res == HT_NEW_ENTRY)
38 {
39
40 hnp = e->data;
41 hnp->length=np->length;
42 hnp->name=(char *)malloc(np->length); //free
43 memcpy(hnp->name,np->name,np->length);
44 }
45
46 hashtb_end(e);
47
48}
49
50
51void
52print_name_prefix_from_npl(void)
53{
akmhoque1771c412012-11-09 13:06:08 -060054 if ( nlsr->debugging )
55 printf("print_name_prefix_from_npl called \n");
56 if ( nlsr->detailed_logging )
57 writeLogg(__FILE__,__FUNCTION__,__LINE__,"print_name_prefix_from_npl called\n");
akmhoque03004e62012-09-06 01:12:28 -050058 int i, npl_element;
59 struct name_prefix *np;
60
61 struct hashtb_enumerator ee;
62 struct hashtb_enumerator *e = &ee;
63
64 hashtb_start(nlsr->npl, e);
65 npl_element=hashtb_n(nlsr->npl);
66
67 for(i=0;i<npl_element;i++)
68 {
69 np=e->data;
akmhoque1771c412012-11-09 13:06:08 -060070 if ( nlsr->debugging )
71 printf("Name Prefix: %s and Length: %d \n",np->name,np->length);
72 if ( nlsr->detailed_logging )
73 writeLogg(__FILE__,__FUNCTION__,__LINE__,"Name Prefix: %s and Length: %d \n",np->name,np->length);
akmhoque03004e62012-09-06 01:12:28 -050074 hashtb_next(e);
75 }
76
77 hashtb_end(e);
78
79 printf("\n");
80}
81