Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/nfn' into typed-abstractmachine
Browse files Browse the repository at this point in the history
  • Loading branch information
basilkohler committed May 23, 2014
2 parents a42bd29 + d0acee3 commit 0997447
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
15 changes: 13 additions & 2 deletions krivine-common.c
Expand Up @@ -425,7 +425,7 @@ create_content_object(struct ccnl_relay_s *ccnl, struct ccnl_prefix_s *prefix,
}

struct ccnl_content_s *
ccnl_nfn_local_content_search(struct ccnl_relay_s *ccnl, struct ccnl_prefix_s *prefix){
ccnl_nfn_local_content_search(struct ccnl_relay_s *ccnl, struct configuration_s *config, struct ccnl_prefix_s *prefix){
DEBUGMSG(2, "ccnl_nfn_local_content_search()\n");

struct ccnl_content_s *content;
Expand All @@ -436,6 +436,17 @@ ccnl_nfn_local_content_search(struct ccnl_relay_s *ccnl, struct ccnl_prefix_s *p
return content;
}
}
struct prefix_mapping_s *iter;
for(iter = config->fox_state->prefix_mapping; iter; iter = iter->next){
if(!ccnl_prefix_cmp(prefix, 0, iter->key, CMP_EXACT)){
for(content = ccnl->contents; content; content = content->next){
if(!ccnl_prefix_cmp(iter->value, 0, content->name, CMP_EXACT)){
return content;
}
}
}
}

return NULL;
}

Expand Down Expand Up @@ -511,7 +522,7 @@ ccnl_nfn_resolve_thunk(struct ccnl_relay_s *ccnl, struct configuration_s *config
if(interest){
interest->last_used = CCNL_NOW();
struct ccnl_content_s *c = NULL;
if((c = ccnl_nfn_local_content_search(ccnl, interest->prefix)) != NULL){
if((c = ccnl_nfn_local_content_search(ccnl, config, interest->prefix)) != NULL){
interest = ccnl_interest_remove(ccnl, interest);
return c;
}
Expand Down
24 changes: 6 additions & 18 deletions krivine.c
Expand Up @@ -335,7 +335,7 @@ create_namecomps(struct ccnl_relay_s *ccnl, struct configuration_s *config, int
struct ccnl_prefix_s *prefix)
{

if(ccnl_nfn_local_content_search(ccnl, prefix)){ //local computation name components
if(ccnl_nfn_local_content_search(ccnl, config, prefix)){ //local computation name components
DEBUGMSG(99, "content local available\n");
return add_local_computation_components(prefix, config);
}
Expand Down Expand Up @@ -758,7 +758,7 @@ ZAM_term(struct ccnl_relay_s *ccnl, struct configuration_s *config,
if(local_search){
parameter_number = choose_parameter(config);
struct ccnl_prefix_s *pref = create_namecomps(ccnl, config, parameter_number, thunk_request, config->fox_state->params[parameter_number]->content);
c = ccnl_nfn_local_content_search(ccnl, pref); //search for a result
c = ccnl_nfn_local_content_search(ccnl, config, pref); //search for a result
if(c) goto handlecontent;
}
//result was not delivered --> choose next parameter
Expand All @@ -767,7 +767,7 @@ ZAM_term(struct ccnl_relay_s *ccnl, struct configuration_s *config,
if(parameter_number < 0) return NULL; //no more parameter --> no result found
//TODO: create new prefix with name components!!!!
struct ccnl_prefix_s *pref = create_namecomps(ccnl, config, parameter_number, thunk_request, config->fox_state->params[parameter_number]->content);
c = ccnl_nfn_local_content_search(ccnl, pref);
c = ccnl_nfn_local_content_search(ccnl, config, pref);
if(c) goto handlecontent;

//Result not in cache, search over the network
Expand Down Expand Up @@ -805,7 +805,7 @@ ZAM_term(struct ccnl_relay_s *ccnl, struct configuration_s *config,
struct ccnl_prefix_s *name = malloc(sizeof(struct ccnl_prefix_s));
name->comp = malloc(2*sizeof(char*));
name->complen = malloc(2*sizeof(int));
name->compcnt = 2;
name->compcnt = 1;
name->comp[1] = "NFN";
name->complen[1] = 3;
name->comp[0] = malloc(CCNL_MAX_PACKET_SIZE);
Expand Down Expand Up @@ -945,21 +945,9 @@ Krivine_reduction(struct ccnl_relay_s *ccnl, char *expression, int thunk_request
char *h = NULL;
if(stack->type == STACK_TYPE_PREFIX){
struct ccnl_prefix_s *pref = stack->content;
struct ccnl_content_s *cont = ccnl_nfn_local_content_search(ccnl, pref);

struct ccnl_content_s *cont = ccnl_nfn_local_content_search(ccnl, config, pref);
if(cont == NULL){
struct prefix_mapping_s *iter;
DEBUGMSG(99, "Searching for a mapping!");
for(iter = (*config)->fox_state->prefix_mapping; iter; iter = iter->next){
if(!ccnl_prefix_cmp(pref, 0, iter->key, CMP_EXACT)){
cont = ccnl_nfn_local_content_search(ccnl, iter->value);
DBL_LINKED_LIST_REMOVE((*config)->fox_state->prefix_mapping, iter);
break;
}
}
if(cont == NULL){
return NULL;
}
return NULL;
}
h = cont->content;
}
Expand Down

0 comments on commit 0997447

Please sign in to comment.