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