blob: a22ecde2ed328c196f09c4f0a324450f63d54347 [file] [log] [blame]
akmhoque8a5babe2012-08-16 17:39:33 -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"
akmhoque03004e62012-09-06 01:12:28 -050021#include "nlsr_npl.h"
akmhoque8a5babe2012-08-16 17:39:33 -050022#include "nlsr_adl.h"
akmhoque03004e62012-09-06 01:12:28 -050023#include "utility.h"
akmhoquefbfd0982012-09-09 20:59:03 -050024#include "nlsr_npt.h"
akmhoque8a5babe2012-08-16 17:39:33 -050025
akmhoque03004e62012-09-06 01:12:28 -050026void
27add_nbr_to_adl(struct name_prefix *new_nbr,int face)
akmhoque8a5babe2012-08-16 17:39:33 -050028{
akmhoque03004e62012-09-06 01:12:28 -050029 struct ndn_neighbor *nbr=(struct ndn_neighbor *)malloc(sizeof(struct ndn_neighbor )); //free
akmhoque53f64222012-09-05 13:57:51 -050030
akmhoque8a5babe2012-08-16 17:39:33 -050031 struct hashtb_enumerator ee;
32 struct hashtb_enumerator *e = &ee;
33 int res;
34
35 hashtb_start(nlsr->adl, e);
akmhoque03004e62012-09-06 01:12:28 -050036 res = hashtb_seek(e, new_nbr->name, new_nbr->length, 0);
akmhoque2852a222012-08-21 12:09:00 -040037
akmhoquee7c4b6d2012-08-21 12:30:25 -040038 if(res == HT_NEW_ENTRY )
39 {
akmhoque8a5babe2012-08-16 17:39:33 -050040
akmhoque53f64222012-09-05 13:57:51 -050041 nbr = e->data;
akmhoque8a5babe2012-08-16 17:39:33 -050042
akmhoque03004e62012-09-06 01:12:28 -050043 nbr->neighbor=(struct name_prefix *)malloc(sizeof( struct name_prefix )); //free
44 nbr->neighbor->name=(char *)malloc(new_nbr->length);
45 memcpy(nbr->neighbor->name,new_nbr->name,new_nbr->length);
46 nbr->neighbor->length=new_nbr->length;
akmhoque53f64222012-09-05 13:57:51 -050047 nbr->face=face;
48 nbr->status=NBR_DOWN;
49 nbr->info_interest_timed_out=0;
50 nbr->lsdb_synch_interval=300;
51 nbr->metric=10;
52 nbr->is_lsdb_send_interest_scheduled=0;
53
akmhoque8a5babe2012-08-16 17:39:33 -050054
akmhoque03004e62012-09-06 01:12:28 -050055 char *time_stamp=(char *)malloc(20);
56 get_current_timestamp_micro(time_stamp);
57 nbr->last_lsdb_version=(char *)malloc(strlen(time_stamp)+1); //free
akmhoque53f64222012-09-05 13:57:51 -050058 memcpy(nbr->last_lsdb_version,time_stamp,strlen(time_stamp)+1);
59 memset(nbr->last_lsdb_version,'0',strlen(time_stamp));
akmhoque03004e62012-09-06 01:12:28 -050060 nbr->last_info_version=(char *)malloc(strlen(time_stamp)+1); //free
61 memcpy(nbr->last_info_version,time_stamp,strlen(time_stamp)+1);
62 memset(nbr->last_info_version,'0',strlen(time_stamp));
63 free(time_stamp);
akmhoque53f64222012-09-05 13:57:51 -050064
65 nbr->last_lsdb_requested=0;
akmhoquee7c4b6d2012-08-21 12:30:25 -040066 }
akmhoque53f64222012-09-05 13:57:51 -050067
akmhoque8a5babe2012-08-16 17:39:33 -050068 hashtb_end(e);
akmhoque53f64222012-09-05 13:57:51 -050069}
akmhoque8a5babe2012-08-16 17:39:33 -050070
akmhoque03004e62012-09-06 01:12:28 -050071
akmhoque53f64222012-09-05 13:57:51 -050072void
73print_adjacent(struct ndn_neighbor *nbr)
74{
akmhoque03004e62012-09-06 01:12:28 -050075 printf("print_adjacent called\n");
akmhoque53f64222012-09-05 13:57:51 -050076 printf("--------Neighbor---------------------------\n");
77 printf(" Neighbor: %s \n",nbr->neighbor->name);
78 printf(" Length : %d \n",nbr->neighbor->length);
79 printf(" Face : %d \n",nbr->face);
80 printf(" Metric : %d \n",nbr->metric);
81 printf(" Status : %d \n",nbr->status);
82 printf(" LSDB Version: %s \n",nbr->last_lsdb_version);
akmhoque03004e62012-09-06 01:12:28 -050083 printf(" Info Version: %s \n",nbr->last_info_version);
akmhoque53f64222012-09-05 13:57:51 -050084 printf(" Info Interest Timed Out : %d \n",nbr->info_interest_timed_out);
85 printf(" LSDB Synch Interval : %ld \n",nbr->lsdb_synch_interval);
86 printf(" Las Time LSDB Requested: %ld \n",nbr->last_lsdb_requested);
akmhoque03004e62012-09-06 01:12:28 -050087 printf(" IS_lsdb_send_interest_scheduled : %d \n",nbr->is_lsdb_send_interest_scheduled);
88
89 printf("\n");
akmhoque8a5babe2012-08-16 17:39:33 -050090
91}
92
93void
94print_adjacent_from_adl(void)
95{
akmhoque53f64222012-09-05 13:57:51 -050096
akmhoque8a5babe2012-08-16 17:39:33 -050097 printf("print_adjacent_from_adl called \n");
98 int i, adl_element;
99 struct ndn_neighbor *nbr;
100
101 struct hashtb_enumerator ee;
102 struct hashtb_enumerator *e = &ee;
103
104 hashtb_start(nlsr->adl, e);
105 adl_element=hashtb_n(nlsr->adl);
106
107 for(i=0;i<adl_element;i++)
108 {
109 nbr=e->data;
akmhoque53f64222012-09-05 13:57:51 -0500110 print_adjacent(nbr);
akmhoque8a5babe2012-08-16 17:39:33 -0500111 hashtb_next(e);
112 }
113
114 hashtb_end(e);
115
akmhoque8a5babe2012-08-16 17:39:33 -0500116}
117
akmhoque03004e62012-09-06 01:12:28 -0500118int
119get_adjacent_status(struct name_prefix *nbr)
120{
121 printf("get_adjacent_status called \n");
122
123 int res;
124 int status=-1;
125 struct ndn_neighbor *nnbr;
126
127 struct hashtb_enumerator ee;
128 struct hashtb_enumerator *e = &ee;
129
130 hashtb_start(nlsr->adl, e);
131 res = hashtb_seek(e, nbr->name, nbr->length, 0);
132
133 if (res == HT_OLD_ENTRY)
134 {
135 nnbr=e->data;
136 status=nnbr->status;
137 }
138 else if(res == HT_NEW_ENTRY)
139 {
140 hashtb_delete(e);
141 }
142
143 hashtb_end(e);
144
145 return status;
146
147}
148
149int
150get_timed_out_number(struct name_prefix *nbr)
151{
152 printf("get_timed_out_number called \n");
153
154 int res,ret=-1;
155 struct ndn_neighbor *nnbr;
156
157 struct hashtb_enumerator ee;
158 struct hashtb_enumerator *e = &ee;
159
160 hashtb_start(nlsr->adl, e);
161 res = hashtb_seek(e, nbr->name, nbr->length, 0);
162
163 if( res == HT_OLD_ENTRY )
164 {
165 nnbr=e->data;
166 ret=nnbr->info_interest_timed_out;
167 }
168 else if(res == HT_NEW_ENTRY)
169 {
170 hashtb_delete(e);
171 }
172
173 hashtb_end(e);
174
175 return ret;
176}
177
178
179void
180update_adjacent_timed_out_to_adl(struct name_prefix *nbr, int increment)
181{
182 printf("update_adjacent_timed_out_to_adl called \n");
183
184 int res;
185 struct ndn_neighbor *nnbr;
186
187 struct hashtb_enumerator ee;
188 struct hashtb_enumerator *e = &ee;
189
190 hashtb_start(nlsr->adl, e);
191 res = hashtb_seek(e, nbr->name, nbr->length, 0);
192
193 if( res == HT_OLD_ENTRY )
194 {
195 nnbr=e->data;
196 nnbr->info_interest_timed_out += increment;
197 }
198 else if(res == HT_NEW_ENTRY)
199 {
200 hashtb_delete(e);
201 }
202
203 hashtb_end(e);
204}
205
206void
207update_adjacent_timed_out_zero_to_adl(struct name_prefix *nbr)
208{
209 printf("update_adjacent_timed_out_zero_to_adl called \n");
210 int time_out_number=get_timed_out_number(nbr);
211 update_adjacent_timed_out_to_adl(nbr,-time_out_number);
212
213}
214
akmhoque8a5babe2012-08-16 17:39:33 -0500215void
akmhoque53f64222012-09-05 13:57:51 -0500216update_adjacent_status_to_adl(struct name_prefix *nbr, int status)
akmhoque8a5babe2012-08-16 17:39:33 -0500217{
218 printf("update_adjacent_status_to_adl called \n");
akmhoque03004e62012-09-06 01:12:28 -0500219
akmhoque8a5babe2012-08-16 17:39:33 -0500220 int res;
221 struct ndn_neighbor *nnbr;
222
223 struct hashtb_enumerator ee;
224 struct hashtb_enumerator *e = &ee;
225
226 hashtb_start(nlsr->adl, e);
akmhoque53f64222012-09-05 13:57:51 -0500227 res = hashtb_seek(e, nbr->name, nbr->length, 0);
228
akmhoque918ff9a2012-08-21 11:34:49 -0400229
akmhoquee7c4b6d2012-08-21 12:30:25 -0400230 if (res == HT_OLD_ENTRY)
231 {
232 nnbr=e->data;
akmhoque42098b12012-08-27 22:54:23 -0500233 if ( nnbr->status!=status )
234 {
235 nnbr->status=status;
236 nlsr->adj_build_flag++;
237 }
akmhoquee7c4b6d2012-08-21 12:30:25 -0400238 }
akmhoqueb903ded2012-08-21 12:56:28 -0400239 else if(res == HT_NEW_ENTRY)
240 {
241 hashtb_delete(e);
242 }
akmhoque53f64222012-09-05 13:57:51 -0500243
akmhoque8a5babe2012-08-16 17:39:33 -0500244 hashtb_end(e);
245}
246
akmhoque8a5babe2012-08-16 17:39:33 -0500247void
akmhoque53f64222012-09-05 13:57:51 -0500248update_lsdb_synch_interval_to_adl(struct name_prefix *nbr, long int interval)
akmhoque8a5babe2012-08-16 17:39:33 -0500249{
akmhoque53f64222012-09-05 13:57:51 -0500250 printf("uupdate_lsdb_synch_interval_to_adl called \n");
akmhoque8a5babe2012-08-16 17:39:33 -0500251
252 int res;
253 struct ndn_neighbor *nnbr;
254
255 struct hashtb_enumerator ee;
256 struct hashtb_enumerator *e = &ee;
257
258 hashtb_start(nlsr->adl, e);
akmhoque53f64222012-09-05 13:57:51 -0500259 res = hashtb_seek(e, nbr->name, nbr->length, 0);
akmhoque8a5babe2012-08-16 17:39:33 -0500260
akmhoque53f64222012-09-05 13:57:51 -0500261
262 if (res == HT_OLD_ENTRY)
akmhoquee7c4b6d2012-08-21 12:30:25 -0400263 {
264 nnbr=e->data;
akmhoque53f64222012-09-05 13:57:51 -0500265 if ( nnbr->lsdb_synch_interval!= interval )
266 {
267 nnbr->lsdb_synch_interval=interval;
akmhoque03004e62012-09-06 01:12:28 -0500268
akmhoque53f64222012-09-05 13:57:51 -0500269 }
akmhoquee7c4b6d2012-08-21 12:30:25 -0400270 }
akmhoqueb903ded2012-08-21 12:56:28 -0400271 else if(res == HT_NEW_ENTRY)
272 {
273 hashtb_delete(e);
274 }
akmhoque53f64222012-09-05 13:57:51 -0500275
akmhoque8a5babe2012-08-16 17:39:33 -0500276 hashtb_end(e);
277}
akmhoqued79438d2012-08-27 13:31:42 -0500278
akmhoque53f64222012-09-05 13:57:51 -0500279
akmhoque53f64222012-09-05 13:57:51 -0500280int
akmhoque03004e62012-09-06 01:12:28 -0500281no_active_nbr(void)
akmhoque53f64222012-09-05 13:57:51 -0500282{
akmhoque03004e62012-09-06 01:12:28 -0500283 int i, adl_element;
284 int no_link=0;
285 struct ndn_neighbor *nbr;
akmhoqued79438d2012-08-27 13:31:42 -0500286 struct hashtb_enumerator ee;
287 struct hashtb_enumerator *e = &ee;
akmhoque03004e62012-09-06 01:12:28 -0500288 hashtb_start(nlsr->adl, e);
289 adl_element=hashtb_n(nlsr->adl);
akmhoqued79438d2012-08-27 13:31:42 -0500290
akmhoque03004e62012-09-06 01:12:28 -0500291 for(i=0;i<adl_element;i++)
akmhoqued79438d2012-08-27 13:31:42 -0500292 {
akmhoque03004e62012-09-06 01:12:28 -0500293 nbr=e->data;
294 if( nbr->status == 1 )
295 no_link++;
296 hashtb_next(e);
akmhoqued79438d2012-08-27 13:31:42 -0500297 }
akmhoque53f64222012-09-05 13:57:51 -0500298
akmhoqued79438d2012-08-27 13:31:42 -0500299 hashtb_end(e);
300
akmhoque03004e62012-09-06 01:12:28 -0500301 return no_link;
akmhoque53f64222012-09-05 13:57:51 -0500302
akmhoqued79438d2012-08-27 13:31:42 -0500303}
akmhoque53f64222012-09-05 13:57:51 -0500304
305int
306is_adj_lsa_build(void)
307{
308 int ret=0;
309
310 int nbr_count=0;
311
312 int i, adl_element;
313 struct ndn_neighbor *nbr;
314
315 struct hashtb_enumerator ee;
316 struct hashtb_enumerator *e = &ee;
317
318 hashtb_start(nlsr->adl, e);
319 adl_element=hashtb_n(nlsr->adl);
320
321 for(i=0;i<adl_element;i++)
322 {
323 nbr=e->data;
324 if(nbr->status == 1 )
325 {
326 nbr_count++;
327 }
328 else if (nbr->info_interest_timed_out >= nlsr->interest_retry)
329 {
330 nbr_count++;
331 }
332 hashtb_next(e);
333 }
334
335 hashtb_end(e);
336 if(nbr_count == adl_element)
337 ret=1;
akmhoque03004e62012-09-06 01:12:28 -0500338
akmhoque53f64222012-09-05 13:57:51 -0500339 return ret;
340}
341
akmhoque53f64222012-09-05 13:57:51 -0500342
343void
344get_active_nbr_adj_data(struct ccn_charbuf *c)
345{
346
347 int i, adl_element;
348 struct ndn_neighbor *nbr;
349 struct hashtb_enumerator ee;
350 struct hashtb_enumerator *e = &ee;
351 hashtb_start(nlsr->adl, e);
352 adl_element=hashtb_n(nlsr->adl);
353
354 for(i=0;i<adl_element;i++)
355 {
356 nbr=e->data;
357 if( nbr->status == 1 )
358 {
359 ccn_charbuf_append_string(c,nbr->neighbor->name);
360 ccn_charbuf_append_string(c,"|");
akmhoque03004e62012-09-06 01:12:28 -0500361
akmhoque53f64222012-09-05 13:57:51 -0500362 char *temp_length=(char *)malloc(20);
363 memset(temp_length,0,20);
364 sprintf(temp_length,"%d",nbr->neighbor->length);
365 ccn_charbuf_append_string(c,temp_length);
366 free(temp_length);
367 ccn_charbuf_append_string(c,"|");
368
369 char *temp_face=(char *)malloc(20);
370 memset(temp_face,0,20);
371 sprintf(temp_face,"%d",nbr->face);
372 ccn_charbuf_append_string(c,temp_face);
373 free(temp_face);
374 ccn_charbuf_append_string(c,"|");
375
376 char *temp_metric=(char *)malloc(20);
377 memset(temp_metric,0,20);
378 sprintf(temp_metric,"%d",nbr->metric);
379 ccn_charbuf_append_string(c,temp_metric);
380 free(temp_metric);
381 ccn_charbuf_append_string(c,"|");
382
383 }
384 hashtb_next(e);
385 }
386
387 hashtb_end(e);
388}
389
akmhoque03004e62012-09-06 01:12:28 -0500390long int
391get_nbr_time_diff_lsdb_req(char *nbr)
392{
393 printf("get_nbr_time_diff_lsdb_req called \n");
394
395 long int time_diff=get_lsdb_synch_interval(nbr)+1;
396 int res;
397 struct ndn_neighbor *nnbr;
398
399 struct hashtb_enumerator ee;
400 struct hashtb_enumerator *e = &ee;
401
402 hashtb_start(nlsr->adl, e);
403 res = hashtb_seek(e, nbr, strlen(nbr)+1, 0);
404
405 if (res == HT_OLD_ENTRY)
406 {
407 nnbr=e->data;
408
409 if (nnbr->last_lsdb_requested == 0)
410 time_diff=get_lsdb_synch_interval(nbr)+1;
411 else time_diff=get_current_time_sec() - get_nbr_last_lsdb_requested(nbr);
412
413 }
414 else if(res == HT_NEW_ENTRY)
415 {
416 hashtb_delete(e);
417 }
418
419 hashtb_end(e);
420
421 return time_diff;
422}
423
424long int
425get_nbr_last_lsdb_requested(char *nbr)
426{
427 printf("get_timed_out_number called \n");
428
429 long int last_lsdb_requested=0;
430
431 int res;
432 struct ndn_neighbor *nnbr;
433
434 struct hashtb_enumerator ee;
435 struct hashtb_enumerator *e = &ee;
436
437 hashtb_start(nlsr->adl, e);
438 res = hashtb_seek(e, nbr, strlen(nbr)+1, 0);
439
440 if (res == HT_OLD_ENTRY)
441 {
442 nnbr=e->data;
443 last_lsdb_requested=nnbr->last_lsdb_requested;
444 }
445 else if(res == HT_NEW_ENTRY)
446 {
447 hashtb_delete(e);
448 }
449
450 hashtb_end(e);
451
452 return last_lsdb_requested;
453}
454
455long int
456get_lsdb_synch_interval(char *nbr)
457{
458 printf("get_lsdb_synch_interval called \n");
459
460 long int lsdb_synch_interval=300;
461
462
463 int res;
464 struct ndn_neighbor *nnbr;
465
466 struct hashtb_enumerator ee;
467 struct hashtb_enumerator *e = &ee;
468
469 hashtb_start(nlsr->adl, e);
470 res = hashtb_seek(e, nbr, strlen(nbr)+1, 0);
471
472 if (res == HT_OLD_ENTRY)
473 {
474 nnbr=e->data;
475 lsdb_synch_interval=nnbr->lsdb_synch_interval;
476 }
477 else if(res == HT_NEW_ENTRY)
478 {
479 hashtb_delete(e);
480 }
481
482 hashtb_end(e);
483
484 return lsdb_synch_interval;
485
486}
487
akmhoque53f64222012-09-05 13:57:51 -0500488char *
489get_nbr_lsdb_version(char *nbr)
490{
491 printf("get_timed_out_number called \n");
492
493 char *version=NULL;
494
495 int res;
496 struct ndn_neighbor *nnbr;
497
498 struct hashtb_enumerator ee;
499 struct hashtb_enumerator *e = &ee;
500
501 hashtb_start(nlsr->adl, e);
502 res = hashtb_seek(e, nbr, strlen(nbr)+1, 0);
akmhoque03004e62012-09-06 01:12:28 -0500503
akmhoque53f64222012-09-05 13:57:51 -0500504 if (res == HT_OLD_ENTRY)
505 {
506 nnbr=e->data;
507 version=(char *)malloc(strlen(nnbr->last_lsdb_version)+1);
508 memset(version,0,strlen(nnbr->last_lsdb_version)+1);
509 memcpy(version,nnbr->last_lsdb_version,strlen(nnbr->last_lsdb_version)+1);
510 }
511 else if(res == HT_NEW_ENTRY)
512 {
513 hashtb_delete(e);
514 }
515
516 hashtb_end(e);
517
518 return version;
519}
520
521void
522update_adjacent_last_lsdb_requested_to_adl(char *nbr, long int timestamp)
523{
524 printf("update_adjacent_last_lsdb_requested_to_adl called \n");
525
526 int res;
527 struct ndn_neighbor *nnbr;
528
529 struct hashtb_enumerator ee;
530 struct hashtb_enumerator *e = &ee;
531
532 hashtb_start(nlsr->adl, e);
533 res = hashtb_seek(e, nbr, strlen(nbr)+1, 0);
534
535 if( res == HT_OLD_ENTRY )
536 {
537 nnbr=e->data;
538 nnbr->last_lsdb_requested=timestamp;
akmhoque03004e62012-09-06 01:12:28 -0500539
540 }
541 else if(res == HT_NEW_ENTRY)
542 {
543 hashtb_delete(e);
544 }
545
546 hashtb_end(e);
547}
548
549void
550set_is_lsdb_send_interest_scheduled_to_zero(char *nbr)
551{
552 printf("set_is_lsdb_send_interest_scheduled_to_zero called \n");
553
554 int res;
555 struct ndn_neighbor *nnbr;
556
557 struct hashtb_enumerator ee;
558 struct hashtb_enumerator *e = &ee;
559
560 hashtb_start(nlsr->adl, e);
561 res = hashtb_seek(e, nbr, strlen(nbr)+1, 0);
562
563 if (res == HT_OLD_ENTRY)
564 {
565 nnbr=e->data;
566 nnbr->is_lsdb_send_interest_scheduled=0;
567 }
568 else if(res == HT_NEW_ENTRY)
569 {
570 hashtb_delete(e);
571 }
572
573 hashtb_end(e);
574}
575
576void
577update_adjacent_lsdb_version_to_adl(struct name_prefix *nbr, char *version)
578{
579 printf("update_adjacent_timed_out_to_adl called \n");
580
581 int res;
582 struct ndn_neighbor *nnbr;
583
584 struct hashtb_enumerator ee;
585 struct hashtb_enumerator *e = &ee;
586
587 hashtb_start(nlsr->adl, e);
588 res = hashtb_seek(e, nbr->name, nbr->length, 0);
589
590 if( res == HT_OLD_ENTRY )
591 {
592 nnbr=e->data;
593 free(nnbr->last_lsdb_version);
594 nnbr->last_lsdb_version=(char *)malloc(strlen(version)+1);
595 memset(nnbr->last_lsdb_version,0,strlen(version)+1);
596 memcpy(nnbr->last_lsdb_version,version,strlen(version)+1);
akmhoque53f64222012-09-05 13:57:51 -0500597 }
598 else if(res == HT_NEW_ENTRY)
599 {
600 hashtb_delete(e);
601 }
602
603 hashtb_end(e);
604
605}
606
607void
608adjust_adjacent_last_lsdb_requested_to_adl(char *nbr, long int sec)
609{
610 printf("update_adjacent_last_lsdb_requested_to_adl called \n");
611
612 int res;
613 struct ndn_neighbor *nnbr;
614
615 struct hashtb_enumerator ee;
616 struct hashtb_enumerator *e = &ee;
617
618 hashtb_start(nlsr->adl, e);
619 res = hashtb_seek(e, nbr, strlen(nbr)+1, 0);
620
621 if( res == HT_OLD_ENTRY )
622 {
623 nnbr=e->data;
624 nnbr->last_lsdb_requested=nnbr->last_lsdb_requested-sec;
akmhoque03004e62012-09-06 01:12:28 -0500625
akmhoque53f64222012-09-05 13:57:51 -0500626 }
627 else if(res == HT_NEW_ENTRY)
628 {
629 hashtb_delete(e);
630 }
631
632 hashtb_end(e);
633
634}
635
akmhoquefbfd0982012-09-09 20:59:03 -0500636int
637get_next_hop_face_from_adl(char *nbr)
638{
639 int res;
640 int connecting_face=NO_FACE;
641 struct ndn_neighbor *nnbr;
642
643 struct hashtb_enumerator ee;
644 struct hashtb_enumerator *e = &ee;
645
646 hashtb_start(nlsr->adl, e);
647 res = hashtb_seek(e, nbr, strlen(nbr)+1, 0);
648
649 if( res == HT_OLD_ENTRY )
650 {
651 nnbr=e->data;
652 connecting_face=nnbr->face;
653
654 }
655 else if(res == HT_NEW_ENTRY)
656 {
657 hashtb_delete(e);
658 }
659
660 hashtb_end(e);
661 return connecting_face;
662}
663
akmhoque53f64222012-09-05 13:57:51 -0500664