akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [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 | #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" |
| 26 | #include "nlsr_route.h" |
| 27 | #include "nlsr_adl.h" |
| 28 | #include "utility.h" |
| 29 | |
| 30 | int |
| 31 | add_npt_entry(char *orig_router, char *name_prefix, int num_face, int *faces, int *route_costs) |
| 32 | { |
| 33 | if ( strcmp(orig_router,nlsr->router_name)== 0) |
| 34 | { |
| 35 | return -1; |
| 36 | } |
| 37 | |
| 38 | struct npt_entry *ne=(struct npt_entry*)malloc(sizeof(struct npt_entry )); |
| 39 | |
| 40 | int res,res_nle,res_fle; |
| 41 | struct hashtb_enumerator ee; |
| 42 | struct hashtb_enumerator *e = ⅇ |
| 43 | |
| 44 | |
| 45 | hashtb_start(nlsr->npt, e); |
| 46 | res = hashtb_seek(e, orig_router, strlen(orig_router), 0); |
| 47 | |
| 48 | if(res == HT_NEW_ENTRY) |
| 49 | { |
| 50 | ne=e->data; |
| 51 | |
| 52 | 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)); |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | struct hashtb_param param_nle = {0}; |
| 60 | ne->name_list= hashtb_create(sizeof(struct name_list_entry ), ¶m_nle); |
| 61 | |
| 62 | struct hashtb_enumerator eenle; |
| 63 | struct hashtb_enumerator *enle = &eenle; |
| 64 | |
| 65 | hashtb_start(ne->name_list, enle); |
| 66 | res_nle = hashtb_seek(enle, name_prefix, strlen(name_prefix), 0); |
| 67 | |
| 68 | if(res_nle == HT_NEW_ENTRY ) |
| 69 | { |
| 70 | struct name_list_entry *nle=(struct name_list_entry *)malloc(sizeof(struct name_list_entry)); |
| 71 | nle=enle->data; |
| 72 | nle->name=(char *)malloc(strlen(name_prefix)+1); |
| 73 | memset(nle->name,0,strlen(name_prefix)+1); |
| 74 | memcpy(nle->name,name_prefix,strlen(name_prefix)); |
| 75 | |
| 76 | |
| 77 | |
| 78 | } |
| 79 | hashtb_end(enle); |
| 80 | |
| 81 | struct hashtb_param param_fle = {0}; |
| 82 | ne->face_list=hashtb_create(sizeof(struct face_list_entry), ¶m_fle); |
| 83 | |
| 84 | 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 | |
| 92 | for ( i=0; i < num_face ; i++) |
| 93 | { |
| 94 | int face=faces[i]; |
| 95 | if ( face != NO_FACE && face != ZERO_FACE) |
| 96 | { |
| 97 | res_fle = hashtb_seek(ef, &face, sizeof(face), 0); |
| 98 | |
| 99 | if ( res_fle == HT_NEW_ENTRY ) |
| 100 | { |
| 101 | struct face_list_entry *fle=(struct face_list_entry *)malloc(sizeof(struct face_list_entry)); |
| 102 | fle=ef->data; |
| 103 | fle->next_hop_face=face; |
| 104 | fle->route_cost=route_costs[i]; |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | } |
| 109 | hashtb_end(ef); |
| 110 | } |
| 111 | |
| 112 | } |
| 113 | else if (res == HT_OLD_ENTRY) |
| 114 | { |
| 115 | free(ne); |
| 116 | struct npt_entry *one; |
| 117 | |
| 118 | one=e->data; |
| 119 | |
| 120 | struct hashtb_enumerator eenle; |
| 121 | struct hashtb_enumerator *enle = &eenle; |
| 122 | |
| 123 | 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 ) |
| 127 | { |
| 128 | struct name_list_entry *nle=(struct name_list_entry *)malloc(sizeof(struct name_list_entry)); |
| 129 | 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)); |
| 133 | } |
| 134 | else if(res_nle == HT_OLD_ENTRY ) |
| 135 | { |
| 136 | |
| 137 | } |
| 138 | hashtb_end(enle); |
| 139 | |
| 140 | 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]; |
| 151 | if ( face != NO_FACE && face != ZERO_FACE) |
| 152 | { |
| 153 | res_fle = hashtb_seek(ef, &face, sizeof(face), 0); |
| 154 | |
| 155 | if ( res_fle == HT_NEW_ENTRY ) |
| 156 | { |
| 157 | struct face_list_entry *fle=(struct face_list_entry *)malloc(sizeof(struct face_list_entry)); |
| 158 | fle=ef->data; |
| 159 | fle->next_hop_face=face; |
| 160 | fle->route_cost=route_costs[i]; |
| 161 | } |
| 162 | } |
| 163 | } |
| 164 | hashtb_end(ef); |
| 165 | } |
| 166 | |
| 167 | |
| 168 | } |
| 169 | hashtb_end(e); |
| 170 | |
| 171 | update_ccnd_fib_for_orig_router(orig_router); |
| 172 | |
| 173 | return res; |
| 174 | } |
| 175 | |
| 176 | void |
| 177 | update_ccnd_fib_for_orig_router(char *orig_router) |
| 178 | { |
akmhoque | aaa1055 | 2013-01-24 08:00:42 -0600 | [diff] [blame] | 179 | |
| 180 | if ( nlsr->debugging ) |
| 181 | { |
| 182 | printf("update_ccnd_fib_for_orig_router called\n"); |
| 183 | } |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 184 | |
| 185 | int res; |
| 186 | struct hashtb_enumerator ee; |
| 187 | struct hashtb_enumerator *e = ⅇ |
| 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 | |
akmhoque | baf53f1 | 2013-01-24 11:06:18 -0600 | [diff] [blame] | 210 | if ( nlsr->debugging ) |
akmhoque | aaa1055 | 2013-01-24 08:00:42 -0600 | [diff] [blame] | 211 | { |
akmhoque | baf53f1 | 2013-01-24 11:06:18 -0600 | [diff] [blame] | 212 | 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 | } |
| 217 | } |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 218 | |
| 219 | first_face=num_face-1; |
| 220 | |
| 221 | if ( nlsr->multi_path_face_num == 0 ) |
| 222 | { |
| 223 | last_face=first_face; |
| 224 | } |
| 225 | else |
| 226 | { |
| 227 | if ( num_face <= nlsr->multi_path_face_num) |
| 228 | { |
| 229 | last_face=0; |
| 230 | } |
akmhoque | dc27b95 | 2013-01-24 09:34:00 -0600 | [diff] [blame] | 231 | else |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 232 | { |
| 233 | last_face=num_face-nlsr->multi_path_face_num; |
| 234 | } |
akmhoque | dc27b95 | 2013-01-24 09:34:00 -0600 | [diff] [blame] | 235 | |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | int i,j, nl_element; |
| 239 | struct name_list_entry *nle; |
| 240 | struct hashtb_enumerator eenle; |
| 241 | struct hashtb_enumerator *enle = &eenle; |
| 242 | |
| 243 | hashtb_start(ne->name_list, enle); |
| 244 | nl_element=hashtb_n(ne->name_list); |
| 245 | |
| 246 | for (i=0;i<nl_element;i++) |
| 247 | { |
| 248 | nle=enle->data; |
| 249 | |
| 250 | for( j=first_face; j>= last_face; j--) |
| 251 | { |
akmhoque | baf53f1 | 2013-01-24 11:06:18 -0600 | [diff] [blame] | 252 | if ( nlsr->debugging ) |
| 253 | { |
| 254 | printf("Possible FIB Entry name: %s face: %d route cost: %d \n",nle->name,faces[j],route_costs[j]); |
| 255 | } |
akmhoque | 9ca1bb8 | 2013-01-24 09:57:57 -0600 | [diff] [blame] | 256 | if ( is_active_neighbor(orig_router) == 0 ) |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 257 | { |
| 258 | if ( nlsr->debugging ) |
| 259 | printf("Adding face: Name:%s Face: %d\n",nle->name,faces[j]); |
| 260 | if ( nlsr->detailed_logging ) |
| 261 | writeLogg(__FILE__,__FUNCTION__,__LINE__,"Adding face: Name:%s Face: %d\n",nle->name,faces[j]); |
akmhoque | f9b35b3 | 2013-01-24 10:25:48 -0600 | [diff] [blame] | 262 | add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_REG, faces[j]); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 263 | } |
| 264 | else |
| 265 | { |
akmhoque | 9ca1bb8 | 2013-01-24 09:57:57 -0600 | [diff] [blame] | 266 | if ( j == last_face && is_active_neighbor(nle->name)==0) |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 267 | { |
| 268 | if ( nlsr->debugging ) |
| 269 | printf("Adding face: Name:%s Face: %d\n",nle->name,faces[j]); |
| 270 | if ( nlsr->detailed_logging ) |
| 271 | writeLogg(__FILE__,__FUNCTION__,__LINE__,"Adding face: Name:%s Face: %d\n",nle->name,faces[j]); |
akmhoque | f9b35b3 | 2013-01-24 10:25:48 -0600 | [diff] [blame] | 272 | add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_REG, faces[j]); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 273 | } |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | |
| 278 | hashtb_next(enle); |
| 279 | } |
| 280 | hashtb_end(enle); |
| 281 | |
| 282 | |
| 283 | |
| 284 | free(faces); |
| 285 | free(route_costs); |
| 286 | |
| 287 | } |
| 288 | hashtb_end(e); |
| 289 | |
| 290 | } |
| 291 | |
| 292 | int |
| 293 | delete_npt_entry_by_router_and_name_prefix(char *orig_router, char *name_prefix) |
| 294 | { |
| 295 | if ( strcmp(orig_router,nlsr->router_name)== 0) |
| 296 | { |
| 297 | return -1; |
| 298 | } |
| 299 | |
| 300 | struct npt_entry *ne; |
| 301 | |
| 302 | int res,res_nle; |
| 303 | struct hashtb_enumerator ee; |
| 304 | struct hashtb_enumerator *e = ⅇ |
| 305 | |
| 306 | |
| 307 | hashtb_start(nlsr->npt, e); |
| 308 | res = hashtb_seek(e, orig_router, strlen(orig_router), 0); |
| 309 | |
| 310 | if(res == HT_NEW_ENTRY) |
| 311 | { |
| 312 | hashtb_delete(e); |
| 313 | return -1; |
| 314 | } |
| 315 | else if (res == HT_OLD_ENTRY) |
| 316 | { |
| 317 | ne=e->data; |
| 318 | |
| 319 | struct hashtb_enumerator eenle; |
| 320 | struct hashtb_enumerator *enle = &eenle; |
| 321 | |
| 322 | hashtb_start(ne->name_list, enle); |
| 323 | res_nle = hashtb_seek(enle, name_prefix, strlen(name_prefix), 0); |
| 324 | |
| 325 | if(res_nle == HT_NEW_ENTRY ) |
| 326 | { |
| 327 | hashtb_delete(enle); |
| 328 | } |
| 329 | else if(res_nle == HT_OLD_ENTRY ) |
| 330 | { |
| 331 | struct name_list_entry *nle; |
| 332 | |
| 333 | nle=enle->data; |
| 334 | |
| 335 | int j; |
| 336 | int num_face=hashtb_n(ne->face_list); |
| 337 | int last_face,first_face; |
| 338 | |
| 339 | int *faces=(int *)malloc(num_face*sizeof(int)); |
| 340 | int *route_costs=(int *)malloc(num_face*sizeof(int)); |
| 341 | |
| 342 | get_all_faces_for_orig_router_from_npt(orig_router,faces,route_costs,num_face); |
| 343 | sort_faces_by_distance(faces,route_costs,0,num_face); |
| 344 | |
| 345 | |
| 346 | first_face=num_face-1; |
| 347 | |
| 348 | if ( nlsr->multi_path_face_num == 0 ) |
| 349 | { |
| 350 | last_face=first_face; |
| 351 | } |
| 352 | else |
| 353 | { |
| 354 | if ( num_face <= nlsr->multi_path_face_num) |
| 355 | { |
| 356 | last_face=0; |
| 357 | } |
akmhoque | dc27b95 | 2013-01-24 09:34:00 -0600 | [diff] [blame] | 358 | else |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 359 | { |
| 360 | last_face=num_face-nlsr->multi_path_face_num; |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | for( j=first_face; j>= last_face; j--) |
| 365 | { |
| 366 | |
akmhoque | 9ca1bb8 | 2013-01-24 09:57:57 -0600 | [diff] [blame] | 367 | if ( is_active_neighbor(orig_router) == 0 ) |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 368 | { |
| 369 | if ( nlsr->debugging ) |
| 370 | printf("Deleting face: Name:%s Face: %d\n",nle->name,faces[j]); |
| 371 | if ( nlsr->detailed_logging ) |
| 372 | writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,faces[j]); |
akmhoque | f9b35b3 | 2013-01-24 10:25:48 -0600 | [diff] [blame] | 373 | add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, faces[j]); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 374 | } |
| 375 | else |
| 376 | { |
akmhoque | 9ca1bb8 | 2013-01-24 09:57:57 -0600 | [diff] [blame] | 377 | if ( j == last_face && is_active_neighbor(nle->name)==0) |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 378 | { |
| 379 | if ( nlsr->debugging ) |
| 380 | printf("Deleting face: Name:%s Face: %d\n",nle->name,faces[j]); |
| 381 | if ( nlsr->detailed_logging ) |
| 382 | writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,faces[j]); |
akmhoque | f9b35b3 | 2013-01-24 10:25:48 -0600 | [diff] [blame] | 383 | add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, faces[j]); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 384 | } |
| 385 | } |
| 386 | |
| 387 | } |
| 388 | |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | hashtb_end(enle); |
| 392 | } |
| 393 | |
| 394 | hashtb_end(e); |
| 395 | |
| 396 | return 0; |
| 397 | } |
| 398 | |
| 399 | void |
| 400 | print_npt(void) |
| 401 | { |
| 402 | |
| 403 | if ( nlsr->debugging ) |
| 404 | { |
| 405 | printf("\n"); |
| 406 | printf("print_npt called\n"); |
| 407 | } |
| 408 | if ( nlsr->detailed_logging ) |
| 409 | { |
| 410 | writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n"); |
| 411 | writeLogg(__FILE__,__FUNCTION__,__LINE__,"print_npt called\n"); |
| 412 | } |
| 413 | int i, npt_element; |
| 414 | |
| 415 | struct npt_entry *ne; |
| 416 | |
| 417 | struct hashtb_enumerator ee; |
| 418 | struct hashtb_enumerator *e = ⅇ |
| 419 | |
| 420 | hashtb_start(nlsr->npt, e); |
| 421 | npt_element=hashtb_n(nlsr->npt); |
| 422 | |
| 423 | for(i=0;i<npt_element;i++) |
| 424 | { |
| 425 | if ( nlsr->debugging ) |
| 426 | { |
| 427 | printf("\n"); |
| 428 | printf("----------NPT ENTRY %d------------------\n",i+1); |
| 429 | } |
| 430 | if ( nlsr->detailed_logging ) |
| 431 | { |
| 432 | writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n"); |
| 433 | writeLogg(__FILE__,__FUNCTION__,__LINE__,"----------NPT ENTRY %d------------------\n",i+1); |
| 434 | } |
| 435 | ne=e->data; |
| 436 | if ( nlsr->debugging ) |
| 437 | printf(" Origination Router: %s \n",ne->orig_router); |
| 438 | if ( nlsr->detailed_logging ) |
| 439 | writeLogg(__FILE__,__FUNCTION__,__LINE__," Origination Router: %s \n",ne->orig_router); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 440 | |
| 441 | int j, nl_element,face_list_element; |
| 442 | struct name_list_entry *nle; |
| 443 | struct hashtb_enumerator eenle; |
| 444 | struct hashtb_enumerator *enle = &eenle; |
| 445 | |
| 446 | hashtb_start(ne->name_list, enle); |
| 447 | nl_element=hashtb_n(ne->name_list); |
| 448 | |
| 449 | for (j=0;j<nl_element;j++) |
| 450 | { |
| 451 | nle=enle->data; |
| 452 | if ( nlsr->debugging ) |
| 453 | printf(" Name Prefix: %s \n",nle->name); |
| 454 | if ( nlsr->detailed_logging ) |
| 455 | writeLogg(__FILE__,__FUNCTION__,__LINE__," Name Prefix: %s \n",nle->name); |
| 456 | hashtb_next(enle); |
| 457 | } |
| 458 | hashtb_end(enle); |
| 459 | |
| 460 | struct face_list_entry *fle; |
| 461 | |
| 462 | struct hashtb_enumerator eef; |
| 463 | struct hashtb_enumerator *ef = &eef; |
| 464 | |
| 465 | hashtb_start(ne->face_list, ef); |
| 466 | face_list_element=hashtb_n(ne->face_list); |
| 467 | if ( face_list_element <= 0 ) |
| 468 | { |
| 469 | if ( nlsr->debugging ) |
| 470 | printf(" Face: No Face \n"); |
| 471 | if ( nlsr->detailed_logging ) |
| 472 | writeLogg(__FILE__,__FUNCTION__,__LINE__," Face: No Face \n"); |
| 473 | |
| 474 | } |
| 475 | else |
| 476 | { |
| 477 | for(j=0;j<face_list_element;j++) |
| 478 | { |
| 479 | fle=ef->data; |
| 480 | if ( nlsr->debugging ) |
akmhoque | f06586e | 2013-02-05 12:09:38 -0600 | [diff] [blame] | 481 | printf(" Face: %d Route_Cost: %f \n",fle->next_hop_face,fle->route_cost); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 482 | if ( nlsr->detailed_logging ) |
| 483 | writeLogg(__FILE__,__FUNCTION__,__LINE__," Face: %d Route_Cost: %d \n",fle->next_hop_face,fle->route_cost); |
| 484 | hashtb_next(ef); |
| 485 | } |
| 486 | } |
| 487 | hashtb_end(ef); |
| 488 | |
| 489 | |
| 490 | hashtb_next(e); |
| 491 | } |
| 492 | |
| 493 | hashtb_end(e); |
| 494 | |
| 495 | if ( nlsr->debugging ) |
| 496 | printf("\n"); |
| 497 | if ( nlsr->detailed_logging ) |
| 498 | writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n"); |
| 499 | } |
| 500 | |
| 501 | void |
| 502 | delete_orig_router_from_npt(char *orig_router) |
| 503 | { |
| 504 | int res,num_face,num_prefix; |
| 505 | struct npt_entry *ne; |
| 506 | |
| 507 | struct hashtb_enumerator ee; |
| 508 | struct hashtb_enumerator *e = ⅇ |
| 509 | |
| 510 | hashtb_start(nlsr->npt, e); |
| 511 | res = hashtb_seek(e, orig_router, strlen(orig_router), 0); |
| 512 | |
| 513 | if ( res == HT_OLD_ENTRY ) |
| 514 | { |
| 515 | ne=e->data; |
| 516 | num_prefix=hashtb_n(ne->name_list); |
| 517 | if ( num_prefix > 0 ) |
| 518 | { |
| 519 | num_face=hashtb_n(ne->face_list); |
| 520 | |
| 521 | if ( num_face > 0 ) |
| 522 | { |
| 523 | int j, nl_element; |
| 524 | struct name_list_entry *nle; |
| 525 | struct hashtb_enumerator eenle; |
| 526 | struct hashtb_enumerator *enle = &eenle; |
| 527 | |
| 528 | hashtb_start(ne->name_list, enle); |
| 529 | nl_element=hashtb_n(ne->name_list); |
| 530 | |
| 531 | for (j=0;j<nl_element;j++) |
| 532 | { |
| 533 | nle=enle->data; |
| 534 | delete_npt_entry_by_router_and_name_prefix(ne->orig_router,nle->name); |
| 535 | hashtb_next(enle); |
| 536 | } |
| 537 | hashtb_end(enle); |
| 538 | |
| 539 | } |
| 540 | |
| 541 | } |
| 542 | hashtb_destroy(&ne->name_list); |
| 543 | hashtb_destroy(&ne->face_list); |
| 544 | hashtb_delete(e); |
| 545 | } |
| 546 | else if ( res == HT_NEW_ENTRY ) |
| 547 | { |
| 548 | hashtb_delete(e); |
| 549 | } |
| 550 | hashtb_end(e); |
| 551 | } |
| 552 | |
| 553 | |
| 554 | void |
| 555 | add_face_to_npt_by_face_id(char *dest_router, int face_id, int route_cost) |
| 556 | { |
| 557 | if ( nlsr->debugging ) |
| 558 | { |
| 559 | printf("add_face_to_npt_by_face_id called\n"); |
| 560 | printf("Dest Router: %s Face: %d Route_cost: %d \n",dest_router, face_id, route_cost); |
| 561 | } |
| 562 | if ( nlsr->detailed_logging ) |
| 563 | { |
| 564 | writeLogg(__FILE__,__FUNCTION__,__LINE__,"add_face_to_npt_by_face_id called\n"); |
| 565 | writeLogg(__FILE__,__FUNCTION__,__LINE__,"Dest Router: %s Face: %d Route_cost: %d \n",dest_router, face_id, route_cost); |
| 566 | } |
| 567 | |
| 568 | |
| 569 | int res,res1; |
| 570 | struct npt_entry *ne; |
| 571 | |
| 572 | struct hashtb_enumerator ee; |
| 573 | struct hashtb_enumerator *e = ⅇ |
| 574 | |
| 575 | hashtb_start(nlsr->npt, e); |
| 576 | res = hashtb_seek(e, dest_router, strlen(dest_router), 0); |
| 577 | |
| 578 | if ( res == HT_OLD_ENTRY ) |
| 579 | { |
| 580 | if ( nlsr->debugging ) |
| 581 | printf("Dest Router Found \n"); |
| 582 | if ( nlsr->detailed_logging ) |
| 583 | writeLogg(__FILE__,__FUNCTION__,__LINE__,"Dest Router Found \n"); |
| 584 | |
| 585 | ne=e->data; |
| 586 | |
| 587 | struct hashtb_enumerator eef; |
| 588 | struct hashtb_enumerator *ef = &eef; |
| 589 | |
| 590 | hashtb_start(ne->face_list, ef); |
| 591 | res1=hashtb_seek(ef, &face_id, sizeof(face_id), 0); |
| 592 | |
| 593 | if ( res1 == HT_OLD_ENTRY ) |
| 594 | { |
| 595 | if ( nlsr->debugging ) |
| 596 | printf("Face Found \n"); |
| 597 | if ( nlsr->detailed_logging ) |
| 598 | writeLogg(__FILE__,__FUNCTION__,__LINE__,"Face Found \n"); |
akmhoque | baf53f1 | 2013-01-24 11:06:18 -0600 | [diff] [blame] | 599 | struct face_list_entry *fle; |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 600 | fle=ef->data; |
| 601 | fle->next_hop_face=face_id; |
| 602 | fle->route_cost=route_cost; |
| 603 | } |
| 604 | else if ( res1 == HT_NEW_ENTRY ) |
| 605 | { |
| 606 | if ( nlsr->debugging ) |
| 607 | printf("Face Not Found \n"); |
| 608 | if ( nlsr->detailed_logging ) |
| 609 | writeLogg(__FILE__,__FUNCTION__,__LINE__,"Face Not Found \n"); |
| 610 | struct face_list_entry *fle=(struct face_list_entry *)malloc(sizeof(struct face_list_entry)); |
| 611 | fle=ef->data; |
| 612 | fle->next_hop_face=face_id; |
| 613 | fle->route_cost=route_cost; |
akmhoque | aaa1055 | 2013-01-24 08:00:42 -0600 | [diff] [blame] | 614 | |
| 615 | |
| 616 | |
| 617 | |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 618 | } |
| 619 | hashtb_end(ef); |
| 620 | } |
| 621 | else if (res == HT_NEW_ENTRY) |
| 622 | { |
| 623 | hashtb_delete(e); |
| 624 | } |
| 625 | |
| 626 | hashtb_end(e); |
| 627 | } |
| 628 | |
| 629 | |
| 630 | void |
| 631 | add_new_fib_entries_to_npt(void) |
| 632 | { |
| 633 | if ( nlsr->debugging ) |
| 634 | printf("add_new_fib_entries_to_npt called\n"); |
| 635 | if ( nlsr->detailed_logging ) |
| 636 | writeLogg(__FILE__,__FUNCTION__,__LINE__,"add_new_fib_entries_to_npt called\n"); |
| 637 | int i,j, rt_element,face_list_element; |
| 638 | |
| 639 | struct routing_table_entry *rte; |
| 640 | |
| 641 | struct hashtb_enumerator ee; |
| 642 | struct hashtb_enumerator *e = ⅇ |
| 643 | |
| 644 | hashtb_start(nlsr->routing_table, e); |
| 645 | rt_element=hashtb_n(nlsr->routing_table); |
| 646 | |
| 647 | for(i=0;i<rt_element;i++) |
| 648 | { |
| 649 | rte=e->data; |
| 650 | |
| 651 | struct face_list_entry *fle; |
| 652 | |
| 653 | struct hashtb_enumerator eef; |
| 654 | struct hashtb_enumerator *ef = &eef; |
| 655 | |
| 656 | hashtb_start(rte->face_list, ef); |
| 657 | face_list_element=hashtb_n(rte->face_list); |
| 658 | if ( face_list_element <= 0 ) |
| 659 | { |
| 660 | if ( nlsr->debugging ) |
akmhoque | e19e3ee | 2013-01-22 14:38:45 -0600 | [diff] [blame] | 661 | printf(" Face: No Face \n"); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 662 | if ( nlsr->detailed_logging ) |
akmhoque | e19e3ee | 2013-01-22 14:38:45 -0600 | [diff] [blame] | 663 | writeLogg(__FILE__,__FUNCTION__,__LINE__," Face: No Face \n"); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 664 | } |
| 665 | else |
| 666 | { |
| 667 | for(j=0;j<face_list_element;j++) |
| 668 | { |
| 669 | fle=ef->data; |
akmhoque | eda9c36 | 2013-01-23 08:54:29 -0600 | [diff] [blame] | 670 | add_face_to_npt_by_face_id(rte->dest_router,fle->next_hop_face,fle->route_cost); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 671 | hashtb_next(ef); |
| 672 | } |
| 673 | } |
| 674 | hashtb_end(ef); |
| 675 | |
| 676 | hashtb_next(e); |
| 677 | } |
| 678 | |
| 679 | hashtb_end(e); |
| 680 | |
| 681 | } |
| 682 | |
| 683 | |
| 684 | void |
| 685 | delete_face_from_npt_by_face_id(char *dest_router, int face_id) |
| 686 | { |
| 687 | if ( nlsr->debugging ) |
| 688 | printf("delete_face_from_npt_by_face_id\n"); |
| 689 | if ( nlsr->detailed_logging ) |
| 690 | writeLogg(__FILE__,__FUNCTION__,__LINE__,"delete_face_from_npt_by_face_id\n"); |
| 691 | |
| 692 | int res,res1; |
| 693 | struct npt_entry *ne; |
| 694 | |
| 695 | struct hashtb_enumerator ee; |
| 696 | struct hashtb_enumerator *e = ⅇ |
| 697 | |
| 698 | hashtb_start(nlsr->npt, e); |
| 699 | res = hashtb_seek(e, dest_router, strlen(dest_router), 0); |
| 700 | |
| 701 | if ( res == HT_OLD_ENTRY ) |
| 702 | { |
| 703 | ne=e->data; |
| 704 | |
| 705 | struct hashtb_enumerator eef; |
| 706 | struct hashtb_enumerator *ef = &eef; |
| 707 | |
| 708 | hashtb_start(ne->face_list, ef); |
| 709 | res1=hashtb_seek(ef, &face_id, sizeof(face_id), 0); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 710 | if ( res1 == HT_OLD_ENTRY ) |
| 711 | { |
| 712 | hashtb_delete(ef); |
| 713 | } |
| 714 | else if ( res1 == HT_NEW_ENTRY ) |
| 715 | { |
| 716 | hashtb_delete(ef); |
| 717 | } |
| 718 | hashtb_end(ef); |
| 719 | } |
| 720 | else if (res == HT_NEW_ENTRY) |
| 721 | { |
| 722 | hashtb_delete(e); |
| 723 | } |
| 724 | |
| 725 | hashtb_end(e); |
| 726 | } |
| 727 | |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 728 | |
| 729 | void |
| 730 | clean_old_fib_entries_from_npt(void) |
| 731 | { |
| 732 | |
| 733 | |
| 734 | if ( nlsr->debugging ) |
| 735 | printf("clean_old_fib_entries_from_npt called\n\n"); |
| 736 | if ( nlsr->detailed_logging ) |
| 737 | writeLogg(__FILE__,__FUNCTION__,__LINE__,"clean_old_fib_entries_from_npt called\n\n"); |
| 738 | int i, npt_element; |
| 739 | |
| 740 | struct npt_entry *ne; |
| 741 | |
| 742 | struct hashtb_enumerator ee; |
| 743 | struct hashtb_enumerator *e = ⅇ |
| 744 | |
| 745 | hashtb_start(nlsr->npt, e); |
| 746 | npt_element=hashtb_n(nlsr->npt); |
| 747 | |
| 748 | for(i=0;i<npt_element;i++) |
| 749 | { |
| 750 | ne=e->data; |
| 751 | |
| 752 | int j,k, nl_element,face_list_element; |
| 753 | struct face_list_entry *fle; |
| 754 | |
| 755 | struct hashtb_enumerator eef; |
| 756 | struct hashtb_enumerator *ef = &eef; |
| 757 | |
| 758 | hashtb_start(ne->face_list, ef); |
| 759 | face_list_element=hashtb_n(ne->face_list); |
| 760 | if ( face_list_element <= 0 ) |
| 761 | { |
| 762 | if ( nlsr->debugging ) |
akmhoque | e49af7a | 2013-01-22 14:58:37 -0600 | [diff] [blame] | 763 | printf(" Face: No Face \n"); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 764 | if ( nlsr->detailed_logging ) |
| 765 | writeLogg(__FILE__,__FUNCTION__,__LINE__," Face: No Face \n"); |
| 766 | |
| 767 | } |
| 768 | else |
| 769 | { |
| 770 | for(j=0;j<face_list_element;j++) |
| 771 | { |
| 772 | fle=ef->data; |
| 773 | int check=does_face_exist_for_router(ne->orig_router,fle->next_hop_face); |
| 774 | if ( check == 0 ) |
| 775 | { |
| 776 | struct name_list_entry *nle; |
| 777 | struct hashtb_enumerator eenle; |
| 778 | struct hashtb_enumerator *enle = &eenle; |
| 779 | |
| 780 | hashtb_start(ne->name_list, enle); |
| 781 | nl_element=hashtb_n(ne->name_list); |
| 782 | |
| 783 | for (k=0;k<nl_element;k++) |
| 784 | { |
| 785 | nle=enle->data; |
akmhoque | f9b35b3 | 2013-01-24 10:25:48 -0600 | [diff] [blame] | 786 | if( is_neighbor(nle->name) == 0 ) |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 787 | { |
| 788 | if ( nlsr->debugging ) |
| 789 | printf("Deleting face: Name:%s Face: %d\n",nle->name,fle->next_hop_face); |
| 790 | if ( nlsr->detailed_logging ) |
akmhoque | f9b35b3 | 2013-01-24 10:25:48 -0600 | [diff] [blame] | 791 | writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,fle->next_hop_face); |
| 792 | add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, fle->next_hop_face); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 793 | } |
| 794 | |
| 795 | |
| 796 | hashtb_next(enle); |
| 797 | } |
| 798 | hashtb_end(enle); |
| 799 | |
akmhoque | f9b35b3 | 2013-01-24 10:25:48 -0600 | [diff] [blame] | 800 | |
akmhoque | aaa1055 | 2013-01-24 08:00:42 -0600 | [diff] [blame] | 801 | hashtb_delete(ef); |
| 802 | j++; |
| 803 | |
| 804 | } |
| 805 | else |
| 806 | { |
akmhoque | aadd5ee | 2013-01-24 10:47:35 -0600 | [diff] [blame] | 807 | struct name_list_entry *nle; |
| 808 | struct hashtb_enumerator eenle; |
| 809 | struct hashtb_enumerator *enle = &eenle; |
| 810 | |
| 811 | hashtb_start(ne->name_list, enle); |
| 812 | nl_element=hashtb_n(ne->name_list); |
| 813 | |
| 814 | for (k=0;k<nl_element;k++) |
| 815 | { |
| 816 | nle=enle->data; |
| 817 | if( is_active_neighbor(ne->orig_router) && get_next_hop_face_from_adl( ne->orig_router ) != fle->next_hop_face ) |
| 818 | { |
| 819 | if ( nlsr->debugging ) |
| 820 | printf("Deleting face: Name:%s Face: %d\n",nle->name,fle->next_hop_face); |
| 821 | if ( nlsr->detailed_logging ) |
| 822 | writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,fle->next_hop_face); |
| 823 | add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, fle->next_hop_face); |
| 824 | } |
| 825 | |
| 826 | |
| 827 | hashtb_next(enle); |
| 828 | } |
| 829 | hashtb_end(enle); |
| 830 | |
akmhoque | aaa1055 | 2013-01-24 08:00:42 -0600 | [diff] [blame] | 831 | hashtb_next(ef); |
| 832 | } |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 833 | } |
| 834 | } |
| 835 | hashtb_end(ef); |
| 836 | |
| 837 | |
| 838 | hashtb_next(e); |
| 839 | } |
| 840 | |
| 841 | hashtb_end(e); |
| 842 | |
| 843 | } |
| 844 | |
| 845 | void |
| 846 | update_npt_with_new_route(void) |
| 847 | { |
akmhoque | 580ccf3 | 2013-01-23 09:12:33 -0600 | [diff] [blame] | 848 | if ( nlsr->debugging ) |
| 849 | printf("update_npt_with_new_route called\n"); |
| 850 | |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 851 | clean_old_fib_entries_from_npt(); |
akmhoque | aaa1055 | 2013-01-24 08:00:42 -0600 | [diff] [blame] | 852 | print_npt(); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 853 | add_new_fib_entries_to_npt(); |
akmhoque | aaa1055 | 2013-01-24 08:00:42 -0600 | [diff] [blame] | 854 | print_npt(); |
| 855 | |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 856 | int i, npt_element; |
| 857 | |
| 858 | struct npt_entry *ne; |
| 859 | |
| 860 | struct hashtb_enumerator ee; |
| 861 | struct hashtb_enumerator *e = ⅇ |
| 862 | |
| 863 | hashtb_start(nlsr->npt, e); |
| 864 | npt_element=hashtb_n(nlsr->npt); |
| 865 | |
| 866 | for(i=0;i<npt_element;i++) |
| 867 | { |
| 868 | |
| 869 | ne=e->data; |
akmhoque | 613446f | 2013-01-23 10:40:12 -0600 | [diff] [blame] | 870 | update_ccnd_fib_for_orig_router(ne->orig_router); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 871 | hashtb_next(e); |
| 872 | } |
| 873 | |
| 874 | hashtb_end(e); |
| 875 | } |
| 876 | |
| 877 | |
| 878 | |
| 879 | void |
| 880 | sort_faces_by_distance(int *faces,int *route_costs,int start,int element) |
| 881 | { |
| 882 | int i,j; |
| 883 | int temp_cost; |
| 884 | int temp_face; |
| 885 | |
| 886 | for ( i=start ; i < element ; i ++) |
| 887 | { |
| 888 | for( j=i+1; j<element; j ++) |
| 889 | { |
| 890 | if (route_costs[j] < route_costs[i] ) |
| 891 | { |
| 892 | temp_cost=route_costs[j]; |
| 893 | route_costs[j]=route_costs[i]; |
| 894 | route_costs[i]=temp_cost; |
| 895 | |
| 896 | temp_face=faces[j]; |
| 897 | faces[j]=faces[i]; |
| 898 | faces[i]=temp_face; |
| 899 | } |
| 900 | } |
| 901 | } |
| 902 | |
| 903 | } |
| 904 | |
| 905 | void |
| 906 | get_all_faces_for_orig_router_from_npt(char *orig_router, int *faces, int *route_costs, int num_faces) |
| 907 | { |
| 908 | |
| 909 | int res,face_list_element,j; |
| 910 | struct hashtb_enumerator ee; |
| 911 | struct hashtb_enumerator *e = ⅇ |
| 912 | |
| 913 | |
| 914 | hashtb_start(nlsr->npt, e); |
| 915 | res = hashtb_seek(e, orig_router, strlen(orig_router), 0); |
| 916 | |
| 917 | if(res == HT_NEW_ENTRY) |
| 918 | { |
| 919 | hashtb_delete(e); |
| 920 | } |
| 921 | else if ( res == HT_OLD_ENTRY ) |
| 922 | { |
| 923 | struct npt_entry *ne; |
| 924 | ne=e->data; |
| 925 | |
| 926 | struct face_list_entry *fle; |
| 927 | |
| 928 | struct hashtb_enumerator eef; |
| 929 | struct hashtb_enumerator *ef = &eef; |
| 930 | |
| 931 | hashtb_start(ne->face_list, ef); |
| 932 | face_list_element=hashtb_n(ne->face_list); |
| 933 | for(j=0;j<face_list_element;j++) |
| 934 | { |
| 935 | fle=ef->data; |
| 936 | faces[j]=fle->next_hop_face; |
| 937 | route_costs[j]=fle->route_cost; |
| 938 | hashtb_next(ef); |
| 939 | } |
| 940 | hashtb_end(ef); |
| 941 | |
| 942 | |
| 943 | } |
| 944 | hashtb_end(e); |
| 945 | |
| 946 | } |
| 947 | |
| 948 | void |
| 949 | destroy_faces_by_orig_router(char *orig_router) |
| 950 | { |
| 951 | |
| 952 | int res; |
| 953 | struct hashtb_enumerator ee; |
| 954 | struct hashtb_enumerator *e = ⅇ |
| 955 | |
| 956 | |
| 957 | hashtb_start(nlsr->npt, e); |
| 958 | res = hashtb_seek(e, orig_router, strlen(orig_router), 0); |
| 959 | |
| 960 | if(res == HT_NEW_ENTRY) |
| 961 | { |
| 962 | hashtb_delete(e); |
| 963 | } |
| 964 | else if ( res == HT_OLD_ENTRY ) |
| 965 | { |
| 966 | struct npt_entry *ne; |
| 967 | ne=e->data; |
| 968 | int num_face=hashtb_n(ne->face_list); |
| 969 | int last_face,first_face; |
| 970 | |
| 971 | int *faces=(int *)malloc(num_face*sizeof(int)); |
| 972 | int *route_costs=(int *)malloc(num_face*sizeof(int)); |
| 973 | |
| 974 | get_all_faces_for_orig_router_from_npt(orig_router,faces,route_costs,num_face); |
| 975 | sort_faces_by_distance(faces,route_costs,0,num_face); |
| 976 | |
| 977 | |
| 978 | first_face=num_face-1; |
| 979 | |
| 980 | if ( nlsr->multi_path_face_num == 0 ) |
| 981 | { |
| 982 | last_face=first_face; |
| 983 | } |
| 984 | else |
| 985 | { |
| 986 | if ( num_face <= nlsr->multi_path_face_num) |
| 987 | { |
| 988 | last_face=0; |
| 989 | } |
| 990 | else if ( nlsr->multi_path_face_num == 0) |
| 991 | { |
| 992 | last_face=num_face-nlsr->multi_path_face_num; |
| 993 | } |
| 994 | } |
| 995 | |
| 996 | int i,j, nl_element; |
| 997 | struct name_list_entry *nle; |
| 998 | struct hashtb_enumerator eenle; |
| 999 | struct hashtb_enumerator *enle = &eenle; |
| 1000 | |
| 1001 | hashtb_start(ne->name_list, enle); |
| 1002 | nl_element=hashtb_n(ne->name_list); |
| 1003 | |
| 1004 | for (i=0;i<nl_element;i++) |
| 1005 | { |
| 1006 | nle=enle->data; |
| 1007 | |
| 1008 | for( j=first_face; j>= last_face; j--) |
| 1009 | { |
akmhoque | 9ca1bb8 | 2013-01-24 09:57:57 -0600 | [diff] [blame] | 1010 | if ( is_active_neighbor(orig_router) == 0 ) |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 1011 | { |
| 1012 | if ( nlsr->debugging ) |
| 1013 | printf("Deleting face: Name:%s Face: %d\n",nle->name,faces[j]); |
| 1014 | if ( nlsr->detailed_logging ) |
| 1015 | writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,faces[j]); |
akmhoque | f9b35b3 | 2013-01-24 10:25:48 -0600 | [diff] [blame] | 1016 | add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, faces[j]); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 1017 | } |
| 1018 | else |
| 1019 | { |
akmhoque | 9ca1bb8 | 2013-01-24 09:57:57 -0600 | [diff] [blame] | 1020 | if ( j == last_face && is_active_neighbor(nle->name)==0) |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 1021 | { |
| 1022 | if ( nlsr->debugging ) |
| 1023 | printf("Deleting face: Name:%s Face: %d\n",nle->name,faces[j]); |
| 1024 | if ( nlsr->detailed_logging ) |
| 1025 | writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,faces[j]); |
akmhoque | f9b35b3 | 2013-01-24 10:25:48 -0600 | [diff] [blame] | 1026 | add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, faces[j]); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 1027 | } |
| 1028 | } |
| 1029 | } |
| 1030 | |
| 1031 | hashtb_next(enle); |
| 1032 | } |
| 1033 | hashtb_end(enle); |
| 1034 | |
| 1035 | |
| 1036 | |
| 1037 | free(faces); |
| 1038 | free(route_costs); |
| 1039 | |
| 1040 | } |
| 1041 | hashtb_end(e); |
| 1042 | |
| 1043 | } |
| 1044 | |
| 1045 | void |
| 1046 | destroy_all_face_by_nlsr(void) |
| 1047 | { |
| 1048 | int i, npt_element; |
| 1049 | |
| 1050 | struct npt_entry *ne; |
| 1051 | |
| 1052 | struct hashtb_enumerator ee; |
| 1053 | struct hashtb_enumerator *e = ⅇ |
| 1054 | |
| 1055 | hashtb_start(nlsr->npt, e); |
| 1056 | npt_element=hashtb_n(nlsr->npt); |
| 1057 | |
| 1058 | for(i=0;i<npt_element;i++) |
| 1059 | { |
| 1060 | ne=e->data; |
| 1061 | destroy_faces_by_orig_router(ne->orig_router); |
| 1062 | hashtb_next(e); |
| 1063 | } |
| 1064 | |
| 1065 | hashtb_end(e); |
| 1066 | |
| 1067 | if ( nlsr->debugging ) |
| 1068 | printf("\n"); |
| 1069 | if ( nlsr->detailed_logging ) |
| 1070 | writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n"); |
| 1071 | } |