--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/servlib/bundling/BPQBlockProcessor.cc Wed May 04 15:44:40 2011 +0100
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2006 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <dtn-config.h>
+#endif
+
+#include "BPQBlockProcessor.h"
+#include "BPQBlock.h"
+
+#include "BlockInfo.h"
+#include "BundleProtocol.h"
+
+namespace dtn {
+
+//----------------------------------------------------------------------
+BPQBlockProcessor::BPQBlockProcessor() :
+ BlockProcessor(BundleProtocol::QUERY_EXTENSION_BLOCK)
+{
+}
+
+//----------------------------------------------------------------------
+int
+BPQBlockProcessor::consume(Bundle* bundle,
+ BlockInfo* block,
+ u_char* buf,
+ size_t len)
+{
+ (void)bundle;
+ (void)block;
+ (void)buf;
+ (void)len;
+
+ //static const char* log = "/home/aidan/Desktop/dtn_log";
+ static const char* log = "/dtn/bundle/protocol";
+ log_err_p(log, "BPQ: consume() returning -1");
+
+ return -1;
+}
+
+//----------------------------------------------------------------------
+int
+BPQBlockProcessor::generate(const Bundle* bundle,
+ BlockInfoVec* xmit_blocks,
+ BlockInfo* block,
+ const LinkRef& link,
+ bool last)
+{
+
+ //static const char* log = "/home/aidan/Desktop/dtn_log";
+ static const char* log = "/dtn/bundle/protocol";
+ log_err_p(log, "BPQ: generate() returning %d", BP_SUCCESS);
+
+ BPQBlock* bpq_block = new BPQBlock(block);
+
+/*
+ for (BlockInfoVec::iterator iter = bundle->recv_blocks().begin();
+ iter != bundle->recv_blocks().end();
+ ++iter)
+ {
+ log_err_p(log,"\n type: 0x%02x ", iter->type());
+ if (iter->data_offset() == 0)
+ log_err_p(log,"(runt)");
+ else {
+ if (!iter->complete())
+ log_err_p(log,"(incomplete) ");
+ log_err_p(log,"data length: %d", iter->full_length());
+ }
+ }
+
+
+
+
+*/
+/* oasys::StaticStringBuffer<1024> buf;
+ bundle->format_verbose(&buf);
+ log_multiline(oasys::LOG_NOTICE, buf.c_str());
+
+*/
+ /*oasys::StringBuffer *sb = new oasys::StringBuffer();
+ //char c[10000];
+ bundle->format_verbose(sb);
+ log_err_p(log, "%s", sb->data());
+ */
+
+
+
+ u_int8_t flags = BundleProtocol::BLOCK_FLAG_DISCARD_BUNDLE_ONERROR |
+ (last ? BundleProtocol::BLOCK_FLAG_LAST_BLOCK : 0);
+
+ generate_preamble(xmit_blocks,
+ block,
+ BundleProtocol::QUERY_EXTENSION_BLOCK,
+ flags,
+ 1 );
+
+
+ // source block must include at least a block header, if not actual data
+// ASSERT(source->contents().len() != 0);
+// ASSERT(source->data_offset() != 0);
+
+// generate_preamble(xmit_blocks, block, source->type(), flags, source->data_length());
+// ASSERT(block->data_offset() == source->data_offset());
+// ASSERT(block->data_length() == source->data_length());
+/*
+ BlockInfo::DataBuffer* contents = block->writable_contents();
+ contents->reserve(block->full_length());
+ memcpy(contents->buf() + block->data_offset(),
+ source->contents().buf() + block->data_offset(),
+ block->data_length());
+ contents->set_len(block->full_length());
+*/
+
+ return BP_SUCCESS;
+}
+
+} // namespace dtn
+