added some debug logging in BPQ initialization
authoraidan
Thu, 11 Aug 2011 15:40:00 +0100
changeset 30 bdf6aee9aa70
parent 29 00dfdf113d87
child 31 2e5913d44299
added some debug logging in BPQ initialization
servlib/bundling/BPQBlock.cc
--- a/servlib/bundling/BPQBlock.cc	Wed Aug 10 13:38:52 2011 +0100
+++ b/servlib/bundling/BPQBlock.cc	Thu Aug 11 15:40:00 2011 +0100
@@ -57,6 +57,8 @@
 {
     log_info_p(LOG, "BPQBlock::constructor()");
 
+    ASSERT( block->type() == BundleProtocol::QUERY_EXTENSION_BLOCK);
+
     initialise(block);
 
     log_info_p(LOG, "leaving constructor");
@@ -161,11 +163,6 @@
 bool
 BPQBlock::match(const BPQBlock* other) const
 {
-/*
-    log_debug_p(LOG, "_BPQ_ Match: this(%s) other(%s)",
-            (char*)query_val_,
-            (char*)other->query_val());
-*/
     return query_len_ == other->query_len() &&
            strncmp( (char*)query_val_, (char*)other->query_val(),
                      query_len_ ) == 0;
@@ -180,7 +177,9 @@
 
     if ( b->source() != NULL ) {
         block = const_cast<BlockInfo*>(b->source());
+        log_debug_p(LOG, "BPQBlock::initialise: b->source() != NULL");
     } else {
+        log_debug_p(LOG, "BPQBlock::initialise: b->source() == NULL");
         block = b;
     }
     
@@ -191,19 +190,25 @@
     u_char* buf = block->data();
 
     // BPQ-kind             1-byte
-    if ( i < len )
+    if ( i < len ) {
         kind_ = (kind_t) buf[i++];
+        log_debug_p(LOG, "BPQBlock::initialise: kind = %d", kind_);
+    }
 
     // matching rule type   1-byte
-    if ( i < len )
+    if ( i < len ) {
         matching_rule_ = (u_int) buf[i++];
+        log_debug_p(LOG, "BPQBlock::initialise: matching rule = %u", matching_rule_);
+    }
 
     // Decode the SDNV-encoded query length. Note that we need to know the length of the
     // of the encoded value and provide some pointers to the encoded value along with
     // where we want the decoded value (in this case, query_len_).
     if ( i < len &&
-        (decoding_len = SDNV::decode(&(buf[i]), len - i, &query_len_)) >= 0 )
+        (decoding_len = SDNV::decode(&(buf[i]), len - i, &query_len_)) >= 0 ) {
         i += decoding_len;
+        log_debug_p(LOG, "BPQBlock::initialise: query len = %u", query_len_);
+    }
     else
         log_err_p(LOG, "Error decoding BPQ query length");
 
@@ -214,13 +219,17 @@
         for (j=0; query_val_ != NULL && i < len && j < query_len_; i++, j++)
             query_val_[j] = buf[i];
 
+        log_debug_p(LOG, "BPQBlock::initialise: query val = %s", query_val_);
+
     } else {
         query_val_ = NULL;
     }
 
     if ( i < len &&
-        (decoding_len = SDNV::decode(&(buf[i]), len - i, &num_frags)) >= 0 )
+        (decoding_len = SDNV::decode(&(buf[i]), len - i, &num_frags)) >= 0 ) {
         i += decoding_len;
+        log_debug_p(LOG, "BPQBlock::initialise: num frags = %u", num_frags);
+    }
     else
         log_err_p(LOG, "Error decoding BPQ fragment length");
 
@@ -235,18 +244,3 @@
 
 } // namespace dtn
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-