blob: 81786af48d7ecab1b3a78b3a4ae5fc17fdf9b935 [file] [log] [blame]
akmhoque3560cb62012-09-09 10:52:30 -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#include <sys/types.h>
12#include <signal.h>
13
14
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_npt.h"
25#include "nlsr_fib.h"
akmhoque810a5b52012-09-09 16:53:14 -050026#include "nlsr_route.h"
akmhoque3cced642012-09-24 16:20:20 -050027#include "nlsr_adl.h"
akmhoque1771c412012-11-09 13:06:08 -060028#include "utility.h"
akmhoque3560cb62012-09-09 10:52:30 -050029
30int
akmhoquede61ba92012-09-20 22:19:12 -050031add_npt_entry(char *orig_router, char *name_prefix, int num_face, int *faces, int *route_costs)
akmhoque3560cb62012-09-09 10:52:30 -050032{
33 if ( strcmp(orig_router,nlsr->router_name)== 0)
34 {
35 return -1;
36 }
akmhoque3cced642012-09-24 16:20:20 -050037
akmhoque0ed6d982013-02-22 14:28:01 -060038 struct npt_entry *ne;//=(struct npt_entry*)calloc(1,sizeof(struct npt_entry ));
akmhoque3560cb62012-09-09 10:52:30 -050039
akmhoquede61ba92012-09-20 22:19:12 -050040 int res,res_nle,res_fle;
akmhoque3560cb62012-09-09 10:52:30 -050041 struct hashtb_enumerator ee;
42 struct hashtb_enumerator *e = &ee;
akmhoque810a5b52012-09-09 16:53:14 -050043
akmhoque3560cb62012-09-09 10:52:30 -050044
45 hashtb_start(nlsr->npt, e);
akmhoque810a5b52012-09-09 16:53:14 -050046 res = hashtb_seek(e, orig_router, strlen(orig_router), 0);
akmhoque3560cb62012-09-09 10:52:30 -050047
48 if(res == HT_NEW_ENTRY)
49 {
50 ne=e->data;
51
akmhoque810a5b52012-09-09 16:53:14 -050052 ne->orig_router=(char *)malloc(strlen(orig_router)+1);
53 memset(ne->orig_router,0,strlen(orig_router)+1);
54 memcpy(ne->orig_router,orig_router,strlen(orig_router));
akmhoque3560cb62012-09-09 10:52:30 -050055
akmhoque810a5b52012-09-09 16:53:14 -050056
akmhoquede61ba92012-09-20 22:19:12 -050057
akmhoque3560cb62012-09-09 10:52:30 -050058
akmhoque0ed6d982013-02-22 14:28:01 -060059 //struct hashtb_param param_nle = {0};
60 ne->name_list= hashtb_create(sizeof(struct name_list_entry ),NULL);
akmhoque3560cb62012-09-09 10:52:30 -050061
akmhoque810a5b52012-09-09 16:53:14 -050062 struct hashtb_enumerator eenle;
63 struct hashtb_enumerator *enle = &eenle;
akmhoque3560cb62012-09-09 10:52:30 -050064
akmhoque810a5b52012-09-09 16:53:14 -050065 hashtb_start(ne->name_list, enle);
66 res_nle = hashtb_seek(enle, name_prefix, strlen(name_prefix), 0);
akmhoque3560cb62012-09-09 10:52:30 -050067
akmhoque810a5b52012-09-09 16:53:14 -050068 if(res_nle == HT_NEW_ENTRY )
akmhoque3560cb62012-09-09 10:52:30 -050069 {
akmhoque0ed6d982013-02-22 14:28:01 -060070 struct name_list_entry *nle;//=(struct name_list_entry *)calloc(1,sizeof(struct name_list_entry));
akmhoque810a5b52012-09-09 16:53:14 -050071 nle=enle->data;
akmhoque0ed6d982013-02-22 14:28:01 -060072 nle->name=(char *)calloc(strlen(name_prefix)+1,sizeof(char));
73 //memset(nle->name,0,strlen(name_prefix)+1);
74 memcpy(nle->name,name_prefix,strlen(name_prefix)+1);
akmhoque3560cb62012-09-09 10:52:30 -050075
akmhoque810a5b52012-09-09 16:53:14 -050076
akmhoque3560cb62012-09-09 10:52:30 -050077
78 }
akmhoque810a5b52012-09-09 16:53:14 -050079 hashtb_end(enle);
80
akmhoque0ed6d982013-02-22 14:28:01 -060081 //struct hashtb_param param_fle = {0};
82 ne->face_list=hashtb_create(sizeof(struct face_list_entry), NULL);
akmhoque3560cb62012-09-09 10:52:30 -050083
akmhoquede61ba92012-09-20 22:19:12 -050084 if ( num_face > 0 )
85 {
86 struct hashtb_enumerator eef;
87 struct hashtb_enumerator *ef = &eef;
88
89 hashtb_start(ne->face_list, ef);
90 int i;
91
akmhoque3cced642012-09-24 16:20:20 -050092 for ( i=0; i < num_face ; i++)
akmhoquede61ba92012-09-20 22:19:12 -050093 {
94 int face=faces[i];
akmhoquea30cb772012-10-07 09:50:34 -050095 if ( face != NO_FACE && face != ZERO_FACE)
akmhoquede61ba92012-09-20 22:19:12 -050096 {
akmhoquea30cb772012-10-07 09:50:34 -050097 res_fle = hashtb_seek(ef, &face, sizeof(face), 0);
98
99 if ( res_fle == HT_NEW_ENTRY )
100 {
akmhoque0ed6d982013-02-22 14:28:01 -0600101 struct face_list_entry *fle;//=(struct face_list_entry *)calloc(1,sizeof(struct face_list_entry));
akmhoquea30cb772012-10-07 09:50:34 -0500102 fle=ef->data;
103 fle->next_hop_face=face;
104 fle->route_cost=route_costs[i];
105 }
akmhoquede61ba92012-09-20 22:19:12 -0500106 }
107
108 }
109 hashtb_end(ef);
110 }
111
akmhoque3560cb62012-09-09 10:52:30 -0500112 }
113 else if (res == HT_OLD_ENTRY)
114 {
115 free(ne);
116 struct npt_entry *one;
117
118 one=e->data;
119
akmhoque810a5b52012-09-09 16:53:14 -0500120 struct hashtb_enumerator eenle;
121 struct hashtb_enumerator *enle = &eenle;
akmhoque3560cb62012-09-09 10:52:30 -0500122
akmhoque810a5b52012-09-09 16:53:14 -0500123 hashtb_start(one->name_list, enle);
124 res_nle = hashtb_seek(enle, name_prefix, strlen(name_prefix), 0);
125
126 if(res_nle == HT_NEW_ENTRY )
akmhoque3560cb62012-09-09 10:52:30 -0500127 {
akmhoque0ed6d982013-02-22 14:28:01 -0600128 struct name_list_entry *nle;//=(struct name_list_entry *)calloc(1,sizeof(struct name_list_entry));
akmhoque810a5b52012-09-09 16:53:14 -0500129 nle=enle->data;
130 nle->name=(char *)malloc(strlen(name_prefix)+1);
131 memset(nle->name,0,strlen(name_prefix)+1);
132 memcpy(nle->name,name_prefix,strlen(name_prefix));
akmhoque3560cb62012-09-09 10:52:30 -0500133 }
akmhoque810a5b52012-09-09 16:53:14 -0500134 else if(res_nle == HT_OLD_ENTRY )
akmhoque3560cb62012-09-09 10:52:30 -0500135 {
akmhoquede61ba92012-09-20 22:19:12 -0500136
akmhoque3560cb62012-09-09 10:52:30 -0500137 }
akmhoque810a5b52012-09-09 16:53:14 -0500138 hashtb_end(enle);
139
akmhoquede61ba92012-09-20 22:19:12 -0500140 if ( num_face > 0 )
141 {
142 struct hashtb_enumerator eef;
143 struct hashtb_enumerator *ef = &eef;
144
145 hashtb_start(one->face_list, ef);
146 int i;
147
148 for ( i=0; i< num_face ; i ++)
149 {
150 int face=faces[i];
akmhoquea30cb772012-10-07 09:50:34 -0500151 if ( face != NO_FACE && face != ZERO_FACE)
akmhoquede61ba92012-09-20 22:19:12 -0500152 {
akmhoquea30cb772012-10-07 09:50:34 -0500153 res_fle = hashtb_seek(ef, &face, sizeof(face), 0);
154
155 if ( res_fle == HT_NEW_ENTRY )
156 {
akmhoque0ed6d982013-02-22 14:28:01 -0600157 struct face_list_entry *fle;//=(struct face_list_entry *)calloc(1,sizeof(struct face_list_entry));
akmhoquea30cb772012-10-07 09:50:34 -0500158 fle=ef->data;
159 fle->next_hop_face=face;
160 fle->route_cost=route_costs[i];
161 }
akmhoquede61ba92012-09-20 22:19:12 -0500162 }
akmhoquede61ba92012-09-20 22:19:12 -0500163 }
164 hashtb_end(ef);
165 }
akmhoque810a5b52012-09-09 16:53:14 -0500166
akmhoque3560cb62012-09-09 10:52:30 -0500167
168 }
169 hashtb_end(e);
akmhoque3cced642012-09-24 16:20:20 -0500170
171 update_ccnd_fib_for_orig_router(orig_router);
172
akmhoque3560cb62012-09-09 10:52:30 -0500173 return res;
174}
175
akmhoque3cced642012-09-24 16:20:20 -0500176void
177update_ccnd_fib_for_orig_router(char *orig_router)
178{
179
akmhoqueb77b95f2013-02-08 12:28:47 -0600180 if ( nlsr->debugging )
181 {
182 printf("update_ccnd_fib_for_orig_router called\n");
183 }
184
akmhoque3cced642012-09-24 16:20:20 -0500185 int res;
186 struct hashtb_enumerator ee;
187 struct hashtb_enumerator *e = &ee;
188
189
190 hashtb_start(nlsr->npt, e);
191 res = hashtb_seek(e, orig_router, strlen(orig_router), 0);
192
193 if(res == HT_NEW_ENTRY)
194 {
195 hashtb_delete(e);
196 }
197 else if ( res == HT_OLD_ENTRY )
198 {
199 struct npt_entry *ne;
200 ne=e->data;
201 int num_face=hashtb_n(ne->face_list);
202 int last_face,first_face;
203
204 int *faces=(int *)malloc(num_face*sizeof(int));
205 int *route_costs=(int *)malloc(num_face*sizeof(int));
206
207 get_all_faces_for_orig_router_from_npt(orig_router,faces,route_costs,num_face);
208 sort_faces_by_distance(faces,route_costs,0,num_face);
209
akmhoqueb77b95f2013-02-08 12:28:47 -0600210 if ( nlsr->debugging )
akmhoque3cced642012-09-24 16:20:20 -0500211 {
akmhoqueb77b95f2013-02-08 12:28:47 -0600212 int m;
213 for ( m =0 ; m< num_face ; m++)
214 {
215 printf("Dest_router: %s Next_Hop_Face: %d Route_cost: %d \n",orig_router,faces[m],route_costs[m]);
216 }
akmhoque3cced642012-09-24 16:20:20 -0500217 }
akmhoqueb77b95f2013-02-08 12:28:47 -0600218
219 last_face=0;
220 if ( nlsr->max_faces_per_prefix == 0) // add all faces available in routing table
akmhoque3cced642012-09-24 16:20:20 -0500221 {
akmhoqueb77b95f2013-02-08 12:28:47 -0600222 first_face=num_face-1;
223 }
224 else if( nlsr->max_faces_per_prefix > 0)
225 {
226 if ( nlsr->max_faces_per_prefix >= num_face)
akmhoque3cced642012-09-24 16:20:20 -0500227 {
akmhoqueb77b95f2013-02-08 12:28:47 -0600228 first_face=num_face-1;
akmhoque3cced642012-09-24 16:20:20 -0500229 }
akmhoqueb77b95f2013-02-08 12:28:47 -0600230 else if ( nlsr->max_faces_per_prefix < num_face)
akmhoque3cced642012-09-24 16:20:20 -0500231 {
akmhoqueb77b95f2013-02-08 12:28:47 -0600232 first_face=nlsr->max_faces_per_prefix-1;
akmhoque3cced642012-09-24 16:20:20 -0500233 }
akmhoqueb77b95f2013-02-08 12:28:47 -0600234
akmhoque3cced642012-09-24 16:20:20 -0500235 }
236
237 int i,j, nl_element;
238 struct name_list_entry *nle;
239 struct hashtb_enumerator eenle;
240 struct hashtb_enumerator *enle = &eenle;
241
242 hashtb_start(ne->name_list, enle);
akmhoque726197c2013-02-18 11:49:24 -0600243 nl_element=hashtb_n(ne->name_list);
244
245 for (i=0;i<nl_element;i++)
246 {
247 nle=enle->data;
248
249 for( j=num_face-1; j>= 0; j--)
250 {
251
252 if ( !( is_neighbor(nle->name) == 1 && get_next_hop_face_from_adl(nle->name) == faces[j] ) )
253 {
254 add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, faces[j]);
255 }
256 }
257
258
259 hashtb_next(enle);
260 }
261
262
263 hashtb_end(enle);
264
265 if ( nlsr->debugging )
266 {
267 printf("First Face Index: %d Last Face Index: %d\n",first_face,last_face);
268 }
269
270 hashtb_start(ne->name_list, enle);
akmhoque3cced642012-09-24 16:20:20 -0500271 nl_element=hashtb_n(ne->name_list);
272
273 for (i=0;i<nl_element;i++)
274 {
275 nle=enle->data;
276
277 for( j=first_face; j>= last_face; j--)
278 {
akmhoqueb77b95f2013-02-08 12:28:47 -0600279 if ( nlsr->debugging )
280 {
281 printf("Possible FIB Entry name: %s face: %d route cost: %d \n",nle->name,faces[j],route_costs[j]);
282 }
283 if ( is_active_neighbor(orig_router) == 0 )
akmhoque3cced642012-09-24 16:20:20 -0500284 {
akmhoque1771c412012-11-09 13:06:08 -0600285 if ( nlsr->debugging )
286 printf("Adding face: Name:%s Face: %d\n",nle->name,faces[j]);
287 if ( nlsr->detailed_logging )
288 writeLogg(__FILE__,__FUNCTION__,__LINE__,"Adding face: Name:%s Face: %d\n",nle->name,faces[j]);
akmhoquea30cb772012-10-07 09:50:34 -0500289 add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_REG, faces[j]);
akmhoque3cced642012-09-24 16:20:20 -0500290 }
291 else
292 {
akmhoqueb77b95f2013-02-08 12:28:47 -0600293 if ( j == last_face && is_active_neighbor(nle->name)==0)
akmhoque3cced642012-09-24 16:20:20 -0500294 {
akmhoque1771c412012-11-09 13:06:08 -0600295 if ( nlsr->debugging )
296 printf("Adding face: Name:%s Face: %d\n",nle->name,faces[j]);
297 if ( nlsr->detailed_logging )
298 writeLogg(__FILE__,__FUNCTION__,__LINE__,"Adding face: Name:%s Face: %d\n",nle->name,faces[j]);
akmhoque3cced642012-09-24 16:20:20 -0500299 add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_REG, faces[j]);
300 }
301 }
302 }
akmhoquea30cb772012-10-07 09:50:34 -0500303
304
akmhoque3cced642012-09-24 16:20:20 -0500305 hashtb_next(enle);
306 }
307 hashtb_end(enle);
308
309
310
311 free(faces);
312 free(route_costs);
313
314 }
315 hashtb_end(e);
316
317}
318
akmhoqueffacaa82012-09-13 17:48:30 -0500319int
akmhoque3cced642012-09-24 16:20:20 -0500320delete_npt_entry_by_router_and_name_prefix(char *orig_router, char *name_prefix)
akmhoqueffacaa82012-09-13 17:48:30 -0500321{
322 if ( strcmp(orig_router,nlsr->router_name)== 0)
323 {
324 return -1;
325 }
326
327 struct npt_entry *ne;
328
329 int res,res_nle;
330 struct hashtb_enumerator ee;
331 struct hashtb_enumerator *e = &ee;
332
333
334 hashtb_start(nlsr->npt, e);
335 res = hashtb_seek(e, orig_router, strlen(orig_router), 0);
336
337 if(res == HT_NEW_ENTRY)
338 {
339 hashtb_delete(e);
340 return -1;
341 }
342 else if (res == HT_OLD_ENTRY)
343 {
344 ne=e->data;
345
346 struct hashtb_enumerator eenle;
347 struct hashtb_enumerator *enle = &eenle;
348
349 hashtb_start(ne->name_list, enle);
350 res_nle = hashtb_seek(enle, name_prefix, strlen(name_prefix), 0);
351
352 if(res_nle == HT_NEW_ENTRY )
353 {
354 hashtb_delete(enle);
355 }
356 else if(res_nle == HT_OLD_ENTRY )
357 {
akmhoque3cced642012-09-24 16:20:20 -0500358 struct name_list_entry *nle;
359
360 nle=enle->data;
361
362 int j;
363 int num_face=hashtb_n(ne->face_list);
364 int last_face,first_face;
365
366 int *faces=(int *)malloc(num_face*sizeof(int));
367 int *route_costs=(int *)malloc(num_face*sizeof(int));
368
369 get_all_faces_for_orig_router_from_npt(orig_router,faces,route_costs,num_face);
370 sort_faces_by_distance(faces,route_costs,0,num_face);
371
372
akmhoqueb77b95f2013-02-08 12:28:47 -0600373 last_face=0;
374 if ( nlsr->max_faces_per_prefix == 0) // add all faces available in routing table
akmhoqueffacaa82012-09-13 17:48:30 -0500375 {
akmhoqueb77b95f2013-02-08 12:28:47 -0600376 first_face=num_face-1;
akmhoqueffacaa82012-09-13 17:48:30 -0500377 }
akmhoqueb77b95f2013-02-08 12:28:47 -0600378 else if( nlsr->max_faces_per_prefix > 0)
akmhoque3cced642012-09-24 16:20:20 -0500379 {
akmhoqueb77b95f2013-02-08 12:28:47 -0600380 if ( nlsr->max_faces_per_prefix >= num_face)
akmhoque3cced642012-09-24 16:20:20 -0500381 {
akmhoqueb77b95f2013-02-08 12:28:47 -0600382 first_face=num_face-1;
akmhoque3cced642012-09-24 16:20:20 -0500383 }
akmhoqueb77b95f2013-02-08 12:28:47 -0600384 else if ( nlsr->max_faces_per_prefix < num_face)
akmhoque3cced642012-09-24 16:20:20 -0500385 {
akmhoqueb77b95f2013-02-08 12:28:47 -0600386 first_face=nlsr->max_faces_per_prefix-1;
akmhoque3cced642012-09-24 16:20:20 -0500387 }
akmhoqueb77b95f2013-02-08 12:28:47 -0600388
389 }
akmhoque3cced642012-09-24 16:20:20 -0500390 for( j=first_face; j>= last_face; j--)
391 {
akmhoquea30cb772012-10-07 09:50:34 -0500392
akmhoqueb77b95f2013-02-08 12:28:47 -0600393 if ( is_active_neighbor(orig_router) == 0 )
akmhoque3cced642012-09-24 16:20:20 -0500394 {
akmhoque1771c412012-11-09 13:06:08 -0600395 if ( nlsr->debugging )
396 printf("Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);
397 if ( nlsr->detailed_logging )
398 writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);
akmhoquea30cb772012-10-07 09:50:34 -0500399 add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, faces[j]);
akmhoque3cced642012-09-24 16:20:20 -0500400 }
401 else
402 {
akmhoqueb77b95f2013-02-08 12:28:47 -0600403 if ( j == last_face && is_active_neighbor(nle->name)==0)
akmhoque3cced642012-09-24 16:20:20 -0500404 {
akmhoque1771c412012-11-09 13:06:08 -0600405 if ( nlsr->debugging )
406 printf("Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);
407 if ( nlsr->detailed_logging )
408 writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);
akmhoque3cced642012-09-24 16:20:20 -0500409 add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, faces[j]);
410 }
411 }
akmhoquea30cb772012-10-07 09:50:34 -0500412
akmhoque3cced642012-09-24 16:20:20 -0500413 }
414
akmhoqueffacaa82012-09-13 17:48:30 -0500415 }
416
417 hashtb_end(enle);
418 }
419
420 hashtb_end(e);
421
422 return 0;
423}
akmhoque3560cb62012-09-09 10:52:30 -0500424
425void
426print_npt(void)
427{
akmhoque1771c412012-11-09 13:06:08 -0600428
429 if ( nlsr->debugging )
430 {
431 printf("\n");
432 printf("print_npt called\n");
433 }
434 if ( nlsr->detailed_logging )
435 {
436 writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");
437 writeLogg(__FILE__,__FUNCTION__,__LINE__,"print_npt called\n");
438 }
akmhoque3560cb62012-09-09 10:52:30 -0500439 int i, npt_element;
440
441 struct npt_entry *ne;
442
443 struct hashtb_enumerator ee;
444 struct hashtb_enumerator *e = &ee;
445
446 hashtb_start(nlsr->npt, e);
447 npt_element=hashtb_n(nlsr->npt);
448
449 for(i=0;i<npt_element;i++)
450 {
akmhoque1771c412012-11-09 13:06:08 -0600451 if ( nlsr->debugging )
452 {
453 printf("\n");
454 printf("----------NPT ENTRY %d------------------\n",i+1);
455 }
456 if ( nlsr->detailed_logging )
457 {
458 writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");
459 writeLogg(__FILE__,__FUNCTION__,__LINE__,"----------NPT ENTRY %d------------------\n",i+1);
460 }
akmhoque3560cb62012-09-09 10:52:30 -0500461 ne=e->data;
akmhoque1771c412012-11-09 13:06:08 -0600462 if ( nlsr->debugging )
463 printf(" Origination Router: %s \n",ne->orig_router);
464 if ( nlsr->detailed_logging )
465 writeLogg(__FILE__,__FUNCTION__,__LINE__," Origination Router: %s \n",ne->orig_router);
akmhoque3560cb62012-09-09 10:52:30 -0500466
akmhoquede61ba92012-09-20 22:19:12 -0500467 int j, nl_element,face_list_element;
akmhoque810a5b52012-09-09 16:53:14 -0500468 struct name_list_entry *nle;
469 struct hashtb_enumerator eenle;
470 struct hashtb_enumerator *enle = &eenle;
akmhoque3560cb62012-09-09 10:52:30 -0500471
akmhoque810a5b52012-09-09 16:53:14 -0500472 hashtb_start(ne->name_list, enle);
473 nl_element=hashtb_n(ne->name_list);
akmhoque3560cb62012-09-09 10:52:30 -0500474
akmhoque810a5b52012-09-09 16:53:14 -0500475 for (j=0;j<nl_element;j++)
akmhoque3560cb62012-09-09 10:52:30 -0500476 {
akmhoque810a5b52012-09-09 16:53:14 -0500477 nle=enle->data;
akmhoque1771c412012-11-09 13:06:08 -0600478 if ( nlsr->debugging )
479 printf(" Name Prefix: %s \n",nle->name);
480 if ( nlsr->detailed_logging )
481 writeLogg(__FILE__,__FUNCTION__,__LINE__," Name Prefix: %s \n",nle->name);
akmhoque810a5b52012-09-09 16:53:14 -0500482 hashtb_next(enle);
akmhoque3560cb62012-09-09 10:52:30 -0500483 }
akmhoque810a5b52012-09-09 16:53:14 -0500484 hashtb_end(enle);
akmhoquede61ba92012-09-20 22:19:12 -0500485
486 struct face_list_entry *fle;
487
488 struct hashtb_enumerator eef;
489 struct hashtb_enumerator *ef = &eef;
490
491 hashtb_start(ne->face_list, ef);
492 face_list_element=hashtb_n(ne->face_list);
493 if ( face_list_element <= 0 )
494 {
akmhoque1771c412012-11-09 13:06:08 -0600495 if ( nlsr->debugging )
496 printf(" Face: No Face \n");
497 if ( nlsr->detailed_logging )
498 writeLogg(__FILE__,__FUNCTION__,__LINE__," Face: No Face \n");
499
akmhoquede61ba92012-09-20 22:19:12 -0500500 }
501 else
502 {
503 for(j=0;j<face_list_element;j++)
504 {
505 fle=ef->data;
akmhoque1771c412012-11-09 13:06:08 -0600506 if ( nlsr->debugging )
akmhoqueb77b95f2013-02-08 12:28:47 -0600507 printf(" Face: %d Route_Cost: %f \n",fle->next_hop_face,fle->route_cost);
akmhoque1771c412012-11-09 13:06:08 -0600508 if ( nlsr->detailed_logging )
509 writeLogg(__FILE__,__FUNCTION__,__LINE__," Face: %d Route_Cost: %d \n",fle->next_hop_face,fle->route_cost);
akmhoquede61ba92012-09-20 22:19:12 -0500510 hashtb_next(ef);
511 }
512 }
513 hashtb_end(ef);
514
akmhoque3560cb62012-09-09 10:52:30 -0500515
516 hashtb_next(e);
517 }
518
519 hashtb_end(e);
520
akmhoque3171d652012-11-13 11:44:33 -0600521 if ( nlsr->debugging )
522 printf("\n");
523 if ( nlsr->detailed_logging )
524 writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");
akmhoque3560cb62012-09-09 10:52:30 -0500525}
akmhoque810a5b52012-09-09 16:53:14 -0500526
527void
akmhoquede61ba92012-09-20 22:19:12 -0500528delete_orig_router_from_npt(char *orig_router)
akmhoque810a5b52012-09-09 16:53:14 -0500529{
akmhoquede61ba92012-09-20 22:19:12 -0500530 int res,num_face,num_prefix;
akmhoque810a5b52012-09-09 16:53:14 -0500531 struct npt_entry *ne;
532
533 struct hashtb_enumerator ee;
534 struct hashtb_enumerator *e = &ee;
535
536 hashtb_start(nlsr->npt, e);
537 res = hashtb_seek(e, orig_router, strlen(orig_router), 0);
538
539 if ( res == HT_OLD_ENTRY )
540 {
541 ne=e->data;
akmhoquede61ba92012-09-20 22:19:12 -0500542 num_prefix=hashtb_n(ne->name_list);
543 if ( num_prefix > 0 )
akmhoque810a5b52012-09-09 16:53:14 -0500544 {
akmhoquede61ba92012-09-20 22:19:12 -0500545 num_face=hashtb_n(ne->face_list);
546
547 if ( num_face > 0 )
akmhoque810a5b52012-09-09 16:53:14 -0500548 {
549 int j, nl_element;
550 struct name_list_entry *nle;
551 struct hashtb_enumerator eenle;
552 struct hashtb_enumerator *enle = &eenle;
553
554 hashtb_start(ne->name_list, enle);
555 nl_element=hashtb_n(ne->name_list);
556
557 for (j=0;j<nl_element;j++)
558 {
559 nle=enle->data;
akmhoque3cced642012-09-24 16:20:20 -0500560 delete_npt_entry_by_router_and_name_prefix(ne->orig_router,nle->name);
akmhoque810a5b52012-09-09 16:53:14 -0500561 hashtb_next(enle);
562 }
563 hashtb_end(enle);
564
565 }
566
567 }
568 hashtb_destroy(&ne->name_list);
akmhoquede61ba92012-09-20 22:19:12 -0500569 hashtb_destroy(&ne->face_list);
akmhoque810a5b52012-09-09 16:53:14 -0500570 hashtb_delete(e);
571 }
572 else if ( res == HT_NEW_ENTRY )
573 {
574 hashtb_delete(e);
575 }
576 hashtb_end(e);
577}
akmhoquefbfd0982012-09-09 20:59:03 -0500578
akmhoquede61ba92012-09-20 22:19:12 -0500579
580void
581add_face_to_npt_by_face_id(char *dest_router, int face_id, int route_cost)
582{
akmhoque1771c412012-11-09 13:06:08 -0600583 if ( nlsr->debugging )
584 {
585 printf("add_face_to_npt_by_face_id called\n");
586 printf("Dest Router: %s Face: %d Route_cost: %d \n",dest_router, face_id, route_cost);
587 }
588 if ( nlsr->detailed_logging )
589 {
590 writeLogg(__FILE__,__FUNCTION__,__LINE__,"add_face_to_npt_by_face_id called\n");
591 writeLogg(__FILE__,__FUNCTION__,__LINE__,"Dest Router: %s Face: %d Route_cost: %d \n",dest_router, face_id, route_cost);
592 }
akmhoquede61ba92012-09-20 22:19:12 -0500593
akmhoque1771c412012-11-09 13:06:08 -0600594
akmhoquede61ba92012-09-20 22:19:12 -0500595 int res,res1;
596 struct npt_entry *ne;
597
598 struct hashtb_enumerator ee;
599 struct hashtb_enumerator *e = &ee;
600
601 hashtb_start(nlsr->npt, e);
602 res = hashtb_seek(e, dest_router, strlen(dest_router), 0);
603
604 if ( res == HT_OLD_ENTRY )
605 {
akmhoque1771c412012-11-09 13:06:08 -0600606 if ( nlsr->debugging )
607 printf("Dest Router Found \n");
608 if ( nlsr->detailed_logging )
609 writeLogg(__FILE__,__FUNCTION__,__LINE__,"Dest Router Found \n");
610
akmhoquede61ba92012-09-20 22:19:12 -0500611 ne=e->data;
612
613 struct hashtb_enumerator eef;
614 struct hashtb_enumerator *ef = &eef;
615
616 hashtb_start(ne->face_list, ef);
617 res1=hashtb_seek(ef, &face_id, sizeof(face_id), 0);
618
619 if ( res1 == HT_OLD_ENTRY )
620 {
akmhoque1771c412012-11-09 13:06:08 -0600621 if ( nlsr->debugging )
622 printf("Face Found \n");
623 if ( nlsr->detailed_logging )
624 writeLogg(__FILE__,__FUNCTION__,__LINE__,"Face Found \n");
akmhoqueb77b95f2013-02-08 12:28:47 -0600625 struct face_list_entry *fle;
akmhoquede61ba92012-09-20 22:19:12 -0500626 fle=ef->data;
627 fle->next_hop_face=face_id;
628 fle->route_cost=route_cost;
629 }
630 else if ( res1 == HT_NEW_ENTRY )
631 {
akmhoque1771c412012-11-09 13:06:08 -0600632 if ( nlsr->debugging )
633 printf("Face Not Found \n");
634 if ( nlsr->detailed_logging )
635 writeLogg(__FILE__,__FUNCTION__,__LINE__,"Face Not Found \n");
akmhoquede61ba92012-09-20 22:19:12 -0500636 struct face_list_entry *fle=(struct face_list_entry *)malloc(sizeof(struct face_list_entry));
637 fle=ef->data;
638 fle->next_hop_face=face_id;
639 fle->route_cost=route_cost;
akmhoqueb77b95f2013-02-08 12:28:47 -0600640
641
642
643
akmhoquede61ba92012-09-20 22:19:12 -0500644 }
645 hashtb_end(ef);
646 }
647 else if (res == HT_NEW_ENTRY)
648 {
649 hashtb_delete(e);
650 }
651
652 hashtb_end(e);
653}
654
655
656void
akmhoque3cced642012-09-24 16:20:20 -0500657add_new_fib_entries_to_npt(void)
akmhoquede61ba92012-09-20 22:19:12 -0500658{
akmhoque1771c412012-11-09 13:06:08 -0600659 if ( nlsr->debugging )
660 printf("add_new_fib_entries_to_npt called\n");
661 if ( nlsr->detailed_logging )
662 writeLogg(__FILE__,__FUNCTION__,__LINE__,"add_new_fib_entries_to_npt called\n");
akmhoquede61ba92012-09-20 22:19:12 -0500663 int i,j, rt_element,face_list_element;
664
665 struct routing_table_entry *rte;
666
667 struct hashtb_enumerator ee;
668 struct hashtb_enumerator *e = &ee;
669
670 hashtb_start(nlsr->routing_table, e);
671 rt_element=hashtb_n(nlsr->routing_table);
672
673 for(i=0;i<rt_element;i++)
674 {
akmhoquede61ba92012-09-20 22:19:12 -0500675 rte=e->data;
akmhoquede61ba92012-09-20 22:19:12 -0500676
677 struct face_list_entry *fle;
678
679 struct hashtb_enumerator eef;
680 struct hashtb_enumerator *ef = &eef;
681
682 hashtb_start(rte->face_list, ef);
683 face_list_element=hashtb_n(rte->face_list);
684 if ( face_list_element <= 0 )
685 {
akmhoque1771c412012-11-09 13:06:08 -0600686 if ( nlsr->debugging )
akmhoqueb77b95f2013-02-08 12:28:47 -0600687 printf(" Face: No Face \n");
akmhoque1771c412012-11-09 13:06:08 -0600688 if ( nlsr->detailed_logging )
akmhoqueb77b95f2013-02-08 12:28:47 -0600689 writeLogg(__FILE__,__FUNCTION__,__LINE__," Face: No Face \n");
akmhoquede61ba92012-09-20 22:19:12 -0500690 }
691 else
692 {
693 for(j=0;j<face_list_element;j++)
694 {
695 fle=ef->data;
akmhoquede61ba92012-09-20 22:19:12 -0500696 add_face_to_npt_by_face_id(rte->dest_router,fle->next_hop_face,fle->route_cost);
697 hashtb_next(ef);
698 }
699 }
700 hashtb_end(ef);
701
702 hashtb_next(e);
703 }
704
705 hashtb_end(e);
706
707}
708
709
710void
711delete_face_from_npt_by_face_id(char *dest_router, int face_id)
712{
akmhoque1771c412012-11-09 13:06:08 -0600713 if ( nlsr->debugging )
714 printf("delete_face_from_npt_by_face_id\n");
715 if ( nlsr->detailed_logging )
716 writeLogg(__FILE__,__FUNCTION__,__LINE__,"delete_face_from_npt_by_face_id\n");
akmhoquede61ba92012-09-20 22:19:12 -0500717
718 int res,res1;
719 struct npt_entry *ne;
720
721 struct hashtb_enumerator ee;
722 struct hashtb_enumerator *e = &ee;
723
724 hashtb_start(nlsr->npt, e);
725 res = hashtb_seek(e, dest_router, strlen(dest_router), 0);
726
727 if ( res == HT_OLD_ENTRY )
728 {
729 ne=e->data;
730
731 struct hashtb_enumerator eef;
732 struct hashtb_enumerator *ef = &eef;
733
734 hashtb_start(ne->face_list, ef);
735 res1=hashtb_seek(ef, &face_id, sizeof(face_id), 0);
akmhoquede61ba92012-09-20 22:19:12 -0500736 if ( res1 == HT_OLD_ENTRY )
737 {
738 hashtb_delete(ef);
739 }
740 else if ( res1 == HT_NEW_ENTRY )
741 {
742 hashtb_delete(ef);
743 }
744 hashtb_end(ef);
745 }
746 else if (res == HT_NEW_ENTRY)
747 {
748 hashtb_delete(e);
749 }
750
751 hashtb_end(e);
752}
753
akmhoquede61ba92012-09-20 22:19:12 -0500754
755void
akmhoque3cced642012-09-24 16:20:20 -0500756clean_old_fib_entries_from_npt(void)
akmhoquede61ba92012-09-20 22:19:12 -0500757{
758
akmhoque1771c412012-11-09 13:06:08 -0600759
760 if ( nlsr->debugging )
761 printf("clean_old_fib_entries_from_npt called\n\n");
762 if ( nlsr->detailed_logging )
763 writeLogg(__FILE__,__FUNCTION__,__LINE__,"clean_old_fib_entries_from_npt called\n\n");
akmhoquede61ba92012-09-20 22:19:12 -0500764 int i, npt_element;
765
766 struct npt_entry *ne;
767
768 struct hashtb_enumerator ee;
769 struct hashtb_enumerator *e = &ee;
770
771 hashtb_start(nlsr->npt, e);
772 npt_element=hashtb_n(nlsr->npt);
773
774 for(i=0;i<npt_element;i++)
775 {
776 ne=e->data;
777
778 int j,k, nl_element,face_list_element;
779 struct face_list_entry *fle;
780
781 struct hashtb_enumerator eef;
782 struct hashtb_enumerator *ef = &eef;
783
784 hashtb_start(ne->face_list, ef);
785 face_list_element=hashtb_n(ne->face_list);
786 if ( face_list_element <= 0 )
787 {
akmhoque1771c412012-11-09 13:06:08 -0600788 if ( nlsr->debugging )
akmhoqueb77b95f2013-02-08 12:28:47 -0600789 printf(" Face: No Face \n");
akmhoque1771c412012-11-09 13:06:08 -0600790 if ( nlsr->detailed_logging )
791 writeLogg(__FILE__,__FUNCTION__,__LINE__," Face: No Face \n");
792
akmhoquede61ba92012-09-20 22:19:12 -0500793 }
794 else
795 {
796 for(j=0;j<face_list_element;j++)
797 {
798 fle=ef->data;
799 int check=does_face_exist_for_router(ne->orig_router,fle->next_hop_face);
800 if ( check == 0 )
801 {
802 struct name_list_entry *nle;
803 struct hashtb_enumerator eenle;
804 struct hashtb_enumerator *enle = &eenle;
805
806 hashtb_start(ne->name_list, enle);
807 nl_element=hashtb_n(ne->name_list);
808
809 for (k=0;k<nl_element;k++)
810 {
811 nle=enle->data;
akmhoque3cced642012-09-24 16:20:20 -0500812 if( is_neighbor(nle->name) == 0 )
813 {
akmhoque1771c412012-11-09 13:06:08 -0600814 if ( nlsr->debugging )
815 printf("Deleting face: Name:%s Face: %d\n",nle->name,fle->next_hop_face);
816 if ( nlsr->detailed_logging )
akmhoqueb77b95f2013-02-08 12:28:47 -0600817 writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,fle->next_hop_face);
akmhoque3cced642012-09-24 16:20:20 -0500818 add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, fle->next_hop_face);
819 }
820
akmhoquede61ba92012-09-20 22:19:12 -0500821
822 hashtb_next(enle);
823 }
824 hashtb_end(enle);
825
akmhoqueb77b95f2013-02-08 12:28:47 -0600826
827 hashtb_delete(ef);
828 j++;
829
akmhoquede61ba92012-09-20 22:19:12 -0500830 }
akmhoqueb77b95f2013-02-08 12:28:47 -0600831 else
832 {
833 struct name_list_entry *nle;
834 struct hashtb_enumerator eenle;
835 struct hashtb_enumerator *enle = &eenle;
836
837 hashtb_start(ne->name_list, enle);
838 nl_element=hashtb_n(ne->name_list);
839
840 for (k=0;k<nl_element;k++)
841 {
842 nle=enle->data;
843 if( is_active_neighbor(ne->orig_router) && get_next_hop_face_from_adl( ne->orig_router ) != fle->next_hop_face )
844 {
845 if ( nlsr->debugging )
846 printf("Deleting face: Name:%s Face: %d\n",nle->name,fle->next_hop_face);
847 if ( nlsr->detailed_logging )
848 writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,fle->next_hop_face);
849 add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, fle->next_hop_face);
850 }
851
852
853 hashtb_next(enle);
854 }
855 hashtb_end(enle);
856
857 hashtb_next(ef);
858 }
akmhoquede61ba92012-09-20 22:19:12 -0500859 }
860 }
861 hashtb_end(ef);
862
863
864 hashtb_next(e);
865 }
866
867 hashtb_end(e);
868
869}
870
871void
akmhoque3cced642012-09-24 16:20:20 -0500872update_npt_with_new_route(void)
akmhoquede61ba92012-09-20 22:19:12 -0500873{
akmhoqueb77b95f2013-02-08 12:28:47 -0600874 if ( nlsr->debugging )
875 printf("update_npt_with_new_route called\n");
876
akmhoquede61ba92012-09-20 22:19:12 -0500877 clean_old_fib_entries_from_npt();
akmhoqueb77b95f2013-02-08 12:28:47 -0600878 print_npt();
akmhoquede61ba92012-09-20 22:19:12 -0500879 add_new_fib_entries_to_npt();
akmhoqueb77b95f2013-02-08 12:28:47 -0600880 print_npt();
881
akmhoque3cced642012-09-24 16:20:20 -0500882 int i, npt_element;
883
884 struct npt_entry *ne;
885
886 struct hashtb_enumerator ee;
887 struct hashtb_enumerator *e = &ee;
888
889 hashtb_start(nlsr->npt, e);
890 npt_element=hashtb_n(nlsr->npt);
891
892 for(i=0;i<npt_element;i++)
893 {
894
895 ne=e->data;
896 update_ccnd_fib_for_orig_router(ne->orig_router);
897 hashtb_next(e);
898 }
899
900 hashtb_end(e);
901}
902
903
904
905void
906sort_faces_by_distance(int *faces,int *route_costs,int start,int element)
907{
908 int i,j;
909 int temp_cost;
910 int temp_face;
911
912 for ( i=start ; i < element ; i ++)
913 {
914 for( j=i+1; j<element; j ++)
915 {
916 if (route_costs[j] < route_costs[i] )
917 {
918 temp_cost=route_costs[j];
919 route_costs[j]=route_costs[i];
920 route_costs[i]=temp_cost;
921
922 temp_face=faces[j];
923 faces[j]=faces[i];
924 faces[i]=temp_face;
925 }
926 }
927 }
928
929}
930
931void
932get_all_faces_for_orig_router_from_npt(char *orig_router, int *faces, int *route_costs, int num_faces)
933{
934
935 int res,face_list_element,j;
936 struct hashtb_enumerator ee;
937 struct hashtb_enumerator *e = &ee;
938
939
940 hashtb_start(nlsr->npt, e);
941 res = hashtb_seek(e, orig_router, strlen(orig_router), 0);
942
943 if(res == HT_NEW_ENTRY)
944 {
945 hashtb_delete(e);
946 }
947 else if ( res == HT_OLD_ENTRY )
948 {
949 struct npt_entry *ne;
950 ne=e->data;
951
952 struct face_list_entry *fle;
953
954 struct hashtb_enumerator eef;
955 struct hashtb_enumerator *ef = &eef;
956
957 hashtb_start(ne->face_list, ef);
958 face_list_element=hashtb_n(ne->face_list);
959 for(j=0;j<face_list_element;j++)
960 {
961 fle=ef->data;
962 faces[j]=fle->next_hop_face;
963 route_costs[j]=fle->route_cost;
964 hashtb_next(ef);
965 }
966 hashtb_end(ef);
967
968
969 }
970 hashtb_end(e);
971
972}
973
974void
975destroy_faces_by_orig_router(char *orig_router)
976{
977
978 int res;
979 struct hashtb_enumerator ee;
980 struct hashtb_enumerator *e = &ee;
981
982
983 hashtb_start(nlsr->npt, e);
984 res = hashtb_seek(e, orig_router, strlen(orig_router), 0);
985
986 if(res == HT_NEW_ENTRY)
987 {
988 hashtb_delete(e);
989 }
990 else if ( res == HT_OLD_ENTRY )
991 {
992 struct npt_entry *ne;
993 ne=e->data;
994 int num_face=hashtb_n(ne->face_list);
995 int last_face,first_face;
996
997 int *faces=(int *)malloc(num_face*sizeof(int));
998 int *route_costs=(int *)malloc(num_face*sizeof(int));
999
1000 get_all_faces_for_orig_router_from_npt(orig_router,faces,route_costs,num_face);
1001 sort_faces_by_distance(faces,route_costs,0,num_face);
akmhoqueb77b95f2013-02-08 12:28:47 -06001002 last_face=0;
akmhoque0ed6d982013-02-22 14:28:01 -06001003 if ( nlsr->max_faces_per_prefix == 0)
akmhoqueb77b95f2013-02-08 12:28:47 -06001004 {
1005 first_face=num_face-1;
1006 }
1007 else if( nlsr->max_faces_per_prefix > 0)
1008 {
1009 if ( nlsr->max_faces_per_prefix >= num_face)
1010 {
1011 first_face=num_face-1;
1012 }
1013 else if ( nlsr->max_faces_per_prefix < num_face)
1014 {
1015 first_face=nlsr->max_faces_per_prefix-1;
1016 }
1017
1018 }
akmhoque3cced642012-09-24 16:20:20 -05001019
1020 int i,j, nl_element;
1021 struct name_list_entry *nle;
1022 struct hashtb_enumerator eenle;
1023 struct hashtb_enumerator *enle = &eenle;
1024
1025 hashtb_start(ne->name_list, enle);
1026 nl_element=hashtb_n(ne->name_list);
1027
1028 for (i=0;i<nl_element;i++)
1029 {
1030 nle=enle->data;
1031
1032 for( j=first_face; j>= last_face; j--)
1033 {
akmhoqueb77b95f2013-02-08 12:28:47 -06001034 if ( is_active_neighbor(orig_router) == 0 )
akmhoque3cced642012-09-24 16:20:20 -05001035 {
akmhoque1771c412012-11-09 13:06:08 -06001036 if ( nlsr->debugging )
1037 printf("Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);
1038 if ( nlsr->detailed_logging )
1039 writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);
akmhoquea30cb772012-10-07 09:50:34 -05001040 add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, faces[j]);
akmhoque3cced642012-09-24 16:20:20 -05001041 }
1042 else
1043 {
akmhoqueb77b95f2013-02-08 12:28:47 -06001044 if ( j == last_face && is_active_neighbor(nle->name)==0)
akmhoque3cced642012-09-24 16:20:20 -05001045 {
akmhoque1771c412012-11-09 13:06:08 -06001046 if ( nlsr->debugging )
1047 printf("Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);
1048 if ( nlsr->detailed_logging )
1049 writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);
akmhoque3cced642012-09-24 16:20:20 -05001050 add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, faces[j]);
1051 }
1052 }
1053 }
1054
1055 hashtb_next(enle);
1056 }
1057 hashtb_end(enle);
1058
1059
1060
1061 free(faces);
1062 free(route_costs);
1063
1064 }
1065 hashtb_end(e);
1066
akmhoquede61ba92012-09-20 22:19:12 -05001067}
1068
akmhoquefbfd0982012-09-09 20:59:03 -05001069void
1070destroy_all_face_by_nlsr(void)
1071{
1072 int i, npt_element;
Obaid Amin0e9a3002013-02-20 14:55:37 -06001073
akmhoquefbfd0982012-09-09 20:59:03 -05001074 struct npt_entry *ne;
1075
1076 struct hashtb_enumerator ee;
Obaid Amin0e9a3002013-02-20 14:55:37 -06001077 struct hashtb_enumerator *e = &ee;
1078
1079 hashtb_start(nlsr->npt, e);
akmhoquefbfd0982012-09-09 20:59:03 -05001080 npt_element=hashtb_n(nlsr->npt);
1081
1082 for(i=0;i<npt_element;i++)
1083 {
akmhoquefbfd0982012-09-09 20:59:03 -05001084 ne=e->data;
akmhoque3cced642012-09-24 16:20:20 -05001085 destroy_faces_by_orig_router(ne->orig_router);
akmhoquefbfd0982012-09-09 20:59:03 -05001086 hashtb_next(e);
1087 }
1088
1089 hashtb_end(e);
1090
akmhoque3171d652012-11-13 11:44:33 -06001091 if ( nlsr->debugging )
1092 printf("\n");
1093 if ( nlsr->detailed_logging )
1094 writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");
akmhoquefbfd0982012-09-09 20:59:03 -05001095}
akmhoque0ed6d982013-02-22 14:28:01 -06001096
1097void
1098destroy_name_list(void)
1099{
1100
1101}
1102
1103void
1104destroy_face_list(void)
1105{
1106
1107}
1108
1109void
1110destroy_npt(void)
1111{
1112
1113
1114 int i, npt_element;
1115 struct npt_entry *ne;
1116
1117 struct hashtb_enumerator ee;
1118 struct hashtb_enumerator *e = &ee;
1119
1120 hashtb_start(nlsr->npt, e);
1121 npt_element=hashtb_n(nlsr->npt);
1122
1123 for(i=0;i<npt_element;i++)
1124 {
1125 ne=e->data;
1126
1127 int j, nl_element,face_list_element;
1128 struct name_list_entry *nle;
1129 struct hashtb_enumerator eenle;
1130 struct hashtb_enumerator *enle = &eenle;
1131
1132 hashtb_start(ne->name_list, enle);
1133 nl_element=hashtb_n(ne->name_list);
1134
1135 for (j=0;j<nl_element;j++)
1136 {
1137 nle=enle->data;
1138 hashtb_next(enle);
1139 }
1140 hashtb_end(enle);
1141
1142 struct face_list_entry *fle;
1143 struct hashtb_enumerator eef;
1144 struct hashtb_enumerator *ef = &eef;
1145
1146 hashtb_start(ne->face_list, ef);
1147 face_list_element=hashtb_n(ne->face_list);
1148
1149 for(j=0;j<face_list_element;j++)
1150 {
1151 fle=ef->data;
1152 hashtb_next(ef);
1153 }
1154
1155 hashtb_end(ef);
1156
1157
1158 hashtb_next(e);
1159 }
1160
1161 hashtb_end(e);
1162}
1163