Precondition: the bytes of 'original' starting at 'offset' to the end of 'original' are a valid Submessage If that Submessage has octetsToNextHeader == 0, returns true and makes 'modified' a copy of 'original' with the Submessage's octetsToNextHeader set to the actual byte count from the end of its SubmessageHeader to the end of 'original', rounded up to the alignment requirements (4 bytes). Other
| 1363 | // with the Submessage's octetsToNextHeader set to the actual byte count from the end of its SubmessageHeader |
| 1364 | // to the end of 'original', rounded up to the alignment requirements (4 bytes). Otherwise returns false. |
| 1365 | bool setOctetsToNextHeader(DDS::OctetSeq& modified, const DDS::OctetSeq& original, unsigned int offset = 0) |
| 1366 | { |
| 1367 | if (offset + RTPS::SMHDR_SZ >= original.length()) { |
| 1368 | return false; |
| 1369 | } |
| 1370 | |
| 1371 | const size_t origLength = original.length() - offset; |
| 1372 | ACE_Message_Block mb_in(to_mb(original.get_buffer() + offset), origLength); |
| 1373 | mb_in.wr_ptr(origLength); |
| 1374 | |
| 1375 | Serializer ser_in(&mb_in, common_encoding); |
| 1376 | ser_in.skip(1); // submessageId |
| 1377 | |
| 1378 | unsigned char flags; |
| 1379 | ser_in >> ACE_InputCDR::to_octet(flags); |
| 1380 | const unsigned int flag_e = flags & RTPS::FLAG_E; |
| 1381 | ser_in.swap_bytes(ACE_CDR_BYTE_ORDER != flag_e); |
| 1382 | |
| 1383 | ACE_UINT16 submessageLength; |
| 1384 | ser_in >> submessageLength; |
| 1385 | if (submessageLength == 0) { |
| 1386 | modified = original; |
| 1387 | const size_t len = roundUp(static_cast<unsigned int>(origLength - RTPS::SMHDR_SZ), RTPS::SM_ALIGN); |
| 1388 | modified[offset + 2 + !flag_e] = len & 0xff; |
| 1389 | modified[offset + 2 + flag_e] = (len >> 8) & 0xff; |
| 1390 | return true; |
| 1391 | } |
| 1392 | return false; |
| 1393 | } |
| 1394 | } |
| 1395 | |
| 1396 | bool CryptoBuiltInImpl::encode_submessage( |
no test coverage detected