servlib/bundling/BundleProtocol.cc
changeset 51 c6ca423f1eaf
parent 50 4ef31c3e5a8b
equal deleted inserted replaced
50:4ef31c3e5a8b 51:c6ca423f1eaf
   131             if (bundle->fragmented_incoming()
   131             if (bundle->fragmented_incoming()
   132                 && xmit_blocks->find_block(BundleProtocol::PAYLOAD_BLOCK)) {
   132                 && xmit_blocks->find_block(BundleProtocol::PAYLOAD_BLOCK)) {
   133                 continue;
   133                 continue;
   134             }
   134             }
   135             
   135             
   136             log_debug_p(LOG, "adding recv_block %d", iter->type());
   136             log_debug_p(LOG, "adding recv_block 0x%x", iter->type());
   137             find_processor(iter->type())->prepare(bundle, 
   137             find_processor(iter->type())->prepare(bundle, 
   138                                                   xmit_blocks,
   138                                                   xmit_blocks,
   139                                                   &*iter, 
   139                                                   &*iter, 
   140                                                   link, 
   140                                                   link, 
   141                                                   BlockInfo::LIST_RECEIVED);
   141                                                   BlockInfo::LIST_RECEIVED);
   142 
       
   143 //            iter->owner()->prepare(bundle, xmit_blocks, &*iter, link,
       
   144 //                                   BlockInfo::LIST_RECEIVED);
       
   145         }
   142         }
   146     }
   143     }
   147     else {
   144     else {
   148         log_debug_p(LOG, "adding primary and payload block");
   145         log_debug_p(LOG, "adding primary and payload block");
   149         BlockProcessor* bp = find_processor(PRIMARY_BLOCK);
   146         BlockProcessor* bp = find_processor(PRIMARY_BLOCK);
   155     // locally generated bundles need to include blocks specified at the API
   152     // locally generated bundles need to include blocks specified at the API
   156     for (BlockInfoVec::iterator iter = api_blocks->begin();
   153     for (BlockInfoVec::iterator iter = api_blocks->begin();
   157          iter != api_blocks->end();
   154          iter != api_blocks->end();
   158          ++iter)
   155          ++iter)
   159     {
   156     {
   160         log_debug_p(LOG, "adding api_block %d", iter->type());
   157         log_debug_p(LOG, "adding api_block 0x%x", iter->type());
   161         find_processor(iter->type())->prepare(bundle, 
   158         find_processor(iter->type())->prepare(bundle, 
   162                                               xmit_blocks,
   159                                               xmit_blocks,
   163                                               &*iter, 
   160                                               &*iter, 
   164                                               link, 
   161                                               link, 
   165                                               BlockInfo::LIST_API);
   162                                               BlockInfo::LIST_API);
   166 
       
   167 //        iter->owner()->prepare(bundle, xmit_blocks, 
       
   168 //                               &*iter, link, BlockInfo::LIST_API);
       
   169     }
   163     }
   170 
   164 
   171     // now we also make sure to prepare() on any registered processors
   165     // now we also make sure to prepare() on any registered processors
   172     // that don't already have a block in the output list. this
   166     // that don't already have a block in the output list. this
   173     // handles the case where we have a locally generated block with
   167     // handles the case where we have a locally generated block with
   181             continue;
   175             continue;
   182         }
   176         }
   183 
   177 
   184         if (! xmit_blocks->has_block(i)) {
   178         if (! xmit_blocks->has_block(i)) {
   185 
   179 
   186             if (i == BundleProtocol::QUERY_EXTENSION_BLOCK)
   180             if (i != BundleProtocol::QUERY_EXTENSION_BLOCK) {
   187                 log_debug_p(LOG, "adding extra BPQ block!!!");
       
   188             else
       
   189                 bp->prepare(bundle, xmit_blocks, NULL, link, BlockInfo::LIST_NONE);
   181                 bp->prepare(bundle, xmit_blocks, NULL, link, BlockInfo::LIST_NONE);
       
   182             } else {
       
   183                 log_warn_p(LOG, "BPQ blocks should only be created by DTN applications");
       
   184             }
   190         }
   185         }
   191     }
   186     }
   192 
   187 
   193     // include any metadata locally generated by the API or DP
   188     // include any metadata locally generated by the API or DP
   194     BlockProcessor* metadata_processor = find_processor(METADATA_BLOCK);
   189     BlockProcessor* metadata_processor = find_processor(METADATA_BLOCK);