44 u_char* buf, |
44 u_char* buf, |
45 size_t len) |
45 size_t len) |
46 { |
46 { |
47 log_info_p(LOG, "BPQBlockProcessor::consume() start"); |
47 log_info_p(LOG, "BPQBlockProcessor::consume() start"); |
48 |
48 |
49 (void)bundle; |
|
50 // (void)block; |
|
51 // (void)buf; |
|
52 // (void)len; |
|
53 |
|
54 int cc; |
49 int cc; |
55 |
50 |
56 if ( (cc = BlockProcessor::consume(bundle, block, buf, len)) < 0) { |
51 if ( (cc = BlockProcessor::consume(bundle, block, buf, len)) < 0) { |
57 log_err_p(LOG, "BPQBlockProcessor::consume(): error handling block 0x%x", |
52 log_err_p(LOG, "BPQBlockProcessor::consume(): error handling block 0x%x", |
58 BundleProtocol::QUERY_EXTENSION_BLOCK); |
53 BundleProtocol::QUERY_EXTENSION_BLOCK); |
88 const LinkRef& link, |
83 const LinkRef& link, |
89 list_owner_t list) |
84 list_owner_t list) |
90 { |
85 { |
91 log_info_p(LOG, "BPQBlockProcessor::prepare()"); |
86 log_info_p(LOG, "BPQBlockProcessor::prepare()"); |
92 |
87 |
|
88 (void)link; |
|
89 (void)list; |
|
90 |
|
91 |
|
92 // Received blocks are added to the end of the list (which |
|
93 // maintains the order they arrived in) but API blocks |
|
94 // are added after the primary block (that is, before the |
|
95 // payload and the received blocks). This places them "outside" |
|
96 // the original blocks. |
|
97 |
93 if ( (const_cast<Bundle*>(bundle))->api_blocks()-> |
98 if ( (const_cast<Bundle*>(bundle))->api_blocks()-> |
94 has_block(BundleProtocol::QUERY_EXTENSION_BLOCK) ) { |
99 has_block(BundleProtocol::QUERY_EXTENSION_BLOCK) ) { |
95 |
100 |
96 log_info_p(LOG, "BPQBlock found in API Block Vec => created locally"); |
101 log_info_p(LOG, "BPQBlock found in API Block Vec => created locally"); |
97 return BlockProcessor::prepare(bundle, xmit_blocks, source, link, list); |
102 |
|
103 ASSERT((*xmit_blocks)[0].type() == BundleProtocol::PRIMARY_BLOCK); |
|
104 xmit_blocks->insert(xmit_blocks->begin() + 1, BlockInfo(this, source)); |
|
105 |
|
106 return BP_SUCCESS; |
98 |
107 |
99 } else if ( (const_cast<Bundle*>(bundle))->recv_blocks(). |
108 } else if ( (const_cast<Bundle*>(bundle))->recv_blocks(). |
100 has_block(BundleProtocol::QUERY_EXTENSION_BLOCK) ) { |
109 has_block(BundleProtocol::QUERY_EXTENSION_BLOCK) ) { |
101 |
110 |
102 log_info_p(LOG, "BPQBlock found in Recv Block Vec => created remotly"); |
111 log_info_p(LOG, "BPQBlock found in Recv Block Vec => created remotly"); |
103 return BlockProcessor::prepare(bundle, xmit_blocks, source, link, list); |
112 |
|
113 xmit_blocks->append_block(this, source); |
|
114 |
|
115 return BP_SUCCESS; |
|
116 |
104 |
117 |
105 } else { |
118 } else { |
106 |
119 |
107 log_info_p(LOG, "BPQBlock not found in bundle"); |
120 log_info_p(LOG, "BPQBlock not found in bundle"); |
108 return BP_FAIL; |
121 return BP_FAIL; |