servlib/bundling/BPQBlockProcessor.cc
changeset 45 208a44ac3a5e
parent 35 2bc8cc69d2a5
child 47 f1d80668861b
equal deleted inserted replaced
44:c4b3e13a1a90 45:208a44ac3a5e
   182 
   182 
   183     delete bpq_block;
   183     delete bpq_block;
   184     log_info_p(LOG, "BPQBlockProcessor::generate() ending");
   184     log_info_p(LOG, "BPQBlockProcessor::generate() ending");
   185     return BP_SUCCESS;
   185     return BP_SUCCESS;
   186 }
   186 }
       
   187 //----------------------------------------------------------------------
       
   188 bool
       
   189 BPQBlockProcessor::validate(const Bundle*           bundle,
       
   190                             BlockInfoVec*           block_list,
       
   191                             BlockInfo*              block,
       
   192                             status_report_reason_t* reception_reason,
       
   193                             status_report_reason_t* deletion_reason)
       
   194 {
       
   195     if ( ! BlockProcessor::validate(bundle, 
       
   196                                     block_list,
       
   197                                     block,reception_reason,
       
   198                                     deletion_reason) ) {
       
   199         log_err_p(LOG, "BlockProcessor validation failed");
       
   200         return false;
       
   201     }
       
   202     
       
   203     if ( block->data_offset() + block->data_length() != block->full_length() ) {
       
   204         
       
   205         log_err_p(LOG, "offset (%lu) + data len (%lu) is not equal to the full len (%lu)",
       
   206                   block->data_offset(), block->data_length(), block->full_length() );
       
   207         *deletion_reason = BundleProtocol::REASON_BLOCK_UNINTELLIGIBLE;
       
   208         return false;
       
   209     }
       
   210 
       
   211     if ( block->contents().buf_len() < block->full_length() ) {
       
   212 
       
   213         log_err_p(LOG, "block buffer len (%lu) is less than the full len (%lu)",
       
   214                   block->contents().buf_len(), block->full_length() );
       
   215         *deletion_reason = BundleProtocol::REASON_BLOCK_UNINTELLIGIBLE;
       
   216         return false;
       
   217     }
       
   218 
       
   219     if ( *(block->data()) != 0 && *(block->data()) != 1 ) {
       
   220 
       
   221         log_err_p(LOG, "invalid kind - should be query (0) or response (1) but is: %u",
       
   222                   (u_int) *block->data() );
       
   223         *deletion_reason = BundleProtocol::REASON_BLOCK_UNINTELLIGIBLE;
       
   224         return false;
       
   225     }
       
   226 
       
   227     return true;
       
   228 }
   187 
   229 
   188 //----------------------------------------------------------------------
   230 //----------------------------------------------------------------------
   189 /*
   231 /*
   190 int
   232 int
   191 BPQBlockProcessor::finalize(const Bundle*  bundle,
   233 BPQBlockProcessor::finalize(const Bundle*  bundle,