blob: 70a99a6c813a204f26b10cf63b8dfe25f8e6b4bc [file] [log] [blame]
akmhoque59980a52012-08-09 12:36:09 -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
akmhoque03004e62012-09-06 01:12:28 -050011#include <sys/types.h>
12#include <signal.h>
13
akmhoque59980a52012-08-09 12:36:09 -050014
15
16#include <ccn/ccn.h>
17#include <ccn/uri.h>
18#include <ccn/keystore.h>
19#include <ccn/signing.h>
20#include <ccn/schedule.h>
21#include <ccn/hashtb.h>
22
23#include "nlsr.h"
24#include "nlsr_ndn.h"
akmhoque902d57e2012-08-17 09:24:38 -050025#include "nlsr_lsdb.h"
akmhoque53f64222012-09-05 13:57:51 -050026#include "utility.h"
akmhoque03004e62012-09-06 01:12:28 -050027#include "nlsr_npl.h"
28#include "nlsr_adl.h"
akmhoque3560cb62012-09-09 10:52:30 -050029#include "nlsr_npt.h"
30#include "nlsr_route.h"
31
32
akmhoque81c25e02012-09-10 14:50:33 -050033#define ON_ERROR_DESTROY(resval) \
34{ \
35 if ((resval) < 0) { \
36 nlsr_destroy(); \
akmhoqueffacaa82012-09-13 17:48:30 -050037 exit(1);\
akmhoque81c25e02012-09-10 14:50:33 -050038 } \
39}
40
41
42#define ON_ERROR_EXIT(resval) \
43{ \
44 if ((resval) < 0) { \
akmhoqueffacaa82012-09-13 17:48:30 -050045 exit(1); \
akmhoque81c25e02012-09-10 14:50:33 -050046 } \
47}
akmhoque59980a52012-08-09 12:36:09 -050048
49struct option longopts[] =
50{
51 { "daemon", no_argument, NULL, 'd'},
52 { "config_file", required_argument, NULL, 'f'},
53 { "help", no_argument, NULL, 'h'},
54 { 0 }
55};
56
57static int
58usage(char *progname)
59{
60
61 printf("Usage: %s [OPTIONS...]\n\
62 NDN routing....\n\
63 -d, --daemon Run in daemon mode\n\
64 -f, --config_file Specify configuration file name\n\
65 -h, --help Display this help message\n", progname);
66
67 exit(1);
68}
69
70void ndn_rtr_gettime(const struct ccn_gettime *self, struct ccn_timeval *result)
71{
72 struct timeval now = {0};
73 gettimeofday(&now, 0);
74 result->s = now.tv_sec;
75 result->micros = now.tv_usec;
76}
77
78static struct ccn_gettime ndn_rtr_ticker = {
79 "timer",
80 &ndn_rtr_gettime,
81 1000000,
82 NULL
83};
84
akmhoqueffacaa82012-09-13 17:48:30 -050085void
86nlsr_lock(void)
87{
88 nlsr->semaphor=NLSR_LOCKED;
89}
90
91void
92nlsr_unlock(void)
93{
94 nlsr->semaphor=NLSR_UNLOCKED;
95}
akmhoque42098b12012-08-27 22:54:23 -050096
97void
akmhoque03004e62012-09-06 01:12:28 -050098nlsr_stop_signal_handler(int sig)
akmhoque42098b12012-08-27 22:54:23 -050099{
akmhoque03004e62012-09-06 01:12:28 -0500100 signal(sig, SIG_IGN);
akmhoqueffacaa82012-09-13 17:48:30 -0500101 nlsr_destroy();
102 exit(0);
akmhoque59980a52012-08-09 12:36:09 -0500103}
104
105void
106process_command_ccnneighbor(char *command)
107{
108 if(command==NULL)
109 {
akmhoque28c45022012-08-09 15:38:02 -0500110 printf(" Wrong Command Format ( ccnneighbor router_name faceX)\n");
akmhoque59980a52012-08-09 12:36:09 -0500111 return;
112 }
113 char *rem;
114 const char *sep=" \t\n";
akmhoque28c45022012-08-09 15:38:02 -0500115 char *rtr_name,*face;
akmhoque59980a52012-08-09 12:36:09 -0500116
akmhoque28c45022012-08-09 15:38:02 -0500117 rtr_name=strtok_r(command,sep,&rem);
118 if(rtr_name==NULL)
akmhoque59980a52012-08-09 12:36:09 -0500119 {
akmhoque28c45022012-08-09 15:38:02 -0500120 printf(" Wrong Command Format ( ccnneighbor router_name faceX)\n");
akmhoque59980a52012-08-09 12:36:09 -0500121 return;
122 }
123
124 face=strtok_r(NULL,sep,&rem);
125 if(face==NULL)
126 {
akmhoque28c45022012-08-09 15:38:02 -0500127 printf(" Wrong Command Format ( ccnneighbor router_name faceX)\n");
akmhoque59980a52012-08-09 12:36:09 -0500128 return;
129 }
130
akmhoque28c45022012-08-09 15:38:02 -0500131 printf("Router: %s face: %s\n",rtr_name,face);
132 int face_id;
133 int res;
134 res=sscanf(face,"face%d",&face_id);
135
136 if(res != 1 )
137 {
138 printf(" Wrong Command Format ( ccnneighbor router_name faceX) where X is integer\n");
139 return;
140 }
141
akmhoque03004e62012-09-06 01:12:28 -0500142 struct name_prefix *nbr=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
143 nbr->name=(char *)malloc(strlen(rtr_name)+1);
144 memset(nbr->name,0,strlen(rtr_name)+1);
145 memcpy(nbr->name,rtr_name,strlen(rtr_name)+1);
146 nbr->length=strlen(rtr_name)+1;
147
148 add_nbr_to_adl(nbr,face_id);
149
150 free(nbr->name);
151 free(nbr);
152}
153
154void
155process_command_ccnname(char *command)
156{
157
158 if(command==NULL)
159 {
160 printf(" Wrong Command Format ( ccnname /name/prefix)\n");
161 return;
162 }
163 char *rem;
164 const char *sep=" \t\n";
165 char *name;
166 name=strtok_r(command,sep,&rem);
167 if(name==NULL)
168 {
169 printf(" Wrong Command Format ( ccnname /name/prefix/ )\n");
170 return;
171 }
172
173 printf("Name Prefix: %s \n",name);
174
akmhoque53f64222012-09-05 13:57:51 -0500175 struct name_prefix *np=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
akmhoque03004e62012-09-06 01:12:28 -0500176 np->name=(char *)malloc(strlen(name)+1);
177 memset(np->name,0,strlen(name)+1);
178 memcpy(np->name,name,strlen(name)+1);
179 np->length=strlen(name)+1;
akmhoque386081b2012-08-10 10:53:21 -0500180
akmhoque03004e62012-09-06 01:12:28 -0500181 add_name_to_npl(np);
akmhoque28c45022012-08-09 15:38:02 -0500182
akmhoque03004e62012-09-06 01:12:28 -0500183 free(np->name);
akmhoque53f64222012-09-05 13:57:51 -0500184 free(np);
akmhoque59980a52012-08-09 12:36:09 -0500185}
186
akmhoque03004e62012-09-06 01:12:28 -0500187
188void
189process_command_router_name(char *command)
190{
191 if(command==NULL)
192 {
193 printf(" Wrong Command Format ( router-name /router/name )\n");
194 return;
195 }
196 char *rem;
197 const char *sep=" \t\n";
198 char *rtr_name;
199
200 rtr_name=strtok_r(command,sep,&rem);
201 if(rtr_name==NULL)
202 {
203 printf(" Wrong Command Format ( router-name /router/name )\n");
204 return;
205 }
206
207
208 nlsr->router_name=(char *)malloc(strlen(rtr_name)+1);
209 memset(nlsr->router_name,0,strlen(rtr_name)+1);
210 memcpy(nlsr->router_name,rtr_name,strlen(rtr_name)+1);
211
212
213}
214
akmhoque59980a52012-08-09 12:36:09 -0500215void
akmhoqued79438d2012-08-27 13:31:42 -0500216process_command_lsdb_synch_interval(char *command)
217{
218 if(command==NULL)
219 {
220 printf(" Wrong Command Format ( lsdb-synch-interval secs )\n");
221 return;
222 }
223 char *rem;
224 const char *sep=" \t\n";
225 char *secs;
226 long int seconds;
227
228 secs=strtok_r(command,sep,&rem);
229 if(secs==NULL)
230 {
231 printf(" Wrong Command Format ( lsdb-synch-interval secs)\n");
232 return;
233 }
234
235 seconds=atoi(secs);
akmhoqueffacaa82012-09-13 17:48:30 -0500236 if ( seconds >= 120 && seconds <= 3600 )
237 {
238 nlsr->lsdb_synch_interval=seconds;
239 }
akmhoqued79438d2012-08-27 13:31:42 -0500240
241}
242
243
244void
245process_command_interest_retry(char *command)
246{
247 if(command==NULL)
248 {
249 printf(" Wrong Command Format ( interest-retry number )\n");
250 return;
251 }
252 char *rem;
253 const char *sep=" \t\n";
akmhoqueffacaa82012-09-13 17:48:30 -0500254 char *retry;
255 long int retry_number;
akmhoqued79438d2012-08-27 13:31:42 -0500256
akmhoqueffacaa82012-09-13 17:48:30 -0500257 retry=strtok_r(command,sep,&rem);
258 if(retry==NULL)
akmhoqued79438d2012-08-27 13:31:42 -0500259 {
260 printf(" Wrong Command Format ( interest-retry number)\n");
261 return;
262 }
263
akmhoqueffacaa82012-09-13 17:48:30 -0500264 retry_number=atoi(retry);
265 if ( retry_number >= 1 && retry_number<=10 )
266 {
267 nlsr->interest_retry=retry_number;
268 }
akmhoqued79438d2012-08-27 13:31:42 -0500269
270}
271
272void
273process_command_interest_resend_time(char *command)
274{
275 if(command==NULL)
276 {
277 printf(" Wrong Command Format ( interest-resend-time secs )\n");
278 return;
279 }
280 char *rem;
281 const char *sep=" \t\n";
282 char *secs;
283 long int seconds;
284
285 secs=strtok_r(command,sep,&rem);
286 if(secs==NULL)
287 {
288 printf(" Wrong Command Format ( interest-resend-time secs)\n");
289 return;
290 }
291
292 seconds=atoi(secs);
akmhoqueffacaa82012-09-13 17:48:30 -0500293 if ( seconds <= 60 && seconds >= 1 )
294 {
295 nlsr->interest_resend_time=seconds;
296 }
akmhoqued79438d2012-08-27 13:31:42 -0500297}
298
akmhoque03004e62012-09-06 01:12:28 -0500299
300
akmhoqued79438d2012-08-27 13:31:42 -0500301void
akmhoque59980a52012-08-09 12:36:09 -0500302process_conf_command(char *command)
303{
304 const char *separators=" \t\n";
305 char *remainder=NULL;
306 char *cmd_type=NULL;
307
308 if(command==NULL || strlen(command)==0 || command[0]=='!')
309 return;
310
311 cmd_type=strtok_r(command,separators,&remainder);
312
313 if(!strcmp(cmd_type,"router-name") )
314 {
315 process_command_router_name(remainder);
316 }
317 else if(!strcmp(cmd_type,"ccnneighbor") )
318 {
319 process_command_ccnneighbor(remainder);
320 }
321 else if(!strcmp(cmd_type,"ccnname") )
322 {
323 process_command_ccnname(remainder);
324 }
akmhoqued79438d2012-08-27 13:31:42 -0500325 else if(!strcmp(cmd_type,"lsdb-synch-interval") )
326 {
327 process_command_lsdb_synch_interval(remainder);
328 }
329 else if(!strcmp(cmd_type,"interest-retry") )
330 {
331 process_command_interest_retry(remainder);
332 }
333 else if(!strcmp(cmd_type,"interest-resend-time") )
334 {
335 process_command_interest_resend_time(remainder);
336 }
akmhoque59980a52012-08-09 12:36:09 -0500337 else
338 {
339 printf("Wrong configuration Command %s \n",cmd_type);
340 }
341}
342
akmhoque03004e62012-09-06 01:12:28 -0500343
akmhoque59980a52012-08-09 12:36:09 -0500344int
345readConfigFile(const char *filename)
346{
347 FILE *cfg;
348 char buf[1024];
349 int len;
350
351 cfg=fopen(filename, "r");
352
353 if(cfg == NULL)
354 {
355 printf("\nConfiguration File does not exists\n");
356 exit(1);
357 }
358
359 while(fgets((char *)buf, sizeof(buf), cfg))
360 {
361 len=strlen(buf);
362 if(buf[len-1] == '\n')
363 buf[len-1]='\0';
364 process_conf_command(buf);
365 }
366
367 fclose(cfg);
368
369 return 0;
370}
371
akmhoque386081b2012-08-10 10:53:21 -0500372void
373nlsr_destroy( void )
374{
375
akmhoque53f64222012-09-05 13:57:51 -0500376 printf("Freeing Allocated Memory....\n");
akmhoquefbfd0982012-09-09 20:59:03 -0500377 /* Destroying all face created by nlsr in CCND */
378 destroy_all_face_by_nlsr();
379
akmhoque386081b2012-08-10 10:53:21 -0500380 /* Destroying every hash table attached to each neighbor in ADL before destorying ADL */
akmhoque53f64222012-09-05 13:57:51 -0500381 hashtb_destroy(&nlsr->npl);
akmhoque03004e62012-09-06 01:12:28 -0500382 hashtb_destroy(&nlsr->adl);
383 hashtb_destroy(&nlsr->lsdb->name_lsdb);
384 hashtb_destroy(&nlsr->lsdb->adj_lsdb);
akmhoque29c1db52012-09-07 14:47:43 -0500385 hashtb_destroy(&nlsr->pit_alsa);
akmhoque3560cb62012-09-09 10:52:30 -0500386 hashtb_destroy(&nlsr->routing_table);
387
388
389 int i, npt_element;
390 struct npt_entry *ne;
391 struct hashtb_enumerator ee;
392 struct hashtb_enumerator *e = &ee;
393 hashtb_start(nlsr->npt, e);
394 npt_element=hashtb_n(nlsr->npt);
395 for(i=0;i<npt_element;i++)
396 {
397 ne=e->data;
akmhoque810a5b52012-09-09 16:53:14 -0500398 hashtb_destroy(&ne->name_list);
akmhoque3560cb62012-09-09 10:52:30 -0500399 hashtb_next(e);
400 }
401
402 hashtb_end(e);
403 hashtb_destroy(&nlsr->npt);
404
akmhoque03004e62012-09-06 01:12:28 -0500405
akmhoque386081b2012-08-10 10:53:21 -0500406 ccn_schedule_destroy(&nlsr->sched);
407 ccn_destroy(&nlsr->ccn);
akmhoque03004e62012-09-06 01:12:28 -0500408
409 free(nlsr->lsdb->lsdb_version);
410 free(nlsr->lsdb);
411 free(nlsr->router_name);
akmhoque386081b2012-08-10 10:53:21 -0500412 free(nlsr);
413
akmhoque53f64222012-09-05 13:57:51 -0500414 printf("Finished freeing allocated memory\n");
415
akmhoque386081b2012-08-10 10:53:21 -0500416}
417
akmhoque03004e62012-09-06 01:12:28 -0500418
akmhoque81c25e02012-09-10 14:50:33 -0500419int
akmhoque902d57e2012-08-17 09:24:38 -0500420init_nlsr(void)
akmhoque59980a52012-08-09 12:36:09 -0500421{
akmhoque03004e62012-09-06 01:12:28 -0500422 if (signal(SIGQUIT, nlsr_stop_signal_handler ) == SIG_ERR)
423 {
424 perror("SIGQUIT install error\n");
akmhoque81c25e02012-09-10 14:50:33 -0500425 return -1;
akmhoque03004e62012-09-06 01:12:28 -0500426 }
427 if (signal(SIGTERM, nlsr_stop_signal_handler ) == SIG_ERR)
428 {
429 perror("SIGTERM install error\n");
akmhoque81c25e02012-09-10 14:50:33 -0500430 return -1;
akmhoque03004e62012-09-06 01:12:28 -0500431 }
432 if (signal(SIGINT, nlsr_stop_signal_handler ) == SIG_ERR)
433 {
434 perror("SIGTERM install error\n");
akmhoque81c25e02012-09-10 14:50:33 -0500435 return -1;
akmhoque03004e62012-09-06 01:12:28 -0500436 }
akmhoque902d57e2012-08-17 09:24:38 -0500437
akmhoque59980a52012-08-09 12:36:09 -0500438 nlsr=(struct nlsr *)malloc(sizeof(struct nlsr));
akmhoque03004e62012-09-06 01:12:28 -0500439
440 struct hashtb_param param_adl = {0};
akmhoque28c45022012-08-09 15:38:02 -0500441 nlsr->adl=hashtb_create(sizeof(struct ndn_neighbor), &param_adl);
akmhoque03004e62012-09-06 01:12:28 -0500442 struct hashtb_param param_npl = {0};
443 nlsr->npl = hashtb_create(sizeof(struct name_prefix), &param_npl);
akmhoque29c1db52012-09-07 14:47:43 -0500444 struct hashtb_param param_pit_alsa = {0};
445 nlsr->pit_alsa = hashtb_create(sizeof(struct pneding_interest), &param_pit_alsa);
akmhoque3560cb62012-09-09 10:52:30 -0500446 struct hashtb_param param_npt = {0};
447 nlsr->npt = hashtb_create(sizeof(struct npt_entry), &param_npt);
448 struct hashtb_param param_rte = {0};
449 nlsr->routing_table = hashtb_create(sizeof(struct routing_table_entry), &param_rte);
akmhoque29c1db52012-09-07 14:47:43 -0500450
akmhoque59980a52012-08-09 12:36:09 -0500451 nlsr->in_interest.p = &incoming_interest;
452 nlsr->in_content.p = &incoming_content;
akmhoque07dd8cc2012-08-16 10:23:01 -0500453
akmhoque03004e62012-09-06 01:12:28 -0500454 nlsr->lsdb=(struct linkStateDatabase *)malloc(sizeof(struct linkStateDatabase));
akmhoque07dd8cc2012-08-16 10:23:01 -0500455
akmhoque03004e62012-09-06 01:12:28 -0500456 char *time_stamp=(char *)malloc(20);
457 memset(time_stamp,0,20);
458 get_current_timestamp_micro(time_stamp);
459 nlsr->lsdb->lsdb_version=(char *)malloc(strlen(time_stamp)+1);
460 memset(nlsr->lsdb->lsdb_version,'0',strlen(time_stamp));
461 free(time_stamp);
462
463 struct hashtb_param param_adj_lsdb = {0};
akmhoquef71d9082012-08-22 12:51:53 -0400464 nlsr->lsdb->adj_lsdb = hashtb_create(sizeof(struct alsa), &param_adj_lsdb);
akmhoque03004e62012-09-06 01:12:28 -0500465 struct hashtb_param param_name_lsdb = {0};
akmhoquef71d9082012-08-22 12:51:53 -0400466 nlsr->lsdb->name_lsdb = hashtb_create(sizeof(struct nlsa), &param_name_lsdb);
akmhoque29c1db52012-09-07 14:47:43 -0500467
468
akmhoque902d57e2012-08-17 09:24:38 -0500469
akmhoque53f64222012-09-05 13:57:51 -0500470
akmhoque59980a52012-08-09 12:36:09 -0500471 nlsr->is_synch_init=1;
akmhoquec9286692012-08-16 09:57:58 -0500472 nlsr->nlsa_id=0;
akmhoqued79438d2012-08-27 13:31:42 -0500473 nlsr->adj_build_flag=0;
akmhoque53f64222012-09-05 13:57:51 -0500474 nlsr->adj_build_count=0;
475 nlsr->is_build_adj_lsa_sheduled=0;
akmhoque29c1db52012-09-07 14:47:43 -0500476 nlsr->is_send_lsdb_interest_scheduled=0;
477 nlsr->is_route_calculation_scheduled=0;
akmhoqued79438d2012-08-27 13:31:42 -0500478
479 nlsr->lsdb_synch_interval = LSDB_SYNCH_INTERVAL;
480 nlsr->interest_retry = INTEREST_RETRY;
481 nlsr->interest_resend_time = INTEREST_RESEND_TIME;
akmhoque42098b12012-08-27 22:54:23 -0500482
akmhoqueffacaa82012-09-13 17:48:30 -0500483 nlsr->semaphor=NLSR_UNLOCKED;
akmhoque81c25e02012-09-10 14:50:33 -0500484
485 return 0;
akmhoque902d57e2012-08-17 09:24:38 -0500486}
487
akmhoque03004e62012-09-06 01:12:28 -0500488
akmhoque902d57e2012-08-17 09:24:38 -0500489int
490main(int argc, char *argv[])
491{
akmhoque81c25e02012-09-10 14:50:33 -0500492 int res, ret;
akmhoque902d57e2012-08-17 09:24:38 -0500493 char *config_file;
akmhoqueffacaa82012-09-13 17:48:30 -0500494 //int daemon_mode;
akmhoque902d57e2012-08-17 09:24:38 -0500495
akmhoque81c25e02012-09-10 14:50:33 -0500496 ret=init_nlsr();
497 ON_ERROR_EXIT(ret);
498
akmhoque59980a52012-08-09 12:36:09 -0500499 while ((res = getopt_long(argc, argv, "df:h", longopts, 0)) != -1)
500 {
501 switch (res)
502 {
503 case 'd':
akmhoqueffacaa82012-09-13 17:48:30 -0500504 //daemon_mode = 1;
akmhoque59980a52012-08-09 12:36:09 -0500505 break;
506 case 'f':
507 config_file = optarg;
508 break;
509 case 'h':
510 default:
511 usage(argv[0]);
512 }
513 }
514
515 readConfigFile(config_file);
516
517 nlsr->ccn=ccn_create();
518 if(ccn_connect(nlsr->ccn, NULL) == -1)
akmhoque03004e62012-09-06 01:12:28 -0500519 {
520 fprintf(stderr,"Could not connect to ccnd\n");
akmhoque81c25e02012-09-10 14:50:33 -0500521 ON_ERROR_DESTROY(-1);
akmhoque03004e62012-09-06 01:12:28 -0500522 }
akmhoque53f64222012-09-05 13:57:51 -0500523 struct ccn_charbuf *router_prefix;
akmhoque03004e62012-09-06 01:12:28 -0500524 router_prefix=ccn_charbuf_create();
525 res=ccn_name_from_uri(router_prefix,nlsr->router_name);
akmhoque59980a52012-08-09 12:36:09 -0500526 if(res<0)
akmhoque03004e62012-09-06 01:12:28 -0500527 {
528 fprintf(stderr, "Bad ccn URI: %s\n",nlsr->router_name);
akmhoque81c25e02012-09-10 14:50:33 -0500529 ON_ERROR_DESTROY(res);
akmhoque03004e62012-09-06 01:12:28 -0500530 }
akmhoque59980a52012-08-09 12:36:09 -0500531
532 ccn_name_append_str(router_prefix,"nlsr");
akmhoque03004e62012-09-06 01:12:28 -0500533 nlsr->in_interest.data=nlsr->router_name;
akmhoque59980a52012-08-09 12:36:09 -0500534 res=ccn_set_interest_filter(nlsr->ccn,router_prefix,&nlsr->in_interest);
535 if ( res < 0 )
akmhoque03004e62012-09-06 01:12:28 -0500536 {
537 fprintf(stderr,"Failed to register interest for router\n");
akmhoque81c25e02012-09-10 14:50:33 -0500538 ON_ERROR_DESTROY(res);
akmhoque03004e62012-09-06 01:12:28 -0500539 }
540 ccn_charbuf_destroy(&router_prefix);
541
542 printf("Router Name : %s\n",nlsr->router_name);
543 printf("lsdb_version: %s\n",nlsr->lsdb->lsdb_version);
akmhoque59980a52012-08-09 12:36:09 -0500544
akmhoque53f64222012-09-05 13:57:51 -0500545 print_name_prefix_from_npl();
546 print_adjacent_from_adl();
akmhoque53f64222012-09-05 13:57:51 -0500547 build_and_install_name_lsas();
548 print_name_lsdb();
549
550 nlsr->sched = ccn_schedule_create(nlsr, &ndn_rtr_ticker);
akmhoque03004e62012-09-06 01:12:28 -0500551 nlsr->event_send_info_interest = ccn_schedule_event(nlsr->sched, 1, &send_info_interest, NULL, 0);
akmhoqueffacaa82012-09-13 17:48:30 -0500552 nlsr->event = ccn_schedule_event(nlsr->sched, 60000000, &refresh_lsdb, NULL, 0);
akmhoque1c9b92f2012-08-13 10:57:50 -0500553
akmhoque59980a52012-08-09 12:36:09 -0500554 while(1)
akmhoque29c1db52012-09-07 14:47:43 -0500555 {
akmhoqueffacaa82012-09-13 17:48:30 -0500556 if ( nlsr->semaphor == NLSR_UNLOCKED )
akmhoque29c1db52012-09-07 14:47:43 -0500557 {
akmhoqueffacaa82012-09-13 17:48:30 -0500558 if( nlsr->sched != NULL )
559 {
560 ccn_schedule_run(nlsr->sched);
561 }
562 if(nlsr->ccn != NULL)
563 {
564 res = ccn_run(nlsr->ccn, 500);
565 }
566 if (!(nlsr->sched && nlsr->ccn))
567 {
568 break;
569 }
akmhoque29c1db52012-09-07 14:47:43 -0500570 }
571
akmhoque59980a52012-08-09 12:36:09 -0500572 }
akmhoque59980a52012-08-09 12:36:09 -0500573
akmhoque59980a52012-08-09 12:36:09 -0500574 return 0;
575}
576