--- a/servlib/bundling/BundleDaemon.cc Thu Aug 18 16:18:35 2011 +0100
+++ b/servlib/bundling/BundleDaemon.cc Mon Aug 22 15:28:21 2011 +0100
@@ -2626,35 +2626,47 @@
{
const BlockInfo* block = NULL;
- /**
- * We are only interested in bundles received from peers or applications
- * and then only if there is a QUERY_EXTENSION_BLOCK in the bundle
- * otherwise, return straight away
- */
- if( event->source_ == EVENTSRC_PEER &&
- bundle->recv_blocks().has_block(BundleProtocol::QUERY_EXTENSION_BLOCK)) {
-
- block = bundle->recv_blocks().
- find_block(BundleProtocol::QUERY_EXTENSION_BLOCK);
-
- } else if ( event->source_ == EVENTSRC_APP &&
- bundle->api_blocks()->has_block(BundleProtocol::QUERY_EXTENSION_BLOCK)) {
-
- block = bundle->api_blocks()->
- find_block(BundleProtocol::QUERY_EXTENSION_BLOCK);
-
- } else if ( event->source_ == EVENTSRC_STORE &&
- bundle->in_bpq_cache() ) {
-
- log_info_p("/dtn/daemon/bpq", "handle_bpq_block: cache bundle from STORE");
- BPQBlock bpq_block(bundle);
- accept_bpq_response(bundle, &bpq_block, false);
- return true;
- } else {
-
- log_debug_p("/dtn/daemon/bpq", "BPQ Block not found in bundle");
- return false;
- }
+ switch (event->source_) {
+ case EVENTSRC_PEER:
+ if (bundle->recv_blocks().has_block(BundleProtocol::QUERY_EXTENSION_BLOCK)) {
+ block = bundle->recv_blocks().
+ find_block(BundleProtocol::QUERY_EXTENSION_BLOCK);
+ }
+ break;
+
+ case EVENTSRC_APP:
+ if (bundle->api_blocks()->has_block(BundleProtocol::QUERY_EXTENSION_BLOCK)) {
+ block = bundle->api_blocks()->
+ find_block(BundleProtocol::QUERY_EXTENSION_BLOCK);
+ }
+ break;
+
+ case EVENTSRC_STORE:
+ if (bundle->in_bpq_cache()) {
+ log_info_p("/dtn/daemon/bpq", "handle_bpq_block: cache bundle from STORE");
+ BPQBlock bpq_block(bundle);
+ accept_bpq_response(bundle, &bpq_block, false);
+ return true;
+ }
+ break;
+
+ case EVENTSRC_FRAGMENTATION:
+ if (bundle->recv_blocks().has_block(BundleProtocol::QUERY_EXTENSION_BLOCK)) {
+ block = bundle->recv_blocks().
+ find_block(BundleProtocol::QUERY_EXTENSION_BLOCK);
+ }
+ else if (bundle->api_blocks()->has_block(BundleProtocol::QUERY_EXTENSION_BLOCK)) {
+ block = bundle->api_blocks()->
+ find_block(BundleProtocol::QUERY_EXTENSION_BLOCK);
+ }
+ break;
+
+ default:
+ log_err_p("/dtn/daemon/bpq", "Handle BPQ Block failed for unknown eventsrc: %s",
+ source_to_str((event_source_t)event->source_));
+ NOTREACHED;
+ return false;
+ }
/**
* At this point the BPQ Block has been found in the bundle
@@ -2670,14 +2682,17 @@
if (answer_bpq_query(bundle, &bpq_block)) {
event->daemon_only_ = true;
}
-
- } else if (bpq_block.kind() == BPQBlock::KIND_RESPONSE &&
- event->source_ != EVENTSRC_APP) { //Skip over local responces
- accept_bpq_response(bundle, &bpq_block, event->source_ != EVENTSRC_STORE);
-
- } else {
+ }
+ else if (bpq_block.kind() == BPQBlock::KIND_RESPONSE) {
+ // don't accept local responses
+ if (event->source_ != EVENTSRC_APP) {
+ accept_bpq_response(bundle, &bpq_block, event->source_ != EVENTSRC_STORE);
+ }
+ }
+ else {
log_err_p("/dtn/daemon/bpq", "ERROR - BPQ Block: invalid kind %d",
bpq_block.kind());
+ NOTREACHED;
return false;
}