akmhoque | 59980a5 | 2012-08-09 12:36:09 -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> |
akmhoque | 7f33727 | 2012-08-14 15:16:30 -0500 | [diff] [blame] | 19 | #include <ccn/bloom.h> |
akmhoque | 59980a5 | 2012-08-09 12:36:09 -0500 | [diff] [blame] | 20 | |
| 21 | #include "nlsr.h" |
| 22 | #include "nlsr_ndn.h" |
| 23 | #include "utility.h" |
akmhoque | 8a5babe | 2012-08-16 17:39:33 -0500 | [diff] [blame] | 24 | #include "nlsr_adl.h" |
akmhoque | d79438d | 2012-08-27 13:31:42 -0500 | [diff] [blame] | 25 | #include "nlsr_lsdb.h" |
| 26 | |
| 27 | int |
| 28 | appendLifetime(struct ccn_charbuf *cb, int lifetime) |
| 29 | { |
| 30 | unsigned char buf[sizeof(int32_t)]; |
| 31 | int32_t dreck = lifetime << 12; |
| 32 | int pos = sizeof(int32_t); |
| 33 | int res = 0; |
| 34 | while (dreck > 0 && pos > 0) |
| 35 | { |
| 36 | pos--; |
| 37 | buf[pos] = dreck & 255; |
| 38 | dreck = dreck >> 8; |
| 39 | } |
| 40 | res |= ccnb_append_tagged_blob(cb, CCN_DTAG_InterestLifetime, buf+pos, sizeof(buf)-pos); |
| 41 | return res; |
| 42 | } |
akmhoque | 59980a5 | 2012-08-09 12:36:09 -0500 | [diff] [blame] | 43 | |
| 44 | enum ccn_upcall_res |
| 45 | incoming_interest(struct ccn_closure *selfp, |
| 46 | enum ccn_upcall_kind kind, struct ccn_upcall_info *info) |
| 47 | { |
| 48 | |
| 49 | switch (kind) { |
| 50 | case CCN_UPCALL_FINAL: |
| 51 | break; |
| 52 | case CCN_UPCALL_INTEREST: |
| 53 | // printing the name prefix for which it received interest |
| 54 | printf("Interest Received for name: "); |
| 55 | struct ccn_charbuf*c; |
| 56 | c=ccn_charbuf_create(); |
| 57 | ccn_uri_append(c,info->interest_ccnb,info->pi->offset[CCN_PI_E_Name]-info->pi->offset[CCN_PI_B_Name],0); |
| 58 | //ccn_name_chop(c,NULL,-1); |
| 59 | printf("%s\n",ccn_charbuf_as_string(c)); |
| 60 | ccn_charbuf_destroy(&c); |
| 61 | |
akmhoque | 1c9b92f | 2012-08-13 10:57:50 -0500 | [diff] [blame] | 62 | process_incoming_interest(selfp, info); |
akmhoque | 59980a5 | 2012-08-09 12:36:09 -0500 | [diff] [blame] | 63 | |
| 64 | /* |
| 65 | struct ccn_charbuf *data=ccn_charbuf_create(); |
| 66 | struct ccn_charbuf *name=ccn_charbuf_create(); |
| 67 | struct ccn_signing_params sp=CCN_SIGNING_PARAMS_INIT; |
| 68 | |
| 69 | ccn_charbuf_append(name, info->interest_ccnb + info->pi->offset[CCN_PI_B_Name], |
| 70 | info->pi->offset[CCN_PI_E_Name] - info->pi->offset[CCN_PI_B_Name]); |
| 71 | |
| 72 | sp.template_ccnb=ccn_charbuf_create(); |
| 73 | ccn_charbuf_append_tt(sp.template_ccnb,CCN_DTAG_SignedInfo, CCN_DTAG); |
| 74 | ccnb_tagged_putf(sp.template_ccnb, CCN_DTAG_FreshnessSeconds, "%ld", 1010); |
| 75 | sp.sp_flags |= CCN_SP_TEMPL_FRESHNESS; |
| 76 | ccn_charbuf_append_closer(sp.template_ccnb); |
| 77 | |
| 78 | res= ccn_sign_content(ospfndn->ccn, data, name, &sp, "hello", strlen("hello")); |
| 79 | res=ccn_put(ospfndn->ccn,data->buf,data->length); |
| 80 | ccn_charbuf_destroy(&data); |
| 81 | |
| 82 | */ |
| 83 | break; |
| 84 | |
| 85 | default: |
| 86 | break; |
| 87 | } |
| 88 | |
| 89 | return CCN_UPCALL_RESULT_OK; |
| 90 | } |
| 91 | |
| 92 | |
| 93 | enum ccn_upcall_res incoming_content(struct ccn_closure* selfp, |
| 94 | enum ccn_upcall_kind kind, struct ccn_upcall_info* info) |
| 95 | { |
| 96 | |
| 97 | |
| 98 | switch(kind) { |
| 99 | case CCN_UPCALL_FINAL: |
| 100 | break; |
| 101 | case CCN_UPCALL_CONTENT: |
| 102 | printf("Content Received for name: "); |
| 103 | struct ccn_charbuf*c; |
| 104 | c=ccn_charbuf_create(); |
| 105 | ccn_uri_append(c,info->interest_ccnb,info->pi->offset[CCN_PI_E],0); |
| 106 | printf("%s\n",ccn_charbuf_as_string(c)); |
| 107 | ccn_charbuf_destroy(&c); |
akmhoque | cb01775 | 2012-08-16 11:03:45 -0500 | [diff] [blame] | 108 | |
| 109 | process_incoming_content(selfp, info); |
| 110 | |
akmhoque | 59980a5 | 2012-08-09 12:36:09 -0500 | [diff] [blame] | 111 | break; |
| 112 | case CCN_UPCALL_INTEREST_TIMED_OUT: |
akmhoque | cb01775 | 2012-08-16 11:03:45 -0500 | [diff] [blame] | 113 | printf("Interest timed out \n"); |
| 114 | struct ccn_charbuf*ic; |
| 115 | ic=ccn_charbuf_create(); |
| 116 | ccn_uri_append(ic,info->interest_ccnb,info->pi->offset[CCN_PI_E_Name],0); |
| 117 | printf("%s\n",ccn_charbuf_as_string(ic)); |
| 118 | ccn_charbuf_destroy(&ic); |
| 119 | process_incoming_timed_out_interest(selfp,info); |
akmhoque | 59980a5 | 2012-08-09 12:36:09 -0500 | [diff] [blame] | 120 | |
akmhoque | 59980a5 | 2012-08-09 12:36:09 -0500 | [diff] [blame] | 121 | break; |
| 122 | default: |
| 123 | fprintf(stderr, "Unexpected response of kind %d\n", kind); |
| 124 | return CCN_UPCALL_RESULT_ERR; |
| 125 | } |
| 126 | |
| 127 | return CCN_UPCALL_RESULT_OK; |
| 128 | } |
akmhoque | 61fe447 | 2012-08-10 10:13:34 -0500 | [diff] [blame] | 129 | |
akmhoque | cb01775 | 2012-08-16 11:03:45 -0500 | [diff] [blame] | 130 | |
| 131 | void |
| 132 | process_incoming_content(struct ccn_closure* selfp, struct ccn_upcall_info* info) |
| 133 | { |
| 134 | printf("process_incoming_content called \n"); |
| 135 | |
akmhoque | 638c20a | 2012-08-16 11:57:48 -0500 | [diff] [blame] | 136 | struct ccn_charbuf*c; |
| 137 | c=ccn_charbuf_create(); |
akmhoque | dde7e32 | 2012-08-16 13:57:06 -0500 | [diff] [blame] | 138 | //ccn_uri_append(c,info->interest_ccnb,info->pi->offset[CCN_PI_E_Name]-info->pi->offset[CCN_PI_B_Name],0); |
| 139 | ccn_uri_append(c,info->interest_ccnb,info->pi->offset[CCN_PI_E_Name],0); |
akmhoque | 638c20a | 2012-08-16 11:57:48 -0500 | [diff] [blame] | 140 | printf("%s\n",ccn_charbuf_as_string(c)); |
| 141 | ccn_charbuf_destroy(&c); |
| 142 | |
| 143 | const unsigned char *comp_ptr1; |
| 144 | size_t comp_size; |
| 145 | int res,i; |
| 146 | int nlsr_position=0; |
| 147 | int name_comps=(int)info->interest_comps->n; |
| 148 | |
| 149 | for(i=0;i<name_comps;i++) |
| 150 | { |
| 151 | res=ccn_name_comp_strcmp(info->interest_ccnb,info->interest_comps,i,"nlsr"); |
| 152 | if( res == 0) |
| 153 | { |
| 154 | nlsr_position=i; |
| 155 | break; |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | res=ccn_name_comp_get(info->interest_ccnb, info->interest_comps,nlsr_position+1,&comp_ptr1, &comp_size); |
| 160 | |
| 161 | |
| 162 | printf("Det= %s \n",comp_ptr1); |
| 163 | |
| 164 | if(!strcmp((char *)comp_ptr1,"lsdb")) |
| 165 | { |
| 166 | process_incoming_content_lsdb(selfp,info); |
| 167 | } |
akmhoque | d79438d | 2012-08-27 13:31:42 -0500 | [diff] [blame] | 168 | if(!strcmp((char *)comp_ptr1,"info")) |
| 169 | { |
| 170 | process_incoming_content_info(selfp,info); |
| 171 | } |
akmhoque | 638c20a | 2012-08-16 11:57:48 -0500 | [diff] [blame] | 172 | |
| 173 | } |
| 174 | |
| 175 | |
| 176 | void |
| 177 | process_incoming_content_lsdb(struct ccn_closure* selfp, struct ccn_upcall_info* info) |
| 178 | { |
| 179 | printf("process_incoming_content_lsdb called \n"); |
| 180 | |
| 181 | const unsigned char *content_data; |
| 182 | size_t length; |
| 183 | ccn_content_get_value(info->content_ccnb, info->pco->offset[CCN_PCO_E_Content]-info->pco->offset[CCN_PCO_B_Content], info->pco, &content_data, &length); |
| 184 | |
akmhoque | dde7e32 | 2012-08-16 13:57:06 -0500 | [diff] [blame] | 185 | |
| 186 | if ( !strcmp((char *)content_data,"NACK")) |
| 187 | { |
| 188 | printf("NACK received for LSDB request. Do nothing \n"); |
| 189 | } |
| 190 | else |
| 191 | { |
| 192 | // Do the LSDB processing here |
| 193 | |
akmhoque | 8a5babe | 2012-08-16 17:39:33 -0500 | [diff] [blame] | 194 | const unsigned char *comp_ptr1; |
| 195 | size_t comp_size; |
| 196 | int res; |
| 197 | |
| 198 | res=ccn_name_comp_get(info->content_ccnb, info->content_comps,info->interest_comps->n-1,&comp_ptr1, &comp_size); |
akmhoque | 2852a22 | 2012-08-21 12:09:00 -0400 | [diff] [blame] | 199 | if ( res >=0) |
akmhoque | 8a5babe | 2012-08-16 17:39:33 -0500 | [diff] [blame] | 200 | printf("Received Database Version: %s \n",(char *)comp_ptr1); |
| 201 | |
akmhoque | dde7e32 | 2012-08-16 13:57:06 -0500 | [diff] [blame] | 202 | } |
akmhoque | 638c20a | 2012-08-16 11:57:48 -0500 | [diff] [blame] | 203 | |
akmhoque | 8a5babe | 2012-08-16 17:39:33 -0500 | [diff] [blame] | 204 | |
akmhoque | 638c20a | 2012-08-16 11:57:48 -0500 | [diff] [blame] | 205 | |
akmhoque | cb01775 | 2012-08-16 11:03:45 -0500 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | |
akmhoque | d79438d | 2012-08-27 13:31:42 -0500 | [diff] [blame] | 209 | |
| 210 | void |
| 211 | process_incoming_content_info(struct ccn_closure* selfp, struct ccn_upcall_info* info) |
| 212 | { |
| 213 | printf("process_incoming_content_info called \n"); |
| 214 | |
| 215 | const unsigned char *content_data; |
| 216 | size_t length; |
| 217 | ccn_content_get_value(info->content_ccnb, info->pco->offset[CCN_PCO_E_Content]-info->pco->offset[CCN_PCO_B_Content], info->pco, &content_data, &length); |
| 218 | |
| 219 | printf("Info Value: %s \n",(char *)content_data); |
| 220 | |
| 221 | |
| 222 | } |
| 223 | |
akmhoque | cb01775 | 2012-08-16 11:03:45 -0500 | [diff] [blame] | 224 | void |
| 225 | process_incoming_timed_out_interest(struct ccn_closure* selfp, struct ccn_upcall_info* info) |
| 226 | { |
| 227 | printf("process_incoming_timed_out_interest called \n"); |
| 228 | |
akmhoque | dde7e32 | 2012-08-16 13:57:06 -0500 | [diff] [blame] | 229 | struct ccn_charbuf*c; |
| 230 | c=ccn_charbuf_create(); |
| 231 | //ccn_uri_append(c,info->interest_ccnb,info->pi->offset[CCN_PI_E_Name]-info->pi->offset[CCN_PI_B_Name],0); |
| 232 | ccn_uri_append(c,info->interest_ccnb,info->pi->offset[CCN_PI_E_Name],0); |
| 233 | printf("%s\n",ccn_charbuf_as_string(c)); |
| 234 | ccn_charbuf_destroy(&c); |
| 235 | |
akmhoque | b2e3a33 | 2012-08-21 12:17:20 -0400 | [diff] [blame] | 236 | //const unsigned char *comp_ptr1; |
| 237 | //size_t comp_size; |
akmhoque | dde7e32 | 2012-08-16 13:57:06 -0500 | [diff] [blame] | 238 | int res,i; |
| 239 | int nlsr_position=0; |
| 240 | int name_comps=(int)info->interest_comps->n; |
| 241 | |
| 242 | for(i=0;i<name_comps;i++) |
| 243 | { |
| 244 | res=ccn_name_comp_strcmp(info->interest_ccnb,info->interest_comps,i,"nlsr"); |
| 245 | if( res == 0) |
| 246 | { |
| 247 | nlsr_position=i; |
| 248 | break; |
| 249 | } |
| 250 | } |
| 251 | |
akmhoque | b2e3a33 | 2012-08-21 12:17:20 -0400 | [diff] [blame] | 252 | //res=ccn_name_comp_get(info->interest_ccnb, info->interest_comps,nlsr_position+1,&comp_ptr1, &comp_size); |
akmhoque | dde7e32 | 2012-08-16 13:57:06 -0500 | [diff] [blame] | 253 | |
| 254 | |
akmhoque | b2e3a33 | 2012-08-21 12:17:20 -0400 | [diff] [blame] | 255 | //printf("Det= %s \n",comp_ptr1); |
akmhoque | dde7e32 | 2012-08-16 13:57:06 -0500 | [diff] [blame] | 256 | |
akmhoque | b2e3a33 | 2012-08-21 12:17:20 -0400 | [diff] [blame] | 257 | //if(!strcmp((char *)comp_ptr1,"lsdb")) |
| 258 | if(ccn_name_comp_strcmp(info->interest_ccnb,info->interest_comps,nlsr_position+1,"lsdb") == 0) |
akmhoque | dde7e32 | 2012-08-16 13:57:06 -0500 | [diff] [blame] | 259 | { |
| 260 | process_incoming_timed_out_interest_lsdb(selfp,info); |
| 261 | } |
akmhoque | d79438d | 2012-08-27 13:31:42 -0500 | [diff] [blame] | 262 | else if(ccn_name_comp_strcmp(info->interest_ccnb,info->interest_comps,nlsr_position+1,"info") == 0) |
| 263 | { |
| 264 | process_incoming_timed_out_interest_info(selfp,info); |
| 265 | } |
akmhoque | cb01775 | 2012-08-16 11:03:45 -0500 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | |
akmhoque | 1c9b92f | 2012-08-13 10:57:50 -0500 | [diff] [blame] | 269 | void |
akmhoque | dde7e32 | 2012-08-16 13:57:06 -0500 | [diff] [blame] | 270 | process_incoming_timed_out_interest_lsdb(struct ccn_closure* selfp, struct ccn_upcall_info* info) |
| 271 | { |
| 272 | printf("process_incoming_timed_out_interest_lsdb called \n"); |
| 273 | |
| 274 | |
| 275 | int res,i; |
| 276 | int nlsr_position=0; |
| 277 | int name_comps=(int)info->interest_comps->n; |
| 278 | |
| 279 | //const unsigned char *comp_ptr1; |
| 280 | //size_t comp_size; |
| 281 | |
| 282 | for(i=0;i<name_comps;i++) |
| 283 | { |
| 284 | res=ccn_name_comp_strcmp(info->interest_ccnb,info->interest_comps,i,"nlsr"); |
| 285 | if( res == 0) |
| 286 | { |
| 287 | nlsr_position=i; |
| 288 | break; |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | |
akmhoque | 8a5babe | 2012-08-16 17:39:33 -0500 | [diff] [blame] | 293 | struct ccn_charbuf *nbr; |
| 294 | nbr=ccn_charbuf_create(); |
| 295 | |
akmhoque | dde7e32 | 2012-08-16 13:57:06 -0500 | [diff] [blame] | 296 | |
akmhoque | 8a5babe | 2012-08-16 17:39:33 -0500 | [diff] [blame] | 297 | const unsigned char *comp_ptr1; |
| 298 | size_t comp_size; |
| 299 | for(i=0;i<nlsr_position;i++) |
| 300 | { |
| 301 | res=ccn_name_comp_get(info->interest_ccnb, info->interest_comps,i,&comp_ptr1, &comp_size); |
akmhoque | 6dc9a24 | 2012-08-21 11:23:57 -0400 | [diff] [blame] | 302 | //printf("%s \n",comp_ptr1); |
akmhoque | 8a5babe | 2012-08-16 17:39:33 -0500 | [diff] [blame] | 303 | ccn_charbuf_append_string(nbr,"/"); |
| 304 | ccn_charbuf_append_string(nbr,(const char *)comp_ptr1); |
| 305 | } |
| 306 | |
akmhoque | 71b552d | 2012-08-21 11:44:34 -0400 | [diff] [blame] | 307 | ccn_charbuf_append_string(nbr,"\0"); |
akmhoque | 8a5babe | 2012-08-16 17:39:33 -0500 | [diff] [blame] | 308 | printf("Interest Timed out for Neighbor: %s\n",ccn_charbuf_as_string(nbr)); |
| 309 | |
| 310 | update_adjacent_status_to_adl(nbr,1); |
| 311 | |
| 312 | ccn_charbuf_destroy(&nbr); |
akmhoque | dde7e32 | 2012-08-16 13:57:06 -0500 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | void |
akmhoque | d79438d | 2012-08-27 13:31:42 -0500 | [diff] [blame] | 316 | process_incoming_timed_out_interest_info(struct ccn_closure* selfp, struct ccn_upcall_info* info) |
| 317 | { |
| 318 | |
| 319 | printf("process_incoming_timed_out_interest_info called \n"); |
| 320 | |
| 321 | int res,i; |
| 322 | int nlsr_position=0; |
| 323 | int name_comps=(int)info->interest_comps->n; |
| 324 | |
| 325 | for(i=0;i<name_comps;i++) |
| 326 | { |
| 327 | res=ccn_name_comp_strcmp(info->interest_ccnb,info->interest_comps,i,"nlsr"); |
| 328 | if( res == 0) |
| 329 | { |
| 330 | nlsr_position=i; |
| 331 | break; |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | struct ccn_charbuf *nbr; |
| 336 | nbr=ccn_charbuf_create(); |
| 337 | |
| 338 | |
| 339 | const unsigned char *comp_ptr1; |
| 340 | size_t comp_size; |
| 341 | for(i=0;i<nlsr_position;i++) |
| 342 | { |
| 343 | res=ccn_name_comp_get(info->interest_ccnb, info->interest_comps,i,&comp_ptr1, &comp_size); |
| 344 | //printf("%s \n",comp_ptr1); |
| 345 | ccn_charbuf_append_string(nbr,"/"); |
| 346 | ccn_charbuf_append_string(nbr,(const char *)comp_ptr1); |
| 347 | } |
| 348 | |
| 349 | ccn_charbuf_append_string(nbr,"\0"); |
| 350 | printf("Info Interest Timed out for Neighbor: %s\n",ccn_charbuf_as_string(nbr)); |
| 351 | |
| 352 | update_adjacent_timed_out_to_adl(nbr,1); |
| 353 | int timed_out=get_timed_out_number(nbr); |
| 354 | if(timed_out<nlsr->interest_retry && timed_out>0) // use configured variables |
| 355 | { |
| 356 | printf("Neighbor: %s Info Interest Timed Out: %d times\n",ccn_charbuf_as_string(nbr),timed_out); |
| 357 | send_info_interest_to_neighbor(nbr); |
| 358 | } |
| 359 | else |
| 360 | { |
| 361 | printf("Neighbor: %s Info Interest Timed Out: %d times\n",ccn_charbuf_as_string(nbr),timed_out); |
| 362 | nlsr->event_build_adj_lsa = ccn_schedule_event(nlsr->sched, 1, &install_adj_lsa, NULL, 0); |
| 363 | } |
| 364 | |
| 365 | ccn_charbuf_destroy(&nbr); |
| 366 | } |
| 367 | |
| 368 | |
| 369 | void |
akmhoque | 1c9b92f | 2012-08-13 10:57:50 -0500 | [diff] [blame] | 370 | process_incoming_interest(struct ccn_closure *selfp, struct ccn_upcall_info *info) |
| 371 | { |
| 372 | printf("process_incoming_interest called \n"); |
| 373 | |
| 374 | |
| 375 | struct ccn_charbuf*c; |
| 376 | c=ccn_charbuf_create(); |
| 377 | ccn_uri_append(c,info->interest_ccnb,info->pi->offset[CCN_PI_E_Name]-info->pi->offset[CCN_PI_B_Name],0); |
| 378 | printf("%s\n",ccn_charbuf_as_string(c)); |
| 379 | ccn_charbuf_destroy(&c); |
| 380 | |
| 381 | const unsigned char *comp_ptr1; |
| 382 | size_t comp_size; |
| 383 | int res,i; |
| 384 | int nlsr_position=0; |
| 385 | int name_comps=(int)info->interest_comps->n; |
| 386 | |
| 387 | for(i=0;i<name_comps;i++) |
| 388 | { |
| 389 | res=ccn_name_comp_strcmp(info->interest_ccnb,info->interest_comps,i,"nlsr"); |
| 390 | if( res == 0) |
| 391 | { |
akmhoque | ea3603e | 2012-08-13 11:24:09 -0500 | [diff] [blame] | 392 | nlsr_position=i; |
akmhoque | 1c9b92f | 2012-08-13 10:57:50 -0500 | [diff] [blame] | 393 | break; |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | res=ccn_name_comp_get(info->interest_ccnb, info->interest_comps,nlsr_position+1,&comp_ptr1, &comp_size); |
akmhoque | e078986 | 2012-08-16 14:23:32 -0500 | [diff] [blame] | 398 | |
akmhoque | 1c9b92f | 2012-08-13 10:57:50 -0500 | [diff] [blame] | 399 | printf("Det= %s \n",comp_ptr1); |
| 400 | |
| 401 | if(!strcmp((char *)comp_ptr1,"lsdb")) |
| 402 | { |
akmhoque | bf1aa83 | 2012-08-13 13:26:59 -0500 | [diff] [blame] | 403 | process_incoming_interest_lsdb(selfp,info); |
akmhoque | 1c9b92f | 2012-08-13 10:57:50 -0500 | [diff] [blame] | 404 | } |
akmhoque | d79438d | 2012-08-27 13:31:42 -0500 | [diff] [blame] | 405 | if(!strcmp((char *)comp_ptr1,"info")) |
| 406 | { |
| 407 | process_incoming_interest_info(selfp,info); |
| 408 | } |
akmhoque | bf1aa83 | 2012-08-13 13:26:59 -0500 | [diff] [blame] | 409 | } |
| 410 | |
| 411 | |
| 412 | void |
| 413 | process_incoming_interest_lsdb(struct ccn_closure *selfp, struct ccn_upcall_info *info) |
| 414 | { |
| 415 | printf("process_incoming_interest_lsdb called \n"); |
| 416 | |
akmhoque | cb01775 | 2012-08-16 11:03:45 -0500 | [diff] [blame] | 417 | int l, res; |
akmhoque | fce8cfc | 2012-08-14 14:00:33 -0500 | [diff] [blame] | 418 | const unsigned char *exclbase; |
akmhoque | 6d49e4d | 2012-08-14 13:49:30 -0500 | [diff] [blame] | 419 | size_t size; |
akmhoque | fce8cfc | 2012-08-14 14:00:33 -0500 | [diff] [blame] | 420 | struct ccn_buf_decoder decoder; |
| 421 | struct ccn_buf_decoder *d; |
| 422 | const unsigned char *comp; |
| 423 | |
akmhoque | 6d49e4d | 2012-08-14 13:49:30 -0500 | [diff] [blame] | 424 | |
| 425 | l = info->pi->offset[CCN_PI_E_Exclude] - info->pi->offset[CCN_PI_B_Exclude]; |
| 426 | if (l > 0) |
| 427 | { |
| 428 | comp = NULL; |
| 429 | size = 0; |
| 430 | exclbase = info->interest_ccnb + info->pi->offset[CCN_PI_B_Exclude]; |
| 431 | d = ccn_buf_decoder_start(&decoder, exclbase, l); |
| 432 | if (ccn_buf_match_dtag(d, CCN_DTAG_Exclude)) |
| 433 | { |
| 434 | ccn_buf_advance(d); |
| 435 | if (ccn_buf_match_dtag(d, CCN_DTAG_Any)) |
| 436 | ccn_buf_advance_past_element(d); |
| 437 | if (ccn_buf_match_dtag(d, CCN_DTAG_Component)) |
| 438 | { |
| 439 | ccn_buf_advance(d); |
| 440 | ccn_buf_match_blob(d, &comp, &size); |
akmhoque | c928669 | 2012-08-16 09:57:58 -0500 | [diff] [blame] | 441 | ccn_buf_check_close(d); |
| 442 | |
| 443 | |
akmhoque | 6d49e4d | 2012-08-14 13:49:30 -0500 | [diff] [blame] | 444 | } |
| 445 | ccn_buf_check_close(d); |
| 446 | } |
akmhoque | 07dd8cc | 2012-08-16 10:23:01 -0500 | [diff] [blame] | 447 | //if (d->decoder.state < 0) |
| 448 | //printf("Parse Failed\n"); |
akmhoque | 6d49e4d | 2012-08-14 13:49:30 -0500 | [diff] [blame] | 449 | if (comp != NULL) |
akmhoque | 37e3adf | 2012-08-14 15:52:50 -0500 | [diff] [blame] | 450 | printf("Number in Exclusion Filter is %s\n",comp); |
akmhoque | 6d49e4d | 2012-08-14 13:49:30 -0500 | [diff] [blame] | 451 | |
| 452 | /* Now comp points to the start of your potential number, and size is its length */ |
| 453 | } |
| 454 | |
akmhoque | f6432c2 | 2012-08-21 13:18:05 -0400 | [diff] [blame] | 455 | int excl_db_version=atoi((char *)comp); |
| 456 | int dbcmp=nlsr->lsdb->version-excl_db_version; |
| 457 | //int dbcmp=strncmp(nlsr->lsdb->version,(char *)comp,16); |
| 458 | |
| 459 | |
akmhoque | 898d4aa | 2012-08-16 10:26:15 -0500 | [diff] [blame] | 460 | |
akmhoque | 6dc9a24 | 2012-08-21 11:23:57 -0400 | [diff] [blame] | 461 | printf (" dbcmp = %d \n",dbcmp); |
akmhoque | 898d4aa | 2012-08-16 10:26:15 -0500 | [diff] [blame] | 462 | |
akmhoque | 07dd8cc | 2012-08-16 10:23:01 -0500 | [diff] [blame] | 463 | if(dbcmp > 0) |
akmhoque | cb01775 | 2012-08-16 11:03:45 -0500 | [diff] [blame] | 464 | { |
akmhoque | f6432c2 | 2012-08-21 13:18:05 -0400 | [diff] [blame] | 465 | printf("Has Updated database (Older: %s New: %ld)\n",comp,nlsr->lsdb->version); |
akmhoque | cb01775 | 2012-08-16 11:03:45 -0500 | [diff] [blame] | 466 | } |
akmhoque | 07dd8cc | 2012-08-16 10:23:01 -0500 | [diff] [blame] | 467 | else |
akmhoque | cb01775 | 2012-08-16 11:03:45 -0500 | [diff] [blame] | 468 | { |
akmhoque | f6432c2 | 2012-08-21 13:18:05 -0400 | [diff] [blame] | 469 | printf("Data base is not updated than the older one (Older: %s New: %ld)\n",comp,nlsr->lsdb->version); |
akmhoque | cb01775 | 2012-08-16 11:03:45 -0500 | [diff] [blame] | 470 | printf("Sending NACK Content back.....\n"); |
akmhoque | 07dd8cc | 2012-08-16 10:23:01 -0500 | [diff] [blame] | 471 | |
akmhoque | cb01775 | 2012-08-16 11:03:45 -0500 | [diff] [blame] | 472 | struct ccn_charbuf *data=ccn_charbuf_create(); |
| 473 | struct ccn_charbuf *name=ccn_charbuf_create(); |
| 474 | struct ccn_signing_params sp=CCN_SIGNING_PARAMS_INIT; |
| 475 | |
akmhoque | 638c20a | 2012-08-16 11:57:48 -0500 | [diff] [blame] | 476 | 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]); |
akmhoque | 8a5babe | 2012-08-16 17:39:33 -0500 | [diff] [blame] | 477 | //ccn_name_append_str(name,"0000000000000001"); |
akmhoque | cb01775 | 2012-08-16 11:03:45 -0500 | [diff] [blame] | 478 | |
| 479 | sp.template_ccnb=ccn_charbuf_create(); |
| 480 | ccn_charbuf_append_tt(sp.template_ccnb,CCN_DTAG_SignedInfo, CCN_DTAG); |
| 481 | ccnb_tagged_putf(sp.template_ccnb, CCN_DTAG_FreshnessSeconds, "%ld", 10); |
| 482 | sp.sp_flags |= CCN_SP_TEMPL_FRESHNESS; |
| 483 | ccn_charbuf_append_closer(sp.template_ccnb); |
| 484 | |
| 485 | res= ccn_sign_content(nlsr->ccn, data, name, &sp, "NACK", strlen("NACK")); |
akmhoque | dde7e32 | 2012-08-16 13:57:06 -0500 | [diff] [blame] | 486 | if(res >= 0) |
| 487 | printf("Signing Content is successful \n"); |
| 488 | |
akmhoque | cb01775 | 2012-08-16 11:03:45 -0500 | [diff] [blame] | 489 | res=ccn_put(nlsr->ccn,data->buf,data->length); |
akmhoque | bf11b1d | 2012-08-16 11:11:17 -0500 | [diff] [blame] | 490 | |
| 491 | if(res >= 0) |
| 492 | printf("Sending NACK Content is successful \n"); |
| 493 | |
akmhoque | cb01775 | 2012-08-16 11:03:45 -0500 | [diff] [blame] | 494 | ccn_charbuf_destroy(&data); |
akmhoque | d79438d | 2012-08-27 13:31:42 -0500 | [diff] [blame] | 495 | ccn_charbuf_destroy(&name); |
akmhoque | cb01775 | 2012-08-16 11:03:45 -0500 | [diff] [blame] | 496 | ccn_charbuf_destroy(&sp.template_ccnb); |
| 497 | |
| 498 | } |
| 499 | |
akmhoque | 1c9b92f | 2012-08-13 10:57:50 -0500 | [diff] [blame] | 500 | } |
| 501 | |
akmhoque | d79438d | 2012-08-27 13:31:42 -0500 | [diff] [blame] | 502 | |
| 503 | void |
| 504 | process_incoming_interest_info(struct ccn_closure *selfp, struct ccn_upcall_info *info) |
| 505 | { |
| 506 | printf("process_incoming_interest_info called \n"); |
| 507 | int res; |
| 508 | |
| 509 | printf("Sending Info Content back.....\n"); |
| 510 | |
| 511 | struct ccn_charbuf *data=ccn_charbuf_create(); |
| 512 | struct ccn_charbuf *name=ccn_charbuf_create(); |
| 513 | struct ccn_signing_params sp=CCN_SIGNING_PARAMS_INIT; |
| 514 | |
| 515 | 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]); |
| 516 | |
| 517 | |
| 518 | sp.template_ccnb=ccn_charbuf_create(); |
| 519 | ccn_charbuf_append_tt(sp.template_ccnb,CCN_DTAG_SignedInfo, CCN_DTAG); |
| 520 | ccnb_tagged_putf(sp.template_ccnb, CCN_DTAG_FreshnessSeconds, "%ld", 10); |
| 521 | sp.sp_flags |= CCN_SP_TEMPL_FRESHNESS; |
| 522 | ccn_charbuf_append_closer(sp.template_ccnb); |
| 523 | |
| 524 | struct ccn_charbuf *c=ccn_charbuf_create(); |
| 525 | ccn_charbuf_reset(c); |
| 526 | ccn_charbuf_putf(c, "%ld", nlsr->lsdb_synch_interval); |
| 527 | ccn_charbuf_append_string(data,ccn_charbuf_as_string(c)); |
| 528 | |
| 529 | res= ccn_sign_content(nlsr->ccn, data, name, &sp, "info", strlen("info")); |
| 530 | if(res >= 0) |
| 531 | printf("Signing Content is successful \n"); |
| 532 | |
| 533 | res=ccn_put(nlsr->ccn,data->buf,data->length); |
| 534 | if(res >= 0) |
| 535 | printf("Sending NACK Content is successful \n"); |
| 536 | |
| 537 | ccn_charbuf_destroy(&data); |
| 538 | ccn_charbuf_destroy(&c); |
| 539 | ccn_charbuf_destroy(&name); |
| 540 | ccn_charbuf_destroy(&sp.template_ccnb); |
| 541 | |
| 542 | } |
| 543 | |
akmhoque | 1c9b92f | 2012-08-13 10:57:50 -0500 | [diff] [blame] | 544 | int |
| 545 | send_lsdb_interest(struct ccn_schedule *sched, void *clienth, |
| 546 | struct ccn_scheduled_event *ev, int flags) |
| 547 | { |
| 548 | |
| 549 | struct ccn_charbuf *name; |
| 550 | long int rnum; |
| 551 | char rnumstr[20]; |
akmhoque | ea3603e | 2012-08-13 11:24:09 -0500 | [diff] [blame] | 552 | char lsdb_str[5]; |
| 553 | char nlsr_str[5]; |
akmhoque | 1c9b92f | 2012-08-13 10:57:50 -0500 | [diff] [blame] | 554 | |
| 555 | int res,i; |
| 556 | int adl_element; |
| 557 | |
| 558 | rnum=random(); |
| 559 | memset(&rnumstr,0,20); |
| 560 | sprintf(rnumstr,"%ld",rnum); |
akmhoque | ea3603e | 2012-08-13 11:24:09 -0500 | [diff] [blame] | 561 | memset(&nlsr_str,0,5); |
| 562 | sprintf(nlsr_str,"nlsr"); |
| 563 | memset(&lsdb_str,0,5); |
| 564 | sprintf(lsdb_str,"lsdb"); |
| 565 | |
akmhoque | 1c9b92f | 2012-08-13 10:57:50 -0500 | [diff] [blame] | 566 | |
| 567 | struct ndn_neighbor *nbr; |
| 568 | |
| 569 | struct hashtb_enumerator ee; |
| 570 | struct hashtb_enumerator *e = ⅇ |
| 571 | |
| 572 | hashtb_start(nlsr->adl, e); |
| 573 | adl_element=hashtb_n(nlsr->adl); |
akmhoque | 07dd8cc | 2012-08-16 10:23:01 -0500 | [diff] [blame] | 574 | //int mynumber=15; |
akmhoque | 1c9b92f | 2012-08-13 10:57:50 -0500 | [diff] [blame] | 575 | |
| 576 | for(i=0;i<adl_element;i++) |
| 577 | { |
| 578 | nbr=e->data; |
akmhoque | a681769 | 2012-08-21 13:50:01 -0400 | [diff] [blame] | 579 | printf("Sending interest for name prefix:%s/%s/%s\n",ccn_charbuf_as_string(nbr->neighbor),nlsr_str,lsdb_str); |
akmhoque | 1c9b92f | 2012-08-13 10:57:50 -0500 | [diff] [blame] | 580 | name=ccn_charbuf_create(); |
akmhoque | a681769 | 2012-08-21 13:50:01 -0400 | [diff] [blame] | 581 | res=ccn_name_from_uri(name,ccn_charbuf_as_string(nbr->neighbor)); |
akmhoque | ea3603e | 2012-08-13 11:24:09 -0500 | [diff] [blame] | 582 | ccn_name_append_str(name,nlsr_str); |
| 583 | ccn_name_append_str(name,lsdb_str); |
akmhoque | f6432c2 | 2012-08-21 13:18:05 -0400 | [diff] [blame] | 584 | //ccn_name_append_str(name,rnumstr); |
akmhoque | 1c9b92f | 2012-08-13 10:57:50 -0500 | [diff] [blame] | 585 | |
akmhoque | 6d49e4d | 2012-08-14 13:49:30 -0500 | [diff] [blame] | 586 | /* adding Exclusion filter */ |
akmhoque | bf1aa83 | 2012-08-13 13:26:59 -0500 | [diff] [blame] | 587 | |
akmhoque | 6d49e4d | 2012-08-14 13:49:30 -0500 | [diff] [blame] | 588 | struct ccn_charbuf *templ; |
| 589 | templ = ccn_charbuf_create(); |
akmhoque | 7f33727 | 2012-08-14 15:16:30 -0500 | [diff] [blame] | 590 | |
akmhoque | 6d49e4d | 2012-08-14 13:49:30 -0500 | [diff] [blame] | 591 | struct ccn_charbuf *c; |
| 592 | c = ccn_charbuf_create(); |
akmhoque | 7f33727 | 2012-08-14 15:16:30 -0500 | [diff] [blame] | 593 | |
| 594 | |
| 595 | ccn_charbuf_append_tt(templ, CCN_DTAG_Interest, CCN_DTAG); |
| 596 | ccn_charbuf_append_tt(templ, CCN_DTAG_Name, CCN_DTAG); |
| 597 | ccn_charbuf_append_closer(templ); /* </Name> */ |
akmhoque | 6d49e4d | 2012-08-14 13:49:30 -0500 | [diff] [blame] | 598 | ccn_charbuf_append_tt(templ, CCN_DTAG_Exclude, CCN_DTAG); |
| 599 | ccnb_tagged_putf(templ, CCN_DTAG_Any, ""); |
| 600 | ccn_charbuf_reset(c); |
akmhoque | 07dd8cc | 2012-08-16 10:23:01 -0500 | [diff] [blame] | 601 | //ccn_charbuf_putf(c, "%u", (unsigned)mynumber); |
akmhoque | a681769 | 2012-08-21 13:50:01 -0400 | [diff] [blame] | 602 | //ccn_charbuf_putf(c, "%s", nbr->last_lsdb_version); |
| 603 | ccn_charbuf_putf(c, "%u", (unsigned)nbr->last_lsdb_version); |
akmhoque | 6d49e4d | 2012-08-14 13:49:30 -0500 | [diff] [blame] | 604 | ccnb_append_tagged_blob(templ, CCN_DTAG_Component, c->buf, c->length); |
| 605 | ccn_charbuf_append_closer(templ); /* </Exclude> */ |
akmhoque | 7f33727 | 2012-08-14 15:16:30 -0500 | [diff] [blame] | 606 | ccn_charbuf_append_closer(templ); /* </Interest> */ |
akmhoque | 37e3adf | 2012-08-14 15:52:50 -0500 | [diff] [blame] | 607 | |
akmhoque | 6d49e4d | 2012-08-14 13:49:30 -0500 | [diff] [blame] | 608 | |
| 609 | /* Adding Exclusion filter done */ |
| 610 | |
akmhoque | 7f33727 | 2012-08-14 15:16:30 -0500 | [diff] [blame] | 611 | res=ccn_express_interest(nlsr->ccn,name,&(nlsr->in_content),templ); |
| 612 | |
akmhoque | 1c9b92f | 2012-08-13 10:57:50 -0500 | [diff] [blame] | 613 | if ( res >= 0 ) |
| 614 | printf("Interest sending Successfull .... \n"); |
akmhoque | 37e3adf | 2012-08-14 15:52:50 -0500 | [diff] [blame] | 615 | ccn_charbuf_destroy(&c); |
akmhoque | 7f33727 | 2012-08-14 15:16:30 -0500 | [diff] [blame] | 616 | ccn_charbuf_destroy(&templ); |
akmhoque | 1c9b92f | 2012-08-13 10:57:50 -0500 | [diff] [blame] | 617 | ccn_charbuf_destroy(&name); |
| 618 | |
akmhoque | 1d7343f | 2012-08-21 10:46:35 -0400 | [diff] [blame] | 619 | hashtb_next(e); |
akmhoque | 1c9b92f | 2012-08-13 10:57:50 -0500 | [diff] [blame] | 620 | } |
| 621 | |
| 622 | hashtb_end(e); |
| 623 | |
akmhoque | bf11b1d | 2012-08-16 11:11:17 -0500 | [diff] [blame] | 624 | nlsr->event_send_lsdb_interest = ccn_schedule_event(nlsr->sched, 60000000, &send_lsdb_interest, NULL, 0); |
akmhoque | 1c9b92f | 2012-08-13 10:57:50 -0500 | [diff] [blame] | 625 | |
| 626 | return 0; |
| 627 | |
| 628 | } |
| 629 | |
akmhoque | d79438d | 2012-08-27 13:31:42 -0500 | [diff] [blame] | 630 | |
| 631 | int |
| 632 | send_info_interest(struct ccn_schedule *sched, void *clienth, |
| 633 | struct ccn_scheduled_event *ev, int flags) |
| 634 | { |
| 635 | |
| 636 | struct ccn_charbuf *name; |
| 637 | long int rnum; |
| 638 | char rnumstr[20]; |
| 639 | char info_str[5]; |
| 640 | char nlsr_str[5]; |
| 641 | |
| 642 | int res,i; |
| 643 | int adl_element; |
| 644 | int scope = 2; //no further than the next host |
| 645 | |
| 646 | rnum=random(); |
| 647 | memset(&rnumstr,0,20); |
| 648 | sprintf(rnumstr,"%ld",rnum); |
| 649 | memset(&nlsr_str,0,5); |
| 650 | sprintf(nlsr_str,"nlsr"); |
| 651 | memset(&info_str,0,5); |
| 652 | sprintf(info_str,"info"); |
| 653 | |
| 654 | |
| 655 | struct ndn_neighbor *nbr; |
| 656 | |
| 657 | struct hashtb_enumerator ee; |
| 658 | struct hashtb_enumerator *e = ⅇ |
| 659 | |
| 660 | hashtb_start(nlsr->adl, e); |
| 661 | adl_element=hashtb_n(nlsr->adl); |
| 662 | //int mynumber=15; |
| 663 | |
| 664 | for(i=0;i<adl_element;i++) |
| 665 | { |
| 666 | nbr=e->data; |
| 667 | printf("Sending interest for name prefix:%s/%s/%s\n",ccn_charbuf_as_string(nbr->neighbor),nlsr_str,info_str); |
| 668 | name=ccn_charbuf_create(); |
| 669 | res=ccn_name_from_uri(name,ccn_charbuf_as_string(nbr->neighbor)); |
| 670 | ccn_name_append_str(name,nlsr_str); |
| 671 | ccn_name_append_str(name,info_str); |
| 672 | //ccn_name_append_str(name,rnumstr); |
| 673 | |
| 674 | /* adding Exclusion filter */ |
| 675 | |
| 676 | struct ccn_charbuf *templ; |
| 677 | templ = ccn_charbuf_create(); |
| 678 | |
| 679 | // struct ccn_charbuf *c; |
| 680 | // c = ccn_charbuf_create(); |
| 681 | |
| 682 | |
| 683 | ccn_charbuf_append_tt(templ, CCN_DTAG_Interest, CCN_DTAG); |
| 684 | ccn_charbuf_append_tt(templ, CCN_DTAG_Name, CCN_DTAG); |
| 685 | ccn_charbuf_append_closer(templ); /* </Name> */ |
| 686 | // ccn_charbuf_append_tt(templ, CCN_DTAG_Exclude, CCN_DTAG); |
| 687 | // ccnb_tagged_putf(templ, CCN_DTAG_Any, ""); |
| 688 | // ccn_charbuf_reset(c); |
| 689 | // //ccn_charbuf_putf(c, "%u", (unsigned)mynumber); |
| 690 | // //ccn_charbuf_putf(c, "%s", nbr->last_lsdb_version); |
| 691 | // ccn_charbuf_putf(c, "%u", (unsigned)nbr->last_lsdb_version); |
| 692 | // ccnb_append_tagged_blob(templ, CCN_DTAG_Component, c->buf, c->length); |
| 693 | // ccn_charbuf_append_closer(templ); /* </Exclude> */ |
| 694 | ccnb_tagged_putf(templ, CCN_DTAG_Scope, "%d", scope); |
| 695 | appendLifetime(templ,nlsr->interest_resend_time); |
| 696 | ccn_charbuf_append_closer(templ); /* </Interest> */ |
| 697 | |
| 698 | |
| 699 | /* Adding Exclusion filter done */ |
| 700 | |
| 701 | res=ccn_express_interest(nlsr->ccn,name,&(nlsr->in_content),templ); |
| 702 | |
| 703 | if ( res >= 0 ) |
| 704 | printf("Interest sending Successfull .... \n"); |
| 705 | // ccn_charbuf_destroy(&c); |
| 706 | ccn_charbuf_destroy(&templ); |
| 707 | ccn_charbuf_destroy(&name); |
| 708 | |
| 709 | hashtb_next(e); |
| 710 | } |
| 711 | |
| 712 | hashtb_end(e); |
| 713 | |
| 714 | //nlsr->event_send_info_interest = ccn_schedule_event(nlsr->sched, 20000000, &send_info_interest, NULL, 0); |
| 715 | |
| 716 | return 0; |
| 717 | |
| 718 | } |
| 719 | |
| 720 | |
| 721 | void |
| 722 | send_info_interest_to_neighbor(struct ccn_charbuf *nbr) |
| 723 | { |
| 724 | |
| 725 | struct ccn_charbuf *name; |
| 726 | long int rnum; |
| 727 | char rnumstr[20]; |
| 728 | char info_str[5]; |
| 729 | char nlsr_str[5]; |
| 730 | |
| 731 | int res; |
| 732 | int scope = 2; //no further than the next host |
| 733 | |
| 734 | rnum=random(); |
| 735 | memset(&rnumstr,0,20); |
| 736 | sprintf(rnumstr,"%ld",rnum); |
| 737 | memset(&nlsr_str,0,5); |
| 738 | sprintf(nlsr_str,"nlsr"); |
| 739 | memset(&info_str,0,5); |
| 740 | sprintf(info_str,"info"); |
| 741 | |
| 742 | printf("Sending interest for name prefix:%s/%s/%s\n",ccn_charbuf_as_string(nbr),nlsr_str,info_str); |
| 743 | name=ccn_charbuf_create(); |
| 744 | res=ccn_name_from_uri(name,ccn_charbuf_as_string(nbr)); |
| 745 | ccn_name_append_str(name,nlsr_str); |
| 746 | ccn_name_append_str(name,info_str); |
| 747 | //ccn_name_append_str(name,rnumstr); |
| 748 | |
| 749 | /* adding Exclusion filter */ |
| 750 | |
| 751 | struct ccn_charbuf *templ; |
| 752 | templ = ccn_charbuf_create(); |
| 753 | |
| 754 | // struct ccn_charbuf *c; |
| 755 | // c = ccn_charbuf_create(); |
| 756 | |
| 757 | |
| 758 | ccn_charbuf_append_tt(templ, CCN_DTAG_Interest, CCN_DTAG); |
| 759 | ccn_charbuf_append_tt(templ, CCN_DTAG_Name, CCN_DTAG); |
| 760 | ccn_charbuf_append_closer(templ); /* </Name> */ |
| 761 | // ccn_charbuf_append_tt(templ, CCN_DTAG_Exclude, CCN_DTAG); |
| 762 | // ccnb_tagged_putf(templ, CCN_DTAG_Any, ""); |
| 763 | // ccn_charbuf_reset(c); |
| 764 | // //ccn_charbuf_putf(c, "%u", (unsigned)mynumber); |
| 765 | // //ccn_charbuf_putf(c, "%s", nbr->last_lsdb_version); |
| 766 | // ccn_charbuf_putf(c, "%u", (unsigned)nbr->last_lsdb_version); |
| 767 | // ccnb_append_tagged_blob(templ, CCN_DTAG_Component, c->buf, c->length); |
| 768 | // ccn_charbuf_append_closer(templ); /* </Exclude> */ |
| 769 | ccnb_tagged_putf(templ, CCN_DTAG_Scope, "%d", scope); |
| 770 | appendLifetime(templ,15); |
| 771 | ccn_charbuf_append_closer(templ); /* </Interest> */ |
| 772 | |
| 773 | |
| 774 | /* Adding Exclusion filter done */ |
| 775 | |
| 776 | res=ccn_express_interest(nlsr->ccn,name,&(nlsr->in_content),templ); |
| 777 | |
| 778 | if ( res >= 0 ) |
| 779 | printf("Interest sending Successfull .... \n"); |
| 780 | // ccn_charbuf_destroy(&c); |
| 781 | ccn_charbuf_destroy(&templ); |
| 782 | ccn_charbuf_destroy(&name); |
| 783 | |
| 784 | } |