As described in CTF section 5.2
"If the packet size field is missing, the whole stream only contains a
single packet. If the content size field is missing, the packet is
filled (no padding). The content and packet sizes include all headers."
Here is the correct semantic:
* Content size and packet size are available:
Packet is filled with data up to content size, and then with padding
up to packet size.
* Content size available, no packet size field:
The stream has a single packet. It is filled up to content size, and
the rest is padding.
* Packet size available, no content size field:
Packet filled completely, no padding.
Fixes #683
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
fprintf(stderr, "[error] Unable to read packet context: %s\n", strerror(-ret));
return ret;
}
fprintf(stderr, "[error] Unable to read packet context: %s\n", strerror(-ret));
return ret;
}
- /* read content size from header */
- len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("content_size"));
+ /* read packet size from header */
+ len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("packet_size"));
if (len_index >= 0) {
struct bt_definition *field;
field = bt_struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
if (len_index >= 0) {
struct bt_definition *field;
field = bt_struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
- packet_index.content_size = bt_get_unsigned_int(field);
+ packet_index.packet_size = bt_get_unsigned_int(field);
} else {
/* Use file size for packet size */
} else {
/* Use file size for packet size */
- packet_index.content_size = filesize * CHAR_BIT;
+ packet_index.packet_size = filesize * CHAR_BIT;
- /* read packet size from header */
- len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("packet_size"));
+ /* read content size from header */
+ len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("content_size"));
if (len_index >= 0) {
struct bt_definition *field;
field = bt_struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
if (len_index >= 0) {
struct bt_definition *field;
field = bt_struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
- packet_index.packet_size = bt_get_unsigned_int(field);
+ packet_index.content_size = bt_get_unsigned_int(field);
- /* Use content size if non-zero, else file size */
- packet_index.packet_size = packet_index.content_size ? : filesize * CHAR_BIT;
+ /* Use packet size if non-zero, else file size */
+ packet_index.content_size = packet_index.packet_size ? : filesize * CHAR_BIT;
}
/* read timestamp begin from header */
}
/* read timestamp begin from header */