-const struct bt_field_class *bt_trace_class_borrow_packet_header_field_class_const(
- const struct bt_trace_class *tc)
-{
- BT_ASSERT_PRE_NON_NULL(tc, "Trace class");
- return tc->packet_header_fc;
-}
-
-enum bt_trace_class_status bt_trace_class_set_packet_header_field_class(
- struct bt_trace_class *tc,
- struct bt_field_class *field_class)
-{
- int ret;
- struct bt_resolve_field_path_context resolve_ctx = {
- .packet_header = field_class,
- .packet_context = NULL,
- .event_header = NULL,
- .event_common_context = NULL,
- .event_specific_context = NULL,
- .event_payload = NULL,
- };
-
- BT_ASSERT_PRE_NON_NULL(tc, "Trace class");
- BT_ASSERT_PRE_NON_NULL(field_class, "Field class");
- BT_ASSERT_PRE_TRACE_CLASS_HOT(tc);
- BT_ASSERT_PRE(bt_field_class_get_type(field_class) ==
- BT_FIELD_CLASS_TYPE_STRUCTURE,
- "Packet header field class is not a structure field class: %!+F",
- field_class);
- ret = bt_resolve_field_paths(field_class, &resolve_ctx);
- if (ret) {
- /*
- * This is the only reason for which
- * bt_resolve_field_paths() can fail: anything else
- * would be because a precondition is not satisfied.
- */
- ret = BT_TRACE_CLASS_STATUS_NOMEM;
- goto end;
- }
-
- bt_field_class_make_part_of_trace_class(field_class);
- bt_object_put_ref(tc->packet_header_fc);
- tc->packet_header_fc = field_class;
- bt_object_get_no_null_check(tc->packet_header_fc);
- bt_field_class_freeze(field_class);
- BT_LIB_LOGV("Set trace class's packet header field class: %!+T", tc);
-
-end:
- return ret;
-}
-