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 <sys/stat.h> |
| 8 | #include <assert.h> |
| 9 | #include <sys/types.h> |
| 10 | #include <signal.h> |
| 11 | #include <sys/socket.h> |
| 12 | #include <sys/un.h> |
| 13 | #include <fcntl.h> |
| 14 | #include <sys/ioctl.h> |
| 15 | #include <netinet/in.h> |
| 16 | #include <netdb.h> |
| 17 | #include <arpa/inet.h> |
| 18 | |
| 19 | #include <ccn/ccn.h> |
| 20 | #include <ccn/uri.h> |
| 21 | #include <ccn/keystore.h> |
| 22 | #include <ccn/signing.h> |
| 23 | #include <ccn/schedule.h> |
| 24 | #include <ccn/hashtb.h> |
| 25 | #include <ccn/sync.h> |
| 26 | #include <ccn/seqwriter.h> |
| 27 | |
| 28 | #include "nlsr.h" |
| 29 | #include "nlsr_sync.h" |
| 30 | #include "nlsr_lsdb.h" |
akmhoque | 4ae1694 | 2012-12-10 11:50:43 -0600 | [diff] [blame] | 31 | #include "utility.h" |
akmhoque | 3b6c66d | 2013-01-31 15:30:23 -0600 | [diff] [blame] | 32 | |
| 33 | |
Syed Obaid Amin | 3a3864b | 2013-01-09 03:05:50 -0600 | [diff] [blame] | 34 | char * |
| 35 | hex_string(unsigned char *s, size_t l) |
| 36 | { |
| 37 | const char *hex_digits = "0123456789abcdef"; |
| 38 | char *r; |
| 39 | int i; |
| 40 | r = calloc(1, 1 + 2 * l); |
| 41 | for (i = 0; i < l; i++) { |
| 42 | r[2*i] = hex_digits[(s[i]>>4) & 0xf]; |
| 43 | r[1+2*i] = hex_digits[s[i] & 0xf]; |
| 44 | } |
| 45 | return(r); |
| 46 | } |
| 47 | |
| 48 | int |
| 49 | sync_cb(struct ccns_name_closure *nc, |
| 50 | struct ccn_charbuf *lhash, |
| 51 | struct ccn_charbuf *rhash, |
| 52 | struct ccn_charbuf *name) |
| 53 | { |
| 54 | char *hexL; |
| 55 | char *hexR; |
akmhoque | 6c2f60a | 2013-01-31 17:29:11 -0600 | [diff] [blame] | 56 | int res; |
Syed Obaid Amin | 3a3864b | 2013-01-09 03:05:50 -0600 | [diff] [blame] | 57 | struct ccn_charbuf *uri = ccn_charbuf_create(); |
| 58 | if (lhash == NULL || lhash->length == 0) { |
| 59 | hexL = strdup("none"); |
| 60 | } else |
| 61 | hexL = hex_string(lhash->buf, lhash->length); |
| 62 | if (rhash == NULL || rhash->length == 0) { |
| 63 | hexR = strdup("none"); |
| 64 | } else |
| 65 | hexR = hex_string(rhash->buf, rhash->length); |
| 66 | if (name != NULL) |
| 67 | ccn_uri_append(uri, name->buf, name->length, 1); |
| 68 | else |
| 69 | ccn_charbuf_append_string(uri, "(null)"); |
a64adam | 04be648 | 2013-01-17 11:29:32 -0600 | [diff] [blame] | 70 | |
akmhoque | 3b6c66d | 2013-01-31 15:30:23 -0600 | [diff] [blame] | 71 | |
a64adam | 04be648 | 2013-01-17 11:29:32 -0600 | [diff] [blame] | 72 | if ( nlsr->debugging ) |
akmhoque | fc5176d | 2013-01-18 09:50:12 -0600 | [diff] [blame] | 73 | printf("Response from sync in the name: %s \n",ccn_charbuf_as_string(uri)); |
| 74 | |
Syed Obaid Amin | 3a3864b | 2013-01-09 03:05:50 -0600 | [diff] [blame] | 75 | fflush(stdout); |
| 76 | free(hexL); |
| 77 | free(hexR); |
akmhoque | 3c0c95d | 2013-01-31 16:46:24 -0600 | [diff] [blame] | 78 | ccn_charbuf_destroy(&uri); |
akmhoque | d6cd61d | 2013-01-17 10:31:15 -0600 | [diff] [blame] | 79 | |
| 80 | |
akmhoque | 3b6c66d | 2013-01-31 15:30:23 -0600 | [diff] [blame] | 81 | //--Doing our thing from here |
akmhoque | 6c2f60a | 2013-01-31 17:29:11 -0600 | [diff] [blame] | 82 | struct ccn_indexbuf cid={0}; |
Syed Obaid Amin | 3a3864b | 2013-01-09 03:05:50 -0600 | [diff] [blame] | 83 | |
| 84 | struct ccn_indexbuf *components=&cid; |
akmhoque | 566517f | 2013-01-31 17:44:28 -0600 | [diff] [blame] | 85 | ccn_name_split (name, components); |
akmhoque | 6c2f60a | 2013-01-31 17:29:11 -0600 | [diff] [blame] | 86 | //ccn_name_chop(name,components,-3); |
| 87 | //process_content_from_sync(name,components); |
Syed Obaid Amin | 3a3864b | 2013-01-09 03:05:50 -0600 | [diff] [blame] | 88 | |
akmhoque | acef1e6 | 2013-01-31 17:15:08 -0600 | [diff] [blame] | 89 | struct ccn_charbuf *content_name = ccn_charbuf_create(); |
akmhoque | 566517f | 2013-01-31 17:44:28 -0600 | [diff] [blame] | 90 | ccn_name_init(content_name); |
| 91 | res = ccn_name_append_components(content_name, name->buf, components->buf[0], components->buf[components->n - 1]); |
| 92 | |
| 93 | struct ccn_indexbuf cid1={0}; |
| 94 | struct ccn_indexbuf *components1=&cid1; |
| 95 | res=ccn_name_split (content_name, components1); |
akmhoque | aaad970 | 2013-01-31 18:12:36 -0600 | [diff] [blame^] | 96 | if ( nlsr->debugging ) |
| 97 | printf("Number of components in name = %d \n",res); |
akmhoque | 1458b1d | 2013-01-31 17:48:32 -0600 | [diff] [blame] | 98 | ccn_name_chop(content_name,components1,-3); |
| 99 | process_content_from_sync(content_name,components1); |
akmhoque | acef1e6 | 2013-01-31 17:15:08 -0600 | [diff] [blame] | 100 | ccn_charbuf_destroy(&content_name); |
Syed Obaid Amin | 3a3864b | 2013-01-09 03:05:50 -0600 | [diff] [blame] | 101 | |
| 102 | return(0); |
| 103 | } |
akmhoque | 3b6c66d | 2013-01-31 15:30:23 -0600 | [diff] [blame] | 104 | |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 105 | |
| 106 | int |
| 107 | get_lsa_position(struct ccn_charbuf * ccnb, struct ccn_indexbuf *comps) |
| 108 | { |
| 109 | |
| 110 | |
| 111 | |
| 112 | int res,i; |
akmhoque | 3b6c66d | 2013-01-31 15:30:23 -0600 | [diff] [blame] | 113 | int lsa_position=0; |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 114 | int name_comps=(int)comps->n; |
| 115 | |
| 116 | for(i=0;i<name_comps;i++) |
| 117 | { |
| 118 | res=ccn_name_comp_strcmp(ccnb->buf,comps,i,"LSA"); |
| 119 | if( res == 0) |
| 120 | { |
| 121 | lsa_position=i; |
| 122 | break; |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | return lsa_position; |
| 127 | |
| 128 | } |
| 129 | |
| 130 | void |
| 131 | get_name_part(struct name_prefix *name_part,struct ccn_charbuf * interest_ccnb, struct ccn_indexbuf *interest_comps, int offset) |
| 132 | { |
| 133 | |
| 134 | |
| 135 | |
| 136 | int res,i; |
| 137 | int lsa_position=0; |
| 138 | int len=0; |
| 139 | |
akmhoque | 2ee1803 | 2013-01-22 10:01:23 -0600 | [diff] [blame] | 140 | |
| 141 | struct ccn_indexbuf cid={0}; |
| 142 | struct ccn_indexbuf *components=&cid; |
| 143 | struct ccn_charbuf *name=ccn_charbuf_create(); |
| 144 | ccn_name_from_uri(name,nlsr->slice_prefix); |
| 145 | ccn_name_split (name, components); |
| 146 | lsa_position=components->n-2; |
akmhoque | 3b6c66d | 2013-01-31 15:30:23 -0600 | [diff] [blame] | 147 | |
akmhoque | 2ee1803 | 2013-01-22 10:01:23 -0600 | [diff] [blame] | 148 | ccn_charbuf_destroy(&name); |
| 149 | |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 150 | |
| 151 | const unsigned char *comp_ptr1; |
| 152 | size_t comp_size; |
| 153 | for(i=lsa_position+1+offset;i<interest_comps->n-1;i++) |
| 154 | { |
| 155 | res=ccn_name_comp_get(interest_ccnb->buf, interest_comps,i,&comp_ptr1, &comp_size); |
| 156 | len+=1; |
| 157 | len+=(int)comp_size; |
| 158 | } |
| 159 | len++; |
| 160 | |
| 161 | char *neighbor=(char *)malloc(len); |
| 162 | memset(neighbor,0,len); |
| 163 | |
| 164 | for(i=lsa_position+1+offset; i<interest_comps->n-1;i++) |
| 165 | { |
| 166 | res=ccn_name_comp_get(interest_ccnb->buf, interest_comps,i,&comp_ptr1, &comp_size); |
| 167 | memcpy(neighbor+strlen(neighbor),"/",1); |
| 168 | memcpy(neighbor+strlen(neighbor),(char *)comp_ptr1,strlen((char *)comp_ptr1)); |
| 169 | |
| 170 | } |
| 171 | |
| 172 | name_part->name=(char *)malloc(strlen(neighbor)+1); |
| 173 | memset(name_part->name,0,strlen(neighbor)+1); |
| 174 | memcpy(name_part->name,neighbor,strlen(neighbor)+1); |
| 175 | name_part->length=strlen(neighbor)+1; |
| 176 | |
akmhoque | 3b6c66d | 2013-01-31 15:30:23 -0600 | [diff] [blame] | 177 | // Add 01/31/2013 |
| 178 | free(neighbor); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 179 | } |
| 180 | |
akmhoque | 09c0afa | 2012-12-14 09:27:00 -0600 | [diff] [blame] | 181 | void |
| 182 | get_host_name_from_command_string(struct name_prefix *name_part,char *nbr_name_uri, int offset) |
| 183 | { |
| 184 | |
| 185 | |
| 186 | |
| 187 | int res,i; |
| 188 | int len=0; |
| 189 | const unsigned char *comp_ptr1; |
| 190 | size_t comp_size; |
| 191 | |
| 192 | struct ccn_charbuf *name=ccn_charbuf_create(); |
| 193 | name = ccn_charbuf_create(); |
| 194 | res = ccn_name_from_uri(name,nbr_name_uri); |
| 195 | if (res < 0) { |
| 196 | fprintf(stderr, "Bad ccn URI: %s\n", nbr_name_uri); |
| 197 | exit(1); |
| 198 | } |
| 199 | |
| 200 | struct ccn_indexbuf cid={0}; |
| 201 | |
| 202 | struct ccn_indexbuf *components=&cid; |
| 203 | ccn_name_split (name, components); |
| 204 | |
| 205 | for(i=components->n-2;i> (0+offset);i--) |
| 206 | { |
| 207 | res=ccn_name_comp_get(name->buf, components,i,&comp_ptr1, &comp_size); |
| 208 | len+=1; |
| 209 | len+=(int)comp_size; |
| 210 | } |
| 211 | len++; |
| 212 | |
| 213 | char *neighbor=(char *)malloc(len); |
| 214 | memset(neighbor,0,len); |
| 215 | |
| 216 | for(i=components->n-2;i> (0+offset);i--) |
| 217 | { |
| 218 | res=ccn_name_comp_get(name->buf, components,i,&comp_ptr1, &comp_size); |
| 219 | if ( i != components->n-2) |
| 220 | memcpy(neighbor+strlen(neighbor),".",1); |
| 221 | memcpy(neighbor+strlen(neighbor),(char *)comp_ptr1,strlen((char *)comp_ptr1)); |
| 222 | |
| 223 | } |
| 224 | |
| 225 | name_part->name=(char *)malloc(strlen(neighbor)+1); |
| 226 | memset(name_part->name,0,strlen(neighbor)+1); |
| 227 | memcpy(name_part->name,neighbor,strlen(neighbor)+1); |
| 228 | name_part->length=strlen(neighbor)+1; |
| 229 | |
akmhoque | 3b6c66d | 2013-01-31 15:30:23 -0600 | [diff] [blame] | 230 | // 01/31/2013 |
| 231 | free(neighbor); |
| 232 | ccn_charbuf_destroy(&name); |
akmhoque | 09c0afa | 2012-12-14 09:27:00 -0600 | [diff] [blame] | 233 | } |
| 234 | |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 235 | |
akmhoque | ed418f3 | 2013-01-30 12:25:04 -0600 | [diff] [blame] | 236 | |
soamin | 1504362 | 2013-01-15 23:10:26 -0600 | [diff] [blame] | 237 | void |
Obaid Amin | e63022a | 2013-01-15 23:36:40 -0600 | [diff] [blame] | 238 | get_content_by_content_name(char *content_name, unsigned char **content_data) |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 239 | { |
| 240 | |
soamin | 1504362 | 2013-01-15 23:10:26 -0600 | [diff] [blame] | 241 | struct ccn_charbuf *name = NULL; |
| 242 | struct ccn_charbuf *templ = NULL; |
| 243 | struct ccn_charbuf *resultbuf = NULL; |
| 244 | struct ccn_parsed_ContentObject pcobuf = { 0 }; |
| 245 | int res; |
| 246 | int allow_stale = 0; |
| 247 | int content_only = 1; |
| 248 | int scope = -1; |
| 249 | const unsigned char *ptr; |
| 250 | size_t length; |
| 251 | int resolve_version = CCN_V_HIGHEST; |
| 252 | int timeout_ms = 3000; |
| 253 | const unsigned lifetime_default = CCN_INTEREST_LIFETIME_SEC << 12; |
| 254 | unsigned lifetime_l12 = lifetime_default; |
| 255 | int get_flags = 0; |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 256 | |
soamin | 1504362 | 2013-01-15 23:10:26 -0600 | [diff] [blame] | 257 | name = ccn_charbuf_create(); |
| 258 | res = ccn_name_from_uri(name,content_name); |
| 259 | if (res < 0) { |
| 260 | fprintf(stderr, "Bad ccn URI: %s\n", content_name); |
| 261 | exit(1); |
| 262 | } |
| 263 | |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 264 | if (allow_stale || lifetime_l12 != lifetime_default || scope != -1) { |
soamin | 1504362 | 2013-01-15 23:10:26 -0600 | [diff] [blame] | 265 | templ = ccn_charbuf_create(); |
| 266 | ccn_charbuf_append_tt(templ, CCN_DTAG_Interest, CCN_DTAG); |
| 267 | ccn_charbuf_append_tt(templ, CCN_DTAG_Name, CCN_DTAG); |
| 268 | ccn_charbuf_append_closer(templ); /* </Name> */ |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 269 | if (allow_stale) { |
| 270 | ccn_charbuf_append_tt(templ, CCN_DTAG_AnswerOriginKind, CCN_DTAG); |
| 271 | ccnb_append_number(templ, |
soamin | 1504362 | 2013-01-15 23:10:26 -0600 | [diff] [blame] | 272 | CCN_AOK_DEFAULT | CCN_AOK_STALE); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 273 | ccn_charbuf_append_closer(templ); /* </AnswerOriginKind> */ |
| 274 | } |
soamin | 1504362 | 2013-01-15 23:10:26 -0600 | [diff] [blame] | 275 | if (scope != -1) { |
| 276 | ccnb_tagged_putf(templ, CCN_DTAG_Scope, "%d", scope); |
| 277 | } |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 278 | if (lifetime_l12 != lifetime_default) { |
| 279 | /* |
| 280 | * Choose the interest lifetime so there are at least 3 |
| 281 | * expressions (in the unsatisfied case). |
| 282 | */ |
| 283 | unsigned char buf[3] = { 0 }; |
| 284 | int i; |
| 285 | for (i = sizeof(buf) - 1; i >= 0; i--, lifetime_l12 >>= 8) |
| 286 | buf[i] = lifetime_l12 & 0xff; |
| 287 | ccnb_append_tagged_blob(templ, CCN_DTAG_InterestLifetime, buf, sizeof(buf)); |
| 288 | } |
soamin | 1504362 | 2013-01-15 23:10:26 -0600 | [diff] [blame] | 289 | ccn_charbuf_append_closer(templ); /* </Interest> */ |
| 290 | } |
| 291 | resultbuf = ccn_charbuf_create(); |
| 292 | if (resolve_version != 0) { |
| 293 | res = ccn_resolve_version(nlsr->ccn, name, resolve_version, 500); |
| 294 | if (res >= 0) { |
| 295 | ccn_uri_append(resultbuf, name->buf, name->length, 1); |
soamin | 1504362 | 2013-01-15 23:10:26 -0600 | [diff] [blame] | 296 | resultbuf->length = 0; |
| 297 | } |
| 298 | } |
| 299 | res = ccn_get(nlsr->ccn, name, templ, timeout_ms, resultbuf, &pcobuf, NULL, get_flags); |
| 300 | if (res >= 0) { |
| 301 | ptr = resultbuf->buf; |
| 302 | length = resultbuf->length; |
| 303 | if (content_only){ |
| 304 | ccn_content_get_value(ptr, length, &pcobuf, &ptr, &length); |
Obaid Amin | e63022a | 2013-01-15 23:36:40 -0600 | [diff] [blame] | 305 | *content_data = (unsigned char *) calloc(length, sizeof(char *)); |
| 306 | memcpy (*content_data, ptr, length); |
soamin | 1504362 | 2013-01-15 23:10:26 -0600 | [diff] [blame] | 307 | } |
| 308 | } |
| 309 | ccn_charbuf_destroy(&resultbuf); |
| 310 | ccn_charbuf_destroy(&templ); |
| 311 | ccn_charbuf_destroy(&name); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 312 | } |
| 313 | |
akmhoque | 4ae1694 | 2012-12-10 11:50:43 -0600 | [diff] [blame] | 314 | void |
soamin | 1504362 | 2013-01-15 23:10:26 -0600 | [diff] [blame] | 315 | process_incoming_sync_content_lsa( unsigned char *content_data) |
akmhoque | 4ae1694 | 2012-12-10 11:50:43 -0600 | [diff] [blame] | 316 | { |
| 317 | |
| 318 | |
| 319 | if ( nlsr->debugging ) |
akmhoque | ed418f3 | 2013-01-30 12:25:04 -0600 | [diff] [blame] | 320 | printf("process_incoming_sync_content_lsa called \n"); |
akmhoque | 4ae1694 | 2012-12-10 11:50:43 -0600 | [diff] [blame] | 321 | |
| 322 | char *sep="|"; |
| 323 | char *rem; |
| 324 | char *orig_router; |
| 325 | char *orl; |
| 326 | int orig_router_length; |
| 327 | char *lst; |
| 328 | int ls_type; |
| 329 | char *lsid; |
| 330 | long int ls_id; |
| 331 | char *isvld; |
| 332 | int isValid; |
| 333 | char *num_link; |
| 334 | int no_link; |
| 335 | char *np; |
| 336 | char *np_length; |
| 337 | int name_length; |
| 338 | char *data; |
| 339 | char *orig_time; |
| 340 | |
| 341 | |
| 342 | if ( nlsr->debugging ) |
| 343 | printf("LSA Data \n"); |
akmhoque | 4ae1694 | 2012-12-10 11:50:43 -0600 | [diff] [blame] | 344 | |
soamin | 1504362 | 2013-01-15 23:10:26 -0600 | [diff] [blame] | 345 | if( strlen((char *)content_data ) > 0 ) |
akmhoque | 4ae1694 | 2012-12-10 11:50:43 -0600 | [diff] [blame] | 346 | { |
| 347 | |
| 348 | orig_router=strtok_r((char *)content_data,sep,&rem); |
| 349 | orl=strtok_r(NULL,sep,&rem); |
| 350 | orig_router_length=atoi(orl); |
| 351 | |
| 352 | if ( nlsr->debugging ) |
| 353 | { |
| 354 | printf(" Orig Router Name : %s\n",orig_router); |
| 355 | printf(" Orig Router Length: %d\n",orig_router_length); |
| 356 | } |
| 357 | |
| 358 | lst=strtok_r(NULL,sep,&rem); |
| 359 | ls_type=atoi(lst); |
| 360 | |
| 361 | if ( nlsr->debugging ) |
| 362 | printf(" LS Type : %d\n",ls_type); |
| 363 | |
| 364 | if ( ls_type == LS_TYPE_NAME ) |
| 365 | { |
| 366 | lsid=strtok_r(NULL,sep,&rem); |
| 367 | ls_id=atoi(lsid); |
| 368 | orig_time=strtok_r(NULL,sep,&rem); |
| 369 | isvld=strtok_r(NULL,sep,&rem); |
| 370 | isValid=atoi(isvld); |
| 371 | np=strtok_r(NULL,sep,&rem); |
| 372 | np_length=strtok_r(NULL,sep,&rem); |
| 373 | name_length=atoi(np_length); |
| 374 | if ( nlsr->debugging ) |
| 375 | { |
| 376 | printf(" LS ID : %ld\n",ls_id); |
| 377 | printf(" isValid : %d\n",isValid); |
| 378 | printf(" Name Prefix : %s\n",np); |
| 379 | printf(" Orig Time : %s\n",orig_time); |
| 380 | printf(" Name Prefix length: %d\n",name_length); |
| 381 | } |
| 382 | |
| 383 | build_and_install_others_name_lsa(orig_router,ls_type,ls_id,orig_time,isValid,np); |
| 384 | |
| 385 | print_name_lsdb(); |
| 386 | |
| 387 | } |
| 388 | else if ( ls_type == LS_TYPE_ADJ ) |
| 389 | { |
| 390 | orig_time=strtok_r(NULL,sep,&rem); |
| 391 | num_link=strtok_r(NULL,sep,&rem); |
| 392 | no_link=atoi(num_link); |
| 393 | data=rem; |
| 394 | |
| 395 | if ( nlsr->debugging ) |
| 396 | { |
akmhoque | ed418f3 | 2013-01-30 12:25:04 -0600 | [diff] [blame] | 397 | printf(" Orig Time : %s\n",orig_time); |
akmhoque | 4ae1694 | 2012-12-10 11:50:43 -0600 | [diff] [blame] | 398 | printf(" No Link : %d\n",no_link); |
| 399 | printf(" Data : %s\n",data); |
| 400 | } |
| 401 | build_and_install_others_adj_lsa(orig_router,ls_type,orig_time,no_link,data); |
| 402 | } |
akmhoque | ed418f3 | 2013-01-30 12:25:04 -0600 | [diff] [blame] | 403 | else if ( ls_type == LS_TYPE_COR ) |
| 404 | { |
| 405 | orig_time=strtok_r(NULL,sep,&rem); |
| 406 | char *cor_r=strtok_r(NULL,sep,&rem); |
| 407 | char *cor_theta=strtok_r(NULL,sep,&rem); |
| 408 | |
| 409 | double r, theta; |
| 410 | r=strtof(cor_r,NULL); |
| 411 | theta=strtof(cor_theta,NULL); |
| 412 | |
| 413 | if ( nlsr->debugging ) |
| 414 | { |
| 415 | printf(" Orig Time : %s\n",orig_time); |
| 416 | printf(" Cor R : %f\n",r); |
| 417 | printf(" Cor Theta : %f\n",theta); |
| 418 | } |
| 419 | build_and_install_others_cor_lsa(orig_router,ls_type,orig_time, (double)r, (double)theta); |
| 420 | } |
| 421 | |
akmhoque | 4ae1694 | 2012-12-10 11:50:43 -0600 | [diff] [blame] | 422 | } |
| 423 | } |
| 424 | |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 425 | void |
| 426 | process_content_from_sync(struct ccn_charbuf *content_name, struct ccn_indexbuf *components) |
| 427 | { |
| 428 | int lsa_position; |
| 429 | int res; |
| 430 | size_t comp_size; |
| 431 | const unsigned char *lst; |
| 432 | const unsigned char *lsid; |
| 433 | const unsigned char *origtime; |
| 434 | |
| 435 | int ls_type; |
| 436 | long int ls_id=0; |
| 437 | |
soamin | 1504362 | 2013-01-15 23:10:26 -0600 | [diff] [blame] | 438 | unsigned char *content_data = NULL; |
| 439 | |
akmhoque | 4ae1694 | 2012-12-10 11:50:43 -0600 | [diff] [blame] | 440 | char *time_stamp=(char *)malloc(20); |
| 441 | memset(time_stamp,0,20); |
| 442 | get_current_timestamp_micro(time_stamp); |
| 443 | |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 444 | struct ccn_charbuf *uri = ccn_charbuf_create(); |
| 445 | ccn_uri_append(uri, content_name->buf, content_name->length, 0); |
| 446 | |
| 447 | struct name_prefix *orig_router=(struct name_prefix *)malloc(sizeof(struct name_prefix)); |
| 448 | |
akmhoque | 2ee1803 | 2013-01-22 10:01:23 -0600 | [diff] [blame] | 449 | |
| 450 | struct ccn_indexbuf cid={0}; |
| 451 | struct ccn_indexbuf *temp_components=&cid; |
| 452 | struct ccn_charbuf *name=ccn_charbuf_create(); |
| 453 | ccn_name_from_uri(name,nlsr->slice_prefix); |
| 454 | ccn_name_split (name, temp_components); |
| 455 | lsa_position=temp_components->n-2; |
akmhoque | 2ee1803 | 2013-01-22 10:01:23 -0600 | [diff] [blame] | 456 | ccn_charbuf_destroy(&name); |
| 457 | |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 458 | |
| 459 | res=ccn_name_comp_get(content_name->buf, components,lsa_position+1,&lst, &comp_size); |
| 460 | |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 461 | ls_type=atoi((char *)lst); |
| 462 | if(ls_type == LS_TYPE_NAME) |
| 463 | { |
akmhoque | 4ae1694 | 2012-12-10 11:50:43 -0600 | [diff] [blame] | 464 | |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 465 | res=ccn_name_comp_get(content_name->buf, components,lsa_position+2,&lsid, &comp_size); |
| 466 | ls_id=atoi((char *)lsid); |
| 467 | res=ccn_name_comp_get(content_name->buf, components,lsa_position+3,&origtime, &comp_size); |
| 468 | get_name_part(orig_router,content_name,components,3); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 469 | |
akmhoque | 4ae1694 | 2012-12-10 11:50:43 -0600 | [diff] [blame] | 470 | int lsa_life_time=get_time_diff(time_stamp,(char *)origtime); |
| 471 | |
akmhoque | 4ae1694 | 2012-12-10 11:50:43 -0600 | [diff] [blame] | 472 | if ( (strcmp((char *)orig_router,nlsr->router_name) == 0 && lsa_life_time < nlsr->lsa_refresh_time) || (strcmp((char *)orig_router,nlsr->router_name) != 0 && lsa_life_time < nlsr->router_dead_interval) ) |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 473 | { |
akmhoque | 4ae1694 | 2012-12-10 11:50:43 -0600 | [diff] [blame] | 474 | int is_new_name_lsa=check_is_new_name_lsa(orig_router->name,(char *)lst,(char *)lsid,(char *)origtime); |
| 475 | if ( is_new_name_lsa == 1 ) |
| 476 | { |
a64adam | 04be648 | 2013-01-17 11:29:32 -0600 | [diff] [blame] | 477 | if ( nlsr->debugging ) |
| 478 | printf("New NAME LSA.....\n"); |
Obaid Amin | e63022a | 2013-01-15 23:36:40 -0600 | [diff] [blame] | 479 | get_content_by_content_name(ccn_charbuf_as_string(uri), &content_data); |
a64adam | f7b051d | 2013-01-17 11:39:58 -0600 | [diff] [blame] | 480 | if ( nlsr->debugging ) |
| 481 | printf("Content Data: %s \n",content_data); |
akmhoque | 4ae1694 | 2012-12-10 11:50:43 -0600 | [diff] [blame] | 482 | process_incoming_sync_content_lsa(content_data); |
| 483 | } |
| 484 | else |
| 485 | { |
a64adam | 04be648 | 2013-01-17 11:29:32 -0600 | [diff] [blame] | 486 | if ( nlsr->debugging ) |
| 487 | printf("Name LSA / Newer Name LSA already xists in LSDB\n"); |
Obaid Amin | e63022a | 2013-01-15 23:36:40 -0600 | [diff] [blame] | 488 | get_content_by_content_name(ccn_charbuf_as_string(uri), &content_data); |
a64adam | 04be648 | 2013-01-17 11:29:32 -0600 | [diff] [blame] | 489 | |
| 490 | if ( nlsr->debugging ) |
| 491 | printf("Content Data: %s \n",content_data); |
akmhoque | 4ae1694 | 2012-12-10 11:50:43 -0600 | [diff] [blame] | 492 | } |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 493 | } |
| 494 | else |
| 495 | { |
a64adam | 04be648 | 2013-01-17 11:29:32 -0600 | [diff] [blame] | 496 | if ( nlsr->debugging ) |
| 497 | printf("Lsa is older than Router LSA refresh time/ Dead Interval\n"); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 498 | } |
| 499 | } |
| 500 | else if(ls_type == LS_TYPE_ADJ) |
| 501 | { |
| 502 | res=ccn_name_comp_get(content_name->buf, components,lsa_position+2,&origtime, &comp_size); |
| 503 | get_name_part(orig_router,content_name,components,2); |
a64adam | 04be648 | 2013-01-17 11:29:32 -0600 | [diff] [blame] | 504 | |
| 505 | if ( nlsr->debugging ) |
| 506 | printf("Orig Time: %s\nOrig Router: %s\n",origtime,orig_router->name); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 507 | |
akmhoque | 4ae1694 | 2012-12-10 11:50:43 -0600 | [diff] [blame] | 508 | int lsa_life_time=get_time_diff(time_stamp,(char *)origtime); |
akmhoque | 4ae1694 | 2012-12-10 11:50:43 -0600 | [diff] [blame] | 509 | if ( (strcmp((char *)orig_router,nlsr->router_name) == 0 && lsa_life_time < nlsr->lsa_refresh_time) || (strcmp((char *)orig_router,nlsr->router_name) != 0 && lsa_life_time < nlsr->router_dead_interval) ) |
| 510 | { |
| 511 | int is_new_adj_lsa=check_is_new_adj_lsa(orig_router->name,(char *)lst,(char *)origtime); |
| 512 | if ( is_new_adj_lsa == 1 ) |
| 513 | { |
a64adam | 04be648 | 2013-01-17 11:29:32 -0600 | [diff] [blame] | 514 | if ( nlsr->debugging ) |
| 515 | printf("New Adj LSA.....\n"); |
Obaid Amin | e63022a | 2013-01-15 23:36:40 -0600 | [diff] [blame] | 516 | get_content_by_content_name(ccn_charbuf_as_string(uri), &content_data); |
a64adam | 04be648 | 2013-01-17 11:29:32 -0600 | [diff] [blame] | 517 | |
| 518 | if ( nlsr->debugging ) |
| 519 | printf("Content Data: %s \n",content_data); |
akmhoque | 4ae1694 | 2012-12-10 11:50:43 -0600 | [diff] [blame] | 520 | process_incoming_sync_content_lsa(content_data); |
| 521 | } |
| 522 | else |
| 523 | { |
a64adam | 04be648 | 2013-01-17 11:29:32 -0600 | [diff] [blame] | 524 | if ( nlsr->debugging ) |
| 525 | printf("Adj LSA / Newer Adj LSA already exists in LSDB\n"); |
Obaid Amin | e63022a | 2013-01-15 23:36:40 -0600 | [diff] [blame] | 526 | get_content_by_content_name(ccn_charbuf_as_string(uri), &content_data); |
a64adam | 04be648 | 2013-01-17 11:29:32 -0600 | [diff] [blame] | 527 | if ( nlsr->debugging ) |
| 528 | printf("Content Data: %s \n",content_data); |
akmhoque | 4ae1694 | 2012-12-10 11:50:43 -0600 | [diff] [blame] | 529 | } |
| 530 | } |
| 531 | else |
| 532 | { |
a64adam | 04be648 | 2013-01-17 11:29:32 -0600 | [diff] [blame] | 533 | if ( nlsr->debugging ) |
| 534 | printf("Lsa is older than Router LSA refresh time/ Dead Interval\n"); |
akmhoque | 4ae1694 | 2012-12-10 11:50:43 -0600 | [diff] [blame] | 535 | } |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 536 | } |
akmhoque | ed418f3 | 2013-01-30 12:25:04 -0600 | [diff] [blame] | 537 | else if(ls_type == LS_TYPE_COR) |
| 538 | { |
| 539 | res=ccn_name_comp_get(content_name->buf, components,lsa_position+2,&origtime, &comp_size); |
| 540 | get_name_part(orig_router,content_name,components,2); |
| 541 | |
| 542 | if ( nlsr->debugging ) |
| 543 | printf("Orig Time: %s\nOrig Router: %s\n",origtime,orig_router->name); |
| 544 | |
| 545 | int lsa_life_time=get_time_diff(time_stamp,(char *)origtime); |
| 546 | if ( (strcmp((char *)orig_router,nlsr->router_name) == 0 && lsa_life_time < nlsr->lsa_refresh_time) || (strcmp((char *)orig_router,nlsr->router_name) != 0 && lsa_life_time < nlsr->router_dead_interval) ) |
| 547 | { |
| 548 | int is_new_cor_lsa=check_is_new_cor_lsa(orig_router->name,(char *)lst,(char *)origtime); |
| 549 | if ( is_new_cor_lsa == 1 ) |
| 550 | { |
| 551 | if ( nlsr->debugging ) |
| 552 | printf("New Cor LSA.....\n"); |
| 553 | get_content_by_content_name(ccn_charbuf_as_string(uri), &content_data); |
| 554 | |
| 555 | if ( nlsr->debugging ) |
| 556 | printf("Content Data: %s \n",content_data); |
| 557 | process_incoming_sync_content_lsa(content_data); |
| 558 | } |
| 559 | else |
| 560 | { |
| 561 | if ( nlsr->debugging ) |
| 562 | printf("Cor LSA / Newer Cor LSA already exists in LSDB\n"); |
| 563 | get_content_by_content_name(ccn_charbuf_as_string(uri), &content_data); |
| 564 | if ( nlsr->debugging ) |
| 565 | printf("Content Data: %s \n",content_data); |
| 566 | } |
| 567 | } |
| 568 | else |
| 569 | { |
| 570 | if ( nlsr->debugging ) |
| 571 | printf("Lsa is older than Router LSA refresh time/ Dead Interval\n"); |
| 572 | } |
| 573 | |
| 574 | } |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 575 | |
Obaid Amin | e63022a | 2013-01-15 23:36:40 -0600 | [diff] [blame] | 576 | if (content_data != NULL) |
| 577 | free(content_data); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 578 | ccn_charbuf_destroy(&uri); |
akmhoque | 3b6c66d | 2013-01-31 15:30:23 -0600 | [diff] [blame] | 579 | //01/31/2013 |
| 580 | free(time_stamp); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 581 | } |
| 582 | |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 583 | void |
| 584 | sync_monitor(char *topo_prefix, char *slice_prefix) |
| 585 | { |
| 586 | |
| 587 | static struct ccns_name_closure nc={0}; |
| 588 | |
| 589 | nlsr->closure = &nc; |
| 590 | struct ccn_charbuf *prefix = ccn_charbuf_create(); |
| 591 | struct ccn_charbuf *roothash = NULL; |
| 592 | struct ccn_charbuf *topo = ccn_charbuf_create(); |
| 593 | nlsr->slice = ccns_slice_create(); |
| 594 | ccn_charbuf_reset(prefix); |
| 595 | ccn_charbuf_reset(topo); |
| 596 | |
| 597 | ccn_charbuf_reset(prefix); |
| 598 | ccn_name_from_uri(prefix, slice_prefix); |
| 599 | |
| 600 | ccn_charbuf_reset(topo); |
| 601 | ccn_name_from_uri(topo, topo_prefix); |
| 602 | |
| 603 | |
| 604 | ccns_slice_set_topo_prefix(nlsr->slice, topo, prefix); |
Syed Obaid Amin | 3a3864b | 2013-01-09 03:05:50 -0600 | [diff] [blame] | 605 | nlsr->closure->callback = &sync_cb; |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 606 | nlsr->ccns = ccns_open(nlsr->ccn, nlsr->slice, nlsr->closure, roothash, NULL); |
akmhoque | 3b6c66d | 2013-01-31 15:30:23 -0600 | [diff] [blame] | 607 | |
| 608 | //01/31/2013 |
| 609 | ccn_charbuf_destroy(&prefix); |
| 610 | ccn_charbuf_destroy(&topo); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 611 | } |
| 612 | |
| 613 | struct ccn_charbuf * |
| 614 | make_template(int scope) |
| 615 | { |
| 616 | struct ccn_charbuf *templ = NULL; |
| 617 | templ = ccn_charbuf_create(); |
| 618 | ccn_charbuf_append_tt(templ, CCN_DTAG_Interest, CCN_DTAG); |
| 619 | ccn_charbuf_append_tt(templ, CCN_DTAG_Name, CCN_DTAG); |
| 620 | ccn_charbuf_append_closer(templ); /* </Name> */ |
| 621 | if (0 <= scope && scope <= 2) |
| 622 | ccnb_tagged_putf(templ, CCN_DTAG_Scope, "%d", scope); |
| 623 | ccn_charbuf_append_closer(templ); /* </Interest> */ |
| 624 | return(templ); |
| 625 | } |
| 626 | |
akmhoque | fc5176d | 2013-01-18 09:50:12 -0600 | [diff] [blame] | 627 | int |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 628 | write_data_to_repo(char *data, char *name_prefix) |
| 629 | { |
akmhoque | 260698b | 2013-01-17 03:54:09 -0600 | [diff] [blame] | 630 | if ( nlsr->debugging ) |
| 631 | { |
| 632 | printf("write_data_to_repo called\n"); |
akmhoque | 47d19d1 | 2013-01-17 04:00:32 -0600 | [diff] [blame] | 633 | printf("Content Name: %s \n",name_prefix); |
akmhoque | 260698b | 2013-01-17 03:54:09 -0600 | [diff] [blame] | 634 | printf("Content Data: %s \n",data); |
| 635 | } |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 636 | |
akmhoque | 2ee1803 | 2013-01-22 10:01:23 -0600 | [diff] [blame] | 637 | struct ccn *temp_ccn; |
| 638 | temp_ccn=ccn_create(); |
| 639 | int ccn_fd=ccn_connect(temp_ccn, NULL); |
| 640 | if(ccn_fd == -1) |
| 641 | { |
| 642 | fprintf(stderr,"Could not connect to ccnd for Data Writing\n"); |
| 643 | writeLogg(__FILE__,__FUNCTION__,__LINE__,"Could not connect to ccnd for Data Writing\n"); |
| 644 | return -1; |
| 645 | } |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 646 | struct ccn_charbuf *name = NULL; |
| 647 | struct ccn_seqwriter *w = NULL; |
akmhoque | 2ee1803 | 2013-01-22 10:01:23 -0600 | [diff] [blame] | 648 | int blocksize = 4096; |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 649 | int freshness = -1; |
| 650 | int torepo = 1; |
| 651 | int scope = 1; |
| 652 | int res; |
| 653 | size_t blockread; |
| 654 | struct ccn_charbuf *templ; |
| 655 | |
| 656 | name = ccn_charbuf_create(); |
| 657 | res = ccn_name_from_uri(name, name_prefix); |
| 658 | if (res < 0) { |
| 659 | fprintf(stderr, "bad CCN URI: %s\n",name_prefix); |
akmhoque | fc5176d | 2013-01-18 09:50:12 -0600 | [diff] [blame] | 660 | return -1; |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 661 | } |
| 662 | |
| 663 | |
akmhoque | 2ee1803 | 2013-01-22 10:01:23 -0600 | [diff] [blame] | 664 | w = ccn_seqw_create(temp_ccn, name); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 665 | if (w == NULL) { |
| 666 | fprintf(stderr, "ccn_seqw_create failed\n"); |
akmhoque | fc5176d | 2013-01-18 09:50:12 -0600 | [diff] [blame] | 667 | return -1; |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 668 | } |
| 669 | ccn_seqw_set_block_limits(w, blocksize, blocksize); |
| 670 | if (freshness > -1) |
| 671 | ccn_seqw_set_freshness(w, freshness); |
| 672 | if (torepo) { |
| 673 | struct ccn_charbuf *name_v = ccn_charbuf_create(); |
| 674 | ccn_seqw_get_name(w, name_v); |
| 675 | ccn_name_from_uri(name_v, "%C1.R.sw"); |
| 676 | ccn_name_append_nonce(name_v); |
| 677 | templ = make_template(scope); |
akmhoque | 2ee1803 | 2013-01-22 10:01:23 -0600 | [diff] [blame] | 678 | res = ccn_get(temp_ccn, name_v, templ, 60000, NULL, NULL, NULL, 0); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 679 | ccn_charbuf_destroy(&templ); |
| 680 | ccn_charbuf_destroy(&name_v); |
| 681 | if (res < 0) { |
| 682 | fprintf(stderr, "No response from repository\n"); |
akmhoque | fc5176d | 2013-01-18 09:50:12 -0600 | [diff] [blame] | 683 | return -1; |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 684 | } |
| 685 | } |
| 686 | |
| 687 | |
| 688 | |
| 689 | |
| 690 | blockread = 0; |
akmhoque | 260698b | 2013-01-17 03:54:09 -0600 | [diff] [blame] | 691 | |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 692 | |
| 693 | blockread=strlen(data); |
| 694 | |
| 695 | if (blockread > 0) { |
akmhoque | 2ee1803 | 2013-01-22 10:01:23 -0600 | [diff] [blame] | 696 | ccn_run(temp_ccn, 100); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 697 | res = ccn_seqw_write(w, data, blockread); |
akmhoque | 260698b | 2013-01-17 03:54:09 -0600 | [diff] [blame] | 698 | while (res == -1) { |
akmhoque | 2ee1803 | 2013-01-22 10:01:23 -0600 | [diff] [blame] | 699 | ccn_run(temp_ccn, 100); |
akmhoque | 260698b | 2013-01-17 03:54:09 -0600 | [diff] [blame] | 700 | res = ccn_seqw_write(w, data, blockread); |
| 701 | } |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 702 | } |
| 703 | |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 704 | ccn_seqw_close(w); |
akmhoque | 2ee1803 | 2013-01-22 10:01:23 -0600 | [diff] [blame] | 705 | ccn_run(temp_ccn, 100); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 706 | ccn_charbuf_destroy(&name); |
akmhoque | 2ee1803 | 2013-01-22 10:01:23 -0600 | [diff] [blame] | 707 | ccn_destroy(&temp_ccn); |
akmhoque | fc5176d | 2013-01-18 09:50:12 -0600 | [diff] [blame] | 708 | |
| 709 | return 0; |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 710 | } |
| 711 | |
| 712 | |
| 713 | int |
| 714 | create_sync_slice(char *topo_prefix, char *slice_prefix) |
| 715 | { |
| 716 | int res; |
| 717 | struct ccns_slice *slice; |
| 718 | struct ccn_charbuf *prefix = ccn_charbuf_create(); |
| 719 | struct ccn_charbuf *topo = ccn_charbuf_create(); |
| 720 | struct ccn_charbuf *clause = ccn_charbuf_create(); |
| 721 | struct ccn_charbuf *slice_name = ccn_charbuf_create(); |
| 722 | struct ccn_charbuf *slice_uri = ccn_charbuf_create(); |
| 723 | |
| 724 | if (prefix == NULL || topo == NULL || clause == NULL || |
| 725 | slice_name == NULL || slice_uri == NULL) { |
| 726 | fprintf(stderr, "Unable to allocate required memory.\n"); |
akmhoque | fc5176d | 2013-01-18 09:50:12 -0600 | [diff] [blame] | 727 | return -1; |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 728 | } |
| 729 | |
| 730 | |
| 731 | slice = ccns_slice_create(); |
| 732 | |
| 733 | ccn_charbuf_reset(topo); |
| 734 | ccn_name_from_uri(topo, topo_prefix); |
| 735 | ccn_charbuf_reset(prefix); |
| 736 | ccn_name_from_uri(prefix,slice_prefix ); |
| 737 | ccns_slice_set_topo_prefix(slice, topo, prefix); |
| 738 | |
| 739 | |
| 740 | res = ccns_write_slice(nlsr->ccn, slice, slice_name); |
akmhoque | 3b6c66d | 2013-01-31 15:30:23 -0600 | [diff] [blame] | 741 | |
| 742 | //01/31/2013 |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 743 | ccns_slice_destroy(&slice); |
| 744 | ccn_charbuf_destroy(&prefix); |
| 745 | ccn_charbuf_destroy(&topo); |
| 746 | ccn_charbuf_destroy(&clause); |
| 747 | ccn_charbuf_destroy(&slice_name); |
| 748 | ccn_charbuf_destroy(&slice_uri); |
akmhoque | 3442576 | 2013-01-23 09:33:29 -0600 | [diff] [blame] | 749 | |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 750 | return 0; |
| 751 | } |
| 752 | |