akmhoque | 03004e6 | 2012-09-06 01:12:28 -0500 | [diff] [blame] | 1 | #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" |
akmhoque | 1771c41 | 2012-11-09 13:06:08 -0600 | [diff] [blame] | 22 | #include "utility.h" |
akmhoque | 03004e6 | 2012-09-06 01:12:28 -0500 | [diff] [blame] | 23 | |
| 24 | |
| 25 | void |
| 26 | add_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 = ⅇ |
| 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 | |
| 51 | void |
| 52 | print_name_prefix_from_npl(void) |
| 53 | { |
akmhoque | 1771c41 | 2012-11-09 13:06:08 -0600 | [diff] [blame] | 54 | 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"); |
akmhoque | 03004e6 | 2012-09-06 01:12:28 -0500 | [diff] [blame] | 58 | int i, npl_element; |
| 59 | struct name_prefix *np; |
| 60 | |
| 61 | struct hashtb_enumerator ee; |
| 62 | struct hashtb_enumerator *e = ⅇ |
| 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; |
akmhoque | 1771c41 | 2012-11-09 13:06:08 -0600 | [diff] [blame] | 70 | 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); |
akmhoque | 03004e6 | 2012-09-06 01:12:28 -0500 | [diff] [blame] | 74 | hashtb_next(e); |
| 75 | } |
| 76 | |
| 77 | hashtb_end(e); |
| 78 | |
| 79 | printf("\n"); |
| 80 | } |
| 81 | |