2 * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
3 * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
6 * SPDX-License-Identifier: MIT
13 #include <common/compat/endian.h>
14 #include <common/macros.h>
20 #define CTF_INDEX_MAGIC 0xC1F1DCC1
21 #define CTF_INDEX_MAJOR 1
22 #define CTF_INDEX_MINOR 1
25 * Header at the beginning of each index file.
26 * All integer fields are stored in big endian.
28 struct ctf_packet_index_file_hdr
{
32 /* struct packet_index_len, in bytes */
33 uint32_t packet_index_len
;
34 } __attribute__((__packed__
));
37 * Packet index generated for each trace packet stored in a trace file.
38 * All integer fields are stored in big endian.
40 struct ctf_packet_index
{
41 uint64_t offset
; /* offset of the packet in the file, in bytes */
42 uint64_t packet_size
; /* packet size, in bits */
43 uint64_t content_size
; /* content size, in bits */
44 uint64_t timestamp_begin
;
45 uint64_t timestamp_end
;
46 uint64_t events_discarded
;
47 uint64_t stream_id
; /* ID of the channel */
48 /* CTF_INDEX 1.0 limit */
49 uint64_t stream_instance_id
; /* ID of the channel instance */
50 uint64_t packet_seq_num
; /* packet sequence number */
51 } __attribute__((__packed__
));
53 static inline size_t ctf_packet_index_len(uint32_t major
, uint32_t minor
)
58 return offsetof(struct ctf_packet_index
, stream_id
)
59 + member_sizeof(struct ctf_packet_index
,
62 return offsetof(struct ctf_packet_index
, packet_seq_num
)
63 + member_sizeof(struct ctf_packet_index
,
72 static inline uint32_t lttng_to_index_major(uint32_t lttng_major
,
73 uint32_t lttng_minor
__attribute__((unused
)))
75 if (lttng_major
== 2) {
81 static inline uint32_t lttng_to_index_minor(uint32_t lttng_major
,
84 if (lttng_major
== 2) {
85 if (lttng_minor
< 8) {
94 static inline void ctf_packet_index_file_hdr_init(
95 struct ctf_packet_index_file_hdr
*hdr
,
96 uint32_t idx_major
, uint32_t idx_minor
)
98 memset(hdr
, 0, sizeof(*hdr
));
99 hdr
->magic
= htobe32(CTF_INDEX_MAGIC
);
100 hdr
->index_major
= htobe32(idx_major
);
101 hdr
->index_minor
= htobe32(idx_minor
);
102 hdr
->packet_index_len
= htobe32(
103 ctf_packet_index_len(idx_major
, idx_minor
));
106 #endif /* LTTNG_INDEX_H */