2673 |
2673 |
2674 /** |
2674 /** |
2675 * At this point the BPQ Block has been found in the bundle |
2675 * At this point the BPQ Block has been found in the bundle |
2676 */ |
2676 */ |
2677 ASSERT ( block != NULL ); |
2677 ASSERT ( block != NULL ); |
2678 BPQBlock bpq_block(const_cast<BlockInfo*> (block) ); |
2678 BPQBlock bpq_block( bundle ); |
2679 |
2679 |
2680 log_info_p("/dtn/daemon/bpq", "handle_bpq_block: Kind: %d Query: %s", |
2680 log_info_p("/dtn/daemon/bpq", "handle_bpq_block: Kind: %d Query: %s", |
2681 (int) bpq_block.kind(), |
2681 (int) bpq_block.kind(), |
2682 (char*)bpq_block.query_val()); |
2682 (char*)bpq_block.query_val()); |
2683 |
2683 |
2685 if (bpq_cache()->answer_query(bundle, &bpq_block)) { |
2685 if (bpq_cache()->answer_query(bundle, &bpq_block)) { |
2686 log_info_p("/dtn/daemon/bpq", "Query: %s answered completely", |
2686 log_info_p("/dtn/daemon/bpq", "Query: %s answered completely", |
2687 (char*)bpq_block.query_val()); |
2687 (char*)bpq_block.query_val()); |
2688 event->daemon_only_ = true; |
2688 event->daemon_only_ = true; |
2689 } |
2689 } |
|
2690 |
2690 } else if (bpq_block.kind() == BPQBlock::KIND_RESPONSE) { |
2691 } else if (bpq_block.kind() == BPQBlock::KIND_RESPONSE) { |
2691 // don't accept local responses |
2692 // don't accept local responses |
2692 if (!local_bundle) { |
2693 if (!local_bundle && |
|
2694 !bundle->is_fragment() ) {//TODO: remove this temp frag exclusion |
2693 |
2695 |
2694 if (bpq_cache()->add_response_bundle(bundle, &bpq_block) && |
2696 if (bpq_cache()->add_response_bundle(bundle, &bpq_block) && |
2695 event->source_ != EVENTSRC_STORE) { |
2697 event->source_ != EVENTSRC_STORE) { |
2696 |
2698 |
2697 bundle->set_in_datastore(true); |
2699 bundle->set_in_datastore(true); |
2698 actions_->store_add(bundle); |
2700 actions_->store_add(bundle); |
2699 } |
2701 } |
2700 } |
2702 } |
|
2703 } else if (bpq_block.kind() == BPQBlock::KIND_RESPONSE_DO_NOT_CACHE_FRAG) { |
|
2704 |
|
2705 // don't accept local responses |
|
2706 if (!local_bundle && |
|
2707 !bundle->is_fragment() ) { |
|
2708 |
|
2709 if (bpq_cache()->add_response_bundle(bundle, &bpq_block) && |
|
2710 event->source_ != EVENTSRC_STORE) { |
|
2711 |
|
2712 bundle->set_in_datastore(true); |
|
2713 actions_->store_add(bundle); |
|
2714 } |
|
2715 } |
|
2716 |
|
2717 |
|
2718 log_info_p("/dtn/daemon/bpq", "Query: %s answered completely"); |
2701 } else { |
2719 } else { |
2702 log_err_p("/dtn/daemon/bpq", "ERROR - BPQ Block: invalid kind %d", |
2720 log_err_p("/dtn/daemon/bpq", "ERROR - BPQ Block: invalid kind %d", |
2703 bpq_block.kind()); |
2721 bpq_block.kind()); |
2704 NOTREACHED; |
2722 NOTREACHED; |
2705 return false; |
2723 return false; |