char * get_orig_router_from_lsa_name(struct ccn_charbuf * content_name) { int start=0; size_t comp_size; const unsigned char *second_last_comp; char *second_comp_type; char *sep="."; char *rem; struct ccn_indexbuf *components=ccn_indexbuf_create(); struct ccn_charbuf *name=ccn_charbuf_create(); ccn_name_from_uri(name,nlsr->slice_prefix); ccn_name_split (name, components); start=components->n-2; ccn_charbuf_destroy(&name); ccn_indexbuf_destroy(&components); struct ccn_indexbuf *comps=ccn_indexbuf_create(); ccn_name_split (content_name, comps); ccn_name_comp_get( content_name->buf, comps, comps->n-1-2, &second_last_comp, &comp_size); second_comp_type=strtok_r((char *)second_last_comp, sep, &rem); if ( strcmp( second_comp_type, "lsId" ) == 0 ){ ccn_name_chop(content_name,comps,-3); } else{ ccn_name_chop(content_name,comps,-2); } struct ccn_charbuf *temp=ccn_charbuf_create(); ccn_name_init(temp); ccn_name_append_components( temp, content_name->buf, comps->buf[start+1], comps->buf[comps->n - 1]); struct ccn_charbuf *temp1=ccn_charbuf_create(); ccn_uri_append(temp1, temp->buf, temp->length, 0); char *orig_router=(char *)calloc(strlen(ccn_charbuf_as_string(temp1))+1, sizeof(char)); memcpy(orig_router,ccn_charbuf_as_string(temp1), strlen(ccn_charbuf_as_string(temp1))); orig_router[strlen(orig_router)]='\0'; ccn_charbuf_destroy(&temp); ccn_charbuf_destroy(&temp1); ccn_indexbuf_destroy(&comps); return orig_router; }
char * get_orig_router_from_info_content_name(struct ccn_charbuf * content_name) { int start,end; start=0; struct ccn_indexbuf *comps=ccn_indexbuf_create(); ccn_name_split (content_name, comps); end=check_for_name_component_in_name(content_name,comps,"nlsr"); struct ccn_charbuf *temp=ccn_charbuf_create(); ccn_name_init(temp); ccn_name_append_components( temp, content_name->buf, comps->buf[start], comps->buf[end]); struct ccn_charbuf *temp1=ccn_charbuf_create(); ccn_uri_append(temp1, temp->buf, temp->length, 0); char *orig_router=(char *)calloc(strlen(ccn_charbuf_as_string(temp1))+1, sizeof(char)); memcpy(orig_router,ccn_charbuf_as_string(temp1), strlen(ccn_charbuf_as_string(temp1))); orig_router[strlen(orig_router)]='\0'; ccn_charbuf_destroy(&temp); ccn_charbuf_destroy(&temp1); ccn_indexbuf_destroy(&comps); return orig_router; }
/** * Find and consume interests that match given content. * * Schedules the sending of the content. * If fdholder is not NULL, pay attention only to interests from that fdholder. * It is allowed to pass NULL for pc, but if you have a (valid) one it * will avoid a re-parse. * For new content, from_face is the source; for old content, from_face is NULL. * @returns number of matches, or -1 if the new content should be dropped. */ PUBLIC int r_match_match_interests(struct ccnr_handle *h, struct content_entry *content, struct ccn_parsed_ContentObject *pc, struct fdholder *fdholder, struct fdholder *from_face) { int n_matched = 0; int new_matches; struct nameprefix_entry *npe = NULL; int ci = 0; int cm = 0; struct ccn_charbuf *name = NULL; struct ccn_indexbuf *namecomps = NULL; unsigned c0 = 0; name = ccn_charbuf_create(); ccn_name_init(name); r_store_name_append_components(name, h, content, 0, -1); namecomps = ccn_indexbuf_create(); ccn_name_split(name, namecomps); c0 = namecomps->buf[0]; for (ci = namecomps->n - 1; ci >= 0; ci--) { int size = namecomps->buf[ci] - c0; npe = hashtb_lookup(h->nameprefix_tab, name->buf + c0, size); if (npe != NULL) break; } ccn_charbuf_destroy(&name); ccn_indexbuf_destroy(&namecomps); for (; npe != NULL; npe = npe->parent, ci--) { // if (npe->fgen != h->forward_to_gen) // r_fwd_update_forward_to(h, npe); if (from_face != NULL && (npe->flags & CCN_FORW_LOCAL) != 0 && (from_face->flags & CCNR_FACE_GG) == 0) return(-1); new_matches = r_match_consume_matching_interests(h, npe, content, pc, fdholder); // if (from_face != NULL && (new_matches != 0 || ci + 1 == cm)) // note_content_from(h, npe, from_face->filedesc, ci); if (new_matches != 0) { cm = ci; /* update stats for this prefix and one shorter */ n_matched += new_matches; } } return(n_matched); }
void get_name_part(struct name_prefix *name_part,struct ccn_charbuf * interest_ccnb, struct ccn_indexbuf *interest_comps, int offset) { int lsa_position=0; struct ccn_indexbuf *components=ccn_indexbuf_create(); struct ccn_charbuf *name=ccn_charbuf_create(); ccn_name_from_uri(name,nlsr->slice_prefix); ccn_name_split (name, components); lsa_position=components->n-2; ccn_charbuf_destroy(&name); struct ccn_charbuf *temp=ccn_charbuf_create(); ccn_name_init(temp); ccn_name_append_components( temp, interest_ccnb->buf, interest_comps->buf[lsa_position+1], interest_comps->buf[interest_comps->n - 1]); struct ccn_charbuf *temp1=ccn_charbuf_create(); ccn_uri_append(temp1, temp->buf, temp->length, 0); name_part->name=(char *)calloc(strlen(ccn_charbuf_as_string(temp1))+1, sizeof(char)); memcpy(name_part->name,ccn_charbuf_as_string(temp1), strlen(ccn_charbuf_as_string(temp1))); name_part->name[strlen(ccn_charbuf_as_string(temp1))]='\0'; name_part->length=strlen(ccn_charbuf_as_string(temp1))+1; ccn_charbuf_destroy(&temp1); ccn_charbuf_destroy(&temp); ccn_indexbuf_destroy(&components); if ( nlsr->debugging ) printf("Name Part: %s \n",name_part->name); }
PUBLIC void ccnr_uri_listen(struct ccnr_handle *ccnr, struct ccn *ccn, const char *uri, ccn_handler p, intptr_t intdata) { struct ccn_charbuf *name; struct ccn_charbuf *uri_modified = NULL; struct ccn_closure *closure; struct ccn_indexbuf *comps; const unsigned char *comp; size_t comp_size; size_t offset; name = ccn_charbuf_create(); ccn_name_from_uri(name, uri); comps = ccn_indexbuf_create(); if (ccn_name_split(name, comps) < 0) abort(); if (ccn_name_comp_get(name->buf, comps, 1, &comp, &comp_size) >= 0) { if (comp_size == 32 && 0 == memcmp(comp, CCNR_ID_TEMPL, 32)) { /* Replace placeholder with our ccnr_id */ offset = comp - name->buf; memcpy(name->buf + offset, ccnr->ccnr_id, 32); uri_modified = ccn_charbuf_create(); ccn_uri_append(uri_modified, name->buf, name->length, 1); uri = (char *)uri_modified->buf; } } closure = calloc(1, sizeof(*closure)); closure->p = p; closure->data = ccnr; closure->intdata = intdata; ccn_set_interest_filter(ccn, name, closure); ccn_charbuf_destroy(&name); ccn_charbuf_destroy(&uri_modified); ccn_indexbuf_destroy(&comps); }
enum ccn_upcall_res incoming_content( struct ccn_closure *selfp, enum ccn_upcall_kind kind, struct ccn_upcall_info *info) { struct ccn_charbuf *name = NULL; struct ccn_charbuf *templ = NULL; struct ccn_charbuf *temp = NULL; const unsigned char *ccnb = NULL; size_t ccnb_size = 0; const unsigned char *data = NULL; size_t data_size = 0; // TANG: no need to write data to stdout //size_t written; const unsigned char *ib = NULL; /* info->interest_ccnb */ struct ccn_indexbuf *ic = NULL; int res; struct mydata *md = selfp->data; if (kind == CCN_UPCALL_FINAL) { if (md != NULL) { selfp->data = NULL; free(md); md = NULL; } return(CCN_UPCALL_RESULT_OK); } if (kind == CCN_UPCALL_INTEREST_TIMED_OUT) return(CCN_UPCALL_RESULT_REEXPRESS); if (kind != CCN_UPCALL_CONTENT && kind != CCN_UPCALL_CONTENT_UNVERIFIED) return(CCN_UPCALL_RESULT_ERR); if (md == NULL) selfp->data = md = calloc(1, sizeof(*md)); ccnb = info->content_ccnb; ccnb_size = info->pco->offset[CCN_PCO_E]; ib = info->interest_ccnb; ic = info->interest_comps; /* XXX - must verify sig, and make sure it is LEAF content */ res = ccn_content_get_value(ccnb, ccnb_size, info->pco, &data, &data_size); if (res < 0) abort(); if (data_size > CHUNK_SIZE) { /* For us this is spam. Give up now. */ fprintf(stderr, "*** Segment %d found with a data size of %d." " This program only works with segments of 1024 bytes." " Try ccncatchunks2 instead.\n", (int)selfp->intdata, (int)data_size); exit(1); } /* OK, we will accept this block. */ //sleep(1); // TANG: No need to write data to stdout, skip 3 lines //written = fwrite(data, data_size, 1, stdout); //if (written != 1) // exit(1); /* A short block signals EOF for us. */ // TANG: to support data_size smaller than 1024, skip 2 lines //if (data_size < CHUNK_SIZE) // exit(0); /* Ask for the next one */ name = ccn_charbuf_create(); ccn_name_init(name); if (ic->n < 2) abort(); res = ccn_name_append_components(name, ib, ic->buf[0], ic->buf[ic->n - 2]); if (res < 0) abort(); temp = ccn_charbuf_create(); //printf("intdata = %d \n ", selfp->intdata); ccn_charbuf_putf(temp, "%d", ++(selfp->intdata)); ccn_name_append(name, temp->buf, temp->length); ccn_charbuf_destroy(&temp); if(DEBUG){ //Print out the interest's name printf("Interest name = "); int myres = 0; struct ccn_indexbuf* ndx = ccn_indexbuf_create(); unsigned char* mycomp = NULL; size_t mysize = 0; ndx->n = 0; myres = ccn_name_split(name, ndx); if(myres < 0){ fprintf(stderr, "ccn_name_split @ ccntraffic. failed"); } int it = 0; for(it = 0; it < ndx->n-1; it++){ mysize = 0; myres = ccn_name_comp_get(name->buf, ndx, it, &mycomp, &mysize); printf("%s/", mycomp); mycomp = NULL; } printf("\n"); } templ = make_template(md); res = ccn_express_interest(info->h, name, selfp, templ); if (res < 0) abort(); ccn_charbuf_destroy(&templ); ccn_charbuf_destroy(&name); return(CCN_UPCALL_RESULT_OK); }
static void ask_set(struct mydata *md, char ** urlList, int flying){ if(DEBUG) printf("In function askset \n "); struct ccn_charbuf * name = NULL; struct ccn_charbuf * templ = NULL; int i = 0; int res = -1; struct ccn_closure * cl = NULL; /* TODO: Zipf Distribution //Test the Zipf distribution printf("Zipf starts \n"); for(i = 1; i < 100000; i++){ printf("%d \n", zipf(5, 100, i)); } printf("Zipfs ends\n"); */ int r = 0; for(r = 0; r < 1; r++){ for(i = 0; i < flying; i++){ cl = &(md->ooo[i].closure); name = ccn_charbuf_create(); printf("url = %s \n", urlList[i]); printf("===\n"); res = ccn_name_from_uri(name, urlList[i]); if(res < 0){ printf("ccn_name_from_uri failed \n"); abort(); } ccn_name_append(name, "0", 1); templ = make_template(md); if(DEBUG){ //Print out the interest's name printf("Sending Interest : "); int myres = 0; struct ccn_indexbuf* ndx = ccn_indexbuf_create(); unsigned char* mycomp = NULL; size_t mysize = 0; ndx->n = 0; myres = ccn_name_split(name, ndx); if(myres < 0){ fprintf(stderr, "ccn_name_split @ ccntraffic. failed"); } int it = 0; for(it = 0; it < ndx->n-1; it++){ mysize = 0; myres = ccn_name_comp_get(name->buf, ndx, it, &mycomp, &mysize); printf("%s/", mycomp); mycomp = NULL; } printf("\n"); } res = ccn_express_interest(md->h, name, cl, templ); if(res < 0) abort(); ccn_charbuf_destroy(&name); } } printf("Sent!\n"); }
/** * Extend a Name with a new version stamp * @param h is the the ccn handle. * May be NULL. This procedure does not use the connection. * @param name is a ccnb-encoded Name prefix. By default it gets extended * in-place with one additional Component that conforms to the * versioning profile and is based on the supplied time, unless a * version component is already present. * @param versioning_flags modifies the default behavior: * CCN_V_REPLACE causes the last component to be replaced if it * appears to be a version stamp. If CCN_V_HIGH is set as well, an * attempt will be made to generate a new version stamp that is * later than the existing one, or to return an error. * CCN_V_NOW bases the version on the current time rather than the * supplied time. * CCN_V_NESTOK will allow the new version component to be appended * even if there is one there (this makes no difference if CCN_V_REPLACE * is also set). * @param secs is the desired time, in seconds since epoch * (ignored if CCN_V_NOW is set). * @param nsecs is the number of nanoseconds. * @returns -1 for error, 0 for success. */ int ccn_create_version(struct ccn *h, struct ccn_charbuf *name, int versioning_flags, intmax_t secs, int nsecs) { size_t i; size_t j; size_t lc = 0; size_t oc = 0; int n; struct ccn_indexbuf *nix = NULL; int myres = -1; int already_versioned = 0; int ok_flags = (CCN_V_REPLACE | CCN_V_HIGH | CCN_V_NOW | CCN_V_NESTOK); // XXX - right now we ignore h, but in the future we may use it to try to avoid non-monotonicies in the versions. nix = ccn_indexbuf_create(); n = ccn_name_split(name, nix); if (n < 0) goto Finish; if ((versioning_flags & ~ok_flags) != 0) goto Finish; /* Check for existing version component */ if (n >= 1) { oc = nix->buf[n-1]; lc = nix->buf[n] - oc; if (lc <= 11 && lc >= 6 && name->buf[oc + 2] == CCN_MARKER_VERSION) already_versioned = 1; } myres = 0; if (already_versioned && (versioning_flags & (CCN_V_REPLACE | CCN_V_NESTOK)) == 0) goto Finish; name->length -= 1; /* Strip name closer */ i = name->length; myres |= ccn_charbuf_append_tt(name, CCN_DTAG_Component, CCN_DTAG); if ((versioning_flags & CCN_V_NOW) != 0) myres |= ccnb_append_now_blob(name, CCN_MARKER_VERSION); else { myres |= ccnb_append_timestamp_blob(name, CCN_MARKER_VERSION, secs, nsecs); } myres |= ccn_charbuf_append_closer(name); /* </Component> */ if (myres < 0) { name->length = i; goto CloseName; } j = name->length; if (already_versioned && (versioning_flags & CCN_V_REPLACE) != 0) { oc = nix->buf[n-1]; lc = nix->buf[n] - oc; if ((versioning_flags & CCN_V_HIGH) != 0 && memcmp(name->buf + oc, name->buf + i, j - i) > 0) { /* Supplied version is in the future. */ name->length = i; // XXX - we could try harder to make this work, for now just error out myres = -1; goto CloseName; } memmove(name->buf + oc, name->buf + i, j - i); name->length -= lc; } CloseName: myres |= ccn_charbuf_append_closer(name); /* </Name> */ Finish: myres = (myres < 0) ? -1 : 0; ccn_indexbuf_destroy(&nix); return(myres); }
/** * Resolve the version, based on existing ccn content. * @param h is the the ccn handle; it may be NULL, but it is preferable to * use the handle that the client probably already has. * @param name is a ccnb-encoded Name prefix. It gets extended in-place with * one additional Component such that it names highest extant * version that can be found, subject to the supplied timeout. * @param versioning_flags presently must be CCN_V_HIGH or CCN_V_HIGHEST, * possibly combined with CCN_V_NESTOK. If CCN_V_NESTOK is not present * and the ending component appears to be a version, the routine * returns 0 immediately, on the assumption that an explicit * version has already been provided. * @param timeout_ms is a time value in milliseconds. This is applied per * fetch attempt, so the total time may be longer by a factor that * depends on the number of (ccn) hops to the source(s). * @returns -1 for error, 0 if name could not be extended, 1 if was. */ int ccn_resolve_version(struct ccn *h, struct ccn_charbuf *name, int versioning_flags, int timeout_ms) { int res; int myres = -1; struct ccn_parsed_ContentObject pco_space = { 0 }; struct ccn_charbuf *templ = NULL; struct ccn_charbuf *prefix = ccn_charbuf_create(); struct ccn_charbuf *cobj = ccn_charbuf_create(); struct ccn_parsed_ContentObject *pco = &pco_space; struct ccn_indexbuf *ndx = ccn_indexbuf_create(); const unsigned char *vers = NULL; size_t vers_size = 0; int n; struct ccn_indexbuf *nix = ccn_indexbuf_create(); unsigned char lowtime[7] = {CCN_MARKER_VERSION, 0, FF, FF, FF, FF, FF}; if ((versioning_flags & ~CCN_V_NESTOK & ~CCN_V_EST) != CCN_V_HIGH) { ccn_seterror(h, EINVAL); ccn_perror(h, "ccn_resolve_version is only implemented for versioning_flags = CCN_V_HIGH(EST)"); goto Finish; } n = ccn_name_split(name, nix); if (n < 0) goto Finish; if ((versioning_flags & CCN_V_NESTOK) == 0) { res = ccn_name_comp_get(name->buf, nix, n - 1, &vers, &vers_size); if (res >= 0 && vers_size == 7 && vers[0] == CCN_MARKER_VERSION) { myres = 0; goto Finish; } } templ = resolve_templ(templ, lowtime, sizeof(lowtime)); ccn_charbuf_append(prefix, name->buf, name->length); /* our copy */ cobj->length = 0; res = ccn_get(h, prefix, templ, timeout_ms, cobj, pco, ndx, 0); while (cobj->length != 0) { if (pco->type == CCN_CONTENT_NACK) // XXX - also check for number of components break; res = ccn_name_comp_get(cobj->buf, ndx, n, &vers, &vers_size); if (res < 0) break; if (vers_size == 7 && vers[0] == CCN_MARKER_VERSION) { /* Looks like we have versions. */ name->length = 0; ccn_charbuf_append(name, prefix->buf, prefix->length); ccn_name_append(name, vers, vers_size); myres = 0; if ((versioning_flags & CCN_V_EST) == 0) break; templ = resolve_templ(templ, vers, vers_size); if (templ == NULL) break; cobj->length = 0; res = ccn_get(h, prefix, templ, timeout_ms, cobj, pco, ndx, CCN_GET_NOKEYWAIT); } else break; } Finish: ccn_charbuf_destroy(&prefix); ccn_charbuf_destroy(&cobj); ccn_indexbuf_destroy(&ndx); ccn_indexbuf_destroy(&nix); ccn_charbuf_destroy(&templ); return(myres); }
// Enumeration support extern int SyncNotifyContent(struct SyncBaseStruct *base, int enumeration, ccnr_accession item, struct ccn_charbuf *name) { // here for any updates, whether from time-based enumeration // or from prefix-based enumeration char *here = "Sync.SyncNotifyContent"; if (base != NULL && base->ccnr != NULL) { struct SyncPrivate *priv = base->priv; int debug = base->debug; if (name == NULL) { // end of an enumeration if (enumeration == 0) { if (debug >= CCNL_WARNING) ccnr_msg(base->ccnr, "%s, end of time-based enum?", here); } else if (enumeration == priv->sliceEnum) { priv->sliceEnum = 0; if (debug >= CCNL_INFO) ccnr_msg(base->ccnr, "%s, all slice names seen", here); } else if (enumeration == priv->sliceBusy) { priv->sliceBusy = 0; struct SyncRootStruct *root = priv->rootHead; while (root != NULL) { struct SyncRootPrivate *rp = root->priv; if (enumeration == rp->sliceBusy) { rp->sliceBusy = 0; if (debug >= CCNL_INFO) SyncNoteSimple(root, here, "slice enum done"); break; } root = root->next; } // may need a new enumeration started root = priv->rootHead; while (root != NULL) { struct SyncRootPrivate *rp = root->priv; if (rp->sliceBusy < 0) { SyncStartSliceEnum(root); break; } root = root->next; } } else { if (debug >= CCNL_WARNING) ccnr_msg(base->ccnr, "%s, end of what enum?", here); } return -1; } if (debug >= CCNL_FINE) { struct ccn_charbuf *uri = SyncUriForName(name); ccnr_msg(base->ccnr, "%s, enum %d, %s!", here, enumeration, ccn_charbuf_as_string(uri)); ccn_charbuf_destroy(&uri); } struct ccn_indexbuf *comps = priv->comps; int splitRes = ccn_name_split(name, comps); if (splitRes < 0) { // really hould not happen! but it does not hurt to log and ignore it if (debug >= CCNL_SEVERE) ccnr_msg(base->ccnr, "%s, invalid name!", here); return 0; } unsigned char *comp0 = NULL; size_t size0 = 0; unsigned char *comp1 = NULL; size_t size1 = 0; ccn_name_comp_get(name->buf, comps, 0, (const unsigned char **) &comp0, &size0); ccn_name_comp_get(name->buf, comps, 1, (const unsigned char **) &comp1, &size1); ccnr_accession mark = item; if (SyncPrefixMatch(priv->localHostPrefix, name, 0)) { // to the local host, don't update the stable target mark = CCNR_NULL_ACCESSION; if (SyncPrefixMatch(priv->sliceCmdPrefix, name, 0)) // this is a new slice SyncHandleSlice(base, name); } if (mark != CCNR_NULL_ACCESSION) priv->stableTarget = ccnr_hwm_update(base->ccnr, priv->stableTarget, mark); // add the name to any applicable roots SyncAddName(base, name, item); return 0; } return -1; }
int sync_cb(struct ccns_name_closure *nc, struct ccn_charbuf *lhash, struct ccn_charbuf *rhash, struct ccn_charbuf *name) { nlsr_lock(); int res; struct ccn_charbuf *content_name; struct ccn_indexbuf *content_comps; struct ccn_indexbuf *name_comps; content_comps = ccn_indexbuf_create(); res = ccn_name_split(name, content_comps); if ( res < 0 ) return 0; if (content_comps->n < 2) return 0; content_name = ccn_charbuf_create(); ccn_name_init(content_name); res = ccn_name_append_components( content_name, name->buf, content_comps->buf[0], content_comps->buf[content_comps->n - 1]); if ( res < 0) return 0; // for debugging struct ccn_charbuf *temp=ccn_charbuf_create(); ccn_uri_append(temp, content_name->buf, content_name->length, 0); if ( nlsr->debugging ) printf("Name before chopping: %s \n",ccn_charbuf_as_string(temp)); ccn_charbuf_destroy(&temp); name_comps = ccn_indexbuf_create(); res=ccn_name_split (content_name, name_comps); if (res < 0) return 0; if ( nlsr->debugging ) { printf("Number of components in name = %d \n",res); printf("Number of components in name as indexbuf->n = %d \n", (int)name_comps->n); } ccn_name_chop(content_name, name_comps, -3); if ( nlsr->debugging ) printf("Number of components in name as indexbuf->n after chopping= %d \n" , (int)name_comps->n); //for debugging struct ccn_charbuf *temp1=ccn_charbuf_create(); ccn_uri_append(temp1, content_name->buf, content_name->length, 0); if ( nlsr->debugging ) printf("Name after chopping: %s \n",ccn_charbuf_as_string(temp1)); ccn_charbuf_destroy(&temp1); //main method that processes contents from the sync process_content_from_sync(content_name, name_comps); ccn_charbuf_destroy(&content_name); ccn_indexbuf_destroy(&content_comps); ccn_indexbuf_destroy(&name_comps); nlsr_unlock(); return(0); }
int check_key_name_hierarchy(const unsigned char *ccnb, struct ccn_parsed_ContentObject *pco, int key_type, int content_type){ printf("check_key_name_hierarchy called\n"); if (key_type == UNKNOWN_KEY ){ return 1; } int res; struct ccn_charbuf *key_name=get_key_name(ccnb, pco); struct ccn_charbuf *key_uri = ccn_charbuf_create(); ccn_uri_append(key_uri, key_name->buf, key_name->length, 0); printf("Key Name: %s\n",ccn_charbuf_as_string(key_uri)); ccn_charbuf_destroy(&key_uri); struct ccn_charbuf *content_name=ccn_charbuf_create(); res=ccn_charbuf_append(content_name, ccnb + pco->offset[CCN_PCO_B_Name], pco->offset[CCN_PCO_E_Name] - pco->offset[CCN_PCO_B_Name]); struct ccn_charbuf *content_uri = ccn_charbuf_create(); ccn_uri_append(content_uri, content_name->buf, content_name->length, 0); printf("Content Name: %s\n",ccn_charbuf_as_string(content_uri)); ccn_charbuf_destroy(&content_uri); if ( key_type == NLSR_KEY){ char *orig_router_key_name=get_orig_router_from_key_name(key_name,0,0); char *orig_router_content_name; if ( content_type == 1 ){ orig_router_content_name=get_orig_router_from_lsa_name(content_name); } else if ( content_type == 0 ){ orig_router_content_name=get_orig_router_from_info_content_name(content_name); } printf("Orig Router (Key Name):%s\n",orig_router_key_name); printf("Orig Router (Content Name):%s\n",orig_router_content_name); if (strcmp(orig_router_key_name,orig_router_content_name) == 0 ){ free(orig_router_key_name); free(orig_router_content_name); ccn_charbuf_destroy(&key_name); ccn_charbuf_destroy(&content_name); return 1; } } if ( key_type == ROUTING_KEY){ char *orig_router_key_name=get_orig_router_from_key_name(key_name,1,0); char *orig_router_content_name=get_orig_router_from_key_name(content_name,1,1); printf("Orig Router (Key Name):%s\n",orig_router_key_name); printf("Orig Router (Content Name):%s\n",orig_router_content_name); if (strcmp(orig_router_key_name,orig_router_content_name) == 0 ){ free(orig_router_key_name); free(orig_router_content_name); ccn_charbuf_destroy(&key_name); ccn_charbuf_destroy(&content_name); return 1; } } if ( key_type == OPERATOR_KEY){ struct ccn_indexbuf *key_name_comps; key_name_comps = ccn_indexbuf_create(); res = ccn_name_split(key_name, key_name_comps); int last_indx=check_for_tag_component_in_name(key_name,key_name_comps,"O.N.Start"); char *site_key_prefix_key=get_name_segments_from_name(key_name,0,last_indx); printf("Site key prefix(key Name):%s\n",site_key_prefix_key); ccn_indexbuf_destroy(&key_name_comps); struct ccn_indexbuf *content_name_comps; content_name_comps = ccn_indexbuf_create(); res = ccn_name_split(content_name, content_name_comps); int last_indx_rtr=check_for_tag_component_in_name(content_name,content_name_comps,"R.N.Start"); char *site_key_prefix_content=get_name_segments_from_name(key_name,0,last_indx_rtr); printf("Site key prefix(Content Name):%s\n",site_key_prefix_content); ccn_indexbuf_destroy(&content_name_comps); if( strcmp(site_key_prefix_key,site_key_prefix_content) == 0 ){ free(site_key_prefix_key); free(site_key_prefix_content); ccn_charbuf_destroy(&key_name); ccn_charbuf_destroy(&content_name); return 1; } } if ( key_type == SITE_KEY){ struct ccn_indexbuf *key_name_comps; key_name_comps = ccn_indexbuf_create(); res = ccn_name_split(key_name, key_name_comps); int last_indx=check_for_tag_component_in_name(key_name,key_name_comps,"M.K"); char *site_key_prefix_key=get_name_segments_from_name(key_name,0,last_indx); printf("Site key prefix(key Name):%s\n",site_key_prefix_key); ccn_indexbuf_destroy(&key_name_comps); struct ccn_indexbuf *content_name_comps; content_name_comps = ccn_indexbuf_create(); res = ccn_name_split(content_name, content_name_comps); int last_indx_rtr=check_for_tag_component_in_name(content_name,content_name_comps,"O.N.Start"); char *site_key_prefix_content=get_name_segments_from_name(key_name,0,last_indx_rtr); printf("Site key prefix(Content Name):%s\n",site_key_prefix_content); ccn_indexbuf_destroy(&content_name_comps); if( strcmp(site_key_prefix_key,site_key_prefix_content) == 0 ){ free(site_key_prefix_key); free(site_key_prefix_content); ccn_charbuf_destroy(&key_name); ccn_charbuf_destroy(&content_name); return 1; } } if ( key_type == ROOT_KEY){ ccn_charbuf_destroy(&key_name); ccn_charbuf_destroy(&content_name); return 1; } ccn_charbuf_destroy(&key_name); ccn_charbuf_destroy(&content_name); return 0; }