plugins/ctf/common/src/msg-iter/msg-iter.cpp \
plugins/ctf/common/src/msg-iter/msg-iter.hpp \
plugins/ctf/common/src/null-cp-finder.hpp \
+ plugins/ctf/common/src/pkt-props.cpp \
+ plugins/ctf/common/src/pkt-props.hpp \
plugins/ctf/fs-sink/fs-sink.cpp \
plugins/ctf/fs-sink/fs-sink-ctf-meta.hpp \
plugins/ctf/fs-sink/fs-sink.hpp \
--- /dev/null
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (c) 2022 EfficiOS Inc. and Linux Foundation
+ */
+
+#include "../../common/src/item-seq/item-seq-iter.hpp"
+#include "../../common/src/item-seq/logging-item-visitor.hpp"
+#include "pkt-props.hpp"
+
+namespace ctf {
+namespace src {
+namespace {
+
+struct ReadPacketPropertiesItemVisitor final : public ItemVisitor
+{
+ void visit(const DataStreamInfoItem& item) override
+ {
+ props.dataStreamCls = item.cls();
+ props.dataStreamId = item.id();
+ }
+
+ void visit(const PktInfoItem& item) override
+ {
+ props.expectedTotalLen = item.expectedTotalLen();
+ props.expectedContentLen = item.expectedContentLen();
+ props.snapshots.discEventRecordCounter = item.discEventRecordCounterSnap();
+ props.snapshots.beginDefClk = item.beginDefClkVal();
+ props.snapshots.endDefClk = item.endDefClkVal();
+ _mDone = true;
+ }
+
+ bool done() const noexcept
+ {
+ return _mDone;
+ }
+
+ PktProps props;
+
+private:
+ bool _mDone = false;
+};
+} /* namespace */
+
+PktProps readPktProps(const TraceCls& traceCls, Medium::UP medium, const bt2c::DataLen pktOffset,
+ const bt2c::Logger& parentLogger)
+{
+ bt2c::Logger logger {parentLogger, "PLUGIN/CTF/PKT-PROPS"};
+ BT_CPPLOGD_SPEC(logger, "Reading packet properties: pkt-offset-bytes={}", pktOffset.bytes());
+
+ ItemSeqIter itemSeqIter {std::move(medium), traceCls, pktOffset, logger};
+ ReadPacketPropertiesItemVisitor visitor;
+ LoggingItemVisitor loggingVisitor {logger};
+
+ while (!visitor.done()) {
+ const Item *item = itemSeqIter.next();
+ BT_ASSERT(item);
+
+ if (parentLogger.wouldLogT()) {
+ item->accept(loggingVisitor);
+ }
+
+ item->accept(visitor);
+ }
+
+ return visitor.props;
+}
+
+} /* namespace src */
+} /* namespace ctf */
--- /dev/null
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (c) 2022 EfficiOS Inc. and Linux Foundation
+ */
+
+#ifndef BABELTRACE_PLUGINS_CTF_COMMON_SRC_PKT_PROPS_HPP
+#define BABELTRACE_PLUGINS_CTF_COMMON_SRC_PKT_PROPS_HPP
+
+#include "cpp-common/bt2c/data-len.hpp"
+#include "cpp-common/bt2c/logging.hpp"
+#include "cpp-common/bt2s/optional.hpp"
+
+#include "item-seq/medium.hpp"
+#include "metadata/ctf-ir.hpp"
+
+namespace ctf {
+namespace src {
+
+struct PktProps final
+{
+ bt2s::optional<bt2c::DataLen> expectedTotalLen;
+ bt2s::optional<bt2c::DataLen> expectedContentLen;
+ const DataStreamCls *dataStreamCls;
+ bt2s::optional<unsigned long long> dataStreamId;
+
+ struct
+ {
+ bt2s::optional<unsigned long long> discEventRecordCounter;
+ bt2s::optional<unsigned long long> beginDefClk;
+ bt2s::optional<unsigned long long> endDefClk;
+ } snapshots;
+};
+
+/*
+ * Extract packet properties at offset.
+ */
+PktProps readPktProps(const TraceCls& traceCls, Medium::UP medium, bt2c::DataLen pktOffset,
+ const bt2c::Logger& parentLogger);
+
+} /* namespace src */
+} /* namespace ctf */
+
+#endif /* BABELTRACE_PLUGINS_CTF_COMMON_SRC_PKT_PROPS_HPP */