-enum bt_packet_status bt_packet_move_context_field(struct bt_packet *packet,
- struct bt_packet_context_field *context_field)
-{
- struct bt_stream_class *stream_class;
- struct bt_field_wrapper *field_wrapper = (void *) context_field;
-
- BT_ASSERT_PRE_NON_NULL(packet, "Packet");
- BT_ASSERT_PRE_NON_NULL(field_wrapper, "Context field");
- BT_ASSERT_PRE_HOT(packet, "Packet", ": %!+a", packet);
- stream_class = packet->stream->class;
- BT_ASSERT_PRE(stream_class->packet_context_fc,
- "Stream class has no packet context field class: %!+S",
- stream_class);
- BT_ASSERT_PRE(field_wrapper->field->class ==
- stream_class->packet_context_fc,
- "Unexpected packet context field's class: "
- "%![fc-]+F, %![expected-fc-]+F", field_wrapper->field->class,
- stream_class->packet_context_fc);
-
- /* Recycle current context field: always exists */
- BT_ASSERT(packet->context_field);
- recycle_context_field(packet->context_field, stream_class);
-
- /* Move new field */
- packet->context_field = field_wrapper;
- return BT_PACKET_STATUS_OK;
-}
-