| 128 | } |
| 129 | |
| 130 | bool DataSampleHeader::partial(const ACE_Message_Block& mb) |
| 131 | { |
| 132 | static const unsigned int LIFESPAN_MASK = mask_flag(LIFESPAN_DURATION_FLAG), |
| 133 | LIFESPAN_LENGTH = 8, |
| 134 | COHERENT_MASK = mask_flag(GROUP_COHERENT_FLAG), |
| 135 | COHERENT_LENGTH = 16, |
| 136 | CONTENT_FILT_MASK = mask_flag(CONTENT_FILTER_FLAG), |
| 137 | BYTE_ORDER_MASK = mask_flag(BYTE_ORDER_FLAG); |
| 138 | |
| 139 | const size_t len = mb.total_length(); |
| 140 | |
| 141 | if (len <= FLAGS_OFFSET) return true; |
| 142 | |
| 143 | Encoding encoding(dsh_encoding_kind); |
| 144 | unsigned char msg_id; |
| 145 | if (!mb_peek(msg_id, mb, MESSAGE_ID_OFFSET, encoding) |
| 146 | || int(msg_id) >= MESSAGE_ID_MAX) { |
| 147 | // This check, and the similar one below for submessage id, are actually |
| 148 | // indicating an invalid header (and not a partial header) but we can |
| 149 | // treat it the same as partial for the sake of the TransportRecvStrategy. |
| 150 | return true; |
| 151 | } |
| 152 | |
| 153 | if (!mb_peek(msg_id, mb, SUBMESSAGE_ID_OFFSET, encoding) |
| 154 | || int(msg_id) >= SUBMESSAGE_ID_MAX) { |
| 155 | return true; |
| 156 | } |
| 157 | |
| 158 | char flags; |
| 159 | if (!mb_peek(flags, mb, FLAGS_OFFSET, encoding)) { |
| 160 | return true; |
| 161 | } |
| 162 | |
| 163 | const unsigned int flags_ext = static_cast<unsigned int>(flags); |
| 164 | |
| 165 | size_t expected = get_max_serialized_size(); |
| 166 | if (!(flags_ext & LIFESPAN_MASK)) expected -= LIFESPAN_LENGTH; |
| 167 | if (!(flags_ext & COHERENT_MASK)) expected -= COHERENT_LENGTH; |
| 168 | |
| 169 | if (flags_ext & CONTENT_FILT_MASK) { |
| 170 | CORBA::ULong seqLen; |
| 171 | encoding.endianness(static_cast<Endianness>(flags_ext & BYTE_ORDER_MASK)); |
| 172 | if (!mb_peek(seqLen, mb, expected, encoding)) { |
| 173 | return true; |
| 174 | } |
| 175 | expected += int32_cdr_size + guid_cdr_size * seqLen; |
| 176 | } |
| 177 | |
| 178 | return len < expected; |
| 179 | } |
| 180 | |
| 181 | void |
| 182 | DataSampleHeader::init(ACE_Message_Block* buffer) |