MCPcopy Create free account
hub / github.com/OpenDDS/OpenDDS / setOctetsToNextHeader

Function setOctetsToNextHeader

dds/DCPS/security/CryptoBuiltInImpl.cpp:1365–1393  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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
1396bool CryptoBuiltInImpl::encode_submessage(

Callers 2

encode_submessageMethod · 0.85
encode_rtps_messageMethod · 0.85

Calls 6

to_mbFunction · 0.85
roundUpFunction · 0.85
skipMethod · 0.80
swap_bytesMethod · 0.80
lengthMethod · 0.45
get_bufferMethod · 0.45

Tested by

no test coverage detected