737 s10_bundle(S10_FROMCACHE,bundle,NULL,0,0,NULL,"__FILE__:__LINE__"); |
737 s10_bundle(S10_FROMCACHE,bundle,NULL,0,0,NULL,"__FILE__:__LINE__"); |
738 break; |
738 break; |
739 |
739 |
740 default: |
740 default: |
741 s10_bundle(S10_OHCRAP,bundle,NULL,0,0,NULL,"__FILE__:__LINE__"); |
741 s10_bundle(S10_OHCRAP,bundle,NULL,0,0,NULL,"__FILE__:__LINE__"); |
742 log_debug("S10_OHCRAP - nknown eventsrc: %s", event->source_); |
742 log_debug("S10_OHCRAP - unknown eventsrc: %d", event->source_); |
743 NOTREACHED; |
743 NOTREACHED; |
744 } |
744 } |
745 |
745 |
746 // if debug logging is enabled, dump out a verbose printing of the |
746 // if debug logging is enabled, dump out a verbose printing of the |
747 // bundle, including all options, otherwise, a more terse log |
747 // bundle, including all options, otherwise, a more terse log |
2623 //---------------------------------------------------------------------- |
2623 //---------------------------------------------------------------------- |
2624 bool |
2624 bool |
2625 BundleDaemon::handle_bpq_block(Bundle* bundle, BundleReceivedEvent* event) |
2625 BundleDaemon::handle_bpq_block(Bundle* bundle, BundleReceivedEvent* event) |
2626 { |
2626 { |
2627 const BlockInfo* block = NULL; |
2627 const BlockInfo* block = NULL; |
|
2628 bool local_bundle = true; |
2628 |
2629 |
2629 switch (event->source_) { |
2630 switch (event->source_) { |
2630 case EVENTSRC_PEER: |
2631 case EVENTSRC_PEER: |
2631 if (bundle->recv_blocks().has_block(BundleProtocol::QUERY_EXTENSION_BLOCK)) { |
2632 if (bundle->recv_blocks().has_block(BundleProtocol::QUERY_EXTENSION_BLOCK)) { |
2632 block = bundle->recv_blocks(). |
2633 block = bundle->recv_blocks(). |
2633 find_block(BundleProtocol::QUERY_EXTENSION_BLOCK); |
2634 find_block(BundleProtocol::QUERY_EXTENSION_BLOCK); |
|
2635 local_bundle = false; |
2634 } else { |
2636 } else { |
2635 return false; |
2637 return false; |
2636 } |
2638 } |
2637 break; |
2639 break; |
2638 |
2640 |
2639 case EVENTSRC_APP: |
2641 case EVENTSRC_APP: |
2640 if (bundle->api_blocks()->has_block(BundleProtocol::QUERY_EXTENSION_BLOCK)) { |
2642 if (bundle->api_blocks()->has_block(BundleProtocol::QUERY_EXTENSION_BLOCK)) { |
2641 block = bundle->api_blocks()-> |
2643 block = bundle->api_blocks()-> |
2642 find_block(BundleProtocol::QUERY_EXTENSION_BLOCK); |
2644 find_block(BundleProtocol::QUERY_EXTENSION_BLOCK); |
|
2645 local_bundle = true; |
2643 } else { |
2646 } else { |
2644 return false; |
2647 return false; |
2645 } |
2648 } |
2646 break; |
2649 break; |
2647 |
2650 |
2648 case EVENTSRC_STORE: |
2651 case EVENTSRC_STORE: |
2649 case EVENTSRC_FRAGMENTATION: |
2652 case EVENTSRC_FRAGMENTATION: |
2650 if (bundle->recv_blocks().has_block(BundleProtocol::QUERY_EXTENSION_BLOCK)) { |
2653 if (bundle->recv_blocks().has_block(BundleProtocol::QUERY_EXTENSION_BLOCK)) { |
2651 block = bundle->recv_blocks(). |
2654 block = bundle->recv_blocks(). |
2652 find_block(BundleProtocol::QUERY_EXTENSION_BLOCK); |
2655 find_block(BundleProtocol::QUERY_EXTENSION_BLOCK); |
2653 } |
2656 local_bundle = false; |
|
2657 } |
2654 else if (bundle->api_blocks()->has_block(BundleProtocol::QUERY_EXTENSION_BLOCK)) { |
2658 else if (bundle->api_blocks()->has_block(BundleProtocol::QUERY_EXTENSION_BLOCK)) { |
2655 block = bundle->api_blocks()-> |
2659 block = bundle->api_blocks()-> |
2656 find_block(BundleProtocol::QUERY_EXTENSION_BLOCK); |
2660 find_block(BundleProtocol::QUERY_EXTENSION_BLOCK); |
|
2661 local_bundle = true; |
2657 } else { |
2662 } else { |
2658 return false; |
2663 return false; |
2659 } |
2664 } |
2660 break; |
2665 break; |
2661 |
2666 |
2681 log_info_p("/dtn/daemon/bpq", "Query: %s answered completely", |
2686 log_info_p("/dtn/daemon/bpq", "Query: %s answered completely", |
2682 (char*)bpq_block.query_val()); |
2687 (char*)bpq_block.query_val()); |
2683 event->daemon_only_ = true; |
2688 event->daemon_only_ = true; |
2684 } |
2689 } |
2685 } |
2690 } |
2686 else if (bpq_block.kind() == BPQBlock::KIND_RESPONSE) { |
2691 // don't accept local responses |
2687 // don't accept local responses |
2692 else if (bpq_block.kind() == BPQBlock::KIND_RESPONSE && !local_bundle) { |
2688 if (event->source_ != EVENTSRC_APP) { |
2693 if (bpq_cache()->add_response_bundle(bundle, &bpq_block) && |
2689 if (bpq_cache()->add_response_bundle(bundle, &bpq_block) && |
2694 event->source_ != EVENTSRC_STORE) { |
2690 event->source_ != EVENTSRC_STORE) { |
2695 |
2691 bundle->set_in_datastore(true); |
2696 bundle->set_in_datastore(true); |
2692 actions_->store_add(bundle); |
2697 actions_->store_add(bundle); |
2693 } |
2698 } |
2694 } |
|
2695 } |
2699 } |
2696 else { |
2700 else { |
2697 log_err_p("/dtn/daemon/bpq", "ERROR - BPQ Block: invalid kind %d", |
2701 log_err_p("/dtn/daemon/bpq", "ERROR - BPQ Block: invalid kind %d", |
2698 bpq_block.kind()); |
2702 bpq_block.kind()); |
2699 NOTREACHED; |
2703 NOTREACHED; |