Skip to content

Writing the YAML configuration file

Philippe Proulx edited this page Sep 10, 2020 · 6 revisions

The barectf YAML configuration file is the only input the barectf command-line tool needs in order to generate the corresponding CTF metadata and C files.

To start with a concrete configuration, here's some minimal configuration:

version: '2.2'
metadata:
  type-aliases:
    uint16:
      class: int
      size: 16
  trace:
    byte-order: le
  streams:
    my_stream:
      packet-context-type:
        class: struct
        fields:
          packet_size: uint16
          content_size: uint16
      events:
        my_event:
          payload-type:
            class: struct
            fields:
              my_field:
                class: int
                size: 8

The version property must be set to the version string (hence the single quotes). As features are added to barectf and to its configuration file schema, this version will be bumped accordingly. The latest version of barectf is 2.2.

The metadata property is where the properties and layout of the eventual CTF trace are defined. The accepted properties of each object are documented in the pages of this wiki. For the moment, note simply that:

  • The native (target) byte order of the trace is set to le (little-endian)
  • There's one defined stream named my_stream
  • The single stream has one defined event named my_event
  • The single event has a structure as its payload type, with a single 8-bit unsigned integer type field named my_field.
  • The stream packet context type is a structure defining the mandatory packet_size and content_size special fields as 16-bit unsigned integer types.

Running barectf with the configuration above (as a file named config.yaml):

barectf config.yaml

produces a C file (barectf.c), and its header file (barectf.h), the latter declaring the following function:

void barectf_my_stream_trace_my_event(
    struct barectf_my_stream_ctx *ctx, uint8_t p_my_field);

ctx is the barectf context for the stream named my_stream (usually initialized and provided by the barectf platform), and p_my_field is the value of the my_event event payload's my_field field.

It is possible to include external YAML files in the configuration file.

Configuration file objects

The available configuration file objects are: