From d0acee3da0aa69e51c74e27b72566085f0657651 Mon Sep 17 00:00:00 2001 From: Christopher Scherb Date: Fri, 23 May 2014 15:04:58 +0200 Subject: [PATCH] Bugfix --- krivine-common.c | 15 +++++++++++++-- krivine.c | 24 ++++++------------------ 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/krivine-common.c b/krivine-common.c index e5d53a16e7a7..a7e2a8ca49f2 100644 --- a/krivine-common.c +++ b/krivine-common.c @@ -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; @@ -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; } @@ -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; } diff --git a/krivine.c b/krivine.c index 264dc44acb5d..434cc98bd5ac 100644 --- a/krivine.c +++ b/krivine.c @@ -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); } @@ -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 @@ -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 @@ -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); @@ -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; }