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" |
| 22 | |
| 23 | |
| 24 | void |
| 25 | add_name_to_npl(struct name_prefix *np) |
| 26 | { |
| 27 | struct name_prefix *hnp=(struct name_prefix *)malloc(sizeof(struct name_prefix )); //free |
| 28 | |
| 29 | struct hashtb_enumerator ee; |
| 30 | struct hashtb_enumerator *e = ⅇ |
| 31 | int res; |
| 32 | |
| 33 | hashtb_start(nlsr->npl, e); |
| 34 | res = hashtb_seek(e, np->name, np->length, 0); |
| 35 | |
| 36 | if(res == HT_NEW_ENTRY) |
| 37 | { |
| 38 | |
| 39 | hnp = e->data; |
| 40 | hnp->length=np->length; |
| 41 | hnp->name=(char *)malloc(np->length); //free |
| 42 | memcpy(hnp->name,np->name,np->length); |
| 43 | } |
| 44 | |
| 45 | hashtb_end(e); |
| 46 | |
| 47 | } |
| 48 | |
| 49 | |
| 50 | void |
| 51 | print_name_prefix_from_npl(void) |
| 52 | { |
| 53 | printf("print_name_prefix_from_npl called \n"); |
| 54 | int i, npl_element; |
| 55 | struct name_prefix *np; |
| 56 | |
| 57 | struct hashtb_enumerator ee; |
| 58 | struct hashtb_enumerator *e = ⅇ |
| 59 | |
| 60 | hashtb_start(nlsr->npl, e); |
| 61 | npl_element=hashtb_n(nlsr->npl); |
| 62 | |
| 63 | for(i=0;i<npl_element;i++) |
| 64 | { |
| 65 | np=e->data; |
| 66 | printf("Name Prefix: %s and Length: %d \n",np->name,np->length); |
| 67 | hashtb_next(e); |
| 68 | } |
| 69 | |
| 70 | hashtb_end(e); |
| 71 | |
| 72 | printf("\n"); |
| 73 | } |
| 74 | |