--- a/servlib/bundling/BPQBlockProcessor.cc Mon Aug 15 18:28:00 2011 +0100
+++ b/servlib/bundling/BPQBlockProcessor.cc Tue Aug 16 15:43:46 2011 +0100
@@ -184,6 +184,48 @@
log_info_p(LOG, "BPQBlockProcessor::generate() ending");
return BP_SUCCESS;
}
+//----------------------------------------------------------------------
+bool
+BPQBlockProcessor::validate(const Bundle* bundle,
+ BlockInfoVec* block_list,
+ BlockInfo* block,
+ status_report_reason_t* reception_reason,
+ status_report_reason_t* deletion_reason)
+{
+ if ( ! BlockProcessor::validate(bundle,
+ block_list,
+ block,reception_reason,
+ deletion_reason) ) {
+ log_err_p(LOG, "BlockProcessor validation failed");
+ return false;
+ }
+
+ if ( block->data_offset() + block->data_length() != block->full_length() ) {
+
+ log_err_p(LOG, "offset (%lu) + data len (%lu) is not equal to the full len (%lu)",
+ block->data_offset(), block->data_length(), block->full_length() );
+ *deletion_reason = BundleProtocol::REASON_BLOCK_UNINTELLIGIBLE;
+ return false;
+ }
+
+ if ( block->contents().buf_len() < block->full_length() ) {
+
+ log_err_p(LOG, "block buffer len (%lu) is less than the full len (%lu)",
+ block->contents().buf_len(), block->full_length() );
+ *deletion_reason = BundleProtocol::REASON_BLOCK_UNINTELLIGIBLE;
+ return false;
+ }
+
+ if ( *(block->data()) != 0 && *(block->data()) != 1 ) {
+
+ log_err_p(LOG, "invalid kind - should be query (0) or response (1) but is: %u",
+ (u_int) *block->data() );
+ *deletion_reason = BundleProtocol::REASON_BLOCK_UNINTELLIGIBLE;
+ return false;
+ }
+
+ return true;
+}
//----------------------------------------------------------------------
/*
--- a/servlib/bundling/BPQBlockProcessor.h Mon Aug 15 18:28:00 2011 +0100
+++ b/servlib/bundling/BPQBlockProcessor.h Tue Aug 16 15:43:46 2011 +0100
@@ -40,6 +40,13 @@
BlockInfo* block,
const LinkRef& link,
bool last);
+
+ bool validate(const Bundle* bundle,
+ BlockInfoVec* block_list,
+ BlockInfo* block,
+ status_report_reason_t* reception_reason,
+ status_report_reason_t* deletion_reason);
+
/*
int finalize(const Bundle* bundle,
BlockInfoVec* xmit_blocks,
--- a/servlib/bundling/BundleProtocol.cc Mon Aug 15 18:28:00 2011 +0100
+++ b/servlib/bundling/BundleProtocol.cc Tue Aug 16 15:43:46 2011 +0100
@@ -169,6 +169,8 @@
}
if (! xmit_blocks->has_block(i)) {
+ if (i == BundleProtocol::QUERY_EXTENSION_BLOCK)
+ log_debug_p(LOG, "adding extra BPQ block!!!");
bp->prepare(bundle, xmit_blocks, NULL, link, BlockInfo::LIST_NONE);
}
}