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