updated daemon to answer local queries
authoraidan
Mon, 15 Aug 2011 18:14:59 +0100
changeset 43 721d4a13bd0b
parent 42 6e7559bfcb52
child 44 c4b3e13a1a90
updated daemon to answer local queries
servlib/bundling/BPQBlock.cc
servlib/bundling/BundleDaemon.cc
--- a/servlib/bundling/BPQBlock.cc	Mon Aug 15 17:48:10 2011 +0100
+++ b/servlib/bundling/BPQBlock.cc	Mon Aug 15 18:14:59 2011 +0100
@@ -190,12 +190,6 @@
 /////////////////////////////////////////////////////
     ASSERT ( block != NULL );
 //    ASSERT ( block->data() != NULL );
-    // BPQ Kind must be 0 or 1
-    if ( *(block->data()) != 0 &&
-         *(block->data()) != 1 ) {
-        log_err_p(LOG, "BPQBlock::initialise: block->data() = %c(should be 0|1)",
-            *(block->data()));
-    }
 
     log_debug_p(LOG, "BPQBlock::initialise: block != NULL");
     log_debug_p(LOG, "BPQBlock::initialise: block->data() != NULL"); 
@@ -228,6 +222,13 @@
     log_debug_p(LOG, "BPQBlock::initialise: extracting buf");
     buf = block->data();
 
+    // BPQ Kind must be 0 or 1
+    if ( *(block->data()) != 0 &&
+         *(block->data()) != 1 ) {
+        log_err_p(LOG, "BPQBlock::initialise: block->data() = %c(should be 0|1)",
+            *(block->data()));
+    }
+
     // BPQ-kind             1-byte
     if ( i < len ) {
         log_debug_p(LOG, "BPQBlock::initialise: extracting kind");
--- a/servlib/bundling/BundleDaemon.cc	Mon Aug 15 17:48:10 2011 +0100
+++ b/servlib/bundling/BundleDaemon.cc	Mon Aug 15 18:14:59 2011 +0100
@@ -922,7 +922,8 @@
 
     // If the even source is PEER or STORE,
     // try to handle a BPQ block
-    if ( event->source_ == EVENTSRC_PEER  || 
+    if ( event->source_ == EVENTSRC_APP   || 
+         event->source_ == EVENTSRC_PEER  || 
          event->source_ == EVENTSRC_STORE ||
          event->source_ == EVENTSRC_FRAGMENTATION) {
 
@@ -2670,11 +2671,13 @@
             event->daemon_only_ = true;
         }
 
-    } else if (bpq_block.kind() == BPQBlock::KIND_RESPONSE) {
+    } 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 {
-        log_err_p("/dtn/daemon/bpq", "ERROR - BPQ Block: invalid kind %d", bpq_block.kind());
+        log_err_p("/dtn/daemon/bpq", "ERROR - BPQ Block: invalid kind %d", 
+            bpq_block.kind());
         return false; 
     }